New HA user and really wracking my brain trying to figure this one out.
I’m trying to trigger a notification if a device’s binary state changes to ON X amount of times within Y minutes. I intend to hardcode these X and Y values depending on the device at hand. Any ideas on how I can do this?
Here’s some rough pseudo code of how I was thinking I could implement, but I’m having trouble translating this over to HA. But maybe there’s a simpler way?
When device state changes to ON, start a timer for Y minutes
timesOn = 1
while timer is < Y minutes
if device state changes to on:
timesOn += 1
if timesOn = X, then
trigger action