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:[email protected]_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[[email protected] 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
A DUCO (Duino-Coin) miner for GigaDevice ARM boards.

GD32 Duino-Coin Miner Description Contains the firmware and miner software for mining DUCO (Duino-Coin) on GigaDevice GD32 chips. Supported boards GD3

Maximilian Gerhardt 2 Feb 20, 2022
[unmaintained] WiFi tools for linux

Note: This project is unmaintained. While I would love to keep up the development on this project, it is difficult for me for several reasons: I don't

Rocky Meza 288 Dec 13, 2022
FERM: A Framework for Efficient Robotic Manipulation

Framework for Efficient Robotic Manipulation FERM is a framework that enables robots to learn tasks within an hour of real time training.

Ruihan (Philip) Zhao 111 Dec 31, 2022
ModbusTCP2MQTT - Sungrow & SMA Solar Inverter addon for Home Assistant

ModbusTCP2MQTT Sungrow & SMA Solar Inverter addon for Home Assistant This addon will connect directly to your Inverter using Modbus TCP. Support model

Teny Smart 40 Dec 21, 2022
This is an incredible led matrix simulation using the ultimate mosaik co-simulation framework.

This project uses the mosaik co-simulation framework, developed by the brilliant developers at the high-ranked Offis institue for computer science, Oldenburg, Germany, to simulate multidimensional LE

Felix 1 Jan 28, 2022
A blender 2.9x addon for managing camera settings

TMG-Camera-Tools A blender 2.9x addon for managing camera settings Tutorial showcasing current features

Mainman002 12 Apr 16, 2022
Simples Keylogger para Windows com um autoboot implementado no sistema

MKW Keylogger Keylogger simples para Windos com um autoboot implementado no sistema, o malware irá capturar pressionamentos de tecla e armazená-lo em

3 Jul 03, 2021
A python library written for the raspberry pi.

A python package for using certain components on the raspberry pi.

Builder212 1 Nov 09, 2021
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
An open source operating system designed primarily for the Raspberry Pi Pico, written entirely in MicroPython

PycOS An open source operating system designed primarily for the Raspberry Pi Pico, written entirely in MicroPython. "PycOS" is an combination of the

8 Oct 06, 2022
GUI wrapper designed for convenient service work with TI CC1352/CC2538/CC2652 based Zigbee sticks or gateways. Packed into single executable file

ZigStar GW Multi tool is GUI wrapper firtsly designed for convenient service work with Zig Star LAN GW, but now supports any TI CC1352/CC2538/CC2652 b

133 Jan 01, 2023
Control DJI Tello with Raspberry Pi and PS4 Controller

Control-DJI-Tello-with-Raspberry-Pi-and-PS4-Controller Demo of this project see

MohammadReza Sharifi 24 Aug 11, 2022
Like htop (CPU and memory usage), but for your case LEDs. 😄

Like htop (CPU and memory usage), but for your case LEDs. 😄

Derek Anderson 3 Dec 08, 2021
For use with an 8-bit parallel TFT touchscreen using micropython

ILI9341-parallel-TFT-driver-for-micropython For use with an 8-bit parallel TFT touchscreen using micropython. Many thanks to prenticedavid and his MCU

3 Aug 02, 2022
A install script for installing qtile and my configs on Raspberry Pi OS

QPI OS - Qtile + Raspberry PI OS Qtile + Raspberry Pi OS :) Installation Run this command in the terminal

RPICoder 3 Dec 19, 2021
A raspberrypi tools for python

raspberrypi-tools how to install: first clone this project: git clone https://github.com/Ardumine/rpi-tools.git then go to the folder cd rpi-tools and

1 Jan 04, 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

12 Jan 07, 2023
Create (templateable) cameras that display qr codes in homeassistant

QRCam This custom component creates cameras displaying qrcodes. The QRCodes can be static or generated from templates. If you use a template as conten

Jannes Müller 5 Oct 06, 2022
Detic ros - A simple ROS wrapper for Detic instance segmentation using pre-trained dataset

Detic ros - A simple ROS wrapper for Detic instance segmentation using pre-trained dataset

Hirokazu Ishida 12 Nov 19, 2022
A set of postprocessing scripts and macro to accelerate the gyroid infill print speed with Klipper

A set of postprocessing scripts and macro to accelerate the gyroid infill print speed with Klipper

Jérôme W. 75 Jan 07, 2023