summaryrefslogtreecommitdiffstats
path: root/blueprints
diff options
context:
space:
mode:
Diffstat (limited to 'blueprints')
-rw-r--r--blueprints/automation/media/sven_scene_switch.yaml2
-rw-r--r--blueprints/automation/motion/motion_switch.yaml3
-rw-r--r--blueprints/automation/motion/occupancy_tracking_restart.yaml170
-rw-r--r--blueprints/automation/motion/presence_switch.yaml256
-rw-r--r--blueprints/script/devices/aircon.yaml20
-rw-r--r--blueprints/script/devices/aircon_off.yaml37
6 files changed, 468 insertions, 20 deletions
diff --git a/blueprints/automation/media/sven_scene_switch.yaml b/blueprints/automation/media/sven_scene_switch.yaml
index 8f54d8d..fe51918 100644
--- a/blueprints/automation/media/sven_scene_switch.yaml
+++ b/blueprints/automation/media/sven_scene_switch.yaml
@@ -78,6 +78,7 @@ action:
- condition: trigger
id: single1
sequence:
+ - service: shell_command.sound_living
- service: media_player.media_play_pause
target:
entity_id: !input media_player
@@ -86,6 +87,7 @@ action:
- condition: trigger
id: double1
sequence:
+ - service: shell_command.sound_living
- service: scene.turn_on
target:
entity_id: !input power_scene
diff --git a/blueprints/automation/motion/motion_switch.yaml b/blueprints/automation/motion/motion_switch.yaml
index dbc5374..67e62b6 100644
--- a/blueprints/automation/motion/motion_switch.yaml
+++ b/blueprints/automation/motion/motion_switch.yaml
@@ -1,5 +1,5 @@
blueprint:
- name: Motion-activated Switch
+ name: Motion-activated Switch (obsolete by presensece_switch)
description: Turn on a light when motion is detected and surroundings are dark
domain: automation
input:
@@ -215,6 +215,7 @@ action:
match: any
state: 'off'
sequence:
+# Race here: state might change between 'condition' check and 'wait_for_trigger'. We might be better to just finish the loop and check once more before the actions...
- wait_for_trigger:
- platform: state
entity_id: !input on_cond_should_be_on
diff --git a/blueprints/automation/motion/occupancy_tracking_restart.yaml b/blueprints/automation/motion/occupancy_tracking_restart.yaml
new file mode 100644
index 0000000..27855b9
--- /dev/null
+++ b/blueprints/automation/motion/occupancy_tracking_restart.yaml
@@ -0,0 +1,170 @@
+# This can be used stand-alone or in combination with 'motion_switch' (to allow more complex light-on scenarios, e.g. based on current illumination level)
+# For this reason, 'light on' should be programmed in 'on_action' if necessary
+# We can use blueprint using the same entrance/inside sensors, however, this is least robust variant
+# Re-entry events (take a towel go back in) will break automation
+# We can try to prevent by ensuring there is no repeated motions for prolonged time (but, then, blueprint will fail if we do something at entrance)
+
+blueprint:
+ name: Occupancy tracking with restart mode
+ description: Only mode differs, intended for cases where new inside trigger unlikely after exit triggered (this might happen in small places like e.g. toilet where motion might be detected after we have already openned the door)
+ domain: automation
+ input:
+ entrance:
+ name: Entrance
+ description: This can be door sensor or motion sensor monitoring passage via entrance area
+ selector:
+ entity:
+ domain: binary_sensor
+ inside:
+ name: Inside
+ description: Triggers when there is motion inside (this could be the same like entrance or additional sensor, e.g. we monitor motions as 'inside' and door sensor as 'entrance'). Independent sensors are much more robust
+ selector:
+ entity:
+ domain: binary_sensor
+ light:
+ name: Light
+ selector:
+ entity:
+ domain: [switch, light]
+ occupancy:
+ name: Occupancy
+ description: State variable (normally created via Helpers) tracking current state
+ selector:
+ entity:
+ domain: input_boolean
+
+ reentry_wait:
+ name: Re-entry Wait
+ description: Time without motions to handle re-entry events (seconds)
+ default: 1
+ selector:
+ number:
+ min: 0
+ max: 30
+ unit_of_measurement: seconds
+
+ reentry_timeout:
+ name: Re-entry Timeout
+ description: Timeout to assume re-entry if no 'no-motions' trigger were fired within timeout (seconds)
+ default: 10
+ selector:
+ number:
+ min: 1
+ max: 300
+ unit_of_measurement: seconds
+
+ on_action:
+ name: on_action
+ description: Actions to perform while occupancy is detected (lights will not be turned on automatically to allow more complex scenarios via motion-switch automation)
+ default: []
+ selector:
+ action:
+ off_action:
+ name: off_action
+ description: Additional actions to perform when place gets free
+ default: []
+ selector:
+ action:
+
+variables:
+ reentry_wait: !input reentry_wait
+
+# Lights are still on while we are waiting for re-entry. So, we don't need to allow re-trigger in this case and 'single' should do
+mode: restart
+
+trigger:
+ # Either door is open or motion in the entrance area is detected
+ - platform: state
+ id: "entrance"
+ entity_id: !input entrance
+ from: "off"
+ to: "on"
+
+ - platform: state
+ id: "inside"
+ entity_id: !input inside
+ from: "off"
+ to: "on"
+
+ # Light is turned off
+ - platform: state
+ id: "light_off"
+ entity_id: !input light
+ from: "on"
+ to: "off"
+
+action:
+ - choose:
+ # Occupancy goes 'off' if lights are manually (or on timeout) switched off
+ # We can't do the same to turn occupancy 'on' as 'entrance' event might be fired after manually turning lights on (it will be interpreted as leaving)
+ # Will be retriggered back 'on' on any movement inside (so, it is not so critical if something is wrong)
+ - conditions:
+ - condition: trigger
+ id: "light_off"
+ sequence:
+ - parallel:
+ - service: input_boolean.turn_off
+ target:
+ entity_id: !input occupancy
+ - choose: []
+ default: !input "off_action"
+
+ # Occupancy goes 'on' once movement inside is detected (we can't rely on trigger as inside & entrance might coincide)
+ - conditions:
+# - condition: trigger
+# id: "inside"
+ - condition: state
+ entity_id: !input inside
+ state: 'on'
+ - condition: or
+ conditions:
+ - condition: state
+ entity_id: !input occupancy
+ state: 'off'
+ - condition: state
+ entity_id: !input light
+ state: 'off'
+ sequence:
+ - parallel:
+ - service: input_boolean.turn_on
+ target:
+ entity_id: !input occupancy
+ - choose: []
+ default: !input "on_action"
+
+ # Occupancy goes 'off' once entrance triggered while occapncy is 'on' and there are no movements inside for a while
+ - conditions:
+# - condition: trigger
+# id: "entrance"
+ - condition: state
+ entity_id: !input entrance
+ state: 'on'
+ - condition: state
+ entity_id: !input occupancy
+ state: 'on'
+ sequence:
+ - if:
+ - condition: template
+ value_template: '{{ (reentry_wait | float) > 0 }}'
+ then:
+ - wait_for_trigger:
+ - platform: state
+ entity_id: !input inside
+ to: 'off'
+ for:
+ seconds: !input reentry_wait
+ timeout:
+ seconds: !input reentry_timeout
+ continue_on_timeout: false
+
+ - parallel:
+ - service: input_boolean.turn_off
+ target:
+ entity_id: !input occupancy
+ - service: switch.turn_off
+ target:
+ entity_id: !input light
+ - choose: []
+ default: !input "off_action"
+
+ default: []
diff --git a/blueprints/automation/motion/presence_switch.yaml b/blueprints/automation/motion/presence_switch.yaml
new file mode 100644
index 0000000..eaaf1a6
--- /dev/null
+++ b/blueprints/automation/motion/presence_switch.yaml
@@ -0,0 +1,256 @@
+blueprint:
+ name: Switch controlled by combination of motion and presence sensors
+ description: Turns on light only on large movements, but turns off only if no movements in the room detected
+ domain: automation
+ input:
+ motion_entity:
+ name: Motion Sensor (or presence sensor if separate motion sensor is not available)
+ selector:
+ entity:
+ domain: binary_sensor
+# device_class: motion
+
+ presence_entity:
+ name: Presence Sensor
+ description: Presence sensor (or motion sensor if presence sensor is not available)
+ selector:
+ entity:
+ domain: binary_sensor
+# device_class: motion
+
+ door_entity:
+ name: Door Contact
+ description: Additionally trigger if door opens while no motion detected
+ default: []
+ selector:
+ entity:
+ multiple: true
+ domain: binary_sensor
+# device_class: contact
+
+ 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
+
+
+############## Light based ##########################
+ 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: °
+
+############################# Preconditions #########################################
+
+# Also should be off for some time, otherwise it can get switched back on once we turn light off
+ on_cond_should_be_off:
+ name: Switch-on precondition - entities which must be off
+ description: E.g. all lights should be off in the room
+ default: []
+ selector:
+ entity:
+ multiple: true
+ domain: [ input_boolean, binary_sensor, switch, light ]
+
+# We can wait a bit if events slightly desynchronized and motion in hall noticed later than in the room
+ on_cond_should_be_on:
+ name: Switch-on precondition - entities which must be on
+ description: E.g. we only turn light if entering from the hall
+ default: []
+ selector:
+ entity:
+ multiple: true
+ domain: [ input_boolean, binary_sensor, switch, light ]
+
+ off_cond_should_be_off:
+ name: Switch-off precondition - entities which must be off
+ description: E.g. if some lights or devices are on, we assume room is still occupied
+ default: []
+ selector:
+ entity:
+ multiple: true
+ domain: [ input_boolean, binary_sensor, switch, light ]
+
+ off_cond_should_be_on:
+ name: Switch-off precondition - entities which must be on
+ description: E.g. motion in coridor should be detected
+ default: []
+ selector:
+ entity:
+ multiple: true
+ domain: [ input_boolean, binary_sensor, switch, light ]
+
+
+############################# Custom Actions #####################################
+
+ 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: "door"
+ entity_id: !input door_entity
+ from: "off"
+ to: "on"
+ - platform: state
+ id: "turn_off"
+ entity_id: !input presence_entity
+ from: "on"
+ to: "off"
+ for:
+ seconds: !input no_motion_wait
+
+action:
+ - choose:
+ - conditions:
+ - condition: or
+ conditions:
+ - condition: trigger
+ id: "turn_on"
+ - condition: and
+ conditions:
+ - condition: trigger
+ id: "door"
+ - condition: state
+ entity_id: !input motion_entity
+ state: 'off'
+ - condition: or
+ conditions:
+ - condition: and
+ conditions:
+ - condition: template
+ value_template: '{{ test == "sensor" }}'
+ - condition: template
+ value_template: '{{ (states(illuminance_entity) | float) < lux_threshold }}'
+ - condition: and
+ conditions:
+ - condition: template
+ value_template: '{{ test == "sun" }}'
+ - condition: numeric_state
+ entity_id: sun.sun
+ attribute: elevation
+ below: !input sun_elevation
+ - condition: template
+ value_template: '{{ test == "none" }}'
+ - condition: state
+ entity_id: !input on_cond_should_be_off
+ state: 'off'
+ for:
+ hours: 0
+ minutes: 0
+ seconds: 10
+ sequence:
+ - repeat:
+ while:
+ - condition: state
+ entity_id: !input on_cond_should_be_on
+ match: any
+ state: 'off'
+ sequence:
+# Race here: state might change between 'condition' check and 'wait_for_trigger'. We might be better to just finish the loop and check once more before the actions...
+ - wait_for_trigger:
+ - platform: state
+ entity_id: !input on_cond_should_be_on
+ to: 'on'
+ timeout:
+ seconds: 2
+ continue_on_timeout: false
+
+ - choose: []
+ default: !input "on_click"
+ - service: switch.turn_on
+ target:
+ entity_id: !input light_target
+
+ - conditions:
+ - condition: trigger
+ id: "turn_off"
+ - condition: state
+ entity_id: !input off_cond_should_be_off
+ state: 'off'
+ - condition: state
+ entity_id: !input off_cond_should_be_on
+ state: 'on'
+ sequence:
+ - choose: []
+ default: !input "off_click"
+ - service: switch.turn_off
+ target:
+ entity_id: !input light_target
+ default: []
diff --git a/blueprints/script/devices/aircon.yaml b/blueprints/script/devices/aircon.yaml
index b2641be..1677c69 100644
--- a/blueprints/script/devices/aircon.yaml
+++ b/blueprints/script/devices/aircon.yaml
@@ -1,6 +1,6 @@
blueprint:
name: AirCon
- description: Stream photos from security camera
+ description: Automatically on/off Air Condition (current state and temperature based)
domain: script
input:
power:
@@ -114,22 +114,4 @@ sequence:
- choose: []
default: !input "confirm"
-# - if:
-# - condition: state
-# entity_id: switch.bedroom_aircon
-# state: 'off'
-# then:
-# - service: switch.turn_on
-# data: {}
-# target:
-# entity_id: switch.bedroom_aircon
-# - delay:
-# hours: 0
-# minutes: 0
-# seconds: 5
-# milliseconds: 0
- - service: scene.turn_on
- target:
- entity_id: scene.hyundai_aircon_cool_18
- metadata: {}
mode: single
diff --git a/blueprints/script/devices/aircon_off.yaml b/blueprints/script/devices/aircon_off.yaml
new file mode 100644
index 0000000..f0132f1
--- /dev/null
+++ b/blueprints/script/devices/aircon_off.yaml
@@ -0,0 +1,37 @@
+blueprint:
+ name: AirCon Off
+ description: Turn off Air Condition
+ domain: script
+ input:
+ power:
+ name: Power
+ description: Aircon Smart Power Plug
+ selector:
+ entity:
+ domain: switch
+ off_scene:
+ name: Off Scene
+ description: Off scene of Aircon
+ selector:
+ entity:
+ domain: scene
+
+alias: AirCon
+sequence:
+ - if:
+ - condition: state
+ entity_id: !input power
+ state: 'on'
+ then:
+ - service: scene.turn_on
+ target:
+ entity_id: !input off_scene
+ - delay:
+ hours: 0
+ minutes: 0
+ seconds: 5
+ milliseconds: 0
+ - service: switch.turn_off
+ target:
+ entity_id: !input power
+mode: single