SleepAsAndroid Application Built On Python For Home Assistant

Share Your Love

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:


You will need:

  • configured MQTT server in configuration.yaml like
  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


  • go to HACS->Integrations->three dots at upper-right conner->Custom repositories
  • add IATkachenko/HA-SleepAsAndroid to ADD CUSTOM REPOSITORY field and select Integration in CATEGORY
  • click add button
  • find Sleep As Andorid integration;
  • click Install (Home assistant restart may be required);


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 where Sleep as Android will create subtopic for the event publishing. Every subtopic will be a unique device in Home Assistant.
  • QOS: quality of service for MQTT

Application configuration:

To configure Sleep As Android for working with this integration:

  1. Go to application settings
  2. Find Services in integration section
  3. Go to Automation
  4. Find MQTT section


  • Enable it
  • URL is a URL for your MQTT server. It should look like tpc:///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 be SleepAsAndroid/username.
  • Client ID is any ID. It is not used by integration and is not published to MQTT (now).


<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):
  1. select Device in automatization trigger and use SleepAsAndroid device;
  2. 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>"



  default: warning
    custom_components.sleep_as_android: debug


If you enjoy this GitHub repository, Please comment and share more repositories on WhatsApp

Share Your Love
Avatar photo
Lingaraj Senapati

Hey There! I am Lingaraj Senapati, the Founder of My skills are Freelance, Web Developer & Designer, Corporate Trainer, Digital Marketer & Youtuber.

Articles: 411

Newsletter Updates

Enter your email address below to subscribe to our newsletter