summaryrefslogtreecommitdiffstats
path: root/blueprints
diff options
context:
space:
mode:
authorSuren A. Chilingaryan <csa@suren.me>2023-04-09 21:17:59 +0400
committerSuren A. Chilingaryan <csa@suren.me>2023-04-09 21:17:59 +0400
commit756a33999df9255deb1c08a443a5621d94da0126 (patch)
treeed40d4465637d99a4da2a0069f18fb15d82f21d5 /blueprints
parent3b67e6bbc959b5d24f12e7df1574e96085431a56 (diff)
downloadhass-756a33999df9255deb1c08a443a5621d94da0126.tar.gz
hass-756a33999df9255deb1c08a443a5621d94da0126.tar.bz2
hass-756a33999df9255deb1c08a443a5621d94da0126.tar.xz
hass-756a33999df9255deb1c08a443a5621d94da0126.zip
Fixes, multi-room sounds, motion tracking in rooms
Diffstat (limited to 'blueprints')
-rw-r--r--blueprints/automation/motion/motion_switch.yaml169
-rw-r--r--blueprints/automation/motion/occupancy_tracking.yaml34
2 files changed, 134 insertions, 69 deletions
diff --git a/blueprints/automation/motion/motion_switch.yaml b/blueprints/automation/motion/motion_switch.yaml
index 31ba62c..dbc5374 100644
--- a/blueprints/automation/motion/motion_switch.yaml
+++ b/blueprints/automation/motion/motion_switch.yaml
@@ -13,12 +13,33 @@ blueprint:
door_entity:
name: Door Contact
description: Additionally trigger if door opens while no motion detected
- default: {}
+ 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
@@ -58,23 +79,48 @@ blueprint:
max: 30
unit_of_measurement: °
+############################# Preconditions #########################################
- light_target:
- name: Light Target
+# 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: [switch, light]
- no_motion_wait:
- name: Wait time
- description: Time to leave the light on after last motion is detected.
- default: 120
+ 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:
- number:
- min: 0
- max: 3600
- unit_of_measurement: seconds
+ 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
@@ -127,56 +173,71 @@ action:
- 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'
- sequence:
- - choose:
- - 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" }}'
- 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: '{{ (states(illuminance_entity) | float) < lux_threshold }}'
+ - condition: and
+ 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
+ - 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:
+ - 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"
diff --git a/blueprints/automation/motion/occupancy_tracking.yaml b/blueprints/automation/motion/occupancy_tracking.yaml
index c573bf9..4edf52c 100644
--- a/blueprints/automation/motion/occupancy_tracking.yaml
+++ b/blueprints/automation/motion/occupancy_tracking.yaml
@@ -95,8 +95,24 @@ trigger:
action:
- choose:
- # Occupancy goes 'on' once movement inside is detected
+ # 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'
@@ -118,6 +134,8 @@ 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'
@@ -149,18 +167,4 @@ action:
- choose: []
default: !input "off_action"
- # 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"
-
default: []