Closed milnivlek closed 1 month ago
I have a similar problem. I configured the sensor using the UI, and after restarting HomeAssinstant the sensor attributes are no longer there.
after reboot
I have the same problem after a reboot. The attributes are missing after a reboot.
Normally the template {{ (states.sensor.muell) }} gives: <template TemplateState(<state sensor.muell=Biotonne, Restmüll in 1 days; 2024-08-16=Biotonne, Restmüll, 2024-08-21=Blaue Tonne, 2024-08-29=Gelbe Tonne, 2024-08-30=Restmüll, Biotonne, 2024-09-04=Blaue Tonne, attribution=Last update: 08/15/24 11:43:13, icon=mdi:numeric-2-box-multiple, friendly_name=muell @ 2024-08-15T11:43:13.041510+02:00>)> After a reboot it gives <template TemplateState(<state sensor.muell=Biotonne, Restmüll in 1 days; attribution=Last update: 08/15/24 11:48:14, icon=mdi:numeric-2-box-multiple, friendly_name=muell @ 2024-08-15T11:48:15.516255+02:00>)>
When I go into the configuration and do a reconfiguration of the sensor (without changing anything) it works again. A reload of the integration does not help. (After a reboot the attributes are still missing and if the attributes are there they are also there after the reload)
Fixed in #2475 looks like the code expected to always get an Enum, but after a restart HA would just return a string representation of the enum
This will be part of the next release or is available now as master (git) version (3-dot menu -> redownload -> change version to master -> fully restart HA (this will increase update cycle by a lot)
I Have A Problem With:
Sensor configuration
What's Your Problem
I tried migrating my sensor config over to the new UI-based flow. Specifically, I set up a sensor like this:
in .. days / Tomoorow / Today: {% if value.daysTo == 0 %}Today{% elif value.daysTo == 1 %}Tomorrow{% else %}in {{value.daysTo}} days{% endif %}
2020-03-20: {{value.date.strftime("%Y-%m-%d")}}
With this, I expect the sensor to always have two attributes that look like this:
However, in practice I observed that these attributes are often missing entirely from the sensor. Oddly, it doesn't happen 100%. But in my case, this is especially reproducible just after restarting Home Assistant.
However, this only happens with the UI-based configuration. I reverted back to my previous equivalent YAML-based sensor config (with the same Waste Collection Schedule plugin version) and the sensor is back to being rock solid.
So there's something odd specifically with the UI-configured flow that causes this sensor attributes to be incorrectly initialized. Maybe a race condition?
Source (if relevant)
No response
Logs
No response
Relevant Configuration
See above.
Checklist Source Error
Checklist Sensor Error
Required