Closed gentoo-root closed 1 month ago
I think the problem is here: https://github.com/denysdovhan/ha-yasno-outages/blob/main/custom_components/yasno_outages/api.py#L78
When searching for a current event we should take larger timeframe for search
take larger timeframe for search
That should also work, but it's not clear to me what is the right time interval that we should pick. 1 hour is certainly not enough because an outage can be longer. Intervals bigger than the longest possible outage should work, but we don't know how big they can be in the future.
Honestly, I fail to understand why we need this two-step logic where we first filter the events then find the current one. Why can't we just go over the list of events once and find the one that satisfies event_start <= now <= event_end
? This way we won't need to pick any interval.
Why can't we just go over the list of events once and find the one that satisfies event_start <= now <= event_end?
Because this is required by calendar integration. get_events
should return all events within a timespan. I wan't to make API abstract and reuse methods in coordinator.
I found another reason for this problem. Should be resolve in #16. Let me know if my fix doesn't help.
get_events should return all events within a timespan.
Should it return the 0:00 .. 4:00 event when we call it with the timespan of 1:00 .. 2:00?
Should be resolve in https://github.com/denysdovhan/ha-yasno-outages/pull/16.
Thanks, let me try it.
Should it return the 0:00 .. 4:00.
That's a good question. We should refer to HA developers docs. I hope they describe what they expect to see.
event_start <= start_date <= event_end or event_start <= end_date <= event_end
I guess your logic is better. Please sens another PR replacing my logic with your.
Fixes: #14