iatkachenko / ha-sleepasandroid Goto Github PK
View Code? Open in Web Editor NEWSleep As Android integration for Home Assistant
License: Apache License 2.0
Sleep As Android integration for Home Assistant
License: Apache License 2.0
Include Alarm Name as Part of Trigger Definition
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.
Support of german translation.
Version:
Installation method (according to instructions):
[ ] Operating System
[ ] Linux VM
[X] Container
[ ] Supervised
[ ] Core
Installation method:
[ ] HACS
[X] manual from release
[ ] manual from git
Integration version:
Root topic:
topic:
[X] I can see MQTT messages from application at MQTT-server
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 510, in async_add_entities
await asyncio.gather(*tasks)
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 750, in _async_add_entity
await entity.add_to_platform_finish()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1003, in add_to_platform_finish
await self.async_added_to_hass()
File "/config/custom_components/sleep_as_android/sensor.py", line 108, in async_added_to_hass
if (old_state := await self.async_get_last_sensor_data()) is not None:
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'SleepAsAndroidSensor' object has no attribute 'async_get_last_sensor_data'
Maybe, because of latest version of hass, 2023.8.3
https://developers.home-assistant.io/docs/core/entity/sensor/#restoring-sensor-states
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:
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.
The current provided blueprint works on device triggers. These don't provide as much information in their trigger variable as a state trigger does (most importantly, there is no from_state
).
I've edited the full.yaml
blueprint to make this work, and I've added the code below. Since I saw some python files in the folder of which I wasn't sure what they did, I opted not to make a pull request but instead do it like this. My idea would be to simply add this as a second blueprint in the repo. Due to problems when re-importing (caused overwriting) I've commented out the source_url
key currently.
When starting sleep tracking, my sleep as android pauses first. I'd like to slowly dim the lights once this happens, but also would like a night light to turn on when I pause it while actually asleep. By using the from_state
trigger variable, I can put a condition in the action that makes it only trigger if the previous state was not sleep_tracking_started
for example.
blueprint:
name: Sleep as Android MQTT entity actions
description: Define actions based on Sleep As Android sensor states
domain: automation
#source_url: https://github.com/IATkachenko/HA-SleepAsAndroid/blob/main/blueprint/full.yaml
input:
sleep_entity:
name: SleepAsAndroid Entity
description: 'Sleep As Android Integration Entity'
selector:
entity:
filter:
integration: sleep_as_android
multiple: false
person:
name: Person
description: Person for checking state
selector:
entity:
domain: person
multiple: false
state:
name: State
description: Person must be in this state
default: home
sleep_tracking_started:
name: sleep_tracking_started
description: sleep_tracking_started event
default: []
selector:
action: {}
sleep_tracking_stopped:
name: sleep_tracking_stopped
description: sleep_tracking_stopped event
default: []
selector:
action: {}
sleep_tracking_paused:
name: sleep_tracking_paused
description: sleep_tracking_paused event
default: []
selector:
action: {}
sleep_tracking_resumed:
name: sleep_tracking_resumed
description: sleep_tracking_resumed event
default: []
selector:
action: {}
alarm_snooze_clicked:
name: alarm_snooze_clicked
description: alarm_snooze_clicked event
default: []
selector:
action: {}
alarm_snooze_canceled:
name: alarm_snooze_canceled
description: alarm_snooze_canceled event
default: []
selector:
action: {}
time_to_bed_alarm_alert:
name: time_to_bed_alarm_alert
description: time_to_bed_alarm_alert event
default: []
selector:
action: {}
alarm_alert_start:
name: alarm_alert_start
description: alarm_alert_start event
default: []
selector:
action: {}
alarm_alert_dismiss:
name: alarm_alert_dismiss
description: alarm_alert_dismiss event
default: []
selector:
action: {}
alarm_skip_next:
name: alarm_skip_next
description: alarm_skip_next event
default: []
selector:
action: {}
show_skip_next_alarm:
name: show_skip_next_alarm
description: show_skip_next_alarm event
default: []
selector:
action: {}
rem:
name: rem
description: rem event
default: []
selector:
action: {}
smart_period:
name: smart_period
description: smart_period event
default: []
selector:
action: {}
before_smart_period:
name: before_smart_period
description: before_smart_period event
default: []
selector:
action: {}
lullaby_start:
name: lullaby_start
description: lullaby_start event
default: []
selector:
action: {}
lullaby_stop:
name: lullaby_stop
description: lullaby_stop event
default: []
selector:
action: {}
lullaby_volume_down:
name: lullaby_volume_down
description: lullaby_volume_down event
default: []
selector:
action: {}
deep_sleep:
name: deep_sleep
description: deep_sleep event
default: []
selector:
action: {}
light_sleep:
name: light_sleep
description: light_sleep event
default: []
selector:
action: {}
awake:
name: awake
description: awake event
default: []
selector:
action: {}
not_awake:
name: not_awake
description: not_awake event
default: []
selector:
action: {}
apnea_alarm:
name: apnea_alarm
description: apnea_alarm event
default: []
selector:
action: {}
antisnoring:
name: antisnoring
description: antisnoring event
default: []
selector:
action: {}
sound_event_snore:
name: sound_event_snore
description: sound_event_snore event
default: []
selector:
action: {}
sound_event_talk:
name: sound_event_talk
description: sound_event_talk event
default: []
selector:
action: {}
sound_event_cough:
name: sound_event_cough
description: sound_event_cough event
default: []
selector:
action: {}
sound_event_baby:
name: sound_event_baby
description: sound_event_baby event
default: []
selector:
action: {}
sound_event_laugh:
name: sound_event_laugh
description: sound_event_laugh event
default: []
selector:
action: {}
before_alarm:
name: before_alarm
description: before_alarm event
default: []
selector:
action: {}
mode: queued
max_exceeded: silent
trigger:
- platform: state
entity_id: !input sleep_entity
to: sleep_tracking_started
id: sleep_tracking_started
# - platform: device
# domain: sleep_as_android
# device_id: !input device
# type: sleep_tracking_started
# id: sleep_tracking_started
- platform: state
entity_id: !input sleep_entity
to: sleep_tracking_stopped
id: sleep_tracking_stopped
- platform: state
entity_id: !input sleep_entity
to: sleep_tracking_paused
id: sleep_tracking_paused
- platform: state
entity_id: !input sleep_entity
to: sleep_tracking_resumed
id: sleep_tracking_resumed
- platform: state
entity_id: !input sleep_entity
to: alarm_snooze_clicked
id: alarm_snooze_clicked
- platform: state
entity_id: !input sleep_entity
to: alarm_snooze_canceled
id: alarm_snooze_canceled
- platform: state
entity_id: !input sleep_entity
to: time_to_bed_alarm_alert
id: time_to_bed_alarm_alert
- platform: state
entity_id: !input sleep_entity
to: alarm_alert_start
id: alarm_alert_start
- platform: state
entity_id: !input sleep_entity
to: alarm_alert_dismiss
id: alarm_alert_dismiss
- platform: state
entity_id: !input sleep_entity
to: alarm_skip_next
id: alarm_skip_next
- platform: state
entity_id: !input sleep_entity
to: show_skip_next_alarm
id: show_skip_next_alarm
- platform: state
entity_id: !input sleep_entity
to: rem
id: rem
- platform: state
entity_id: !input sleep_entity
to: smart_period
id: smart_period
- platform: state
entity_id: !input sleep_entity
to: before_smart_period
id: before_smart_period
- platform: state
entity_id: !input sleep_entity
to: lullaby_start
id: lullaby_start
- platform: state
entity_id: !input sleep_entity
to: lullaby_stop
id: lullaby_stop
- platform: state
entity_id: !input sleep_entity
to: lullaby_volume_down
id: lullaby_volume_down
- platform: state
entity_id: !input sleep_entity
to: deep_sleep
id: deep_sleep
- platform: state
entity_id: !input sleep_entity
to: light_sleep
id: light_sleep
- platform: state
entity_id: !input sleep_entity
to: awake
id: awake
- platform: state
entity_id: !input sleep_entity
to: not_awake
id: not_awake
- platform: state
entity_id: !input sleep_entity
to: apnea_alarm
id: apnea_alarm
- platform: state
entity_id: !input sleep_entity
to: antisnoring
id: antisnoring
- platform: state
entity_id: !input sleep_entity
to: sound_event_snore
id: sound_event_snore
- platform: state
entity_id: !input sleep_entity
to: sound_event_talk
id: sound_event_talk
- platform: state
entity_id: !input sleep_entity
to: sound_event_cough
id: sound_event_cough
- platform: state
entity_id: !input sleep_entity
to: sound_event_baby
id: sound_event_baby
- platform: state
entity_id: !input sleep_entity
to: sound_event_laugh
id: sound_event_laugh
- platform: state
entity_id: !input sleep_entity
to: before_alarm
id: before_alarm
condition:
- condition: state
entity_id: !input person
state: !input state
action:
- choose:
- conditions:
condition: trigger
id: sleep_tracking_started
sequence: !input sleep_tracking_started
- conditions:
condition: trigger
id: sleep_tracking_stopped
sequence: !input sleep_tracking_stopped
- conditions:
condition: trigger
id: sleep_tracking_paused
sequence: !input sleep_tracking_paused
- conditions:
condition: trigger
id: sleep_tracking_resumed
sequence: !input sleep_tracking_resumed
- conditions:
condition: trigger
id: alarm_snooze_clicked
sequence: !input alarm_snooze_clicked
- conditions:
condition: trigger
id: alarm_snooze_canceled
sequence: !input alarm_snooze_canceled
- conditions:
condition: trigger
id: time_to_bed_alarm_alert
sequence: !input time_to_bed_alarm_alert
- conditions:
condition: trigger
id: alarm_alert_start
sequence: !input alarm_alert_start
- conditions:
condition: trigger
id: alarm_alert_dismiss
sequence: !input alarm_alert_dismiss
- conditions:
condition: trigger
id: alarm_skip_next
sequence: !input alarm_skip_next
- conditions:
condition: trigger
id: show_skip_next_alarm
sequence: !input show_skip_next_alarm
- conditions:
condition: trigger
id: rem
sequence: !input rem
- conditions:
condition: trigger
id: smart_period
sequence: !input smart_period
- conditions:
condition: trigger
id: before_smart_period
sequence: !input before_smart_period
- conditions:
condition: trigger
id: lullaby_start
sequence: !input lullaby_start
- conditions:
condition: trigger
id: lullaby_stop
sequence: !input lullaby_stop
- conditions:
condition: trigger
id: lullaby_volume_down
sequence: !input lullaby_volume_down
- conditions:
condition: trigger
id: deep_sleep
sequence: !input deep_sleep
- conditions:
condition: trigger
id: light_sleep
sequence: !input light_sleep
- conditions:
condition: trigger
id: awake
sequence: !input awake
- conditions:
condition: trigger
id: not_awake
sequence: !input not_awake
- conditions:
condition: trigger
id: apnea_alarm
sequence: !input apnea_alarm
- conditions:
condition: trigger
id: antisnoring
sequence: !input antisnoring
- conditions:
condition: trigger
id: sound_event_snore
sequence: !input sound_event_snore
- conditions:
condition: trigger
id: sound_event_talk
sequence: !input sound_event_talk
- conditions:
condition: trigger
id: sound_event_cough
sequence: !input sound_event_cough
- conditions:
condition: trigger
id: sound_event_baby
sequence: !input sound_event_baby
- conditions:
condition: trigger
id: sound_event_laugh
sequence: !input sound_event_laugh
- conditions:
condition: trigger
id: before_alarm
sequence: !input before_alarm
Version:
Installation method (according to instructions):
[X] Operating System
[ ] Container
[ ] Supervised
[ ] Core
Installation method:
[X] HACS
[ ] manual from release
[ ] manual from git
Integration version:
Root topic:
topic:
[X] I can see MQTT messages from application at MQTT-server
The integration settings does not show what is really current, but always the default.
The integration / sensor works as expected.
The integration settings (name/topic/qos) to reflect what is really configured
sensor/SleepAsAndroid/%%%device%%%
2022-02-18 16:34:32 WARNING (MainThread) [custom_components.sleep_as_android.sensor] Got Unknown event, but it is not in TRIGGERS list: will not fire this event for trigger!
The fact that the config box does not mention the need for a restart, and the box not fetching the active real settings it looks to be completely broken even though it works.
Version: 2022.6.0.dev20220525
Installation method (according to instructions):
[ ] Operating System
[x] Container
[ ] Supervised
[ ] Core
Installation method:
[x] HACS
[ ] manual from release
[ ] manual from git
Integration version: 1.9.1
Detected integration that uses deprecated `async_get_registry` to access device registry, use async_get instead. Please report issue to the custom component author for sleep_as_android using this method at custom_components/sleep_as_android/sensor.py, line 96: device_registry = await dr.async_get_registry(self.hass)
With the newest Home-Assistant dev version this needs a fix soon!
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.
Version:2022.3.0b3
Installation method (according to instructions):
[ ] Operating System
[ โ] Container
[ ] Supervised
[ ] Core
Installation method:
[ โ] HACS
[ ] manual from release
[ ] manual from git
Integration version:v1.8.0
2022-02-26 20:11:31 ERROR (MainThread) [homeassistant.components.sensor] Error while setting up sleep_as_android platform for sensor
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 249, in _async_setup_platform
await asyncio.shield(task)
File "/config/custom_components/sleep_as_android/sensor.py", line 48, in async_setup_entry
await instance.subscribe_root_topic(async_add_entities)
File "/config/custom_components/sleep_as_android/__init__.py", line 208, in subscribe_root_topic
self._subscription_state = await subscription.async_subscribe_topics(
TypeError: async_subscribe_topics() takes 2 positional arguments but 3 were given
Integration version: v1.2.1
Root topic: Integration fails configuration checks
topic: Can't check (application won't start) but believe it was default
[ ] I can see MQTT messages from application at MQTT-server
Integration fails to load
Integration should load!
Install the integration
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)).
Just upgraded to core-2021.7.0
Hi Igor,
I spent hours (actually days) to get this component working. I had getting error like "Unknown module pyhaversion" or so (I don've the logs). And the solution was very simple - enable Version module https://www.home-assistant.io/integrations/version
Please add note to README file about this (HA-SleepAsAndroid requires Version module enabled).
I installed it directly, just copied it to custom_components directory without HACS
Great work, thank you very much for this component!
I'm using emqx as the server side of mqtt, and SleepAsAndroid configured emqx's server and the test is successful, but I can't see the corresponding client device in emqx's client list.
What should I do now? I can see mqtt coming from other devices like nodered.
Thank You!
Hello, I have a very similar issue to the solved one here: #41
I have read through that discussion and tried to mimic the solution, but no device shows up in the Sleep As Android blueprint, after restarting HA.
The Application Topic is: SleepAsAndroid/subtopic
The Integration MQTT Topic is: SleepAsAndroid/subtopic
Using the "Test" command in the application causes an event to pop up in the HA MQTT Integration when listening, and also in MQTT Explorer running on my desktop PC. And I've set an alarm on my Sleep As Android application to try to fire off a test event, which seems to work fine ("alarm_alert_start" "alarm_alert_dismiss" show up in MQTT Explorer).
I am doing something wrong but am not quite sure what it is. I am very new to this. Thank for you very much for your hard work!
2021.12.4:
Installation method (according to instructions):
[X] Operating System
[ ] Container
[ ] Supervised
[ ] Core
Installation method:
[X] HACS
[ ] manual from release
[ ] manual from git
Integration version:v1.6.0
Root topic:
topic:
[X] I can see MQTT messages from application at MQTT-server
After installing the SAA Integration and restarting HA, the SAA Integration is not available under Settings / Integrations
N/A
No output generated, despite having added the debug setting to my config.yaml
Integration version: 1.2.0
Root topic: SleepAsAndroid
topic:
Thanks for working on this! Testing it out now!
I'm having issues where no devices or entities are showing up or being created. Listening to MQTT event 'SleepAsAndroid' is working and showing the appropriate events. I have two clients with different Client IDs in the app. The integration was installed and I left both the sensor name and topic as default 'SleepAsAndroid'.
HA Logs:
2021-02-07 15:02:29 INFO (MainThread) [custom_components.sleep_as_android] Setting up 67fab8a69bcd5607d95ff896ab1d4fb3
2021-02-07 15:02:33 DEBUG (MainThread) [custom_components.sleep_as_android.sensor] Subscribing to root topic 'SleepAsAndroid'
2021-02-07 15:02:34 DEBUG (MainThread) [custom_components.sleep_as_android.sensor] Subscribing to root topic is done!
MQTT Logs:
[INFO] found mqtt on Home Assistant
1612728941: New client connected from 192.XXX.X.XX as Test2 (p2, c1, k60, u'mqtt').
1612728941: Client Test2 disconnected.
1612728948: New connection from 192.XXX.X.XX on port 1883.
1612728948: New client connected from 192.XXX.X.XX as Test1 (p2, c1, k60, u'mqtt').
1612728948: Client Test1 disconnected.
1612728952: New connection from 192.XXX.X.XX on port 1883.
1612728952: New client connected from 192.XXX.X.XX as Test1 (p2, c1, k60, u'mqtt').
1612728952: Client Test1 disconnected.
Any ideas what I'm missing?
This is working great! Anyway to add support for multiple users through the UI, creating different entities?
I have noticed an inconsistent/ unreliable triggering of this automation and upon checking the "Trace Timeline" I was getting the following message: "Stopped because maximum number of parallel runs reached at XXXXXX"
Based on the documentation, the default # of parallel runs is 10 so I have updated the Blueprint to 30 which solved this issue:
Blueprint folder: /config/blueprints/automation/IATkachenko/full.yaml
Code change:
max: 30 #line added after "mode: queued" (line 199). The default is 10 as detailed in https://www.home-assistant.io/docs/automation/modes
Maybe others are facing the same issue and this simple change can be updated into the Blueprint. Thanks
Version: 2023.6.3
Installation method (according to instructions):
[X] Operating System
[ ] Linux VM
[ ] Container
[ ] Supervised
[ ] Core
Installation method:
[X] HACS
[ ] manual from release
[ ] manual from git
Integration version:
Root topic:
topic:
[X] I can see MQTT messages from application at MQTT-server
Put Home Assistant debug log, related to the issue, here
Version: 2023.9.1
Installation method (according to instructions):
[ X ] Operating System (10.5)
[ ] Linux VM
[ ] Container
[ ] Supervised
[ ] Core
Installation method:
[ X ] HACS
[ ] manual from release
[ ] manual from git
Integration version: v2.2.0
Root topic: SleepAsAndroid
[ X ] I can see MQTT messages from application at MQTT-server (only the first one though)
Only one sensor shows up which reports unavailable
After Pressing Test like in the steps below, all sensors would show up and report the correct values.
2023-09-10 12:50:09.831 DEBUG (MainThread) [custom_components.sleep_as_android] Got message ReceiveMessage(topic='SleepAsAndroid/lorenz', payload='{"event":"Unknown"}', qos=0, retain=0, subscribed_topic='SleepAsAndroid/+', timestamp=datetime.datetime(2023, 9, 10, 10, 50, 9, 831189, tzinfo=datetime.timezone.utc))
2023-09-10 12:50:09.832 DEBUG (MainThread) [custom_components.sleep_as_android] create_entity_id: my name is SleepAsAndroid, device name is lorenz
2023-09-10 12:50:09.832 DEBUG (MainThread) [custom_components.sleep_as_android] sensor entity_id is SleepAsAndroid_lorenz
2023-09-10 12:50:09.833 INFO (MainThread) [custom_components.sleep_as_android] New device! Let's create sensor for lorenz
2023-09-10 12:50:09.833 DEBUG (MainThread) [custom_components.sleep_as_android.sensor] New attributes is {'timestamp': 'unavailable', 'label': 'unavailable'}
2023-09-10 12:50:09.833 DEBUG (MainThread) [custom_components.sleep_as_android.sensor] Creating sensor with name lorenz
2023-09-10 12:50:09.833 DEBUG (MainThread) [custom_components.sleep_as_android.sensor] Processing message ReceiveMessage(topic='SleepAsAndroid/lorenz', payload='{"event":"Unknown"}', qos=0, retain=0, subscribed_topic='SleepAsAndroid/+', timestamp=datetime.datetime(2023, 9, 10, 10, 50, 9, 831189, tzinfo=datetime.timezone.utc))
2023-09-10 12:50:09.833 DEBUG (MainThread) [custom_components.sleep_as_android.sensor] Got payload['event']='Unknown'. Will use STATE_UNKNOWN='unknown' instead
2023-09-10 12:50:09.833 DEBUG (MainThread) [custom_components.sleep_as_android.sensor] New attributes is {'timestamp': 'unavailable', 'label': 'unavailable'}
2023-09-10 12:50:09.833 DEBUG (MainThread) [custom_components.sleep_as_android.sensor] Will not update state because old self.state='unknown' == new_state='unknown'
2023-09-10 12:50:09.833 DEBUG (MainThread) [custom_components.sleep_as_android.sensor] Firing 'SleepAsAndroid_lorenz' with payload: '{'event': 'unknown'}'
2023-09-10 12:50:09.835 DEBUG (MainThread) [custom_components.sleep_as_android.sensor] My identifiers is {('sleep_as_android', 'SleepAsAndroid_lorenz')}
2023-09-10 12:50:09.837 DEBUG (MainThread) [custom_components.sleep_as_android.sensor] My identifiers is {('sleep_as_android', 'SleepAsAndroid_lorenz')}
2023-09-10 12:50:09.837 DEBUG (MainThread) [custom_components.sleep_as_android.sensor] My device id is 19f4d0ea86bded0b5121a31057bed36f
2023-09-10 12:50:09.837 DEBUG (MainThread) [custom_components.sleep_as_android.sensor] Got self._attr_native_value='unknown'. Will use STATE_UNKNOWN='unknown' instead
2023-09-10 12:50:09.837 DEBUG (MainThread) [custom_components.sleep_as_android.sensor] async_added_to_hass: restored previous state for SleepAsAndroid_lorenz: self.state='unknown', self.native_value='unknown'.
My Mosquitto MQTT broker only log this:
2023-09-10 13:09:40: New client connected from 192.168.0.81:47932 as SleepAsAndroid (p2, c1, k60, u'mqtt-user').
2023-09-10 13:09:40: Client SleepAsAndroid disconnected.
Thanks for working on this!
Version: 2023.8 beta
Installation method (according to instructions):
[X] Operating System
[ ] Linux VM
[ ] Container
[ ] Supervised
[ ] Core
Installation method:
[X] HACS
[ ] manual from release
[ ] manual from git
Integration version: 1.10.0
Root topic: SleepAsAndroid
topic: SleepAsAndroid/William
[X] I can see MQTT messages from application at MQTT-server
Integration does not produce any entities
Integration should produce entities
2023-07-30 22:11:39.081 DEBUG (MainThread) [custom_components.sleep_as_android] Got message ReceiveMessage(topic='SleepAsAndroid/William', payload='{"event":"sleep_tracking_started"}', qos=0, retain=0, subscribed_topic='SleepAsAndroid/William', timestamp=datetime.datetime(2023, 7, 31, 3, 11, 39, 81566, tzinfo=datetime.timezone.utc))
2023-07-30 22:11:39.081 DEBUG (MainThread) [custom_components.sleep_as_android] sensor entity_id is SleepAsAndroid_William
2023-07-30 22:11:39.081 DEBUG (MainThread) [custom_components.sleep_as_android.sensor] Processing message ReceiveMessage(topic='SleepAsAndroid/William', payload='{"event":"sleep_tracking_started"}', qos=0, retain=0, subscribed_topic='SleepAsAndroid/William', timestamp=datetime.datetime(2023, 7, 31, 3, 11, 39, 81566, tzinfo=datetime.timezone.utc))
2023-07-30 22:11:39.081 DEBUG (MainThread) [custom_components.sleep_as_android.sensor] New attributes is {'timestamp': 'unavailable', 'label': 'unavailable'}
Integration version: I tried the last one and the main branch from github
Last HACS version, last HA-OS version
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
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).
Version: 2023.5.2
Installation method (according to instructions):
[X] Operating System
[ ] Linux VM
[ ] Container
[ ] Supervised
[ ] Core
Installation method:
[X] HACS
[ ] manual from release
[ ] manual from git
Integration version: 1.9.2
Root topic: SleepAsAndroid
topic: SleepAsAndroid/%%%device%%%
[X] I can see MQTT messages from application at MQTT-server
MQTT Messages arrive but nothing happens because integration is not loaded.
Integration should get loaded correctly
2023-05-08 08:14:06.193 INFO (MainThread) [custom_components.sleep_as_android] Setting up 40986c100e0ebc908eea6859744826ee
2023-05-08 08:14:06.193 ERROR (MainThread) [homeassistant.config_entries] Error setting up entry SleepAsAndroid for sleep_as_android
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/config_entries.py", line 387, in async_setup
result = await component.async_setup_entry(hass, self)
File "/config/custom_components/sleep_as_android/__init__.py", line 42, in async_setup_entry
hass.config_entries.async_setup_platforms(config_entry, [Platform.SENSOR])
AttributeError: 'ConfigEntries' object has no attribute 'async_setup_platforms'
2023-05-08 08:14:28.929 DEBUG (MainThread) [custom_components.sleep_as_android.device_trigger] Got subscription to trigger: {'platform': 'device', 'domain': 'sleep_as_android', 'device_id': '0a36bcd493898618cc9f841fe0ae21e5', 'type': 'sleep_tracking_started', 'id': 'sleep_tracking_started'}
2023-05-08 08:14:28.929 DEBUG (MainThread) [custom_components.sleep_as_android.device_trigger] Got subscription to trigger: {'platform': 'device', 'domain': 'sleep_as_android', 'device_id': '0a36bcd493898618cc9f841fe0ae21e5', 'type': 'sleep_tracking_stopped', 'id': 'sleep_tracking_stopped'}
2023-05-08 08:14:28.930 DEBUG (MainThread) [custom_components.sleep_as_android.device_trigger] Got subscription to trigger: {'platform': 'device', 'domain': 'sleep_as_android', 'device_id': '0a36bcd493898618cc9f841fe0ae21e5', 'type': 'sleep_tracking_paused', 'id': 'sleep_tracking_paused'}
2023-05-08 08:14:28.933 DEBUG (MainThread) [custom_components.sleep_as_android.device_trigger] Got subscription to trigger: {'platform': 'device', 'domain': 'sleep_as_android', 'device_id': '0a36bcd493898618cc9f841fe0ae21e5', 'type': 'sleep_tracking_resumed', 'id': 'sleep_tracking_resumed'}
2023-05-08 08:14:28.933 DEBUG (MainThread) [custom_components.sleep_as_android.device_trigger] Got subscription to trigger: {'platform': 'device', 'domain': 'sleep_as_android', 'device_id': '0a36bcd493898618cc9f841fe0ae21e5', 'type': 'alarm_snooze_clicked', 'id': 'alarm_snooze_clicked'}
2023-05-08 08:14:28.933 DEBUG (MainThread) [custom_components.sleep_as_android.device_trigger] Got subscription to trigger: {'platform': 'device', 'domain': 'sleep_as_android', 'device_id': '0a36bcd493898618cc9f841fe0ae21e5', 'type': 'alarm_snooze_canceled', 'id': 'alarm_snooze_canceled'}
2023-05-08 08:14:28.933 DEBUG (MainThread) [custom_components.sleep_as_android.device_trigger] Got subscription to trigger: {'platform': 'device', 'domain': 'sleep_as_android', 'device_id': '0a36bcd493898618cc9f841fe0ae21e5', 'type': 'time_to_bed_alarm_alert', 'id': 'time_to_bed_alarm_alert'}
2023-05-08 08:14:28.934 DEBUG (MainThread) [custom_components.sleep_as_android.device_trigger] Got subscription to trigger: {'platform': 'device', 'domain': 'sleep_as_android', 'device_id': '0a36bcd493898618cc9f841fe0ae21e5', 'type': 'alarm_alert_start', 'id': 'alarm_alert_start'}
2023-05-08 08:14:28.934 DEBUG (MainThread) [custom_components.sleep_as_android.device_trigger] Got subscription to trigger: {'platform': 'device', 'domain': 'sleep_as_android', 'device_id': '0a36bcd493898618cc9f841fe0ae21e5', 'type': 'alarm_alert_dismiss', 'id': 'alarm_alert_dismiss'}
2023-05-08 08:14:28.934 DEBUG (MainThread) [custom_components.sleep_as_android.device_trigger] Got subscription to trigger: {'platform': 'device', 'domain': 'sleep_as_android', 'device_id': '0a36bcd493898618cc9f841fe0ae21e5', 'type': 'alarm_skip_next', 'id': 'alarm_skip_next'}
2023-05-08 08:14:28.934 DEBUG (MainThread) [custom_components.sleep_as_android.device_trigger] Got subscription to trigger: {'platform': 'device', 'domain': 'sleep_as_android', 'device_id': '0a36bcd493898618cc9f841fe0ae21e5', 'type': 'show_skip_next_alarm', 'id': 'show_skip_next_alarm'}
2023-05-08 08:14:28.934 DEBUG (MainThread) [custom_components.sleep_as_android.device_trigger] Got subscription to trigger: {'platform': 'device', 'domain': 'sleep_as_android', 'device_id': '0a36bcd493898618cc9f841fe0ae21e5', 'type': 'rem', 'id': 'rem'}
2023-05-08 08:14:28.934 DEBUG (MainThread) [custom_components.sleep_as_android.device_trigger] Got subscription to trigger: {'platform': 'device', 'domain': 'sleep_as_android', 'device_id': '0a36bcd493898618cc9f841fe0ae21e5', 'type': 'smart_period', 'id': 'smart_period'}
2023-05-08 08:14:28.935 DEBUG (MainThread) [custom_components.sleep_as_android.device_trigger] Got subscription to trigger: {'platform': 'device', 'domain': 'sleep_as_android', 'device_id': '0a36bcd493898618cc9f841fe0ae21e5', 'type': 'before_smart_period', 'id': 'before_smart_period'}
2023-05-08 08:14:28.935 DEBUG (MainThread) [custom_components.sleep_as_android.device_trigger] Got subscription to trigger: {'platform': 'device', 'domain': 'sleep_as_android', 'device_id': '0a36bcd493898618cc9f841fe0ae21e5', 'type': 'lullaby_start', 'id': 'lullaby_start'}
2023-05-08 08:14:28.935 DEBUG (MainThread) [custom_components.sleep_as_android.device_trigger] Got subscription to trigger: {'platform': 'device', 'domain': 'sleep_as_android', 'device_id': '0a36bcd493898618cc9f841fe0ae21e5', 'type': 'lullaby_stop', 'id': 'lullaby_stop'}
2023-05-08 08:14:28.935 DEBUG (MainThread) [custom_components.sleep_as_android.device_trigger] Got subscription to trigger: {'platform': 'device', 'domain': 'sleep_as_android', 'device_id': '0a36bcd493898618cc9f841fe0ae21e5', 'type': 'lullaby_volume_down', 'id': 'lullaby_volume_down'}
2023-05-08 08:14:28.935 DEBUG (MainThread) [custom_components.sleep_as_android.device_trigger] Got subscription to trigger: {'platform': 'device', 'domain': 'sleep_as_android', 'device_id': '0a36bcd493898618cc9f841fe0ae21e5', 'type': 'deep_sleep', 'id': 'deep_sleep'}
2023-05-08 08:14:28.935 DEBUG (MainThread) [custom_components.sleep_as_android.device_trigger] Got subscription to trigger: {'platform': 'device', 'domain': 'sleep_as_android', 'device_id': '0a36bcd493898618cc9f841fe0ae21e5', 'type': 'light_sleep', 'id': 'light_sleep'}
2023-05-08 08:14:28.936 DEBUG (MainThread) [custom_components.sleep_as_android.device_trigger] Got subscription to trigger: {'platform': 'device', 'domain': 'sleep_as_android', 'device_id': '0a36bcd493898618cc9f841fe0ae21e5', 'type': 'awake', 'id': 'awake'}
2023-05-08 08:14:28.936 DEBUG (MainThread) [custom_components.sleep_as_android.device_trigger] Got subscription to trigger: {'platform': 'device', 'domain': 'sleep_as_android', 'device_id': '0a36bcd493898618cc9f841fe0ae21e5', 'type': 'not_awake', 'id': 'not_awake'}
2023-05-08 08:14:28.936 DEBUG (MainThread) [custom_components.sleep_as_android.device_trigger] Got subscription to trigger: {'platform': 'device', 'domain': 'sleep_as_android', 'device_id': '0a36bcd493898618cc9f841fe0ae21e5', 'type': 'apnea_alarm', 'id': 'apnea_alarm'}
2023-05-08 08:14:28.936 DEBUG (MainThread) [custom_components.sleep_as_android.device_trigger] Got subscription to trigger: {'platform': 'device', 'domain': 'sleep_as_android', 'device_id': '0a36bcd493898618cc9f841fe0ae21e5', 'type': 'antisnoring', 'id': 'antisnoring'}
2023-05-08 08:14:28.936 DEBUG (MainThread) [custom_components.sleep_as_android.device_trigger] Got subscription to trigger: {'platform': 'device', 'domain': 'sleep_as_android', 'device_id': '0a36bcd493898618cc9f841fe0ae21e5', 'type': 'sound_event_snore', 'id': 'sound_event_snore'}
2023-05-08 08:14:28.937 DEBUG (MainThread) [custom_components.sleep_as_android.device_trigger] Got subscription to trigger: {'platform': 'device', 'domain': 'sleep_as_android', 'device_id': '0a36bcd493898618cc9f841fe0ae21e5', 'type': 'sound_event_talk', 'id': 'sound_event_talk'}
2023-05-08 08:14:28.937 DEBUG (MainThread) [custom_components.sleep_as_android.device_trigger] Got subscription to trigger: {'platform': 'device', 'domain': 'sleep_as_android', 'device_id': '0a36bcd493898618cc9f841fe0ae21e5', 'type': 'sound_event_cough', 'id': 'sound_event_cough'}
2023-05-08 08:14:28.937 DEBUG (MainThread) [custom_components.sleep_as_android.device_trigger] Got subscription to trigger: {'platform': 'device', 'domain': 'sleep_as_android', 'device_id': '0a36bcd493898618cc9f841fe0ae21e5', 'type': 'sound_event_baby', 'id': 'sound_event_baby'}
2023-05-08 08:14:28.937 DEBUG (MainThread) [custom_components.sleep_as_android.device_trigger] Got subscription to trigger: {'platform': 'device', 'domain': 'sleep_as_android', 'device_id': '0a36bcd493898618cc9f841fe0ae21e5', 'type': 'sound_event_laugh', 'id': 'sound_event_laugh'}
2023-05-08 08:14:28.938 DEBUG (MainThread) [custom_components.sleep_as_android.device_trigger] Got subscription to trigger: {'platform': 'device', 'domain': 'sleep_as_android', 'device_id': '0a36bcd493898618cc9f841fe0ae21e5', 'type': 'before_alarm', 'id': 'before_alarm'}
2023-05-08 08:14:28.938 DEBUG (MainThread) [custom_components.sleep_as_android.device_trigger] Got subscription to trigger: {'platform': 'device', 'domain': 'sleep_as_android', 'device_id': '0a36bcd493898618cc9f841fe0ae21e5', 'type': 'before_alarm'}
2023-05-08 08:14:48.083 ERROR (MainThread) [homeassistant.config_entries] Error setting up entry SleepAsAndroid for sleep_as_android
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/config_entries.py", line 387, in async_setup
result = await component.async_setup_entry(hass, self)
File "/config/custom_components/sleep_as_android/__init__.py", line 42, in async_setup_entry
hass.config_entries.async_setup_platforms(config_entry, [Platform.SENSOR])
AttributeError: 'ConfigEntries' object has no attribute 'async_setup_platforms
Last working HA version: 2023.4.5
I updated directly from there so I can't say if it broke on 2023.5 or one of the point releases.
I'm currently at work but I will see if I can find anything else later in the day.
Version:
Installation method (according to instructions):
[ ] Operating System
[ ] Linux VM
[X] Container
[ ] Supervised
[ ] Core
Installation method:
[X] HACS
[ ] manual from release
[ ] manual from git
Integration version:
Root topic:
topic:
[ ] I can see MQTT messages from application at MQTT-server
After upgrading to SleepAsAndroid 20231001 there appears to be a new event type that's causing the custom component to fail.
2023-10-13 21:02:31.873 ERROR (MainThread) [homeassistant.util.logging] Exception in message_received when handling msg on 'SleepAsAndroid/Pixel 8 Pro': '{"event":"Unknown"}'
Traceback (most recent call last):
File "/config/custom_components/sleep_as_android/__init__.py", line 253, in message_received
target_sensor.process_message(msg)
File "/config/custom_components/sleep_as_android/sensor.py", line 156, in process_message
if self.state != new_state:
^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/sensor/__init__.py", line 569, in state
raise ValueError(
ValueError: Sensor sensor.sleepasandroid_pixel_8_pro provides state value 'alarm_rescheduled', which is not in the list of options provided
I'm not sure, but it appears the filter for events in SleepAsAndroid doesn't work.
Integration version: v1.2.0
HASS version: 2021.3.4
Root topic: SleepAsAndroid
configured Sleep as android to use SleepAsAndroid/roman
topic
topic:
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.
Device and entity that would collect the events and states from the mqtt topic
I followed all the steps as described in readme
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!
just wanted to say hi and thank you for the integration
Version: 2022.11.1
Installation method (according to instructions):
[x] Linux VM
[ ] Operating System
[ ] Container
[ ] Supervised
[ ] Core
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
topic: sensor/SleepAsAndroid/%%%device%%%
[x] I can see MQTT messages from application at MQTT-server
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.
The device to be deleteable in the devices screen
Not sure, but I think
N/A
Thank you for the great quality of life boost this is giving me!
2021.11.1:
Installation method (according to instructions):
[X] Operating System
[ ] Container
[ ] Supervised
[ ] Core
Installation method:
[X] HACS
[ ] manual from release
[ ] manual from git
Integration version: v1.4.0
Root topic: SleepAsAndroid
topic: bartfp3
[ X] I can see MQTT messages from application at MQTT-server
Configuration changes in name and/or topic are submitted. The integration reports success but values do not change from defaults.
Values change to strings entered
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
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.
Version: 2022.3.0b5
Installation method (according to instructions):
[X] Operating System
[ ] Container
[ ] Supervised
[ ] Core
Installation method:
[X] HACS
[ ] manual from release
[ ] manual from git
Integration version: v1.8.2
Root topic:
topic:
[X] I can see MQTT messages from application at MQTT-server
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'"
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'
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.