mampfes / hacs_waste_collection_schedule

Home Assistant integration framework for (garbage collection) schedules
MIT License
988 stars 631 forks source link

[Bug]: UI-configured `appointment_types` sensor doesn't consistently have the expected attributes #2297

Closed milnivlek closed 1 month ago

milnivlek commented 2 months ago

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:

With this, I expect the sensor to always have two attributes that look like this:

Trash: 2024-07-23
Recycling: 2024-07-30

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

aw750s commented 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.

2024-08-04 02_33_33-Einstellungen – Home Assistant – Mozilla Firefox after reboot 2024-08-04 02_34_47-Einstellungen – Home Assistant – Mozilla Firefox

holgergrote commented 1 month ago

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)

5ila5 commented 1 month ago

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)