I’m currently trying to write an automatic staircase light and I want to define the switch-on time.
However, I want to have two values.
a fixed one in the controller (4min)
a variable IDer is set from the Homeassistant.
My idea would be that he basically uses the one in the home assistant, if for some reason the connection breaks down (WLAN, HA not accessible) a fixed defined value should be used.
So that the function is guaranteed in any case.
How can you implement something like this with ESPHome?
i would suggest to have multiple timer(s) controlling the same light, so if no value recieved from HA then do default 5min + blink every minute, and in HA you set default to 3min (fixed) with no blink, the blink informs you the unit has no connection as added bonus.
in your code you check for a HA timeout, NULL value or 0(zero = testing) if 1 of those is “detected” then default / initial valiue kicks in
I would probably approach this by creating a global variable, defined to restore on boot. When the value from HA is updated write to the global, then use that as your timeout for the light. You will need to check the value is valid each time before updating the variable.