68 lines
2.1 KiB
YAML
Executable File
68 lines
2.1 KiB
YAML
Executable File
########## ############################################################
|
|
# @CCOSTAN
|
|
# Original Repo : https://github.com/CCOSTAN/Home-AssistantConfig
|
|
## Announce when people come or go.
|
|
## Announce over all Chromecast Audios
|
|
# Read more at https://vCloudInfo.com
|
|
######################################################################
|
|
- alias: 'People Greeting'
|
|
id: 29c5c9dd-550a-4761-a224-78cdc3dd9f43
|
|
mode: restart
|
|
trigger:
|
|
- platform: state
|
|
entity_id:
|
|
- person.carlo
|
|
- person.stacey
|
|
- person.paige
|
|
- person.justin
|
|
from: 'not_home'
|
|
to: 'home'
|
|
|
|
action:
|
|
# This Group is defined in the groups directory.
|
|
|
|
- service: group.set
|
|
data:
|
|
object_id: "arriving"
|
|
add_entities: >-
|
|
{{ trigger.to_state.entity_id }}
|
|
|
|
- wait_template: "{{ states.binary_sensor.mcu1_gpio12.state == 'on' }}"
|
|
timeout: '00:05:00'
|
|
|
|
- wait_template: "{{ states.binary_sensor.kitchen_door.state == 'on' }}"
|
|
timeout: '00:1:00'
|
|
|
|
- delay: '00:01:00'
|
|
- service: script.speech_engine
|
|
data:
|
|
# {% set person = state_attr(trigger.entity_id, "friendly_name")%} This is another way to do it.
|
|
# {% set person = trigger.entity_id.split('.')[1]|replace('_', ' ')%}
|
|
personarriving: >
|
|
{% set person = expand('group.arriving')|map(attribute='name')|join(' and ') %}
|
|
{% set peoplecount = expand('group.arriving') | count %}
|
|
{% if peoplecount == 1 %}
|
|
{% set is_are = ' is ' %}
|
|
{% else %}
|
|
{% set is_are = ' are ' %}
|
|
{% endif %}
|
|
{%- macro greeting_sentence(person, is_are) -%}
|
|
{{ [
|
|
"Welcome back home " ~ person,
|
|
person ~ is_are + " home now."
|
|
] | random }}
|
|
[Welcome them home in a random style]
|
|
{%- endmacro -%}
|
|
|
|
{{greeting_sentence(person, is_are)}}
|
|
call_responsibilities: 1
|
|
call_no_announcement: 1
|
|
call_garage_check: 1
|
|
call_window_check: 1
|
|
|
|
- service: group.set
|
|
data:
|
|
object_id: "arriving"
|
|
entities: []
|
|
|