I’m having some wierdness where phantom / mqtt data is screwing with my automation. I believe i can solve (or rather workaround) it by matching the time of any physical state changes/updates with the now()time template, so as to ignore the phantom data, but the process is eluding me.
my mqtt stream shows lots of these pairs - even when the button hasn’t been pressed for hours:
hue/hue_dimmer_switch_2/buttonevent 1002
hue/hue_dimmer_switch_2/lastupdated 2017-12-12T09:50:49
the lastupdated is accurate - ie the button was physically pressed at 9:50am - but i’m getting these popping up in my mqtt stream every five (or so) minutes a few times a day.
a modified automation with the buttonevent state change as the trigger, and a condition that the lastupdated time is equal to now (within say 5 seconds), would squash this bug.
mooching through the forum has got me to this template to pull and strip time from now():
{{ strptime(now().strftime("%H:%M:%S"), "%H:%M:%S") -strptime("0", "%M") }}
which would give me:
14:16:19
but i am stumped as to how to go about extracting the time from the mqtt payload.
can anyone point me in the right direction?