Only one entity is added with status unavailable
General information
Home Assistant
Version: 2023.9.1 Installation method (according to instructions): [ X ] Operating System (10.5) [ ] Linux VM [ ] Container [ ] Supervised [ ] Core
Integration
Installation method: [ X ] HACS [ ] manual from release [ ] manual from git Integration version: v2.2.0 Root topic: SleepAsAndroid
Application settings
[ X ] I can see MQTT messages from application at MQTT-server (only the first one though)
How it works now?
Only one sensor shows up which reports unavailable
What do you expect?
After Pressing Test like in the steps below, all sensors would show up and report the correct values.
Steps to reproduce
- Input mqtt url and topic (SleepAsAndroid/client)
- Add the integration in home assistant with these settings:
- Press Test in app (App reports "Connecting..." then "Success")
- Only one Entity (sensor.sleepasandroid_client) shows up which has status unavailable
Debug log
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'.
Additional information
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!
LMaier-dev, hello.
All goes well with your setup: while pressing "test" in the App the integration got payload='{"event":"Unknown"}' (the first message from log) and translate it to sensor state.
Try to start sleep tracking and you will see "sleep tracking started" payload and corresponding sensor state.
ps. the integration have just one sensor with current sleep tracking state.
а я поддерживаю предыдущего оратора...
что я делаю не так?
@baradetsky, пишете в чужом issue, в ситуации когда ваши настройки не соответствуют настройкам автора, не прикладываете логи и диагностическую информацию, которая требуется при создании issue.
ps. у вас в приложении, скорее всего (понять по скринам ваши настройки невозможно, поэтому форма issue запрашивает все что запрашивает, а не только один пункт, про который вы написали), в разделе topic, написано "SleepAsAndroid", а интеграция, скорее всего настроена на путь по умолчанию. Поэтому она и не видит данные. Пропишите в приложении topic SleepAsAndroid/baradetsky. Если не поможет -- открой issue, с логами и настройками, будем детальнее разбираться.
LMaier-dev, hello.
All goes well with your setup: while pressing "test" in the App the integration got
payload='{"event":"Unknown"}'(the first message from log) and translate it to sensor state.Try to start sleep tracking and you will see "sleep tracking started" payload and corresponding sensor state.
ps. the integration have just one sensor with current sleep tracking state.
Hi @IATkachenko, Very sorry, I forgot I opened this issue. Actually the next day it worked fine already (And it does to this day). I didnt even have to press the test button again. Feel free to close this issue when and if @baradetsky opens a separate one. Thanks again for this integration.