bruxy70 / Garbage-Collection

🗑 Custom Home Assistant sensor for scheduling garbage collection (or other regularly re-occurring events - weekly on given days, semi-weekly or monthly)
MIT License
383 stars 90 forks source link

The sensor. is showing wrong values if there is no any schedule in future #438

Closed marianbezeg closed 1 year ago

marianbezeg commented 1 year ago

Before you submit a new bug report, please check that

Describe the bug

Sensor is showing that next schedule will be in 54 days. But there is no future schedule ("Next date") for this sensor.

image

Configuration

alias: Include dates - Nebezpečný odpad
description: ""
use_blueprint:
  path: bruxy70/include.yaml
  input:
    garbage_collection_entity: sensor.nebezpecny_odpad
    include: |-
      2022-02-28
      2022-08-24

Sensor is configured as "blank" with manual update.

Debug logs

2022-11-10 10:49:09.061 DEBUG (MainThread) [custom_components.garbage_collection] Setting Nebezpečný odpad (blank) from ConfigFlow
2022-11-10 10:49:19.696 DEBUG (MainThread) [custom_components.garbage_collection.sensor] (Nebezpečný odpad) Calling update
2022-11-10 10:49:19.696 DEBUG (MainThread) [custom_components.garbage_collection.sensor] (Nebezpečný odpad) Dates loaded, firing a garbage_collection_loaded event
2022-11-10 10:49:19.965 DEBUG (MainThread) [custom_components.garbage_collection] called add_date 2022-02-28 from sensor.nebezpecny_odpad
2022-11-10 10:49:20.120 DEBUG (MainThread) [custom_components.garbage_collection] called add_date 2022-08-24 from sensor.nebezpecny_odpad
2022-11-10 10:49:20.171 DEBUG (MainThread) [custom_components.garbage_collection] called update_state for sensor.nebezpecny_odpad
2022-11-10 10:49:20.172 DEBUG (MainThread) [custom_components.garbage_collection.sensor] (Nebezpečný odpad) Looking for next collection
bruxy70 commented 1 year ago

I have just configured it with the same blueprint and dates, and this is what I get:

image
bruxy70 commented 1 year ago
image
marianbezeg commented 1 year ago

I've checked my sensor and its almost same. image There is nothing in calendar in next year. I see that you have number 2 there as well. Shouldn't this be something like no schedule, N/A etc. ?

bruxy70 commented 1 year ago

I will see if I can change that without breaking things.

marianbezeg commented 1 year ago

Looks like there is another issue with same thing. After the last scheduled date state is always today...

image

marianbezeg commented 1 year ago

Me again, i edited code to fix this issue. I dont know if this is correct approach but at least its working for me :)

image image image

bruxy70 commented 1 year ago

Thanks for the find. I did not really expect this condition, but you are right that with the blank and no dates added it could happen. So I added the code to set the state and next date to None. Check the latest release if it helps. If yes, please close the ticket.

marianbezeg commented 1 year ago

@bruxy70 well, it looks like that now its working correctly.

Maybe last thing is to keep icon to "self._attr_icon = self._icon_normal" if there is no schedule as now there is no icon for the sensor. I assume that one from configured helper should be visible, but maybe its only how I see this thing 😄

image

github-actions[bot] commented 1 year ago

This issue has been automatically marked as stale because it has not had any activity in last 30 days. It will be closed in 5 days if no further activity occurs. Thank you for your contributions.