Sleep As Android custom integration
This integration will allow you to get events from your SleepAsAndroid application in a form of the sensor states and events in Home assistant.
Installation & configuration
Requirements
You will need:
- Home Assistant with configured MQTT integration
example of configuration.yaml:mqtt: broker: mqtt.myserver port: 1883 username: ha_user discovery: true
- Sleep As android application
- go to Settings -> Services -> Automatization -> MQTT
- enable and configure MQTT
Installation
- go to HACS ->
Integrations - press
+ Explore & Add repositoriesbutton - type
Sleep As Androidin search field and click at integration name - press
Install this repository to HACSbutton - press
Installbutton (if you have outdated version of Home Assistant -- check integration version in Wiki ) - restart Home Assistant
- go to Home Assistant
Settings->Integrations->Add Integration(right bottom conner) - type
Sleep As Androidin search field and click at integration name
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.Topic template: template for MQTT topic whereSleep as Androidwill publish event.%%%device%%%may be used in template to point to device name position. Examples:- SleepAsAndroid/igor - no
%%%device%%%in template just one device will be tracked and one device will be created forHomeAssistant - SleepAsAndroid/%%%device%%% - all sub topics in
SleepAsAndroid/will be recognized as devices - devices/%%%device%%%/SleepAsAndroidData - all subtopic in
devices/will be used as devices, data will be taken from/SleepAsAndroidDatafor every device, iedevices/igor/SleepAsAndroidDatafor device igor
- SleepAsAndroid/igor - no
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
URLis a URL for your MQTT server. It should look liketcp://mqtt_user:[email protected]_host:mqtt_portTopicis a topic name where the application will publish events. SeeTopic templatesection of component configuration for details. Application settings MUST NOT have%%%device%%%macro. Use desired device name at postion of%%%device%%%of integration configuration. Examples related to integration configuration above: SleepAsAndroid/igor or devices/igor/SleepAsAndroidData. Device name will be "igor" in both cases.Client IDis any ID. It is not used by integration and is not published to MQTT (now).
More details in Wiki.
Usage
blueprint (recommended)
- import blueprint:
- Got to Home Assistant
settings blueprintsimport blueprintbutton- put blueprint URL
- press
previewbutton - press
importbutton
- Got to Home Assistant
- create automatization based on blueprint:
personandstateis using to run actions only if person in state (to avoid run home automatization related to sleep tracking while vacation in Siberia, for example)- add actions for evens
on device event
- select
Devicein automatization trigger and useSleepAsAndroiddevice; - select trigger from a list.
on sensor state change
is an integration name in lower case without spaces from the Settings dialog. is a device name List of events is available at Sleep As Android documentation page
State of sensor sensor.
will contain the recent event name, that got published by the application.
on event
is an integration name in lower case without spaces from the Settings dialog. If application publishes a new event, then integration fires
event with payload:
{
"event": "
"
}
Troubleshooting
configuration.yaml:
logger:
default: warning
logs:
custom_components.sleep_as_android: debug


topic:
Home assistant Configuration:
I restart but i have not entities why?????
Id i see logs i can se connected client and After disconnected at the Same back issue??