> For the complete documentation index, see [llms.txt](https://docs.appfarm.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.appfarm.io/library/action-nodes/keep-device-awake.md).

# Keep device awake

The Keep Device Awake action node prevents the user's device from going to sleep while the app is in use. This action node is available in apps.

{% hint style="info" %}
Showroom: [Keep device awake example](https://showroom.appfarm.app/action-nodes/keep-device-awake), with its setup in Appfarm Create ([register](https://showroom.appfarm.app/sign-up) for access).
{% endhint %}

## Usage

Use Keep Device Awake in apps where the screen needs to stay on without the user touching it, for example a dashboard on a wall-mounted screen, a step-by-step guide on a tablet, or a scanning station.

Set **Mode** to `Enable` to start preventing sleep, and run the action node again with `Disable` to let the device sleep normally. `Toggle` switches between the two, based on whether sleep prevention is currently active in the app.

Run the action node from an action that the user triggers, for example from an **On Click** event handler on a button. Browsers usually refuse to keep the device awake when the request doesn't come from a user interaction, for example in an **On App Load** action.

{% hint style="warning" %}
**Important**

If the browser can't prevent the device from sleeping, the action node fails with *PreventDeviceSleepEnableError* (Appfarm Error Code: 17032) and the rest of the action doesn't run. This happens when the browser refuses the request, or doesn't respond to it within 10 seconds. Use a [Catch exception](https://docs.appfarm.io/library/action-nodes/catch-exception.md) action node with **Defined errors** and the code `17032` to handle the failure, for example by showing a message to the user.

When `Toggle` fails to enable sleep prevention, the next `Toggle` tries to enable it again.
{% endhint %}

## Properties

| Property | Description                                                                                                                                                                                                                                                                                                      |
| -------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **Mode** | <p>Select whether to start or stop preventing the device from sleeping.<br><br><code>Toggle</code>: Enable sleep prevention if it isn't active, otherwise disable it.<br><code>Enable</code>: Prevent the device from sleeping. This is the default.<br><code>Disable</code>: Let the device sleep normally.</p> |


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.appfarm.io/library/action-nodes/keep-device-awake.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
