summaryrefslogtreecommitdiffstats
path: root/blueprints/automation/lights/light_switch_combo.yaml
diff options
context:
space:
mode:
Diffstat (limited to 'blueprints/automation/lights/light_switch_combo.yaml')
-rw-r--r--blueprints/automation/lights/light_switch_combo.yaml92
1 files changed, 92 insertions, 0 deletions
diff --git a/blueprints/automation/lights/light_switch_combo.yaml b/blueprints/automation/lights/light_switch_combo.yaml
new file mode 100644
index 0000000..9ea8655
--- /dev/null
+++ b/blueprints/automation/lights/light_switch_combo.yaml
@@ -0,0 +1,92 @@
+blueprint:
+ name: Light Switch Combo
+ description: Switch to control another switch, light bulb, or power plug (no sync) and allow another action on double click
+ domain: automation
+ input:
+ switch:
+ name: switch
+ description: controller
+ selector:
+ entity:
+ domain: switch
+ master:
+ name: master
+ description: another switch, smart bulb, or power socket
+ selector:
+ entity:
+ dblclick:
+ name: dblclick
+ description: Actions to perform on double click
+ default: []
+ selector:
+ action:
+ on_click:
+ name: on_click
+ description: Additional actions to perform while turning on master switch
+ default: []
+ selector:
+ action:
+ off_click:
+ name: off_click
+ description: Additional actions to perform while turning off master switch
+ default: []
+ selector:
+ action:
+
+#variables:
+# switch_entity: !input switch
+# master_entity: !input master
+
+trigger:
+ - platform: state
+ entity_id: !input "switch"
+
+# Can't do 'restart' since it will break wait_for_trigger
+mode: single
+action:
+ - wait_for_trigger:
+ - platform: state
+ entity_id: !input switch
+ timeout: '1'
+ continue_on_timeout: true
+
+ - if:
+ - condition: template
+ value_template: '{{ wait.trigger == None }}'
+ then:
+ - if:
+ - condition: state
+ entity_id: !input switch
+ state: 'on'
+ then:
+ - if:
+ - condition: state
+ entity_id: !input master
+ state: 'on'
+ then:
+ - parallel:
+ - service: homeassistant.toggle
+ target:
+ entity_id: !input master
+ - choose: []
+ default: !input "off_click"
+ else:
+ - parallel:
+ - service: homeassistant.toggle
+ target:
+ entity_id: !input master
+ - choose: []
+ default: !input "on_click"
+ else:
+ - choose: []
+ default: !input "dblclick"
+# - service: switch.turn_off
+# target:
+# entity_id: switch.all_lights
+# - service: input_button.press
+# target:
+# entity_id: input_button.button_confirm
+
+ - service: switch.turn_off
+ target:
+ entity_id: !input switch