I think I did this correctly, but hoping someone could spot check me. If this is correct, great, I can leave this up for the rest of the community to benefit from.
I am making an automation that will play a chime audio file (stored locally) and then do a Google TTS to tell me when a lightning strike is detected and its distance. The main area of concern is the trigger section. Understanding that there could me a high number of lightning strikes within a 1 hour period, I do not want the automation to trigger more than once a minute.
Interesting. I have been able to get the âdonât run if last triggered xâ to work in previous automations. I had to take the sloppy route and add a delay at the end. Let me give this another try.
I am getting a âno default value specifiedâ error so I modified it to:
I cannot figure out why my float is not working though. If I change it from a 1 to a 2, it will trigger the automation when the lightening strike count hits 1, 3, 5, etc. When I switch it to 1, it will not trigger the automation at all; regardless of the sensorâs value.
Here is the code will trigger successfully when the lightning strike count hits 1, 3, 5, etc., but not if the automation has last ran within past 60 seconds:
Ah! Great tip on this.entity_id, I thought it was a placeholder when I first read it.
Whenever I try {{ states ('sensor.blitzortung_lightning_counter') }} it only triggers the automation when the value goes from 0 to a number greater than 0. It will only retrigger the automation after the value goes back to 0.
I saw your edit while typing this as well. Thatâs another great tip about excluding unknown or unavailable. I have several other automations that pop up in my logs because of that. I got a good laugh out of your lightning capital comment. I am definitely going to scale this back once I get it working well. Wife would not be pleased with this going off all through the night.
Also, I donât want to waste anyoneâs time. I would love to get this working as originally intended, but as a last resort, I could just change the duration that it counts lightning strikes to 15 minutes. That would basically give me an alert once every 15 minutes (if the storm is still occurring) because the counter will reset back to 0.
Apologies Rob, I misread your last post. I was still using a value template. When switching it to - platform: state like you suggested, everything is working exactly as expected.
I really appreciate your time today!
For anyone in the future that wants to do something similar, here is the final working code:
I used your example and added a TTS message that will be pushed to my poolside Apple TV.
I also made mine triggered by distance. This one is 50-60 miles.
I have a second one that is identical except itâs for 20-25 miles.
I have done a proof of work with an iPod mini and both automations are working as expected.
Thanks to everyone who provided the information above. It was very helpful