-
-
Notifications
You must be signed in to change notification settings - Fork 7.6k
Add Sleep as Android integration #38465
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
tr4nt0r
wants to merge
6
commits into
home-assistant:next
Choose a base branch
from
tr4nt0r:sleep_as_android
base: next
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,169 @@ | ||
--- | ||
title: Sleep as Android | ||
description: Instructions on how to integrate Sleep as Android with Home Assistant. | ||
ha_category: | ||
- Event | ||
ha_iot_class: Local push | ||
ha_release: 2025.5 | ||
ha_config_flow: true | ||
ha_codeowners: | ||
- '@tr4nt0r' | ||
ha_domain: sleep | ||
ha_integration_type: integration | ||
ha_platforms: | ||
- event | ||
ha_quality_scale: silver | ||
--- | ||
|
||
The **Sleep as Android** {% term integration %} connects the Sleep as Android app to Home Assistant, allowing you to trigger automations based on alarm clock or sleep cycle events. | ||
|
||
## About Sleep as Android | ||
|
||
**Sleep as Android** is a smart alarm clock with sleep cycle tracking capabilities and numerous other features to analyze and improve sleeping habits. It is available exclusively for Android devices and can be downloaded from [Google Play](https://play.google.com/store/apps/details?id=com.urbandroid.sleep). | ||
|
||
## How you can use this integration | ||
|
||
The Sleep as Android integration allows you to trigger sleep-related automations. You can trigger actions when sleep tracking starts or stops, such as dimming the lights or adjusting thermostat settings. Alarm events allow you to respond to snoozing or dismissing alarms — like starting a morning routine or sending a notification if the alarm was skipped. Additionally, you can react to specific sleep phases or sound detections (for example, snoring or baby crying), or monitor critical conditions such as sleep apnea. | ||
|
||
## Prerequisites | ||
|
||
This integration uses webhooks to receive events from Sleep as Android. By default, webhook triggers can only be accessed from devices on the same network as Home Assistant. If you want to receive events while away from your home network, remote access must be enabled, either by adding a [remote URL](/docs/configuration/remote/) or via [Nabu Casa Cloud](https://www.nabucasa.com/config/webhooks/). | ||
|
||
Steps to set up the integration: | ||
|
||
1. Preferably, open Home Assistant on the device you want to connect to the Sleep as Android integration and initiate the setup. | ||
2. You will be presented a URL during the setup process. Mark the URL and copy it to the clipboard. | ||
3. Open the Sleep as Android app and navigate to *{% icon "mdi:cog" %} Settings → Services → Automation → Webhooks*. | ||
4. Turn on the switch to enable webhooks and paste the webhook URL from your clipboard into the URL field. | ||
|
||
{% tip %} | ||
|
||
If you scroll to the top and click on *Events* you can individually select and deselect on which events the Sleep as Android app should trigger. | ||
|
||
{% endtip %} | ||
|
||
{% include integrations/config_flow.md %} | ||
|
||
### Configuration parameters | ||
|
||
{% configuration_basic %} | ||
"Webhook ID": | ||
description: "The ID for the webhook URL." | ||
"Cloudhook": | ||
description: "Whether a Nabu Casa Cloudhook is used." | ||
{% endconfiguration_basic %} | ||
|
||
## Events | ||
|
||
The integration offers various event entities that will display the most recent events from Sleep as Android. The event attributes provide additional details depending on the event type. | ||
|
||
### Alarm clock | ||
|
||
Events related to the alarm clock feature. | ||
|
||
{% details "Available event types" %} | ||
|
||
| Event type | Description | | ||
| ------------------------- | -------------------------- | | ||
| `alarm_alert_dismiss` | Alarm stopped | | ||
| `alarm_alert_start` | Alarm started | | ||
| `alarm_rescheduled` | Alarm rescheduled | | ||
| `alarm_skip_next` | Snoozing | | ||
| `alarm_wake_up_check` | Wake-up check notification | | ||
| `before_smart_period` | 45min before smart wake-up | | ||
| `show_skip_next_alarm` | 1h before alarm | | ||
| `smart_period` | Smart wake-up started | | ||
| `time_to_bed_alarm_alert` | Time to bed | | ||
|
||
{% enddetails %} | ||
|
||
### Anti-snoring | ||
|
||
When the anti-snoring is triggered. | ||
|
||
{% details "Available event types" %} | ||
|
||
| Event type | Description | | ||
| ------------- | ---------------------- | | ||
| `antisnoring` | Anti-snoring triggered | | ||
|
||
{% enddetails %} | ||
|
||
### Lullaby | ||
|
||
Events related to the Lullaby feature. | ||
|
||
{% details "Available event types" %} | ||
|
||
| Event type | Description | | ||
| --------------------- | ------------------------------- | | ||
| `lullaby_start` | Lullaby started playing | | ||
| `lullaby_stop` | Lullaby stopped playing | | ||
| `lullaby_volume_down` | Lullaby started lowering volume | | ||
|
||
{% enddetails %} | ||
|
||
### Sleep phase | ||
|
||
Events when entering a new sleep phase. | ||
|
||
{% details "Available event types" %} | ||
|
||
| Event type | Description | | ||
| ------------- | ----------- | | ||
| `awake` | Woke up | | ||
| `deep_sleep` | Deep sleep | | ||
| `light_sleep` | Light sleep | | ||
| `not_awake` | Fell asleep | | ||
| `rem` | REM sleep | | ||
|
||
{% enddetails %} | ||
|
||
### Sleep tracking | ||
|
||
Events related to the sleep tracking feature. | ||
|
||
{% details "Available event types" %} | ||
|
||
| Event type | Description | | ||
| ------------------------ | ---------------- | | ||
| `sleep_tracking_paused` | Tracking paused | | ||
| `sleep_tracking_resumed` | Tracking resumed | | ||
| `sleep_tracking_started` | Tracking started | | ||
| `sleep_tracking_stopped` | Tracking stopped | | ||
|
||
{% enddetails %} | ||
|
||
### Sound recognition | ||
|
||
Events triggered when a specific sound is detected during sleep tracking. | ||
|
||
{% details "Available event types" %} | ||
|
||
| Event type | Description | | ||
| ------------------- | -------------------- | | ||
| `sound_event_baby` | Baby crying | | ||
| `sound_event_cough` | Coughing or sneezing | | ||
| `sound_event_laugh` | Laughter | | ||
| `sound_event_snore` | Snoring | | ||
| `sound_event_talk` | Talking | | ||
|
||
{% enddetails %} | ||
|
||
### Sleep apnea | ||
|
||
When a significant dip in oxygen saturation level is detected. | ||
|
||
{% details "Available event types" %} | ||
|
||
| Event type | Description | | ||
| ------------- | -------------------- | | ||
| `apnea_alarm` | Sleep apnea detected | | ||
|
||
{% enddetails %} | ||
|
||
## Removing the integration | ||
|
||
This integration can be removed by following these steps: | ||
|
||
{% include integrations/remove_device_service.md %} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Standardize front matter values to snake_case
The
ha_category
andha_iot_class
values should follow the snake_case convention (e.g.,event
andlocal_push
) to ensure consistency across documentation.Possible diff:
📝 Committable suggestion