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

Numerical above condition of schedule scheme re-evaluates every time the numerical state changes rather than when the condition changes. #333

Closed aredon closed 4 months ago

aredon commented 7 months ago

Checklist

Expected behavior

I have a scheme controlling my thermostat with a condition about the outdoor temperature being above a certain point. I would expect that this condition is evaluated as a boolean - as in - if the temperature outside is below the target temperature the condition should be false. Then, if "re-evaluate when conditions change" is checked, I would expect the scheme to fire when the condition flips over to true. This would then change the indoor target temperature of the thermostat and I can make changes to it after that without them being overridden.

Actual behavior

The scheme is editing the temperature every time the outdoor temperature sensor updates its value. Rather than when the condition changes its boolean state (e.g. from true to false or false to true). That is to say, when the outdoor temperature is > 30, the scheme fires off when the temperature is 32, 35, 40, 44, 45, etc. Throughout the day. This causes the thermostat to keep resetting the indoor target temperature to whatever the schedule has in place. Meaning I am constantly seeing my own desired temperature overridden if I dare deviate from my schedule.

Steps to Reproduce

1.) Create a scheme 2.) Use a sensor with a changing numerical state, I suggest outdoor temperature 3.) Check "re-evaluate when conditions change" 4.) Observe repeated application of the scheme when the conditions have, in fact, not changed.

image image image

aredon commented 7 months ago

Shameless bump

nielsfaber commented 6 months ago

This issue should be solved with the v3.3.1 release. Please update your installation and let me know if all works OK now.

aredon commented 6 months ago

I saw this in the change log and smiled. I'll set this up to be tested today.

Unfortunately what I was trying to do with it isn't going to work very well anyway. I have a dual-fuel system (gas + heat pump) and wanted to make two heat schedules based on when the outdoor temperature would be switching between the two systems. Unfortunately the nest integration doesn't seem to report the outdoor temperature it is using. So I can't have perfect synergy between the schedules and the thermostat.

Still - I appreciate you fixing this bug so I can use the conditions for other things. Love this card.

aredon commented 6 months ago

I got a chance to test this and I'm wondering if a new feature is needed? I changed the logic to [aredon] is home & outdoor temp is above 30. If I have "re-evaluate when conditions change" checked does that require both conditions change or is it either? It seems like it's all but I will keep testing.

I want both conditions to be met for the schedule to run and for the re-evaluate to happen if the state of either condition changes. Perhaps that is not the intended behavior?

nielsfaber commented 6 months ago

This functionality should be in place already. A small demonstration: image

I configured similar conditions but use an input_boolean and slider entity instead (easier to make manual changes). Important is to set the switch in the top right to 'all' rather than 'any' (it is equivalent to AND vs OR). image

Now, if I play with the condition entities: image With this combination, the debug log states Conditions have failed, skipping execution of actions. If I set the slider to 15, the same line repeats (only one condition has been met). If I also set the switch to ON, the log states Executing service climate.set_temperature on entity climate.generic_thermostat, in other words, the schedule is triggered.

While dragging the slider downwards, this is ignored (before the schedule would trigger for any change) until reaching the point 10, here the log line Conditions have failed, skipping execution of action repeats. I can drag the slider back to 15 and the climate temperature is set again.

This is all according to my expectation so it should work OK for you as well.

github-actions[bot] commented 5 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