summaryrefslogtreecommitdiffstats
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
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
-rw-r--r--.storage/input_boolean8
-rw-r--r--.storage/lovelace.lovelace_status32
-rw-r--r--.storage/lovelace.lovelace_test214
-rw-r--r--automations.yaml396
-rw-r--r--blueprints/automation/motion/motion_switch.yaml169
-rw-r--r--blueprints/automation/motion/occupancy_tracking.yaml34
-rw-r--r--configuration.yaml1
-rw-r--r--custom/scripts/sleep-and-wake.yaml26
-rw-r--r--custom/shell.yaml2
-rw-r--r--scripts.yaml2
10 files changed, 751 insertions, 133 deletions
diff --git a/.storage/input_boolean b/.storage/input_boolean
index f03e5e7..6c81959 100644
--- a/.storage/input_boolean
+++ b/.storage/input_boolean
@@ -48,6 +48,14 @@
{
"name": "Occupancy Bathroom",
"id": "occupancy_bathroom"
+ },
+ {
+ "name": "Mode Office Sleep",
+ "id": "mode_house_sleep_2"
+ },
+ {
+ "name": "Mode Office Hibernate",
+ "id": "mode_office_hibernate"
}
]
}
diff --git a/.storage/lovelace.lovelace_status b/.storage/lovelace.lovelace_status
index 1cfbb25..b259dfc 100644
--- a/.storage/lovelace.lovelace_status
+++ b/.storage/lovelace.lovelace_status
@@ -194,16 +194,24 @@
"name": "Kitchen1"
},
{
- "entity": "binary_sensor.kitchen_motions2_occupancy",
- "name": "Kitchen2"
- },
- {
"entity": "binary_sensor.bathroom_motions_occupancy",
"name": "Bathroom"
},
{
"entity": "binary_sensor.toilet_motions_occupancy",
"name": "Toilet"
+ },
+ {
+ "entity": "binary_sensor.guestroom_motions_occupancy",
+ "name": "Guestroom"
+ },
+ {
+ "entity": "binary_sensor.bedroom_motions_occupancy",
+ "name": "Bedroom"
+ },
+ {
+ "entity": "binary_sensor.presence_presence",
+ "name": "Living"
}
],
"title": "Motions"
@@ -220,16 +228,24 @@
"name": "Kitchen1"
},
{
- "entity": "binary_sensor.kitchen_motions2_occupancy",
- "name": "Kitchen2"
- },
- {
"entity": "binary_sensor.bathroom_motions_occupancy",
"name": "Bathroom"
},
{
"entity": "binary_sensor.toilet_motions_occupancy",
"name": "Toilet"
+ },
+ {
+ "entity": "binary_sensor.guestroom_motions_occupancy",
+ "name": "Guestroom"
+ },
+ {
+ "entity": "binary_sensor.bedroom_motions_occupancy",
+ "name": "Bedroom"
+ },
+ {
+ "entity": "binary_sensor.presence_presence",
+ "name": "Living"
}
],
"hours_to_show": 2,
diff --git a/.storage/lovelace.lovelace_test b/.storage/lovelace.lovelace_test
index 42bcdbf..fcdba8e 100644
--- a/.storage/lovelace.lovelace_test
+++ b/.storage/lovelace.lovelace_test
@@ -114,6 +114,33 @@
],
"hours_to_show": 1,
"title": "Vibration Sensor (1h)"
+ },
+ {
+ "type": "entities",
+ "entities": [
+ {
+ "entity": "input_number.knob_office_current"
+ },
+ {
+ "entity": "input_number.knob_office_brightness0"
+ },
+ {
+ "entity": "input_number.knob_office_temperature0"
+ },
+ {
+ "entity": "input_number.knob_office_hue0"
+ },
+ {
+ "entity": "input_number.knob_office_brightness1"
+ },
+ {
+ "entity": "input_number.knob_office_temperature1"
+ },
+ {
+ "entity": "input_number.knob_office_hue1"
+ }
+ ],
+ "title": "Knob Control"
}
]
},
@@ -132,11 +159,7 @@
},
{
"entity": "binary_sensor.kitchen_motions_occupancy",
- "name": "Kitchen/Table"
- },
- {
- "entity": "binary_sensor.kitchen_motions2_occupancy",
- "name": "Kitchen/Sink"
+ "name": "Kitchen"
},
{
"type": "divider"
@@ -155,6 +178,28 @@
{
"entity": "binary_sensor.toilet_door_contact",
"name": "Door"
+ },
+ {
+ "type": "divider"
+ },
+ {
+ "entity": "binary_sensor.presence_presence",
+ "name": "Living"
+ },
+ {
+ "entity": "sensor.presence_target_distance",
+ "name": "Distance"
+ },
+ {
+ "type": "divider"
+ },
+ {
+ "entity": "binary_sensor.bedroom_motions_occupancy",
+ "name": "Bedroom"
+ },
+ {
+ "entity": "binary_sensor.guestroom_motions_occupancy",
+ "name": "Guestroom"
}
]
},
@@ -167,11 +212,7 @@
},
{
"entity": "binary_sensor.kitchen_motions_occupancy",
- "name": "Kitchen/Table"
- },
- {
- "entity": "binary_sensor.kitchen_motions2_occupancy",
- "name": "Kitchen/Sink"
+ "name": "Kitchen"
},
{
"entity": "binary_sensor.bathroom_motions_occupancy",
@@ -184,6 +225,18 @@
{
"entity": "binary_sensor.toilet_door_contact",
"name": "Toilet Door"
+ },
+ {
+ "entity": "binary_sensor.presence_occupancy",
+ "name": "Living"
+ },
+ {
+ "entity": "binary_sensor.bedroom_motions_occupancy",
+ "name": "Bedroom"
+ },
+ {
+ "entity": "binary_sensor.guestroom_motions_occupancy",
+ "name": "Guestroom"
}
],
"hours_to_show": 1,
@@ -198,11 +251,7 @@
},
{
"entity": "binary_sensor.kitchen_motions_occupancy",
- "name": "Kitchen/Table"
- },
- {
- "entity": "binary_sensor.kitchen_motions2_occupancy",
- "name": "Kitchen/Sink"
+ "name": "Kitchen"
},
{
"entity": "binary_sensor.bathroom_motions_occupancy",
@@ -215,10 +264,52 @@
{
"entity": "binary_sensor.toilet_door_contact",
"name": "Toilet Door"
+ },
+ {
+ "entity": "binary_sensor.presence_occupancy",
+ "name": "Living"
+ },
+ {
+ "entity": "binary_sensor.bedroom_motions_occupancy",
+ "name": "Bedroom"
+ },
+ {
+ "entity": "binary_sensor.guestroom_motions_occupancy",
+ "name": "Guestroom"
}
],
"hours_to_show": 12,
"title": "Motion Sensors (12h)"
+ },
+ {
+ "type": "history-graph",
+ "entities": [
+ {
+ "entity": "binary_sensor.presence_presence",
+ "name": "Prsence"
+ },
+ {
+ "entity": "sensor.presence_target_distance",
+ "name": "Distance"
+ }
+ ],
+ "hours_to_show": 1,
+ "title": "Presence (1h)"
+ },
+ {
+ "type": "history-graph",
+ "entities": [
+ {
+ "entity": "binary_sensor.presence_presence",
+ "name": "Presence"
+ },
+ {
+ "entity": "sensor.presence_target_distance",
+ "name": "Distance"
+ }
+ ],
+ "hours_to_show": 12,
+ "title": "Presence (12h)"
}
]
},
@@ -253,11 +344,7 @@
},
{
"entity": "binary_sensor.kitchen_motions_occupancy",
- "name": "Motions/Table"
- },
- {
- "entity": "binary_sensor.kitchen_motions2_occupancy",
- "name": "Motions/Sink"
+ "name": "Motions/Kitchen"
},
{
"type": "divider"
@@ -268,11 +355,7 @@
},
{
"entity": "sensor.kitchen_motions_illuminance_lux",
- "name": "Lux/Table"
- },
- {
- "entity": "sensor.kitchen_motions2_illuminance_lux",
- "name": "Lux/Sink"
+ "name": "Lux/Kitchen"
}
]
},
@@ -356,19 +439,11 @@
},
{
"entity": "binary_sensor.kitchen_motions_occupancy",
- "name": "Motions/Table"
- },
- {
- "entity": "binary_sensor.kitchen_motions2_occupancy",
- "name": "Motions/Sink"
+ "name": "Motions"
},
{
"entity": "sensor.kitchen_motions_illuminance_lux",
- "name": "Lux/Table"
- },
- {
- "entity": "sensor.kitchen_motions2_illuminance_lux",
- "name": "Lux/Sink"
+ "name": "Lux"
}
],
"hours_to_show": 1,
@@ -506,28 +581,81 @@
"type": "entities",
"entities": [
{
- "entity": "input_number.knob_office_current"
+ "entity": "sensor.hall_motions_illuminance_lux",
+ "name": "Hall"
},
{
- "entity": "input_number.knob_office_brightness0"
+ "entity": "sensor.kitchen_motions_illuminance_lux",
+ "name": "Kitchen"
},
{
- "entity": "input_number.knob_office_temperature0"
+ "entity": "sensor.presence_illuminance_lux",
+ "name": "Living"
},
{
- "entity": "input_number.knob_office_hue0"
+ "entity": "sensor.bedroom_motions_illuminance_lux",
+ "name": "Bedroom"
},
{
- "entity": "input_number.knob_office_brightness1"
+ "entity": "sensor.guestroom_motions_illuminance_lux",
+ "name": "Guestroom"
+ }
+ ],
+ "title": "Illuminance"
+ },
+ {
+ "type": "history-graph",
+ "entities": [
+ {
+ "entity": "sensor.hall_motions_illuminance_lux",
+ "name": "Hall"
},
{
- "entity": "input_number.knob_office_temperature1"
+ "entity": "sensor.kitchen_motions_illuminance_lux",
+ "name": "Kitchen"
},
{
- "entity": "input_number.knob_office_hue1"
+ "entity": "sensor.presence_illuminance_lux",
+ "name": "Living"
+ },
+ {
+ "entity": "sensor.bedroom_motions_illuminance_lux",
+ "name": "Bedroom"
+ },
+ {
+ "entity": "sensor.guestroom_motions_illuminance_lux",
+ "name": "Guestroom"
}
],
- "title": "Knob Control"
+ "hours_to_show": 1,
+ "title": "Illuminance (1h)"
+ },
+ {
+ "type": "history-graph",
+ "entities": [
+ {
+ "entity": "sensor.hall_motions_illuminance_lux",
+ "name": "Hall"
+ },
+ {
+ "entity": "sensor.kitchen_motions_illuminance_lux",
+ "name": "Kitchen"
+ },
+ {
+ "entity": "sensor.presence_illuminance_lux",
+ "name": "Living"
+ },
+ {
+ "entity": "sensor.bedroom_motions_illuminance_lux",
+ "name": "Bedroom"
+ },
+ {
+ "entity": "sensor.guestroom_motions_illuminance_lux",
+ "name": "Guestroom"
+ }
+ ],
+ "hours_to_show": 12,
+ "title": "Illuminance (12h)"
}
]
}
diff --git a/automations.yaml b/automations.yaml
index 4446daf..38cc979 100644
--- a/automations.yaml
+++ b/automations.yaml
@@ -64,6 +64,9 @@
- conditions:
- condition: trigger
id: Toilet
+ - condition: state
+ entity_id: binary_sensor.toilet_motions_occupancy
+ state: 'off'
sequence:
- type: turn_off
device_id: 07b7086cf34752386c82a5109311ac6e
@@ -81,14 +84,35 @@
device_id: 04c6f563c006599ed7754aba652654ae
entity_id: switch.bathroom_lights_center
domain: switch
- - type: turn_off
- device_id: 558ce3c924f9478aad68cb5b98f05ecc
- entity_id: switch.kitchen_lights_left
- domain: switch
- - type: turn_off
- device_id: 558ce3c924f9478aad68cb5b98f05ecc
- entity_id: switch.kitchen_lights_center
- domain: switch
+ - if:
+ - condition: state
+ entity_id: binary_sensor.motions_kitchen
+ state: 'off'
+ then:
+ - type: turn_off
+ device_id: 558ce3c924f9478aad68cb5b98f05ecc
+ entity_id: switch.kitchen_lights_left
+ domain: switch
+ - type: turn_off
+ device_id: 558ce3c924f9478aad68cb5b98f05ecc
+ entity_id: switch.kitchen_lights_center
+ domain: switch
+ - if:
+ - condition: state
+ entity_id: binary_sensor.guestroom_motions_occupancy
+ state: 'off'
+ - condition: state
+ entity_id: input_boolean.mode_guests
+ state: 'off'
+ then:
+ - type: turn_off
+ device_id: e83c3f421447fac86b5089fbd286ed43
+ entity_id: switch.guestroom_lights_left
+ domain: switch
+ - type: turn_off
+ device_id: e83c3f421447fac86b5089fbd286ed43
+ entity_id: switch.guestroom_lights_center
+ domain: switch
default: []
mode: single
- id: '1654901560778'
@@ -132,6 +156,8 @@
device_id: bf45f1d630db6e2aa1307866603f548a
entity_id: light.smart_light
domain: light
+ - service: shell_command.sound_living
+ data: {}
off_click:
- type: turn_off
device_id: 4ca2827c57a086e0da4d63756b15261b
@@ -288,6 +314,7 @@
target:
entity_id:
- switch.lights_living
+ data: {}
- service: script.sleep_and_wake
data:
mode: hibernate
@@ -347,6 +374,24 @@
- condition: trigger
id: right
sequence:
+ - service: shell_command.sound_combined
+ data: {}
+ - service: media_player.media_play_pause
+ target:
+ entity_id: media_player.smartpi
+ data: {}
+ - conditions:
+ - condition: trigger
+ id: right_dbl
+ sequence:
+ - service: script.play_playlist
+ data:
+ media_player: media_player.smartpi
+ playlist: darksoft
+ - conditions:
+ - condition: trigger
+ id: right_hold
+ sequence:
- service: script.bedroom_aircon
data: {}
default:
@@ -788,7 +833,7 @@
target:
entity_id: input_button.button_confirm
data: {}
- temperature: 6000
+ temperature: 4500
on_light: 'no'
- id: '1672991247298'
alias: 'Living: Light Sync'
@@ -818,7 +863,7 @@
motion_entity: binary_sensor.motions_kitchen
illumination_test: sensor
illuminance_entity: sensor.kitchen_motions_illuminance_lux
- lux_threshold: 40
+ lux_threshold: 60
- id: '1673037015865'
alias: 'Motions: Night Light'
description: ''
@@ -863,6 +908,8 @@
device_id: 87071fc9d8fb9ebbccb145f5642c7404
entity_id: light.aqara_hub_m1s_426c
domain: light
+ door_entity:
+ - binary_sensor.entrance_door_contact
- id: '1673153262822'
alias: 'Motions: Global v1'
description: ''
@@ -1187,3 +1234,332 @@
data:
message: Connected via Vivacell
mode: single
+- id: '1680824553612'
+ alias: 'Motions: Bedroom'
+ description: ''
+ use_blueprint:
+ path: motion/motion_switch.yaml
+ input:
+ light_target:
+ - switch.bedroom_lights_left
+ - switch.bedroom_lights_center
+ motion_entity: binary_sensor.bedroom_motions_occupancy
+ illumination_test: sun
+ illuminance_entity: sensor.kitchen_motions_illuminance_lux
+ lux_threshold: 60
+ no_motion_wait: 60
+ on_cond_should_be_off:
+ - switch.lights_bedroom
+ on_cond_should_be_on:
+ - binary_sensor.hall_motions_occupancy
+ off_cond_should_be_off:
+ - switch.lights_bedroom
+ on_click:
+ - service: automation.turn_on
+ data: {}
+ target:
+ entity_id: automation.motions_bedroom_from_hall
+- id: '1680827972411'
+ alias: 'Motions: Guestroom'
+ description: ''
+ use_blueprint:
+ path: motion/motion_switch.yaml
+ input:
+ light_target:
+ - switch.guestroom_lights_left
+ - switch.guestroom_lights_center
+ motion_entity: binary_sensor.guestroom_motions_occupancy
+ illumination_test: sun
+ illuminance_entity: sensor.kitchen_motions_illuminance_lux
+ lux_threshold: 60
+ no_motion_wait: 60
+ on_cond_should_be_off:
+ - switch.lights_guest
+- id: '1680829267506'
+ alias: 'Motions: Living'
+ description: ''
+ use_blueprint:
+ path: motion/motion_switch.yaml
+ input:
+ light_target:
+ - switch.living_lights_left
+ - switch.living_lights_center
+ motion_entity: binary_sensor.presence_presence
+ illumination_test: sun
+ illuminance_entity: sensor.kitchen_motions_illuminance_lux
+ lux_threshold: 60
+ no_motion_wait: 1200
+ on_cond_should_be_off:
+ - switch.lights_living
+ on_cond_should_be_on:
+ - binary_sensor.hall_motions_occupancy
+- id: '1680830396231'
+ alias: 'Motions: Living Office Wakeup'
+ description: ''
+ use_blueprint:
+ path: motion/motion_switch.yaml
+ input:
+ light_target: []
+ motion_entity: binary_sensor.presence_presence
+ illumination_test: none
+ illuminance_entity: sensor.presence_illuminance_lux
+ lux_threshold: 60
+ on_click:
+ - parallel:
+ - service: script.sleep_and_wake
+ data:
+ mode: wake
+ target: office
+ - service: media_player.media_play
+ target:
+ entity_id: media_player.smartpi
+ data: {}
+ off_click:
+ - parallel:
+ - service: script.sleep_and_wake
+ data:
+ mode: hibernate
+ target: office
+ - service: switch.turn_off
+ data: {}
+ target:
+ entity_id: switch.lights_living
+ no_motion_wait: 2400
+ on_cond_should_be_on:
+ - binary_sensor.hall_motions_occupancy
+ - input_boolean.mode_office_sleep
+ off_cond_should_be_off:
+ - binary_sensor.hall_motions_occupancy
+- id: '1680918876959'
+ alias: Modes
+ description: ''
+ trigger:
+ - platform: state
+ entity_id:
+ - input_boolean.mode_alone
+ - input_boolean.mode_guests
+ condition: []
+ action:
+ - choose:
+ - conditions:
+ - condition: state
+ entity_id: input_boolean.mode_guests
+ state: 'on'
+ sequence:
+ - service: automation.turn_off
+ data: {}
+ target:
+ entity_id: automation.motions_guestroom
+ - conditions:
+ - condition: state
+ entity_id: input_boolean.mode_guests
+ state: 'off'
+ sequence:
+ - service: automation.turn_on
+ data: {}
+ target:
+ entity_id: automation.motions_guestroom
+ - conditions:
+ - condition: state
+ entity_id: input_boolean.mode_alone
+ state: 'on'
+ sequence:
+ - service: automation.turn_on
+ data: {}
+ target:
+ entity_id: automation.motions_bedroom
+ - conditions:
+ - condition: state
+ entity_id: input_boolean.mode_alone
+ state: 'off'
+ sequence:
+ - service: automation.turn_off
+ data: {}
+ target:
+ entity_id: automation.motions_bedroom
+ mode: single
+- id: '1680923844207'
+ alias: 'Motions: Bedroom from Hall'
+ description: ''
+ trigger:
+ - type: no_motion
+ platform: device
+ device_id: 6deb0a6fb7a4a849ba22afc166cf9919
+ entity_id: binary_sensor.hall_motions_occupancy
+ domain: binary_sensor
+ for:
+ hours: 0
+ minutes: 0
+ seconds: 30
+ condition:
+ - condition: state
+ entity_id: input_boolean.mode_alone
+ state: 'on'
+ - condition: state
+ entity_id: input_boolean.mode_guests
+ state: 'off'
+ - condition: state
+ entity_id:
+ - binary_sensor.bedroom_bedsidelamp
+ - switch.bedroom_tablelamp
+ - switch.bedroom_lights_right
+ state: 'off'
+ - type: is_no_motion
+ condition: device
+ device_id: 4df2316b687cb4638268ae44eaad7e14
+ entity_id: binary_sensor.bedroom_motions_occupancy
+ domain: binary_sensor
+ for:
+ hours: 0
+ minutes: 0
+ seconds: 20
+ action:
+ - service: homeassistant.turn_off
+ data: {}
+ target:
+ entity_id: switch.lights_bedroom
+ - service: automation.turn_off
+ data:
+ stop_actions: false
+ target:
+ entity_id: automation.motions_bedroom_from_hall
+ mode: single
+- id: '1681005500468'
+ alias: 'Bedroom: Switch3'
+ description: ''
+ trigger:
+ - platform: device
+ domain: mqtt
+ device_id: dd15920a1e112dc1f45e5dd497aa3939
+ type: action
+ subtype: 1_single
+ discovery_id: 0x70ac08fffe419fa1 action_1_single
+ id: left1
+ - platform: device
+ domain: mqtt
+ device_id: dd15920a1e112dc1f45e5dd497aa3939
+ type: action
+ subtype: 2_single
+ discovery_id: 0x70ac08fffe419fa1 action_2_single
+ id: center1
+ - platform: device
+ domain: mqtt
+ device_id: dd15920a1e112dc1f45e5dd497aa3939
+ type: action
+ subtype: 3_single
+ discovery_id: 0x70ac08fffe419fa1 action_3_single
+ id: right1
+ - platform: device
+ domain: mqtt
+ device_id: dd15920a1e112dc1f45e5dd497aa3939
+ type: action
+ subtype: 1_double
+ discovery_id: 0x70ac08fffe419fa1 action_1_double
+ id: left2
+ - platform: device
+ domain: mqtt
+ device_id: dd15920a1e112dc1f45e5dd497aa3939
+ type: action
+ subtype: 2_double
+ discovery_id: 0x70ac08fffe419fa1 action_2_double
+ id: center2
+ - platform: device
+ domain: mqtt
+ device_id: dd15920a1e112dc1f45e5dd497aa3939
+ type: action
+ subtype: 3_double
+ discovery_id: 0x70ac08fffe419fa1 action_3_double
+ id: right2
+ - platform: device
+ domain: mqtt
+ device_id: dd15920a1e112dc1f45e5dd497aa3939
+ type: action
+ subtype: 1_hold
+ discovery_id: 0x70ac08fffe419fa1 action_1_hold
+ id: left3
+ - platform: device
+ domain: mqtt
+ device_id: dd15920a1e112dc1f45e5dd497aa3939
+ type: action
+ subtype: 2_hold
+ discovery_id: 0x70ac08fffe419fa1 action_2_hold
+ id: center3
+ - platform: device
+ domain: mqtt
+ device_id: dd15920a1e112dc1f45e5dd497aa3939
+ type: action
+ subtype: 3_hold
+ discovery_id: 0x70ac08fffe419fa1 action_3_hold
+ id: right3
+ condition: []
+ action:
+ - choose:
+ - conditions:
+ - condition: trigger
+ id: left1
+ sequence:
+ - service: homeassistant.toggle
+ data: {}
+ target:
+ entity_id:
+ - switch.bedroom_tablelamp
+ - conditions:
+ - condition: trigger
+ id: left2
+ sequence:
+ - service: homeassistant.toggle
+ data: {}
+ target:
+ entity_id:
+ - switch.bedroom_lights_left
+ - conditions:
+ - condition: trigger
+ id: left3
+ sequence:
+ - service: homeassistant.toggle
+ data: {}
+ target:
+ entity_id:
+ - light.smart_light
+ - conditions:
+ - condition: trigger
+ id: center1
+ sequence:
+ - if:
+ - condition: device
+ device_id: 8ea1ddea398d0a1bcbef996a9fdc06c5
+ domain: media_player
+ entity_id: media_player.smartpi
+ type: is_playing
+ then:
+ - service: shell_command.sound_living
+ data: {}
+ else:
+ - service: shell_command.sound_combined
+ data: {}
+ - service: media_player.media_play_pause
+ target:
+ entity_id: media_player.smartpi
+ data: {}
+ - conditions:
+ - condition: trigger
+ id: center2
+ sequence:
+ - service: media_player.media_next_track
+ data: {}
+ target:
+ entity_id: media_player.smartpi
+ - conditions:
+ - condition: trigger
+ id: center3
+ sequence:
+ - service: script.play_playlist
+ data:
+ media_player: media_player.smartpi
+ playlist: darksoft
+ default:
+ - service: input_button.press
+ data: {}
+ target:
+ entity_id: input_button.button_confirm
+ mode: single
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: []
diff --git a/configuration.yaml b/configuration.yaml
index f157cca..034b3f0 100644
--- a/configuration.yaml
+++ b/configuration.yaml
@@ -99,3 +99,4 @@ input_number: !include custom/input_number.yaml
binary_sensor: !include custom/binary_sensor.yaml
script manual: !include_dir_merge_named custom/scripts/
automation manual: !include_dir_merge_list custom/automation/
+shell_command: !include custom/shell.yaml
diff --git a/custom/scripts/sleep-and-wake.yaml b/custom/scripts/sleep-and-wake.yaml
index a71518a..c8e180d 100644
--- a/custom/scripts/sleep-and-wake.yaml
+++ b/custom/scripts/sleep-and-wake.yaml
@@ -42,6 +42,9 @@ sleep_and_wake:
- service: switch.turn_off
target:
entity_id: switch.living_lights_right
+ - service: input_boolean.turn_on
+ target:
+ entity_id: input_boolean.mode_office_sleep
- conditions:
- condition: template
@@ -61,6 +64,12 @@ sleep_and_wake:
- service: switch.turn_off
target:
entity_id: switch.living_lights_right
+ - service: input_boolean.turn_on
+ target:
+ entity_id:
+ - input_boolean.mode_office_sleep
+ - input_boolean.mode_office_hibernate
+
- conditions:
- condition: template
@@ -78,6 +87,12 @@ sleep_and_wake:
- service: wake_on_lan.send_magic_packet
data:
mac: "e8:6a:64:7b:5d:0a"
+ - service: input_boolean.turn_off
+ target:
+ entity_id:
+ - input_boolean.mode_office_sleep
+ - input_boolean.mode_office_hibernate
+
- conditions:
- condition: template
@@ -108,7 +123,10 @@ sleep_and_wake:
# entity_id: switch.hall_lights_right
- service: input_boolean.turn_on
target:
- entity_id: input_boolean.mode_house_sleep
+ entity_id:
+ - input_boolean.mode_house_sleep
+ - input_boolean.mode_office_sleep
+ - input_boolean.mode_office_hibernate
- conditions:
- condition: template
@@ -126,7 +144,11 @@ sleep_and_wake:
entity_id: switch.hall_lights_right
- service: input_boolean.turn_on
target:
- entity_id: input_boolean.mode_house_hibernate
+ entity_id:
+ - input_boolean.mode_office_sleep
+ - input_boolean.mode_office_hibernate
+ - input_boolean.mode_house_sleep
+ - input_boolean.mode_house_hibernate
- conditions:
- condition: template
diff --git a/custom/shell.yaml b/custom/shell.yaml
new file mode 100644
index 0000000..6c05d1b
--- /dev/null
+++ b/custom/shell.yaml
@@ -0,0 +1,2 @@
+sound_combined: 'ssh -i /config/keys/id_rsa csa@localhost pacmd set-default-sink combined'
+sound_living: 'ssh -i /config/keys/id_rsa csa@localhost pacmd set-default-sink 0'
diff --git a/scripts.yaml b/scripts.yaml
index 09cb932..bf0740b 100644
--- a/scripts.yaml
+++ b/scripts.yaml
@@ -102,7 +102,7 @@ turn_on_office_lights:
- service: light.turn_on
data:
brightness_pct: 100
- kelvin: 6000
+ kelvin: 4500
target:
entity_id: light.yeelight_color_0x7caaf86
- service: homeassistant.turn_off