My question is there anyway to set a 1.5 second timer? Instead of 00:00:01 can I do 00:00:01:50?
I have an outdoor cat that lives in our garage, but we like to let her out during the day. I currently have an automation that triggers a script at 9am that opens my Garage and starts a 1 second timer. Then a separate automation watching that 1 second timer and when it changes from active to idle it sends a stop command to my garage. This has worked perfect for a long time. However, my naughty cat went and got herself pregnant. As she’s gotten bigger she can’t fit under the space of the garage anymore. I changed the timer to 2 seconds but that leaves it open like a full 12 inches and I don’t want a person slipping in under the garage. My question is there anyway to set a 1.5 second timer? Instead of 00:00:01 can I do 00:00:01:50?
So I pulled up the scripts.yaml and i tried a variation of options and couldn’t get anything to work. Finally found that delay: 00:00:01.5 works perfect.
Just an FYI, the resolution of delays in scripts (or actions of automations) is only one second. I.e., when it gets to a delay step, it will try to “wake up” the amount of time specified later. But the “wake up” only happens once every second. So let’s say you just missed a wake-up time, and you delay 1.5 seconds. That will actually delay 2 seconds, because it will wake up about 1 second later, and it will discover that 1.5 seconds has not gone by. So it will sleep another second, and when it wakes up this time it will see that at least 1.5 seconds has gone by, so the next step of the script/action will run. So in this case the delay was not really 1.5 seconds but (roughly) 2 seconds. Bottom line – if you have a delay step of 1.5 seconds, it will delay at least that much, but it might delay up to 2.5 seconds, depending on where it falls in the one second “wake up” period.
Now the good part is, if the automation or script is started by a timer, it will also be based on the one second resolution, so it should be fairly consistent … until you add more “stuff” and things get delayed a bit, and pow, you miss a window and go another whole second.
BTW, have you ever seen the “Timer got out of sync. Resetting” error message? Yeah, it has to do with this one second scheduling underlying the system timing. That basically means the one second period was blown, and that means that delays can go even longer sometimes than usual.
Hey, this is “just” Python running on a non-real-time OS. You can’t expect very accurate timing control.