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
Plug and Play on Internet of Things with LoRa wireless modulation.

IoT-PnP Plug and Play on Internet of Things with LoRa wireless modulation. Device Side In the '505_PnP' folder has a modified ardunino template code s

Lambert Yang 1 May 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
MicroPython driver for 74HC595 shift registers

MicroPython 74HC595 A MicroPython library for 74HC595 8-bit shift registers. There's both an SPI version and a bit-bang version, each with a slightly

Mike Causer 17 Nov 29, 2022
Raspberry Pi Pico and LoRaWAN from CircuitPython

Raspberry Pi Pico and LoRaWAN from CircuitPython Enable LoRaWAN communications on your Raspberry Pi Pico or any RP2040-based board using CircuitPython

Alasdair Allan 15 Oct 08, 2022
The software that powers the sPot: a 4th generation

This code is meant to accompany this project in which a Spotify client is built into an iPod "Classic" from 2004. Everything is meant to run on a Raspberry Pi Zero W.

Guy Dupont 683 Dec 28, 2022
A Python script to monitor the latest block on an LCD.

PiHole-Monitoring A Python script to monitor the latest block on a lcd display. The first number represents the dns queries from the last 24h, the sec

Maxi 4 Dec 05, 2022
Open-Source board for converting RaspberryPI to Brain-computer interface

The easiest way to the neuroscience world with the shield for RaspberryPi - PIEEG (website). Open-source. Crowdsupply This project is the result of se

Ildaron 436 Jan 01, 2023
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
The robot is an autonomous small scale racing car using NVIDIA Jetson Nano.

The robot is an autonomous small scale racing car using NVIDIA Jetson Nano. This project utilizes deep learning neural network framework Keras/Tensorflow, together with computer vision library OpenCV

1 Dec 08, 2021
This Home Assistant custom component adding support for controlling Midea dehumidifiers on local network.

This custom component for Home assistant adds support for Midea dehumidifier appliances via the local area network. homeassistant-midea-dehumidifier-l

Nenad Bogojevic 91 Dec 28, 2022
3d printable macropad

Pico Mpad A 3D printable macropad for automating frequently repeated actions. Hardware To build this project you need access to a 3d printer. The mode

Dmytro Panin 94 Jan 07, 2023
A Macropad using the Raspberry Pi Pico, programmed with CircuitPython.

A Macropad using the Raspberry Pi Pico, programmed with CircuitPython.

15 Oct 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
CPU benchmark by calculating Pi, powered by Python3

cpu-benchmark Info: CPU benchmark by calculating Pi, powered by Python 3. Algorithm The program calculates pi with an accuracy of 10,000 decimal place

Alex Dedyura 20 Jan 03, 2023
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
This is a Virtual Keyboard which is simple yet effective to use.

Virtual-Keyboard This is a Virtual KeyBoard which can track finger movements and lets you type anywhere ranging from notepad to even web browsers. It

Jehan Patel 3 Oct 01, 2021
Drobo Status is a python program that will connect to your Drobo and return JSON data regarding your Drobo

This is a simple python script that will run a docker container to pull data from Drobo. It will give information like (Name, serial, firmware, disk-total, disk-used, disk-free and individual disk st

Biofects 1 Jan 15, 2022
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
a weather application for the raspberry pi and the Pimorioni Inky pHAT.

raspi-weather a weather application for the raspberry pi and the Inky pHAT

Derek Caelin 59 Oct 24, 2022
Transform a Raspberry Pi into a network diagnostic machine.

EtherView Last updated jan 30, 2022. Welcome to the EtherView project! This is a project to transform a RaspberryPi into a portable network diagnostic

1 Jan 30, 2022