From 89c3a72b37082dd985caa5e43b7454f4b0aaf289 Mon Sep 17 00:00:00 2001 From: Georgi Gardev Date: Sat, 9 Oct 2021 12:17:09 +0300 Subject: [PATCH] Player 2 presence --- .../automation/arrival_detection.yaml | 34 ++++++++ config/packages/modules/presence.yaml | 87 +++++++++---------- config/packages/routines/leaving_home.yaml | 2 - 3 files changed, 73 insertions(+), 50 deletions(-) create mode 100644 config/blueprints/automation/arrival_detection.yaml diff --git a/config/blueprints/automation/arrival_detection.yaml b/config/blueprints/automation/arrival_detection.yaml new file mode 100644 index 0000000..16722c3 --- /dev/null +++ b/config/blueprints/automation/arrival_detection.yaml @@ -0,0 +1,34 @@ +# When someone's state changesd to "home", wait for 15 minutes for the door to be opened, +# and then mark me as home + +blueprint: + name: Person arrival detection + domain: automation + input: + person: + input_boolean: + +trigger: + - platform: state + entity_id: !input person + to: "home" + +condition: + condition: state + entity_id: !input input_boolean + state: "off" + +action: + - service: notify.telegram + data: + title: "๐Ÿ  *Presence Module ยท Arrival Detection*" + message: "Device marked as home. Waiting for door to open!" + - wait_template: "{{ is_state('binary_sensor.front_door', 'on') }}" + continue_on_timeout: false + timeout: 00:15:00 + - service: input_boolean.turn_on + entity_id: !input input_boolean + - service: notify.telegram + data: + title: "๐Ÿ  *Presence Module ยท Arrival Detection*" + message: "โœ… Hey, I've marked you as home now!" diff --git a/config/packages/modules/presence.yaml b/config/packages/modules/presence.yaml index 1009618..8725832 100644 --- a/config/packages/modules/presence.yaml +++ b/config/packages/modules/presence.yaml @@ -9,6 +9,8 @@ person: user_id: !secret georgi_user_id device_trackers: - device_tracker.carbon + - name: Player 2 + id: !secret player_2_user_id # https://www.home-assistant.io/integrations/device_tracker device_tracker: @@ -37,6 +39,9 @@ input_boolean: georgi_home: name: Georgi home icon: mdi:account + player_2_home: + name: Player 2 home + icon: mdi:account binary_sensor: - platform: template @@ -50,6 +55,25 @@ binary_sensor: {% else %} mdi:account-off-outline {% endif %} + player_2_home: + friendly_name: Player 2 + device_class: presence + value_template: "{{ is_state('input_boolean.player_2_home', 'on') }}" + icon_template: > + {% if is_state('input_boolean.georgi_home', 'on') %} mdi:account + {% else %} mdi:account-off-outline + {% endif %} + + someone_home: + friendly_name: Someone home + device_class: presence + value_template: > + {{ is_state('input_boolean.georgi_home', 'on') or is_state('input_boolean.player_2_home', 'on') }} + icon_template: > + {% if is_state('input_boolean.georgi_home', 'on') or is_state('input_boolean.player_2_home', 'on') %} mdi:account + {% else %} mdi:account-off-outline + {% endif %} + trisensor_motion: friendly_name: TriSensor motion device_class: motion @@ -60,7 +84,6 @@ binary_sensor: device_class: motion value_template: "{{ is_state('sensor.multisensor_6_burglar', '8') }}" - group: hallway_motion: name: Hallway Motion @@ -89,39 +112,24 @@ sensor: automation: - # When my state changes to "home", wait for 15 minutes for the door to be opened, and then mark me as home - - alias: Presence ยท Arrival detection - trigger: - - platform: state - entity_id: person.georgi - to: "home" - condition: - condition: state - entity_id: input_boolean.georgi_home - state: "off" - action: - - service: notify.telegram - data: - title: "๐Ÿ  *Presence Module ยท Arrival Detection*" - message: "Device marked as home. Waiting for door to open!" - - wait_template: "{{ is_state('binary_sensor.front_door', 'on') }}" - continue_on_timeout: false - timeout: 00:15:00 - - service: input_boolean.turn_on - entity_id: input_boolean.georgi_home - - service: notify.telegram - data: - title: "๐Ÿ  *Presence Module ยท Arrival Detection*" - message: "โœ… Hey, I've marked you as home now!" + - alias: Presence ยท Georgi Arrival detection + use_blueprint: + path: arrival_detection.yaml + input: + person: person.georgi + input_boolean: input_boolean.georgi_home + + - alias: Presence ยท Player 2 Arrival detection + use_blueprint: + path: arrival_detection.yaml + input: + person: person.player_2 + input_boolean: input_boolean.player_2 - alias: Presence ยท Leaving home trigger: - platform: state - entity_id: person.georgi - from: "home" - to: "not_home" - - platform: state - entity_id: input_boolean.georgi_home + entity_id: binary_sensor.someone_home to: "off" action: - service: script.routine_leaving_home @@ -129,7 +137,7 @@ automation: - alias: Presence ยท Coming home trigger: platform: state - entity_id: binary_sensor.georgi_home + entity_id: binary_sensor.someone_home to: "on" action: - service: script.routine_coming_home @@ -158,22 +166,5 @@ homeassistant: device_tracker.carbon: icon: mdi:cellphone-iphone - device_tracker.tile_p_6e3c33752f24f417254c039040a984bd: - friendly_name: Georgi's iPhone Tile - icon: mdi:cellphone-iphone - - device_tracker.tile_1bcb2b3021b9f96b: - friendly_name: Keys Tile - icon: mdi:key-variant - - automation.presence_coming_home: - icon: mdi:home-account - - automation.presence_leaving_home: - icon: mdi:home - - automation.presence_arrival_detecion: - icon: mdi:account-plus-outline - group.hallway_motion: icon: mdi:motion-sensor diff --git a/config/packages/routines/leaving_home.yaml b/config/packages/routines/leaving_home.yaml index d4ada99..024311b 100644 --- a/config/packages/routines/leaving_home.yaml +++ b/config/packages/routines/leaving_home.yaml @@ -9,7 +9,6 @@ script: - service: homeassistant.turn_off entity_id: - - input_boolean.georgi_home - media_player.nvidia_shield - media_player.living_room_tv - light.all @@ -19,7 +18,6 @@ script: - service: media_player.media_stop entity_id: group.all_sonos - - service: script.dashboards_light_down - service: input_select.select_option entity_id: input_select.hallway_dashboard_mode data: