Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Recollect Waste integration calendar entity not functioning? #92652

Closed
jayscovill opened this issue May 5, 2023 · 8 comments · Fixed by #98037
Closed

Recollect Waste integration calendar entity not functioning? #92652

jayscovill opened this issue May 5, 2023 · 8 comments · Fixed by #98037

Comments

@jayscovill
Copy link

The problem

My understanding of the behaviour of this integration is that the calendar entity (calendar.recollect_waste) should toggle on the day of scheduled pickup.

For instance, my scheduled collection was Thursday, May 4, 2023 (sensor.recollect_waste_current_pickup). But the calendar.recollect_waste entity didn't toggle on until 6:30PM the day of the collection which way past the typical morning/afternoon pickup time.

I have an automation that triggers on toggle of the calendar.recollect_waste event plus an offset of a few hours. But that automation never triggers because the calendar.recollect_waste entity doesn't trigger when expected.

Am I misunderstanding the behaviour of the calendar.recollect_waste entity or is there something broken with it?

What version of Home Assistant Core has the issue?

core-2023.4.6

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant Supervised

Integration causing the issue

Recollect Waste

Link to integration documentation on our website

https://www.home-assistant.io/integrations/recollect_waste/

Diagnostics information

No response

Example YAML snippet

alias: Notification - Alert - Garbage Day
description: ""
trigger:
  - platform: calendar
    event: start
    offset: "7:45:0"
    entity_id: calendar.recollect_waste
    id: garbage_day_on
  - platform: calendar
    event: end
    offset: "0:0:0"
    entity_id: calendar.recollect_waste
    id: garbage_day_off
  - platform: event
    id: garbage_day_ack
    event_type: mobile_app_notification_action
    event_data:
      action: garbage_day_ack
condition: []
action:
  - choose:
      - conditions:
          - condition: trigger
            id: garbage_day_on
        sequence:
          - service: input_boolean.turn_on
            data: {}
            target:
              entity_id: input_boolean.garbage_day_on
      - conditions:
          - condition: trigger
            id: garbage_day_off
        sequence:
          - service: input_boolean.turn_off
            data: {}
            target:
              entity_id: input_boolean.garbage_day_on
      - conditions:
          - condition: trigger
            id: garbage_day_ack
        sequence:
          - service: alert.turn_off
            data: {}
            target:
              entity_id: alert.garbage_day
mode: parallel
max: 10

Anything in the logs that might be useful for us?

No response

Additional information

No response

@home-assistant
Copy link

home-assistant bot commented May 5, 2023

Hey there @bachya, mind taking a look at this issue as it has been labeled with an integration (recollect_waste) you are listed as a code owner for? Thanks!

Code owner commands

Code owners of recollect_waste can trigger bot actions by commenting:

  • @home-assistant close Closes the issue.
  • @home-assistant rename Awesome new title Renames the issue.
  • @home-assistant reopen Reopen the issue.
  • @home-assistant unassign recollect_waste Removes the current integration label and assignees on the issue, add the integration domain after the command.

(message by CodeOwnersMention)


recollect_waste documentation
recollect_waste source
(message by IssueLinks)

@bachya
Copy link
Contributor

bachya commented May 6, 2023

ReCollect Waste only gives us pickup dates, not times. Therefore, the integration creates all-day events that start at midnight on the pickup date and end at midnight the next day. So, I don't think the integration is doing anything strange.

@allenporter is the calendar guru, so I'll tag him in—do you notice ReCollect doing something it shouldn't?

@allenporter
Copy link
Contributor

allenporter commented May 6, 2023

Just sharing some early thoughts as I read the code, but may look closer....

Potential track to explore 1:

The challenge with calendar entities is that they have two separate responsibilities making it hard to use update coordinators:

  • [Agenda] How often does the underlying data source update? e.g. say you have an RPC to send to get the schedule, how often do you send it. Usually calendars don't change super often, so something like a trash day schedule its not really interesting to poll very often. As a result, this integration sets the poll time to 1 day in the data update coordinator.
  • [Next/Active Event] How often does the entity itself update and reflect state for the "event" that is next/upcoming or active. For example, say you got your schedule and list of upcoming events you need to know "the meeting has started' and set the entity state to on. You want that state changed very often so often this happens once per minute for example. It won't be expensive since it's just reading the agenda.

The problem with a simple data coordinator entity is that it combines these two concepts of fetching the agenda and updating state for the next event into one operation. As a result you have to:

  • have an agenda data update coordinator that polls when makes sense
  • have a polling entity update interval disabling some of the features of the update coordinator entity that runs every minute or so. I think you need to change should poll and disable async_update.

If this is the issue here, perhaps we can take learnings from what you have to change and update the developer docs since i think this would be common for any cloud based calendar.

I'd love to somehow separate the concept of "Calendar Entity" from "Event Entity" to resolve this, but boy would that be a big breaking change.

Potential track to explore 2:

I notice in async_get_events that it is not looking at the start / end date range. This probably usually works ok given the start date is >= today from the update coordinator. However, the trigger may assume that the calendar is actually doing filtering based on the start/end date ranges. In #89918 I was attempting to fix bugs with triggers where it might drop events in certain cases. Now I believe it should never drop an event, but may trigger later if an event is returned outside the window requested.

This could also just interact with track 1 and not need any special handling.

One thing I did in rainbird calendar since its generating synthetic events on the fly form a schedule is just report back 2 weeks of events so there is something to see in the calendar UI. You could consider a change like that and then adding filtering in the "next event" case and the "get events in a range" case.

@jayscovill
Copy link
Author

ReCollect Waste only gives us pickup dates, not times. Therefore, the integration creates all-day events that start at midnight on the pickup date and end at midnight the next day. So, I don't think the integration is doing anything strange.

@allenporter is the calendar guru, so I'll tag him in—do you notice ReCollect doing something it shouldn't?

That's what I expected but that's not the behaviour I'm seeing. In my case the calendar entity didn't go into an "on" state until approximately May 4 6:30PM, the day of the collection, not 12AM. It then toggled off at May 5 6:30PM. So it's definitely staying on for 24 hours...but it's coming on around eighteen and half hours after it's supposed to?

@allenporter
Copy link
Contributor

It would probably work if you started home assistant around midnight given what I said above about the refresh cycles.

@bachya
Copy link
Contributor

bachya commented May 7, 2023

That makes great sense, @allenporter—I never stopped to consider that ReCollect's single coordinator would only update the calendar entity's state every so often (as you point out, every 1 day) and cause drift. I'll chew on having the calendar entity poll more regularly.

@allenporter
Copy link
Contributor

@bachya Caldav, Google Calendar, etc all do this fwiw.

@issue-triage-workflows
Copy link

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates.
Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍
This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

@issue-triage-workflows issue-triage-workflows bot closed this as not planned Won't fix, can't repro, duplicate, stale Aug 12, 2023
@github-actions github-actions bot locked and limited conversation to collaborators Sep 25, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.