will not work - numeric_state fires on first change of sensor value after restart if it is in range. It may happen much later than 10s after start.
No, The bit being on, as a condition, in its firing, stops it !
- sensor value is 0, automation trigger has below:30
- HA is rebooted
- Bit is set on start
- 10s passes since HA started
- Bit is changed to off
- in an hour sensor reports value 1
- At this point, bit is off and it is first time sensor reports value since HA start thus automation fires
still this would be a more elegant way to do it:
in the automation, you can leave out 'from: ‘off’ ', since it is a binary, and that only has 2 states. Using the delay_on in the binary_sensor definition, you can leave out the timing issue from the trigger…
making it even nicer, you can write your condition as:
condition: template
value_template: >
{{is_state('binary_sensor.occupied','on')}}
Like this you can check the templates in the templates editor.
Thanks @pnbruckner for explaining how numeric_state
trigger works.
I think I have found why I get false triggers randomly. For my part, the problem seems there after I reload the automations.
Since reloading the automations reset them, I guess it makes it loose it’s last state and then on the next state change, the trigger happens. Same as when rebooting I guess.
It would be nice if there was a way restore automatically the last known value taken from the recorder data on restart and on automations reload.
You could always make an automation that sends you a message when it gets the unavailable state. I found it quite helpful to put telegram send message actions to my automations to see what home assistant is doing during the day. This helps debugging automation allot more easy. Mostly i add these actions to new automation for some time and when everything keeps running like it should I remove it. This way you get instant messages in telegram everytime an automation triggers and it’s easier to find a problem