bmcclure / ha-chore-helper

A Home Assistant helper integration for managing recurring chores.
MIT License
59 stars 7 forks source link

Next due date updates slowly #39

Open zsmb13 opened 7 months ago

zsmb13 commented 7 months ago

System Health details

System Information

version core-2024.2.2
installation_type Home Assistant Container
dev false
hassio false
docker true
user root
virtualenv false
python_version 3.12.1
os_name Linux
os_version 4.4.302+
arch x86_64
timezone Europe/Budapest
config_dir /config
Home Assistant Community Store GitHub API | ok -- | -- GitHub Content | ok GitHub Web | ok GitHub API Calls Remaining | 4970 Installed Version | 1.34.0 Stage | running Available Repositories | 1409 Downloaded Repositories | 34 HACS Data | ok
AccuWeather can_reach_server | ok -- | -- remaining_requests | 29
Home Assistant Cloud logged_in | false -- | -- can_reach_cert_server | ok can_reach_cloud_auth | ok can_reach_cloud | ok
Dashboards dashboards | 4 -- | -- resources | 20 views | 25 mode | storage
Recorder oldest_recorder_run | February 18, 2024 at 18:55 -- | -- current_recorder_run | February 28, 2024 at 11:24 estimated_db_size | 1180.21 MiB database_engine | sqlite database_version | 3.44.2
Spotify api_endpoint_reachable | ok -- | --

Checklist

Describe the issue

This might not be a bug per se, but perhaps just a lack of understand on my part. I'm trying to figure out when and how exactly chores should have their next due dates updated. Generally, chores do seem to work fine on my installation, their next due dates just update really slowly.

  1. For chores that I freshly create, it takes them a while to receive their first due dates. It shows as "Unknown" for quite some time. (This is what the logs below show, two new chores with no due dates determined, even after restarting HA.) Here's a chore I created 15 minutes ago which still doesn't have any due date, and therefore doesn't show up on my dashboard either:

    Screenshot 2024-02-28 at 11 28 32

  2. For existing chores that have due dates that I complete, it also takes them a while (several hours in some cases) for their next due date to be updated. Here's an older screenshot where I completed a chore well before its due date, 11 days early. The chore is set up to every 14 days, so its next due date should be in March after completing it on the 18th of February. However, it still showed up with a due date of the 29th for at least half a day. It eventually updated, but I don't know when and how.

    image

Is it possible I have something set up incorrectly? Is there something I could do (like call a service manually) to force chores to update their due dates?

Reproduction steps

  1. Create a new chore
  2. Look at its next due date shortly after its creation
  3. It just shows up as "Unknown"

Debug logs

