I have an automation for roller shades that is triggering twice every time it is run. The triggers are a physical button on a switch and an input select helper with options “up” and “down.” The input select allows the shade to be controlled on the dashboard. To keep the state of the helper in sync with the state of the roller shade, part of the action is to update the helper, but that will trigger the automation once more. The automation works, but I believe it is causing a lot of duplicate warnings in the logs.
I tried adding context user id as a condition to test that a user vs automation updating the helper state, but was unable to get it working. Please let me know if there is a better way of configuring this automation.
alias: Test automation
description: ""
triggers:
- trigger: state
entity_id:
- event.window_switch_scene_001
id: shade_up_button
- trigger: state
entity_id:
- event.window_switch_scene_003
id: shade_down_button
enabled: true
- trigger: state
entity_id:
- input_select.shade
id: input_shade_up
enabled: true
from: Down
to: Up
- trigger: state
entity_id:
- input_select.shade
id: input_shade_down
enabled: true
from: Up
to: Down
conditions: []
actions:
- choose:
- conditions:
- condition: or
conditions:
- condition: and
conditions:
- condition: trigger
id:
- shade_up_button
- condition: state
entity_id: event.window_switch_scene_001
attribute: event_type
state: KeyPressed
- condition: trigger
id:
- input_shade_up
alias: Shade Up
sequence:
- action: switch.turn_on
metadata: {}
data: {}
target:
entity_id: switch.window_relay_1_up
- action: input_select.select_option
metadata: {}
data:
option: Up
target:
entity_id: input_select.shade
- conditions:
- condition: or
conditions:
- condition: and
conditions:
- condition: trigger
id:
- shade_down_button
- condition: state
entity_id: event.window_switch_scene_003
attribute: event_type
state: KeyPressed
- condition: trigger
id:
- input_shade_down
alias: Shade Down
sequence:
- action: switch.turn_on
metadata: {}
data: {}
target:
entity_id: switch.window_relay_2_down
- action: input_select.select_option
metadata: {}
data:
option: Down
target:
entity_id: input_select.shade
mode: single