Notify me when someone else enters or leaves the house
This commit is contained in:
parent
1ca5c8d232
commit
0a4b965613
|
@ -0,0 +1,4 @@
|
||||||
|
notify:
|
||||||
|
- name: correl
|
||||||
|
platform: pushbullet
|
||||||
|
api_key: !secret pushbullet_api_key
|
|
@ -50,17 +50,46 @@ automation:
|
||||||
- service: script.sonos_tts
|
- service: script.sonos_tts
|
||||||
data_template:
|
data_template:
|
||||||
message: >-
|
message: >-
|
||||||
Welcome home,
|
{% set occupants
|
||||||
{{ states
|
= states.sensor.occupants.state.split(', ')
|
||||||
| selectattr("entity_id", "in",
|
| select
|
||||||
states.group.phones.attributes.entity_id)
|
| reject('equalto', 'Somebody')
|
||||||
| selectattr('state', 'eq', 'home')
|
| join(', ')
|
||||||
| map(attribute='attributes.friendly_name')
|
%}
|
||||||
| join(' and ')}}!
|
Welcome home
|
||||||
|
{{ occupants }}!
|
||||||
trigger:
|
trigger:
|
||||||
- entity_id: binary_sensor.occupied
|
- entity_id: binary_sensor.occupied
|
||||||
platform: state
|
platform: state
|
||||||
to: 'on'
|
to: 'on'
|
||||||
|
- alias: Notify me when someone arrives at home
|
||||||
|
action:
|
||||||
|
- service: notify.correl
|
||||||
|
data_template:
|
||||||
|
title: Occupancy
|
||||||
|
message: >-
|
||||||
|
{% set occupants = states.sensor.occupants.state.split(', ')
|
||||||
|
%}
|
||||||
|
{% if occupants | length == 0 %}
|
||||||
|
Nobody is home
|
||||||
|
{% elif occupants | length == 1 %}
|
||||||
|
{{ occupants[0] }} is home
|
||||||
|
{% else %}
|
||||||
|
{{ occupants[:-2].join(', ') }}
|
||||||
|
{{ occupants[-2].join(' and ') }}
|
||||||
|
are home
|
||||||
|
{% endif %}
|
||||||
|
trigger:
|
||||||
|
- platform: state
|
||||||
|
entity_id: sensor.occupants
|
||||||
|
condition:
|
||||||
|
- condition: template
|
||||||
|
value_template: >-
|
||||||
|
{% set from = trigger.from_state.state.split(', ') | select %}
|
||||||
|
{% set to = trigger.to_state.state.split(', ') | select %}
|
||||||
|
{{ from|reject('equalto', 'Correl') | sort
|
||||||
|
!= to|reject('equalto', 'Correl') | sort
|
||||||
|
}}
|
||||||
|
|
||||||
input_boolean:
|
input_boolean:
|
||||||
occupied:
|
occupied:
|
||||||
|
@ -84,7 +113,22 @@ binary_sensor:
|
||||||
{{ is_state('group.all_lights', 'on')
|
{{ is_state('group.all_lights', 'on')
|
||||||
or is_state('media_player.den', 'playing')
|
or is_state('media_player.den', 'playing')
|
||||||
}}
|
}}
|
||||||
|
sensor:
|
||||||
|
- platform: template
|
||||||
|
sensors:
|
||||||
|
occupants:
|
||||||
|
friendly_name: List of occupants
|
||||||
|
value_template: >-
|
||||||
|
{% if is_state('binary_sensor.occupied', 'on') %}
|
||||||
|
{{ states
|
||||||
|
| selectattr("entity_id", "in",
|
||||||
|
states.group.phones.attributes.entity_id)
|
||||||
|
| selectattr('state', 'eq', 'home')
|
||||||
|
| map(attribute='attributes.friendly_name')
|
||||||
|
| join(', ')
|
||||||
|
| default('Somebody', true)
|
||||||
|
}}
|
||||||
|
{% endif %}
|
||||||
group:
|
group:
|
||||||
Occupancy:
|
Occupancy:
|
||||||
view: yes
|
view: yes
|
||||||
|
|
|
@ -9,3 +9,4 @@ http_password: secret
|
||||||
aws_access_key_id: secret
|
aws_access_key_id: secret
|
||||||
aws_secret_access_key: secret
|
aws_secret_access_key: secret
|
||||||
darksky_api_key: secret
|
darksky_api_key: secret
|
||||||
|
pushbullet_api_key: secret
|
||||||
|
|
Loading…
Reference in New Issue