In this post today I am explaining another repository SleepAsAndroid, which is an application that integrates with the sensor states and events in Home assistant. The entire script built on python.
How To Install And Configuration:
Requirements:
You will need:
- configured MQTT server in
configuration.yaml
like
mqtt:
broker: mqtt.myserver
port: 1883
username: ha_husr
discovery: true
- Sleep As android with MQTT support (currently beta version)
- go to Settings -> Services -> Automatization -> MQTT
- enable and configure MQTT
- Home Assistant v2021.7
Installation:
- go to HACS->Integrations->three dots at upper-right conner->Custom repositories
- add
IATkachenko/HA-SleepAsAndroid
toADD CUSTOM REPOSITORY
field and selectIntegration
inCATEGORY
- click
add
button - find
Sleep As Andorid
integration; - click
Install
(Home assistant restart may be required);
Configuration:
Component configuration
Name
: name of the device/sensor and a prefix for the events. Will be used as a default prefix for devices and events.Root Topic
: MQTT topic whereSleep as Android
will create subtopic for the event publishing. Every subtopic will be a unique device inHome Assistant
.QOS
: quality of service for MQTT
Application configuration:
To configure Sleep As Android
for working with this integration:
- Go to application settings
- Find Services in integration section
- Go to Automation
- Find MQTT section
Then:
- Enable it
URL
is a URL for your MQTT server. It should look liketpc:///mqtt_user:[email protected]_host:mqtt_port
Topic
is a topic name where the application will publish events. MUST be a subtopic in Root topic from integration settings. Topic name will be used as a suffix for the default device name in HomeAssistant.- For example, if your root topic is
SleepAsAndroid
, a valid subtopic would beSleepAsAndroid/username
.
- For example, if your root topic is
Client ID
is any ID. It is not used by integration and is not published to MQTT (now).

Usage:
<name>
is an integration name in lower case without spaces from the Settings
dialog. List of events is available at Sleep As Android documentation page
on device event (recommended):
- select
Device
in automatization trigger and useSleepAsAndroid
device; - select trigger from a list.
on sensor state change:
State of sensor sensor.<name>
will contain the recent event name, that got published by the application.
on event:
If the application publishes a new event, then integration fires <name>
event with payload:
{
"event": "<event_name_from_application>"
}
Troubleshooting
configuration.yaml
:
logger:
default: warning
logs:
custom_components.sleep_as_android: debug
GitHub:
If you enjoy this GitHub repository, Please comment and share more repositories on WhatsApp