Sleep As Android integration for Home Assistant

Overview

version_badge Validate with hassfest hacs_badge Custom badge

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:

Installation

  • go to HACS -> Integrations
  • press + Explore & Add repositories button
  • type Sleep As Android in search field and click at integration name
  • press Install this repository to HACS button
  • press Install button (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 Android in 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 where Sleep as Android will 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 for HomeAssistant
    • 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 /SleepAsAndroidData for every device, ie devices/igor/SleepAsAndroidData for device igor
  • 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

Then:

  • Enable it
  • URL is a URL for your MQTT server. It should look like tcp://mqtt_user:mqtt_password@mqtt_host:mqtt_port
  • Topic is a topic name where the application will publish events. See Topic template section 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 ID is any ID. It is not used by integration and is not published to MQTT (now).

SleepAsAndroid configuration

More details in Wiki.

Usage

blueprint (recommended)

  1. import blueprint:
    1. Got to Home Assistant settings
    2. blueprints
    3. import blueprint button
    4. put blueprint URL
    5. press preview button
    6. press import button
  2. create automatization based on blueprint:
    • person and state is 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

  1. select Device in automatization trigger and use SleepAsAndroid device;
  2. 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
Comments
  • Setup failed for sleep_as_android: Integration not found.

    Setup failed for sleep_as_android: Integration not found.

    After update to version 1.2.4 getting such error in logs:

    Logger: homeassistant.setup
    Source: setup.py:173
    First occurred: 1:42:57 PM (1 occurrences)
    Last logged: 1:42:57 PM
    
    Setup failed for sleep_as_android: Integration not found.
    

    In Integrations menu:

    image

    If delete Integration - new will not presented in Add menu.

    Sleep sensor exists, but with state: unavailable.

    Revert to v1.2.3 fix the problem.

    bug CI 
    opened by hACKrus 13
  • No integration showing up

    No integration showing up

    General information

    Home Assistant

    2021.12.4: Installation method (according to instructions): [X] Operating System [ ] Container [ ] Supervised [ ] Core

    Integration

    Installation method: [X] HACS [ ] manual from release [ ] manual from git Integration version:v1.6.0 Root topic:

    Application settings

    topic: [X] I can see MQTT messages from application at MQTT-server

    How it works now?

    After installing the SAA Integration and restarting HA, the SAA Integration is not available under Settings / Integrations

    What do you expect?

    N/A

    Steps to reproduce

    1. Install Integration through HACS as described
    2. Restart HA
    3. Go to Settings / Integrations / Add integration
    4. Select / Search Slaap As Android

    Debug log

    No output generated, despite having added the debug setting to my config.yaml
    

    Additional information

    documentation 
    opened by KeerlITServices 9
  • Device, nor entity created in HA

    Device, nor entity created in HA

    General information

    Integration

    Integration version: v1.2.0 HASS version: 2021.3.4 Root topic: SleepAsAndroid

    Application settings

    configured Sleep as android to use SleepAsAndroid/roman topic image topic:

    • [x] I can see MQTT messages from application at MQTT-server

    How it works now?

    The events are published by Sleep app to the broker and I can read them using mqtt client, However, the HASS integration doesn't create any device nor entity.

    What do you expect?

    Device and entity that would collect the events and states from the mqtt topic

    Steps to reproduce

    I followed all the steps as described in readme

    Debug log

    I can see logs like:

    2[root@nas config]# grep sleep_as_android home-assistant.log | head -12
    2021-04-22 13:11:41 WARNING (MainThread) [homeassistant.loader] You are using a custom integration sleep_as_android which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant
    2021-04-22 13:11:42 INFO (MainThread) [homeassistant.bootstrap] Setting up stage 2: {'persistent_notification', 'input_number', 'map', 'input_datetime', 'mqtt', 'media_source', 'script', 'dhcp', 'met', 'default_config', 'alarm_control_panel', 'logbook', 'input_select', 'influxdb', 'cover', 'input_boolean', 'mobile_app', 'blueprint', 'sun', 'group', 'sleep_as_android', 'ssdp', 'updater', 'zeroconf', 'tts', 'counter', 'scene', 'my', 'tag', 'switch', 'zone', 'input_text', 'sensor', 'tasmota', 'kodi', 'binary_sensor', 'zha', 'history', 'system_health', 'automation', 'hacs', 'timer', 'nodered'}
    2021-04-22 13:11:42 DEBUG (MainThread) [homeassistant.setup] Dependency sleep_as_android will wait for dependencies ['mqtt']
    2021-04-22 13:11:44 INFO (MainThread) [homeassistant.setup] Setting up sleep_as_android
    2021-04-22 13:11:44 INFO (MainThread) [homeassistant.setup] Setup of domain sleep_as_android took 0.0 seconds
    2021-04-22 13:11:44 INFO (MainThread) [custom_components.sleep_as_android] Setting up ea7971cef4d1354ff40a907b229a869f 
    2021-04-22 13:11:44 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event component_loaded[L]: component=sleep_as_android>
    2021-04-22 13:11:44 INFO (MainThread) [homeassistant.components.sensor] Setting up sensor.sleep_as_android
    2021-04-22 13:11:44 DEBUG (MainThread) [custom_components.sleep_as_android.sensor] Subscribing to root topic 'SleepAsAndroid'
    2021-04-22 13:11:44 DEBUG (MainThread) [custom_components.sleep_as_android.sensor] Subscribing to root topic is done!
    
    

    Additional information

    just wanted to say hi and thank you for the integration

    opened by rplevka 9
  • No entity for sleep as android In Home Assistant

    No entity for sleep as android In Home Assistant

    I have done all your passages in documentation: App Configuration: Screenshot_20210402_135146_com urbandroid sleep Home assistant Configuration: Screenshot_20210402_135348 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??

    documentation need more info 
    opened by hdjweb 9
  • Update Blueprint To Allow Utilizing New Sensor Attributes.

    Update Blueprint To Allow Utilizing New Sensor Attributes.

    General information

    Could I request an update to the Blueprint to allow entering a value for the the new attributes from Issue 30

    (specifically the Label attribute) When using the Blueprint to create an automation, to create a Condition based on the Label. For example, only run if the Label matches, or Run Except if the Label Matches.

    enhancement 
    opened by MikeKMiller 8
  • Old devices have no delete option

    Old devices have no delete option

    General information

    Home Assistant

    Version: 2022.11.1 Installation method (according to instructions): [x] Linux VM [ ] Operating System [ ] Container [ ] Supervised [ ] Core

    Integration

    Installation method: [x] HACS [ ] manual from release [ ] manual from git Integration version: 1.9.2 Root topic: nothing? not sure where to check that setting

    Application settings

    topic: sensor/SleepAsAndroid/%%%device%%% [x] I can see MQTT messages from application at MQTT-server

    How it works now?

    99.9% as expected, everything works great, except I have old devices that I can not delete from HA that have been changed out for other phones etc.

    What do you expect?

    The device to be deleteable in the devices screen

    Steps to reproduce

    Not sure, but I think

    1. add phone as a sensor
    2. change the device name
    3. old device has no delete button in device list

    Debug log

    N/A
    

    Additional information

    Thank you for the great quality of life boost this is giving me!

    enhancement 
    opened by thomasfinstad 6
  • Alarm Name As Part of Trigger

    Alarm Name As Part of Trigger

    General information

    Include Alarm Name as Part of Trigger Definition

    Usage scenario

    I use alarms in SleepAsAndroid for both Wake Up Alarms, as well as various reminders throughout the day. Being able to filter by specific Alarm Names would allow setting automations based on specific alarms.

    The MQTT call from SleepAsAndroid includes value2 which usually contains the Alarm Name.

    enhancement 
    opened by MikeKMiller 5
  • Integration doesn't create device or anything...

    Integration doesn't create device or anything...

    General information

    Integration

    Integration version: I tried the last one and the main branch from github

    Last HACS version, last HA-OS version

    Application settings

    topic:

    mqtt:
      broker: core-mosquitto
      port: 1883
      discovery: true
    
    sleep_as_android:
      name: SleepAsAndroid
      topic_template: SleepAsAndroid/fbsleep
    

    [x] I can see MQTT messages from application at MQTT-server

    How it works now?

    I can use the MQTT integration to send (and receive in MyMQTT on android), and I can subscribe manually to the above topic and send it from the SleepAsAndroid, but the HACS integration doesn't create any device or logs anything on log (I've set the logger to debug).

    bug 
    opened by franzbischoff 5
  • Unable to prepare setup for platform sleep_as_android.sensor: Platform not found

    Unable to prepare setup for platform sleep_as_android.sensor: Platform not found

    General information

    Integration

    Integration version: v1.2.1 Root topic: Integration fails configuration checks

    Application settings

    topic: Can't check (application won't start) but believe it was default [ ] I can see MQTT messages from application at MQTT-server

    How it works now?

    Integration fails to load

    What do you expect?

    Integration should load!

    Steps to reproduce

    Install the integration

    Debug log

    Logger: homeassistant.setup
    Source: setup.py:311
    First occurred: 12:00:55 PM (1 occurrences)
    Last logged: 12:00:55 PM
    
    Unable to prepare setup for platform sleep_as_android.sensor: Platform not found (cannot import name 'TRIGGER_BASE_SCHEMA' from 'homeassistant.components.device_automation' (/usr/src/homeassistant/homeassistant/components/device_automation/__init__.py)).
    

    Additional information

    Just upgraded to core-2021.7.0

    bug 
    opened by TheRealWaldo 5
  • Fails to start with Home Assistant 2022.3.0b5 (unexpected keyword argument 'new_state')

    Fails to start with Home Assistant 2022.3.0b5 (unexpected keyword argument 'new_state')

    General information

    Home Assistant

    Version: 2022.3.0b5 Installation method (according to instructions): [X] Operating System [ ] Container [ ] Supervised [ ] Core

    Integration

    Installation method: [X] HACS [ ] manual from release [ ] manual from git Integration version: v1.8.2 Root topic:

    Application settings

    topic: [X] I can see MQTT messages from application at MQTT-server

    How it works now?

    The integration used to work. (MQTT broker settings etc all fine and have not changed.)

    Upon startup, the integration errors out with "TypeError: async_subscribe_topics() got an unexpected keyword argument 'new_state'"

    Debug log

    2022-03-01 14:18:50 ERROR (MainThread) [homeassistant.components.sensor] Error while setting up sleep_as_android platform for sensor
    Traceback (most recent call last):
      File "/hass/homeassistant/lib/python3.9/site-packages/homeassistant/helpers/entity_platform.py", line 249, in _async_setup_platform
        await asyncio.shield(task)
      File "/hass/.homeassistant/custom_components/sleep_as_android/sensor.py", line 48, in async_setup_entry
        await instance.subscribe_root_topic(async_add_entities)
      File "/hass/.homeassistant/custom_components/sleep_as_android/__init__.py", line 257, in subscribe_root_topic
        self._subscription_state = await subscribe_2021_07(
      File "/hass/.homeassistant/custom_components/sleep_as_android/__init__.py", line 235, in subscribe_2021_07
        return await subscription.async_subscribe_topics(
    TypeError: async_subscribe_topics() got an unexpected keyword argument 'new_state'
    
    

    Additional information

    bug 
    opened by Steltek 4
  • Configuration not saved

    Configuration not saved

    General information

    Home Assistant

    2021.11.1: Installation method (according to instructions): [X] Operating System [ ] Container [ ] Supervised [ ] Core

    Integration

    Installation method: [X] HACS [ ] manual from release [ ] manual from git Integration version: v1.4.0 Root topic: SleepAsAndroid

    Application settings

    topic: bartfp3 [ X] I can see MQTT messages from application at MQTT-server

    How it works now?

    Configuration changes in name and/or topic are submitted. The integration reports success but values do not change from defaults.

    What do you expect?

    Values change to strings entered

    Steps to reproduce

    1. Integration
    2. SleepAsAndroid
    3. Configure
    4. Submit

    Debug log

    2021-11-08 20:14:59 WARNING (SyncWorker_3) [homeassistant.loader] We found a custom integration sleep_as_android which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant
    

    Additional information

    This is part of troubleshooting why the integration does not create a device for the app. MQTT explorer shows events being published to the broker. Home Assistant is able to read another sensor over MQTT.

    bug 
    opened by bartsmit 4
Releases(v1.10.0)
Owner
Igor
Igor
Home Assistant custom integration for e-distribución

e-Distribución is an energy distribution company that covers most of South Spain area. If you live in this area, you probably are able to register into their website to get some information about your power demand, energy consumption, or even cycle billing (in terms of consumptions).

VMG 17 Sep 7, 2022
Home Assistant custom integration for Yi cameras: yi-hack-MStar, yi-hack-Allwinner and yi-hack-Allwinner-v2

yi-hack Home Assistant integration Overview yi-hack Home Assistant is a custom integration for Yi cameras (or Sonoff camera) with one of the following

roleo 131 Jan 3, 2023
Home Assistant integration for energy consumption data from UK SMETS (Smart) meters using the Hildebrand Glow API.

Hildebrand Glow (DCC) Integration Home Assistant integration for energy consumption data from UK SMETS (Smart) meters using the Hildebrand Glow API. T

Aniket 153 Dec 30, 2022
Electrolux Pure i9 robot vacuum integration for Home Assistant.

Home Assistant Pure i9 This repository integrates your Electrolux Pure i9 robot vacuum with the smart home platform Home Assistant. The integration co

Niklas Ekman 15 Dec 22, 2022
Water quality integration for Home Assistant with data provided by Budapest FVM

Water Quality FVM (Budapest, HU) custom integration for Home Assistant This custom component integrates water quality information provided by Budapest

Atticus Maximus 3 Dec 23, 2021
A Home Assistant integration for Solaredge inverters

A Home Assistant integration for Solaredge inverters. Supports multiple inverters chained through RS485.

Seth 50 Dec 23, 2022
Nordpool_diff custom integration for Home Assistant

nordpool_diff custom integration for Home Assistant Requires https://github.com/custom-components/nordpool Applies non-causal FIR differentiator1 to N

Joonas Pulakka 45 Dec 23, 2022
Smart EQ connect - Custom Integration for Home Assistant

Smart EQ Connect platform as a Custom Component for Home Assistant.

Rene Nulsch 2 Jan 4, 2022
OPNsense integration with Home Assistant

hass-opnsense Join OPNsense with home-assistant! hass-opnsense uses the built-in xmlrpc service of OPNsense for all interactions. This project is curr

Travis Glenn Hansen 54 Jan 3, 2023
Component for deep integration LedFx from Home Assistant.

LedFX for Home Assistant Component for deep integration LedFx from Home Assistant. Table of Contents FAQ Install Config Performance FAQ Q. What versio

Dmitry Mamontov 28 Dec 13, 2022
Aqara Camera G3 integration for Home Assistant

Aqara Camera G3 integration for Home Assistant ATTENTION: The component only works after enabled telnet. Only supportd stream. Not support still image

null 14 Dec 18, 2022
Skykettle ha - Redmond SkyKettle integration for Home Assistant

Redmond SkyKettle integration for Home Assistant This integration allows to cont

Alexey 'Cluster' Avdyukhin 48 Jan 6, 2023
Ha-rpi gpio - Home Assistant Raspberry Pi GPIO Integration

Home Assistant Raspberry Pi GPIO custom integration This is a spin-off from the

Shay Levy 98 Dec 24, 2022
Sleep Functionality for Adafruit MacroPad RP2040

Adafruit-MacroPad-RP2040 Sleep Functionality for Adafruit MacroPad RP2040 Details This is a modification of AdaFruit project bundle found here specifi

null 9 Dec 18, 2022
Volkswagen ID component for Home Assistant

Volkswagen ID component for Home Assistant This folder contains both a generic Python 3 library for the Volkswagen ID API and a component for Home Ass

null 55 Jan 7, 2023
Sensor of Temperature Feels Like for Home Assistant.

Please ⭐ this repo if you find it useful Sensor of Temperature Feels Like for Home Assistant Installation Install from HACS (recommended) Have HACS in

Andrey 60 Dec 25, 2022
Интеграция Home Assistant с ЛК "Интер РАО"

ЕЛК ЖКХ «Интер РАО» для Home Assistant Предоставление информации о текущем состоянии ваших аккаунтов в ЕЛК ЖКХ. Введение @ TODO @ Установка Посредство

Alexander Ryazanov 27 Nov 5, 2022
Provide Unifi device info via api to Home Assistant that will give ap sensors

Unifi AP Device info Provide Unifi device info via api to Home Assistant that will give ap sensors

null 12 Jan 7, 2023
Switch predictor for Home Assistant with AppDeamon

Home Assistant AppDeamon - Event predictor WORK IN PROGRESS - CURRENTLY NOT COMPLETE AND NOT WORK This is an idea under development (when I have free

null 37 Dec 17, 2022