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
Jarvis: a personal assistant which can help you to manage your system

Jarvis Jarvis is personal AI based assistant which can help you to manage stuff in your computer. This is demo but I decided to make it more better so

2 Jun 02, 2022
Run this code to blink your ThinkPad LED with a hidden mysterious Morse code! ;)

TMorse Run this code to blink your ThinkPad LED with a hidden mysterious Morse code! ;) Compatible with python3.9+. No third-party library is required

Mahyar 2 Jul 11, 2022
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
Home Assistant custom integration to fetch data from Powerpal

Powerpal custom component for Home Assistant Component to integrate with powerpal. This repository and integration is not affiliated with Powerpal. Th

Lawrence 32 Jan 07, 2023
a fork of the OnionShare software better optimized for lower spec lightweight machines and ARM processors

OnionShare-Optimized A fork of the OnionShare software better optimized for lower spec lightweight machines and ARM processors such as Raspberry Pi or

ALTPORT 4 Aug 05, 2021
Shotgrid Toolkit Engine for Gaffer

Shotgun toolkit engine for Gaffer Contact : Diego Garcia Huerta Overview Implementation of a shotgun engine for Gaffer. It supports the classic bootst

Diego Garcia Huerta 12 May 21, 2022
Code reimplementation of some papers published in SAIL-Lab

SAIL SAIL-Lab统一代码库 Motivation 创建这个项目的动机最早来源于实验室组内成员相互Debug代码的时候遇到的麻烦。

Jianwen Chen 8 Nov 15, 2022
Implementation of Forwards Kinematics, Inverse Kinematics, Point to Point Movement and Synchronous movement for Kuka KR 120 R2700-2.

I made this project for my university course in robotics. I rarely found any information regarding the implementation of mathematics in code. So I decided to make this repo in order to help others :)

2 Dec 27, 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
This application works with serial communication. Use a simple gui to send and receive serial data from arduino and control leds and motor direction

This application works with serial communication. Use a simple gui to send and receive serial data from arduino and control leds and motor direction

ThyagoKZKR 2 Jul 18, 2022
Inykcal is a software written in python for selected E-Paper displays.

Inykcal is a software written in python for selected E-Paper displays. It converts these displays into useful information dashboards. It's open-source, free for personal use, fully modular and user-f

Ace 727 Jan 02, 2023
Fener ROS2 package version 2

Fener's ROS2 codes that runs on the vehicle. This node contains basic sensing and actuation nodes for vehicle control. Also example applications will be added.

Muhammed Sezer 1 Jan 18, 2022
Point Density-Aware Voxels for LiDAR 3D Object Detection (CVPR 2022)

PDV PDV is LiDAR 3D object detection method. This repository is based off [OpenPCDet]. Point Density-Aware Voxels for LiDAR 3D Object Detection Jordan

Toronto Robotics and AI Laboratory 114 Dec 21, 2022
Alternative firmware for ESP8266 with easy configuration using webUI, OTA updates, automation using timers or rules, expandability and entirely local control over MQTT, HTTP, Serial or KNX. Full documentation at

Alternative firmware for ESP8266/ESP32 based devices with easy configuration using webUI, OTA updates, automation using timers or rules, expandability

Theo Arends 59 Dec 26, 2022
Tool to create 3D printable terrain with integrated path/road part files (Single material 3d printer)

BACKGROUND This has been an ongoing project of mine for a few months now. I run trails a lot and original the goal was to create a function to combine

9 Apr 26, 2022
Philippe 1 Jan 09, 2022
circuitpython version of PyBasic for microcontrollers

cPyBasic Circuitpython version of PyBasic for microcontrollers Current version work only for Adafruit titano & CardKB for now. The origninal PyBasic w

BeBoXoS 3 Nov 14, 2021
Modi2-firmware-updater - MODI+ Firmware Updater With Python

MODI+ Firmware Updater 실행 준비 python3(파이썬3.9 혹은 그 이상의 버전)를 컴퓨터에 설치 python3 -m pip

LUXROBO 1 Feb 04, 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

14 Dec 18, 2022
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