I would like to visualize my timers/countdowns I virtually created for my motion controlled lights. Wondering how to do it best.
I know I could use appdeamon to update an entity every second with the number of seconds left, but it just feels wrong having 5 motion sensors updating every second and generate lots of noise in the state changes/traffic.
Alternatively I’ve created an entity with state on|off and a timestamp as attribute for when it will fire/time out.
This at least reduces the state updates to a minimum - but how would you go about showing in the UI how many seconds before it triggers ?
I tried using templates based on time/date but the highest resolution here seem to be every minute which would be to low.
It’s that or appdaemon + plenty of time to figure out how to make it work
I always put it in separate files, it also have the advantage that if you decommission one lamp, you can remove it with all associated sensor/timer. Same for adding one, just copy/paste the file and modify the entities id.
never having used a timer yet, but I think this accomplishes the same? What, if any, would be the difference in end-result here? Does the timer restart when motion is detected, or does it simply count down and switch off the light. My binary_sensor timed waits for no movement and until that moment doesn’t act. Which is what I need. Can I achieve that with the timer also?
You just made me realize I could use jninja templates to generate these. Actually surprised I can’t find others doing that. Gonna give it a try later today
But, I don’t get what’s the difference between this and checking that the movement sensor has been ‘to: off’ ‘for: 5 minutes’?? I mean, if it hasn’t been off for that time this counting will also be somehow reset, won’t it?
in this case, we need the trigger to be On, and start doing things. like turning on a light or switch. And then, after a certain period has passed, do yet another set of things. hence the timer and trigger On in 1 automation
For some system, for example some 433MHz to MQTT sensor, their is not state, but only an impulse every time a movement is detected. So you need a trigger based automation and not a state based one.
Another thing timer gives you is flexibility, you can restart, change the duration or stop a timer from any other automation.
Also you can choose to activate deactivate part of the automation, for example I often don’t want the light to be turned off after 5 minutes, and for that, I deactivate the “turn-off” automation.
And lastly, you can display the remaining time of a timer in the frontend, which is much harder if you use state based timing (but surely somehow possible).
hmm - how do you put automation + timer setup into seperate files ? I thought there was no way to include two top level things via home assistant include support ?
also - when I use your example I see the timer start correctly the first time and count down - great. But when I move again the timer still counts down it does not stop. When it reaches zero nothing happened and when I moved again instead of counting down it just switched to “active” - no info about countdown.
In my case the folder is called packages.
And in this folder I have for example a file called office_light_automation.yaml which contain the example I posted earlier with automation and timer top level element.
Now I can copy this file for other light, without any problem with having several automation and timer blocked declared in different files.
Regarding the last question, no I’m not sure what’s going on. You’re sure your trigger or actions are configured properly?
I actually rechecked after your last question, with my setup, the display of timer in the frontend is also wrong.
The timer is restarted (because I still receive the finished event in my automation and the light are turned off), but the frontend still shows the initial count down, and doesn’t reinitialise itself.
okey so I’m not going crazy i’ll see if I can isolate it and open a bug on it.
Whats weird though is that as you say the timer does seem to fire at the right time but when I get the state of it it still says the full time is remaining.