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
Monorepo for my Raspberry Pi dashboard and GPS satellite listener.

🥧 pi dashboard My blog post: Listening to Satellites with my Raspberry Pi This is the monorepo for my Raspberry Pi dashboard!

Andrew Healey 27 Jun 08, 2022
My 500 LED xmas tree

xmastree2020 This repository contains the code used for Matt's Christmas tree, as featured in "I wired my tree with 500 LED lights and calculated thei

Stand-up Maths 581 Jan 07, 2023
A modular sequencer based on Pi Pico & EuroPi

PicoSequencer A modular sequencer based on Pi Pico & EuroPi by Zeno Van Moerkerke / Keurslager Kurt For now it is 'only' a trigger sequencer, but I si

5 Oct 27, 2022
Segger Embedded Studio project for building & debugging Flipper Zero firmware.

Segger Embedded Studio project for Flipper Zero firmware Установка Добавить данный репозиторий в качестве сабмодуля в корень локальной копии репозитор

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

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

Alexander Ryazanov 27 Nov 05, 2022
PyLog - Simple keylogger that uses pynput to listen to keyboard input.

Simple keylogger that uses pynput to listen to keyboard input. Outputs to a text file and the terminal. Press the escape key to stop.

1 Dec 29, 2021
A Python class for controlling the Pimoroni RGB Keypad for Raspberry Pi Pico

rgbkeypad A Python class for controlling the Pimoroni RGB Keypad for the Raspberry Pi Pico. Compatible with MicroPython and CircuitPython. keypad = RG

Martin O'Hanlon 43 Nov 11, 2022
Robot Framework keyword library wrapper for atlassian-python-api

Robot Framework keyword library wrapper for atlassian-python-api

Marcin Koperski 3 Jul 29, 2022
NYCT-GTFS - Real-time NYC subway data parsing for humans

NYCT-GTFS - Real-time NYC subway data parsing for humans This python library provides a human-friendly, native python interface for dealing with the N

Andrew Dickinson 37 Dec 27, 2022
🏡 My Home Assistant Configs. Be sure to 🌟 my repo to follow the updates!

Home Assistant Configuration Here's my Home Assistant configuration. I have installed HA on a Lenovo ThinkCentre M93P Tiny with an Intel Dual-Core i5-

iLyas Bakouch 25 Dec 30, 2022
The ABR Control library is a python package for the control and path planning of robotic arms in real or simulated environments.

The ABR Control library is a python package for the control and path planning of robotic arms in real or simulated environments. ABR Control provides API's for the Mujoco, CoppeliaSim (formerly known

Applied Brain Research 277 Jan 05, 2023
Claussoft Personal Digital Assistant

Claussoft Personal Digital Assistant Install on Linux $ sudo apt update $ sudo apt install espeak ffmpeg libespeak1 portaudio19-dev $ pip install -r r

Christian Clauss 3 Dec 14, 2022
Monitor Live USB Plug In & Plug Out Events

I/O - Live USB Monitoring Author: Jonathan Scott @jonathandata1 Date: 3/13/2021 CURRENT VERSION 1.0 This is just a simple bash script that calls a pyt

Jonathan Scott 17 Dec 03, 2022
Terkin is a flexible data logger application for MicroPython and CPython environments.

Terkin Data logging for humans, written in MicroPython. Documentation: https://terkin.org/ Source Code: https://github.com/hiveeyes/terkin-datalogger

hiveeyes 45 Dec 15, 2022
Alarm Control Panel component for Zigbee Keypads using action_transaction field

hass_transaction_alarm_panel Alarm Control Panel component for Zigbee Keypads using action_transaction field. Works together with zigbee2mqtt Supporte

Konstantin 4 Jun 09, 2022
Micro Displays for Raspberry Pi

micro-displays Micro Displays for Raspberry Pi Why? I'm super bored in lockdown. Add a Raspberry Pi 400 and a few tiny displays... The top half of the

ig 291 Jul 06, 2022
LifeSaver automatically, periodically saves USB flash drive data into the PC

LifeSaver automatically, periodically saves USB flash drive data into the PC. Theoriticaly it will work with any any connected drive ex - Hard Disk ,SSD ... But, can't handle Backing up multipatition

siddharth dhaka 4 Sep 26, 2021
a library for using WS2812b leds (aka neopixels) with Raspberry Pi Pico

pico_ws2812b a library for using WS2812b leds (aka neopixels) with Raspberry Pi Pico You'll first need to save the ws2812b.py file to your device (for

76 Nov 25, 2022
🐱🖨Cat printer is a portable thermal printer sold on AliExpress for around $20.

Cat printer is a portable thermal printer sold on AliExpress for around $20. This repository contains Python code for talking to the cat printer over

671 Jan 05, 2023
Controlling fireworks with micropython

Controlling-fireworks-with-micropython How the code works line 1-4 from machine

Montso Mokake 1 Jan 08, 2022