nielsfaber / scheduler-component

Custom component for HA that enables the creation of scheduler entities
GNU General Public License v3.0
639 stars 41 forks source link

Scheduled action not executed if a condition state is unavailable #350

Closed jasonpstokes closed 2 months ago

jasonpstokes commented 5 months ago

Checklist

Hi, thanks for this component- it's been working great! Except I've encountered an issue similar to #263, where the Scheduler will not run if one of the conditions is in an unavailable state.

2024-04-25 20:00:00.001 DEBUG (MainThread) [custom_components.scheduler.timer] Timer 1d3f77 has reached slot 3
2024-04-25 20:00:00.001 DEBUG (MainThread) [custom_components.scheduler.switch] Schedule 1d3f77 is triggered, proceed with actions
2024-04-25 20:00:00.001 DEBUG (MainThread) [custom_components.scheduler.actions] [1d3f77]: Entity binary_sensor.skylight_contact is unavailable, scheduled action cannot be executed
2024-04-25 20:01:00.003 DEBUG (MainThread) [custom_components.scheduler.timer] Timer of 1d3f77 set for 2024-04-25 21:30:00+10:00

My conditions: image

Even though the Scheduler condition is checking that the Skylight binary sensor is 'not On', with Skylight being unavailable (due to a flat sensor battery) the Scheduler tasks fails.

image

github-actions[bot] commented 4 months ago

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 7 days

jasonpstokes commented 4 months ago

bump

nielsfaber commented 3 months ago

You say

I checked for similar existing issues (both open and closed) before posting.

And then

I've encountered an issue similar to https://github.com/nielsfaber/scheduler-component/issues/263

So why are you opening a duplicate topic?

As mentioned in the other topic, scheduler has its own code for handling conditions, which may work a bit different than HA automations. Scheduler will wait until the entities used in both the actions and conditions become available, if so it will check the conditions and fire the actions.

So for your case

Even though the Scheduler condition is checking that the Skylight binary sensor is 'not On', with Skylight being unavailable (due to a flat sensor battery) the Scheduler tasks fails.

A binary_sensor that is unavailable, can be either on or off but HA has no communication. The status is indeterminate, so scheduler is unable to judge whether your condition is satisfied or not.

This implementation has a long history of various request from users. For example, users complained that their schedule did not trigger because their thermostat was unavailable for 1-2 mins exactly during the scheduled time. So this mechanism is supposed to be tolerant for unavailable entities, and the unavailable state is assumed to be a temporary issue which should sort itself within a matter of minutes. I am reluctant to change the implementation since what may be an improvement for you may be worse for others.

github-actions[bot] commented 2 months ago

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 7 days

jasonpstokes commented 2 months ago

Thanks for the response.

I understand your relunctance to change this, but don't see how this makes the plugin "tolerant" if an unavailable condition fails the whole schedule; an unavailable state is still a state. This also makes it inconsistent with the Home Assistant platform it's built on.

If unavailable was recognised/available as a valid state, to be chosen and considered in conditions, then we could build conditions to factor unavailable states, if that logic is needed. e.g. Skylight is not on or unavailable. So - at least with my very limited understanding - nothing would be lost here, but more flexibilty gained.