summaryrefslogtreecommitdiffstats
path: root/blueprints/automation
diff options
context:
space:
mode:
Diffstat (limited to 'blueprints/automation')
-rw-r--r--blueprints/automation/camera/intrusion.yaml91
-rw-r--r--blueprints/automation/homeassistant/motion_light.yaml54
-rw-r--r--blueprints/automation/homeassistant/notify_leaving_zone.yaml46
-rw-r--r--blueprints/automation/lights/knob-bulb-control.yaml271
-rw-r--r--blueprints/automation/lights/knob-multi-bulb-control.yaml191
-rw-r--r--blueprints/automation/lights/light_button.yaml171
-rw-r--r--blueprints/automation/lights/light_switch.yaml115
-rw-r--r--blueprints/automation/lights/light_switch_combo.yaml92
-rw-r--r--blueprints/automation/lights/light_sync.yaml55
-rw-r--r--blueprints/automation/motion/motion_switch.yaml163
10 files changed, 1249 insertions, 0 deletions
diff --git a/blueprints/automation/camera/intrusion.yaml b/blueprints/automation/camera/intrusion.yaml
new file mode 100644
index 0000000..4d2b62c
--- /dev/null
+++ b/blueprints/automation/camera/intrusion.yaml
@@ -0,0 +1,91 @@
+blueprint:
+ name: Intrusion
+ description: Script to execute in case of intrusion, e.g. streaming photos from Security Camera
+ domain: automation
+ input:
+ sensors:
+ name: Sensors
+ description: Trigger on motion, open doors, etc.
+ default: []
+ selector:
+ entity:
+ multiple: true
+ domain: [ binary_sensor, light, switch ]
+ mode:
+ name: Mode
+ description: Switch enabling/disabling shooting
+ selector:
+ entity:
+ domain: input_boolean
+ arm_delay:
+ name: Arm Delay
+ description: Delay before 'Away' mode activated and intrusion detection is operational (to allow you leaving the flat)
+ default: 15
+ selector:
+ number:
+ min: 0
+ max: 60
+ unit_of_measurement: m
+ disarm_delay:
+ name: Disarm Delay
+ description: Delay before alarms triggered after motion is detected (to allow disarm on arrival), camera shots are made without delay
+ default: 5
+ selector:
+ number:
+ min: 0
+ max: 60
+ unit_of_measurement: m
+ camera_script:
+ name: camera_script
+ description: Streaming Script for Security Camera
+ default: []
+ selector:
+ action:
+ script:
+ name: script
+ description: Alarming scipt to issue notifications once intrusion is confirmed
+ default: []
+ selector:
+ action:
+
+trigger:
+ - platform: state
+ entity_id: !input "sensors"
+ to: 'on'
+
+condition:
+ - condition: state
+ entity_id: !input "mode"
+ state: 'on'
+ enabled: true
+ for:
+ hours: 0
+ minutes: !input arm_delay
+ seconds: 0
+
+variables:
+ disarm_delay: !input disarm_delay
+ disarm_delay_seconds: '{{ (( disarm_delay * 60 )) }}'
+
+mode: single
+action:
+ - parallel:
+ - choose: []
+ default: !input "camera_script"
+ - sequence:
+ - service: input_button.press
+ target:
+ entity_id: input_button.button_confirm
+ - wait_for_trigger:
+ - platform: state
+ entity_id: !input mode
+ to: 'off'
+ timeout: '{{ disarm_delay_seconds }}'
+ continue_on_timeout: true
+
+ - if:
+ - condition: template
+ value_template: '{{ wait.trigger == None }}'
+ then:
+ - choose: []
+ default: !input "script"
diff --git a/blueprints/automation/homeassistant/motion_light.yaml b/blueprints/automation/homeassistant/motion_light.yaml
new file mode 100644
index 0000000..54a4a4f
--- /dev/null
+++ b/blueprints/automation/homeassistant/motion_light.yaml
@@ -0,0 +1,54 @@
+blueprint:
+ name: Motion-activated Light
+ description: Turn on a light when motion is detected.
+ domain: automation
+ source_url: https://github.com/home-assistant/core/blob/dev/homeassistant/components/automation/blueprints/motion_light.yaml
+ input:
+ motion_entity:
+ name: Motion Sensor
+ selector:
+ entity:
+ domain: binary_sensor
+ device_class: motion
+ light_target:
+ name: Light
+ selector:
+ target:
+ entity:
+ domain: light
+ no_motion_wait:
+ name: Wait time
+ description: Time to leave the light on after last motion is detected.
+ default: 120
+ selector:
+ number:
+ min: 0
+ max: 3600
+ unit_of_measurement: seconds
+
+# If motion is detected within the delay,
+# we restart the script.
+mode: restart
+max_exceeded: silent
+
+trigger:
+ platform: state
+ entity_id: !input motion_entity
+ from: "off"
+ to: "on"
+
+action:
+ - alias: "Turn on the light"
+ service: light.turn_on
+ target: !input light_target
+ - alias: "Wait until there is no motion from device"
+ wait_for_trigger:
+ platform: state
+ entity_id: !input motion_entity
+ from: "on"
+ to: "off"
+ - alias: "Wait the number of seconds that has been set"
+ delay: !input no_motion_wait
+ - alias: "Turn off the light"
+ service: light.turn_off
+ target: !input light_target
diff --git a/blueprints/automation/homeassistant/notify_leaving_zone.yaml b/blueprints/automation/homeassistant/notify_leaving_zone.yaml
new file mode 100644
index 0000000..1dc8a0e
--- /dev/null
+++ b/blueprints/automation/homeassistant/notify_leaving_zone.yaml
@@ -0,0 +1,46 @@
+blueprint:
+ name: Zone Notification
+ description: Send a notification to a device when a person leaves a specific zone.
+ domain: automation
+ source_url: https://github.com/home-assistant/core/blob/dev/homeassistant/components/automation/blueprints/notify_leaving_zone.yaml
+ input:
+ person_entity:
+ name: Person
+ selector:
+ entity:
+ domain: person
+ zone_entity:
+ name: Zone
+ selector:
+ entity:
+ domain: zone
+ notify_device:
+ name: Device to notify
+ description: Device needs to run the official Home Assistant app to receive notifications.
+ selector:
+ device:
+ integration: mobile_app
+
+trigger:
+ platform: state
+ entity_id: !input person_entity
+
+variables:
+ zone_entity: !input zone_entity
+ # This is the state of the person when it's in this zone.
+ zone_state: "{{ states[zone_entity].name }}"
+ person_entity: !input person_entity
+ person_name: "{{ states[person_entity].name }}"
+
+condition:
+ condition: template
+ # The first case handles leaving the Home zone which has a special state when zoning called 'home'.
+ # The second case handles leaving all other zones.
+ value_template: "{{ zone_entity == 'zone.home' and trigger.from_state.state == 'home' and trigger.to_state.state != 'home' or trigger.from_state.state == zone_state and trigger.to_state.state != zone_state }}"
+
+action:
+ - alias: "Notify that a person has left the zone"
+ domain: mobile_app
+ type: notify
+ device_id: !input notify_device
+ message: "{{ person_name }} has left {{ zone_state }}"
diff --git a/blueprints/automation/lights/knob-bulb-control.yaml b/blueprints/automation/lights/knob-bulb-control.yaml
new file mode 100644
index 0000000..5b6c3c7
--- /dev/null
+++ b/blueprints/automation/lights/knob-bulb-control.yaml
@@ -0,0 +1,271 @@
+blueprint:
+ name: Knob Bulb Control
+ description: Knob (clicking/rotating) to control bulb (or LED band) brightness, color temperature, and hue
+ domain: automation
+ input:
+ knob:
+ name: knob
+ description: controller (select _action entity)
+ selector:
+ entity:
+ domain: sensor
+ light:
+ name: Bulb
+ description: smart bulb or power socket
+ selector:
+ entity:
+ multiple: true
+ domain: light
+ toggle:
+ name: toggle
+ description: Script to run on clicking knob button (e.g. turn-of bulb power on/off)
+ default: []
+ selector:
+ action:
+
+ brightness:
+ name: Brightness
+ description: Current brightness of the bulb
+ selector:
+ entity:
+ domain: input_number
+ temperature:
+ name: Temperature
+ description: Current color temperature of the bulb
+ selector:
+ entity:
+ domain: input_number
+ hue:
+ name: Hue
+ description: Current hue of the bulb
+ selector:
+ entity:
+ domain: input_number
+ state:
+ name: State
+ description: Indicates if button is pressed and we currently changing the hue
+ selector:
+ entity:
+ domain: input_boolean
+
+ brightness_step:
+ name: Brightness Step
+ description: Increment/Decrement of brightness
+ default: 50
+ selector:
+ number:
+ min: 10
+ max: 100
+ hue_delay:
+ name: Hue Delay
+ description: Delay between hue changes
+ default: 500
+ selector:
+ number:
+ min: 100
+ max: 10000
+
+# Light is triggering when bulb is controlled by other means. So, I think it is better to follow 'multi' way
+# and just store knob settings for the bulb ignoring how it is changed in other ways (in the end use-cases differ also)
+trigger:
+ - platform: state
+ id: knob
+ entity_id: !input "knob"
+ to:
+ - "toggle"
+ - "brightness_step_up"
+ - "brightness_step_down"
+ - "color_temperature_step_up"
+ - "color_temperature_step_down"
+ - "hue_move"
+
+ - platform: state
+ id: brightness_change
+ entity_id: !input light
+ attribute: brightness
+# - platform: state
+# id: hue_move
+# entity_id: !input state
+# to: 'on'
+
+variables:
+ light: !input light
+ brightness: !input brightness
+ temperature: !input temperature
+ hue: !input hue
+
+ brightness_step: !input brightness_step
+ hue_delay: !input hue_delay
+
+mode: queued
+action:
+- choose:
+ - conditions:
+ - condition: trigger
+ id: knob
+ sequence:
+ - choose:
+ - conditions:
+ - condition: template
+ value_template: '{{ trigger.to_state.state == "brightness_step_up" }}'
+ sequence:
+ - service: light.turn_on
+ data:
+ brightness_step: '{{ brightness_step }}'
+ target:
+ entity_id: !input light
+ - conditions:
+ - condition: template
+ value_template: '{{ trigger.to_state.state == "brightness_step_down" }}'
+ sequence:
+ - service: light.turn_on
+ data:
+ brightness_step: '-{{ brightness_step }}'
+ target:
+ entity_id: !input light
+ - conditions:
+ - condition: template
+ value_template: '{{ trigger.to_state.state == "color_temperature_step_up" }}'
+ sequence:
+ - service: input_number.increment
+ target:
+ entity_id: !input temperature
+ - service: light.turn_on
+ data:
+ kelvin: '{{ states(temperature) }}'
+ target:
+ entity_id: !input light
+ - conditions:
+ - condition: template
+ value_template: '{{ trigger.to_state.state == "color_temperature_step_down" }}'
+ sequence:
+ - service: input_number.decrement
+ data: {}
+ target:
+ entity_id: !input temperature
+ - service: light.turn_on
+ data:
+ kelvin: '{{ states(temperature) }}'
+ target:
+ entity_id: !input light
+ - conditions:
+ - condition: template
+ value_template: '{{ trigger.to_state.state == "hue_move" }}'
+ sequence:
+ - service: input_boolean.turn_on
+ target:
+ entity_id: !input state
+ - repeat:
+ until:
+# - condition: state
+# entity_id: !input state
+# state: 'off'
+ - condition: template
+ value_template: '{{ wait.trigger != None }}'
+ sequence:
+ - if:
+ - condition: template
+ value_template: '{{ states(hue) | float < 359 }}'
+ then:
+ - service: input_number.increment
+ data: {}
+ target:
+ entity_id: !input hue
+ else:
+ - service: input_number.set_value
+ data:
+ value: 0
+ target:
+ entity_id: !input hue
+ - service: light.turn_on
+ data:
+ hs_color: '{{ states(hue) }}, 100'
+ target:
+ entity_id: !input light
+ - wait_for_trigger:
+ - platform: state
+ entity_id: !input knob
+ to: 'hue_stop'
+ timeout:
+ milliseconds: !input hue_delay
+ continue_on_timeout: true
+ - service: input_boolean.turn_off
+ target:
+ entity_id: !input state
+# - conditions:
+# - condition: template
+# value_template: '{{ trigger.to_state.state == "hue_stop" }}'
+# sequence:
+# - service: input_boolean.turn_off
+# target:
+# entity_id: !input state
+ - conditions:
+ - condition: template
+ value_template: '{{ trigger.to_state.state == "toggle" }}'
+ sequence:
+ - choose: []
+ default: !input "toggle"
+
+ - conditions:
+ - condition: trigger
+ id: brightness_change
+ - condition: state
+ entity_id: !input light
+ state: 'on'
+ sequence:
+ - service: input_number.set_value
+ data:
+ value: '{{ state_attr(light, ''brightness'') }}'
+ target:
+ entity_id: !input brightness
+
+# - conditions:
+# - condition: trigger
+# id: hue_move
+# sequence:
+# - repeat:
+# until:
+# - condition: state
+# entity_id: !input state
+# state: 'off'
+# - condition: template
+# value_template: '{{ wait.trigger != None }}'
+# sequence:
+# - if:
+# - condition: template
+# value_template: '{{ states(hue) | float < 359 }}'
+# then:
+# - service: input_number.increment
+# data: {}
+# target:
+# entity_id: !input hue
+# else:
+# - service: input_number.set_value
+# data:
+# value: 0
+# target:
+# entity_id: !input hue
+# - service: light.turn_on
+# data:
+# hs_color: '{{ states(hue) }}, 100'
+# target:
+# entity_id: !input light
+#
+# - wait_for_trigger:
+# - platform: state
+# entity_id: !input knob
+# to: 'hue_stop'
+# timeout:
+# milliseconds: !input hue_delay
+# continue_on_timeout: true
+#
+# - if:
+# - condition: template
+# value_template: '{{ wait.trigger != None }}'
+# then:
+# - service: input_boolean.turn_off
+# target:
+# entity_id: !input state
+# - delay:
+# timeout:
+# milliseconds: !input hue_delay
diff --git a/blueprints/automation/lights/knob-multi-bulb-control.yaml b/blueprints/automation/lights/knob-multi-bulb-control.yaml
new file mode 100644
index 0000000..412ce3d
--- /dev/null
+++ b/blueprints/automation/lights/knob-multi-bulb-control.yaml
@@ -0,0 +1,191 @@
+blueprint:
+ name: Knob Multi-Bulb Control
+ description: Knob (clicking/rotating) to control bulb (or LED band) brightness, color temperature, and hue
+ domain: automation
+ input:
+ knob:
+ name: knob
+ description: controller (select _action entity)
+ selector:
+ entity:
+ domain: sensor
+ lights:
+ name: Bulb
+ description: smart bulb or power socket
+ selector:
+ entity:
+ multiple: true
+ domain: light
+ toggle:
+ name: toggle
+ description: Script to run on clicking knob button (e.g. turn-of bulb power on/off)
+ default: []
+ selector:
+ action:
+
+ name:
+ name: name
+ description: Name of variables tracking bulb parameters (should include ***_current, ***_brighness0, ***_temperature0, ***_hue0
+ default: knob_office
+
+ hue_delay:
+ name: Hue Delay
+ description: Delay between hue changes
+ default: 500
+ selector:
+ number:
+ min: 100
+ max: 10000
+
+trigger:
+ - platform: state
+ id: knob
+ entity_id: !input "knob"
+ to:
+ - "toggle"
+ - "brightness_step_up"
+ - "brightness_step_down"
+ - "color_temperature_step_up"
+ - "color_temperature_step_down"
+ - "hue_move"
+
+variables:
+ name: !input name
+ current: 'input_number.{{ name + "_current" }}'
+ brightness: 'input_number.{{ name + "_brightness" }}{{ states(current) | int }}'
+ temperature: 'input_number.{{ name + "_temperature" }}{{ states(current) | int }}'
+ hue: 'input_number.{{ name + "_hue" }}{{ states(current) | int }}'
+
+ lights: !input lights
+ light: '{{ lights[states(current) | int] }}'
+
+ hue_delay: !input hue_delay
+
+mode: queued
+action:
+- choose:
+ - conditions:
+ - condition: trigger
+ id: knob
+ sequence:
+ - choose:
+ - conditions:
+ - condition: template
+ value_template: '{{ trigger.to_state.state == "brightness_step_up" }}'
+ sequence:
+ - service: input_number.increment
+ target:
+ entity_id: '{{ brightness }}'
+ - service: light.turn_on
+ data:
+ brightness: '{{ states(brightness) }}'
+ target:
+ entity_id: '{{ light }}'
+ - conditions:
+ - condition: template
+ value_template: '{{ trigger.to_state.state == "brightness_step_down" }}'
+ sequence:
+ - service: input_number.decrement
+ data: {}
+ target:
+ entity_id: '{{ brightness }}'
+ - service: light.turn_on
+ data:
+ brightness: '{{ states(brightness) }}'
+ target:
+ entity_id: '{{ light }}'
+ - conditions:
+ - condition: template
+ value_template: '{{ trigger.to_state.state == "color_temperature_step_up" }}'
+ sequence:
+ - service: input_number.increment
+ target:
+ entity_id: '{{ temperature }}'
+ - service: light.turn_on
+ data:
+ kelvin: '{{ states(temperature) }}'
+ target:
+ entity_id: '{{ light }}'
+ - conditions:
+ - condition: template
+ value_template: '{{ trigger.to_state.state == "color_temperature_step_down" }}'
+ sequence:
+ - service: input_number.decrement
+ target:
+ entity_id: '{{ temperature }}'
+ - service: light.turn_on
+ data:
+ kelvin: '{{ states(temperature) }}'
+ target:
+ entity_id: '{{ light }}'
+ - conditions:
+ - condition: template
+ value_template: '{{ trigger.to_state.state == "hue_move" }}'
+ sequence:
+ - repeat:
+ until:
+ - condition: template
+ value_template: '{{ wait.trigger != None }}'
+ sequence:
+ - if:
+ - condition: template
+ value_template: '{{ states(hue) | float < 359 }}'
+ then:
+ - service: input_number.increment
+ data: {}
+ target:
+ entity_id: '{{ hue }}'
+ else:
+ - service: input_number.set_value
+ data:
+ value: 0
+ target:
+ entity_id: '{{ hue }}'
+ - service: light.turn_on
+ data:
+ hs_color: '{{ states(hue) }}, 100'
+ target:
+ entity_id: '{{ light }}'
+ - wait_for_trigger:
+ - platform: state
+ entity_id: !input knob
+ to: 'hue_stop'
+ timeout:
+ milliseconds: !input hue_delay
+ continue_on_timeout: true
+ - conditions:
+ - condition: template
+ value_template: '{{ trigger.to_state.state == "toggle" }}'
+ sequence:
+ - if:
+ - condition: template
+ value_template: '{{ toggle | length > 0 }}'
+ then:
+ - choose: []
+ default: !input "toggle"
+ else:
+ - service: input_number.increment
+ target:
+ entity_id: '{{ current }}'
+ - if:
+ - condition: template
+ value_template: '{{ states(current) | float == (lights | length) }}'
+ then:
+ - service: input_number.set_value
+ data:
+ value: 0
+ target:
+ entity_id: '{{ current }}'
+
+ - service: light.turn_off
+ target:
+ entity_id: '{{ lights[states(current) | int] }}'
+ - delay:
+ seconds: 1
+ - service: light.turn_on
+ data:
+ kelvin: '{{ states("input_number." + name + "_temperature" + (states(current) | int | string)) }}'
+ brightness: '{{ states("input_number." + name + "_brightness" + (states(current) | int | string)) }}'
+# hs_color: '{{ states("input_number." + name + "_hue" + (states(current) | int | string)) }}, 100'
+ target:
+ entity_id: '{{ lights[states(current) | int] }}'
diff --git a/blueprints/automation/lights/light_button.yaml b/blueprints/automation/lights/light_button.yaml
new file mode 100644
index 0000000..7aeb0ab
--- /dev/null
+++ b/blueprints/automation/lights/light_button.yaml
@@ -0,0 +1,171 @@
+blueprint:
+ name: Light Button
+ description: Button to control smart bulb and perform other actions when bulb turns on/off, plus additional actions on double-click and long-press (select *_action entity)
+ domain: automation
+ input:
+ button:
+ name: button
+ description: controller
+ selector:
+ entity:
+ domain: sensor
+ light:
+ name: light
+ description: another switch, smart bulb, or power socket
+ selector:
+ entity:
+ domain: light
+ temperature:
+ name: Temperature
+ description: Color Temperature
+ default: 6500
+ selector:
+ number:
+ min: 2000
+ max: 6500
+ on_click:
+ name: on_click
+ description: Additional actions to perform while turning on master light
+ default: []
+ selector:
+ action:
+ off_click:
+ name: off_click
+ description: Additional actions to perform while turning off master light
+ default: []
+ selector:
+ action:
+ dblclick:
+ name: dblclick
+ description: Actions to perform on double click
+ default: []
+ selector:
+ action:
+ longclick:
+ name: longclick
+ description: Actions to perform on long-press (single action)
+ default: []
+ selector:
+ action:
+ hold:
+ name: hold
+ description: Actions to perform on hold (iterative until released)
+ default: []
+ selector:
+ action:
+ hold_delay:
+ name: Hold Delay
+ description: Delay between calling hold actions (milliseconds)
+ default: 500
+ selector:
+ number:
+ min: 100
+ max: 10000
+
+ state:
+ name: State
+ description: Indicates if button is pressed and we currently changing the brightness
+ default: None
+ selector:
+ entity:
+ domain: input_boolean
+
+trigger:
+ - platform: state
+ id: button
+ entity_id: !input "button"
+ to:
+ - "single"
+ - "double"
+ - "hold"
+
+
+variables:
+ state: !input state
+ hold: !input hold
+
+# Can't do 'restart' since it will break wait_for_trigger
+mode: single
+
+action:
+- choose:
+ - conditions:
+ - condition: trigger
+ id: button
+ sequence:
+ - choose:
+ - conditions:
+ - condition: template
+ value_template: '{{ trigger.to_state.state == "single" }}'
+ sequence:
+ - if:
+ - condition: state
+ entity_id: !input light
+ state: 'on'
+ then:
+ - parallel:
+ - service: light.turn_off
+ target:
+ entity_id: !input light
+ - choose: []
+ default: !input "off_click"
+ else:
+ - parallel:
+ - service: light.turn_on
+ data:
+ brightness_pct: 100
+ kelvin: !input temperature
+ target:
+ entity_id: !input light
+ - choose: []
+ default: !input "on_click"
+
+ - conditions:
+ - condition: template
+ value_template: '{{ trigger.to_state.state == "double" }}'
+ sequence:
+ - choose: []
+ default: !input "dblclick"
+
+ - conditions:
+ - condition: template
+ value_template: '{{ trigger.to_state.state == "hold" }}'
+ sequence:
+ - choose: []
+ default: !input "longclick"
+
+ - if:
+ - condition: template
+ value_template: '{{ hold | length > 0 }}'
+ then:
+ - if:
+ - condition: template
+ value_template: '{{ state }}'
+ then:
+ - service: input_boolean.turn_on
+ target:
+ entity_id: !input state
+
+ - repeat:
+ until:
+ - condition: template
+ value_template: '{{ wait.trigger != None }}'
+ sequence:
+ - choose: []
+ default: !input "hold"
+
+ - wait_for_trigger:
+ - platform: state
+ entity_id: !input button
+ to: 'release'
+ timeout:
+ milliseconds: !input hold_delay
+ continue_on_timeout: true
+
+ - if:
+ - condition: template
+ value_template: '{{ state }}'
+ then:
+ - service: input_boolean.turn_off
+ target:
+ entity_id: !input state
diff --git a/blueprints/automation/lights/light_switch.yaml b/blueprints/automation/lights/light_switch.yaml
new file mode 100644
index 0000000..b3a4f81
--- /dev/null
+++ b/blueprints/automation/lights/light_switch.yaml
@@ -0,0 +1,115 @@
+blueprint:
+ name: Light Switch
+ description: Switch to control light bulb or power plug (including two-way synchronization)
+ domain: automation
+ input:
+ switch:
+ name: Switch
+ description: controller
+ selector:
+ entity:
+ domain: switch
+ light:
+ name: Bulb
+ description: smart bulb or power socket
+ selector:
+ entity:
+ domain: [light, switch]
+ 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
+ light_entity: !input light
+ dblclick: !input dblclick
+
+trigger:
+ - platform: state
+ entity_id: !input "switch"
+ - platform: state
+ entity_id: !input "light"
+
+mode: single
+action:
+ - choose:
+ - conditions:
+ - "{{ trigger.entity_id == switch_entity }}"
+ sequence:
+ - if:
+ - condition: template
+ value_template: '{{ dblclick | length > 0 }}'
+ then:
+ - 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: template
+ value_template: '{{trigger.to_state.state == "on" }}'
+ then:
+ - parallel:
+ - choose: []
+ default: !input "on_click"
+ - service: homeassistant.turn_on
+ target:
+ entity_id: !input light
+ else:
+ - parallel:
+ - choose: []
+ default: !input "off_click"
+ - service: homeassistant.turn_off
+ target:
+ entity_id: !input light
+ else:
+ - choose: []
+ default: !input "dblclick"
+ else:
+ - if:
+ - condition: template
+ value_template: '{{trigger.to_state.state == "on" }}'
+ then:
+ - parallel:
+ - choose: []
+ default: !input "on_click"
+ - service: homeassistant.turn_on
+ target:
+ entity_id: !input light
+ else:
+ - parallel:
+ - choose: []
+ default: !input "off_click"
+ - service: homeassistant.turn_off
+ target:
+ entity_id: !input light
+ - conditions:
+ - "{{ trigger.entity_id == light_entity }}"
+ sequence:
+ - service: >
+ {% if trigger.to_state.state == "on" %}
+ switch.turn_on
+ {% else %}
+ switch.turn_off
+ {% endif %}
+ target:
+ entity_id: !input switch
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
diff --git a/blueprints/automation/lights/light_sync.yaml b/blueprints/automation/lights/light_sync.yaml
new file mode 100644
index 0000000..44161ae
--- /dev/null
+++ b/blueprints/automation/lights/light_sync.yaml
@@ -0,0 +1,55 @@
+blueprint:
+ name: Light Sync
+ description: Allows to switch both parts of lustre with single click
+ domain: automation
+
+ input:
+ master:
+ name: Master
+ description: Master Switch
+ selector:
+ entity:
+ domain: switch
+ slave:
+ name: Slave
+ description: Slave Switch
+ selector:
+ entity:
+ domain: switch
+ 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:
+
+
+trigger:
+ - platform: state
+ entity_id: !input "master"
+
+mode: single
+action:
+ - if:
+ - condition: template
+ value_template: '{{trigger.to_state.state == "on" }}'
+ then:
+ - parallel:
+ - choose: []
+ default: !input "on_click"
+ - service: homeassistant.turn_on
+ target:
+ entity_id: !input slave
+ else:
+ - parallel:
+ - choose: []
+ default: !input "off_click"
+ - service: homeassistant.turn_off
+ target:
+ entity_id: !input slave
diff --git a/blueprints/automation/motion/motion_switch.yaml b/blueprints/automation/motion/motion_switch.yaml
new file mode 100644
index 0000000..c78e31f
--- /dev/null
+++ b/blueprints/automation/motion/motion_switch.yaml
@@ -0,0 +1,163 @@
+blueprint:
+ name: Motion-activated Switch
+ description: Turn on a light when motion is detected and surroundings are dark
+ domain: automation
+ input:
+ motion_entity:
+ name: Motion Sensor
+ selector:
+ entity:
+ domain: binary_sensor
+ device_class: motion
+
+ illumination_test:
+ name: Illumination Test
+ description: Select how to check if existing illumination is sufficient
+ default: sun
+ selector:
+ select:
+ options:
+ - label: Illuminance Sensor
+ value: sensor
+ - label: Sun Elevation
+ value: sun
+ - label: Always turn on lights
+ value: none
+ illuminance_entity:
+ name: Illuminance Sensor
+ description: Sensor providing information about illumination in the room (keep empty to rely on sun position)
+ selector:
+ entity:
+ domain: sensor
+ device_class: illuminance
+ lux_threshold:
+ name: LUX threshold
+ description: Threshold bellow which we consider that lighting is needed
+ default: 40
+ selector:
+ number:
+ min: 10
+ max: 1000
+ unit_of_measurement: lux
+ sun_elevation:
+ name: Sun Elevation
+ description: Sun elevation (suggested between 0 and -6) when dusks settles and we need to turn on lights)
+ default: 0
+ selector:
+ number:
+ min: -30
+ max: 30
+ unit_of_measurement: °
+
+
+ light_target:
+ name: Light Target
+ default: []
+ selector:
+ entity:
+ multiple: true
+ domain: [switch, light]
+ no_motion_wait:
+ name: Wait time
+ description: Time to leave the light on after last motion is detected.
+ default: 120
+ selector:
+ number:
+ min: 0
+ max: 3600
+ unit_of_measurement: seconds
+
+ on_click:
+ name: on_click
+ description: Additional actions to perform while turning on master light
+ default: []
+ selector:
+ action:
+ off_click:
+ name: off_click
+ description: Additional actions to perform while turning off master light
+ default: []
+ selector:
+ action:
+
+
+
+variables:
+ lux_threshold: !input lux_threshold
+ illuminance_entity: !input illuminance_entity
+ test: !input illumination_test
+
+ current_lux: '{{ (states(illuminance_entity) | float) }}'
+
+# If motion is detected within the delay,
+# we restart the script.
+mode: restart
+max_exceeded: silent
+
+trigger:
+ - platform: state
+ id: "turn_on"
+ entity_id: !input motion_entity
+ from: "off"
+ to: "on"
+ - platform: state
+ id: "turn_off"
+ entity_id: !input motion_entity
+ from: "on"
+ to: "off"
+ for:
+ seconds: !input no_motion_wait
+
+action:
+ - choose:
+ - conditions:
+ - condition: trigger
+ id: "turn_on"
+ sequence:
+ - choose:
+ - conditions:
+ - condition: template
+ value_template: '{{ test == "sensor" }}'
+ sequence:
+ - if:
+ - condition: template
+ value_template: '{{ (states(illuminance_entity) | float) < lux_threshold }}'
+ then:
+ - choose: []
+ default: !input "on_click"
+ - service: switch.turn_on
+ target:
+ entity_id: !input light_target
+
+ - conditions:
+ - condition: template
+ value_template: '{{ test == "sun" }}'
+ sequence:
+ - if:
+ - condition: numeric_state
+ entity_id: sun.sun
+ attribute: elevation
+ below: !input sun_elevation
+ then:
+ - choose: []
+ default: !input "on_click"
+ - service: switch.turn_on
+ target:
+ entity_id: !input light_target
+ default:
+ - choose: []
+ default: !input "on_click"
+ - service: switch.turn_on
+ target:
+ entity_id: !input light_target
+
+ - conditions:
+ - condition: trigger
+ id: "turn_off"
+ sequence:
+ - choose: []
+ default: !input "off_click"
+ - service: switch.turn_off
+ target:
+ entity_id: !input light_target
+ default: []