2024-02-28 11:25:01.568 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: entity_id=sensor.weekly_plant_watering, old_state=None, new_state=<state sensor.weekly_plant_watering=unknown; last_completed=None, last_updated=None, overdue=False, overdue_days=None, next_due_date=None, offset_dates=None, add_dates=None, remove_dates=None, unit_of_measurement=days, device_class=chore_helper__schedule, icon=mdi:watering-can-outline, friendly_name=Weekly plant watering @ 2024-02-28T11:25:01.567935+01:00>>
2024-02-28 11:25:01.572 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event component_loaded[L]: component=min_max>
2024-02-28 11:25:01.574 INFO (MainThread) [homeassistant.components.binary_sensor] Setting up trend.binary_sensor
2024-02-28 11:25:01.577 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: entity_id=sensor.triweekly_plant_watering, old_state=None, new_state=<state sensor.triweekly_plant_watering=unknown; last_completed=None, last_updated=None, overdue=False, overdue_days=None, next_due_date=None, offset_dates=None, add_dates=None, remove_dates=None, unit_of_measurement=days, device_class=chore_helper__schedule, icon=mdi:watering-can-outline, friendly_name=Triweekly plant watering @ 2024-02-28T11:25:01.577002+01:00>>
2024-02-28 11:25:24.764 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event chore_helper_loaded[L]: entity_id=sensor.weekly_plant_watering, due_dates=[]>
2024-02-28 11:25:24.765 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: entity_id=sensor.weekly_plant_watering, old_state=<state sensor.weekly_plant_watering=unknown; last_completed=None, last_updated=None, overdue=False, overdue_days=None, next_due_date=None, offset_dates=None, add_dates=None, remove_dates=None, unit_of_measurement=days, device_class=chore_helper__schedule, icon=mdi:watering-can-outline, friendly_name=Weekly plant watering @ 2024-02-28T11:25:01.567935+01:00>, new_state=<state sensor.weekly_plant_watering=unknown; last_completed=None, last_updated=2024-02-28T11:25:24.764716+01:00, overdue=False, overdue_days=None, next_due_date=None, offset_dates=None, add_dates=None, remove_dates=None, unit_of_measurement=days, device_class=chore_helper__schedule, icon=mdi:watering-can-outline, friendly_name=Weekly plant watering @ 2024-02-28T11:25:01.567935+01:00>>
2024-02-28 11:25:24.765 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event chore_helper_loaded[L]: entity_id=sensor.triweekly_plant_watering, due_dates=[]>
2024-02-28 11:25:24.766 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: entity_id=sensor.triweekly_plant_watering, old_state=<state sensor.triweekly_plant_watering=unknown; last_completed=None, last_updated=None, overdue=False, overdue_days=None, next_due_date=None, offset_dates=None, add_dates=None, remove_dates=None, unit_of_measurement=days, device_class=chore_helper__schedule, icon=mdi:watering-can-outline, friendly_name=Triweekly plant watering @ 2024-02-28T11:25:01.577002+01:00>, new_state=<state sensor.triweekly_plant_watering=unknown; last_completed=None, last_updated=2024-02-28T11:25:24.766093+01:00, overdue=False, overdue_days=None, next_due_date=None, offset_dates=None, add_dates=None, remove_dates=None, unit_of_measurement=days, device_class=chore_helper__schedule, icon=mdi:watering-can-outline, friendly_name=Triweekly plant watering @ 2024-02-28T11:25:01.577002+01:00>>

Diagnostics dump

No response

adbsmith commented 5 months ago

I am also seeing this issue where my next due dates are not updating after marking chores as complete. I didn’t have this issue the first day of installing but now a few days later it’s taking forever to update. Love the chore system, but this needs a fix to really be useable.

bmcclure commented 2 months ago

Hm, the dates should be calculated anytime the state is updated. This normally happens automatically, but there is also an update_state service which can be used to update it anytime.

When you're experiencing the delays in updating, does it fix it by calling the update service, or is the update not working even then?

renasg commented 2 months ago

I am also facing this issue. I have been playing a bit with this chore system and kinda of trying to find a way to define the date when the chore was complete because I probably will not right way mark it as completed. So I wanted to create some sort of interface where I could define the date in case I completed let's say 2 days ago today and I want to register that as my date of completion instead of current date.

I used the chore_helper.complete service and included last_completed attribute and it worked in the sense the "Last completed" date changed to the one I defined but the next due date did not change right way. I even tried the chore_helper.update_state service and still no change on the due date.

I even tried yesterday using the chore_helper.complete service without defining the last_completed, so the current date would be used and again the due date did not change. In fact, it seems that it got updated but only at midnight.

Captura de ecrã 2024-07-17, às 15 25 05

Sorry somethings are in portuguese but I think you get the idea. This is an After 2 weeks chore to clean my cat's litter box. The due date before was 23rd July as you can see I even tried to play with the chore_helper.remove_date service.

I also tried to define it as an After 14 days chore with an alternative chore and still got the same issue. I set it as completed and then 6 minutes after not updating the due date, I called the chore_helper.update_state service and as you can see from the print below it still says 13 days and the due date set to 30th July, when should be 14 days and due date 31st July. My guess is it will be corrected at midnight today.

Captura de ecrã 2024-07-17, às 16 02 41

Hope this helps you debug it.

I really like this chore system and I hope this is a minor bug that could be easily spotted.

Keep up with the good work!