Hello,
I’m trying to use the physical press on/off of a z-wave switch to control a group of z-wave outlets.
The light connected to the z-wave switch is automated by the sunrise/sunset so I don’t actually want to change it’s state when the switch is pressed just the state of the group of z-wave outlets.
I’ve done this in the past with SmartThings by listening for the on/off event then if it’s a physical button press turning the group of lamps on/off and then switching the light connected to the switch back to it’s original state (an infinite loop is prevented by only triggering when it’s a physical switch press not virtual otherwise turning the light back to it’s original state will trigger another event).
Is there a way to tell when a state trigger is from the physical switch rather than virtual event triggered by HA?
I’ve also tried to prevent this loop using a condition with a “trigger.for > 2” to see if the previous state was set for more than 2 seconds preventing a loop but I can’t seem to get that working either.
automation: - alias: 'Sunset Outside Lights On' trigger: - platform: sun event: 'sunset' action: service: switch.turn_on entity_id: group.outside_lights - alias: 'Sunrise Outside Lights Off' trigger: - platform: sun event: 'sunrise' #offset: '-00:45:00' action: service: switch.turn_off entity_id: group.outside_lights - alias: Control Living Room Lights On trigger: - platform: state entity_id: switch.ge_45609_onoff_relay_switch_switch_2 from: 'off' to: 'on' condition: - condition: template value_template: '{{ int(trigger.for) > 2 }}' action: - service: switch.turn_on entity_id: group.living_room #- service: switch.turn_off # entity_id: switch.ge_45609_onoff_relay_switch_switch_2 - alias: Control Living Room Lights Off trigger: - platform: state entity_id: switch.ge_45609_onoff_relay_switch_switch_2 from: 'on' to: 'off' condition: - condition: template value_template: '{{ int(trigger.for) > 2 }}' action: - service: switch.turn_off entity_id: group.living_room #- service: switch.turn_on # entity_id: switch.ge_45609_onoff_relay_switch_switch_2
Thanks!