I have HA running on a PI running Hassbian. I have HA connecting to an MQTT broker which is a separate private VM which is collecting MQTT feeds from different devices. I have a Philips Hue bridge and light bulbs configured within HA and I can control those without any issue. My goal is to be able to turn the lights on when a person is detected from my Meraki camera and then turn the lights off after a certain amount of time. I have the first part working with this automation…
However, I am not sure how to get the second part working. Basically I need to write another automation to turn the lights off. For example, if the word “person” is not seen for 5 minutes turn the lights off. Just not sure if this would be a condition template or not and how to write the logic. Any help would be appreciated. Thanks
I don’t use MQTT, but I’m thinking, maybe the easiest way to do this is to define a 5 minute timer. Then add to the existing automation’s action a step that starts the timer. If the automation is triggered again within the 5 minute interval, the timer will be restarted. But, if the automation isn’t triggered again for 5 minutes, the timer will finish. Then you can have a second automation that is triggered by the timer finishing that then turns the light off.
Thanks much for the reply. I found a similar recommendation and was able to find some sample code. Below is the end result and this is working perfectly. For demo purposes, I have my timer set to 1 minute. For a home or business type building automation system, a longer timer would probably work better.
First, I added the following timer to my configuration.yaml
timer:
timer_light:
duration: '00:01:00'
Second, I updated my automations.yaml to start a timer with the first automation and check for the timer to be finished in the second automation.