Hello! First post, n00b to HA!
I spent hours trying to figure this out.
“SHORT” question: How do I reliably determine that a light-switch toggle was the result of a HA automation?
I’ve seen the suggestion to use trigger.to_state.context.parent == none, which works when the light turns on via motion, but it doesn’t work on another automation, where I turn the lights off via a time_pattern & motion check. Inspecting the trace.json, I don’t see anything I can key off of.
GOAL (and I’m sure this is common):
- Motion detected, lights turn on
- Human powers off the switch. He must want it that way.
- Do not automate anything with those lights until there has been no motion or further manual control of that switch for some cool down period
Automations I’ve got so far:
- if manual_control_timer active, restart timer
- else, turn on light
- (this gets correctly identified as a HA automation, vs a human interaction)
Every 30 seconds
- if no motion has been detected for 20min, and manual_control_timer not active, turn off light
- This one is the problem - when this automation turns off the light, it triggers the next automation, bc I don’t know what to key off of to identify it as an automation vs a manual control
ON light switch ToGGLE
- if trigger.to_state.context.parent_id == none (a human toggled it, but doesn’t seem reliable), we restart the manual_control_timer
- This one restarts the timer regardless, bc parent_id is always none, and gets me stuck in an infinite manual control
Anyways - thank you so much for any advice. Other than that one detection, I think this setup would work pretty sweet