More consolidation for #56

This commit is contained in:
CCOSTAN
2017-04-13 16:03:32 +00:00
parent f0deff928a
commit 83115dde77
3 changed files with 20 additions and 11 deletions

View File

@@ -17,21 +17,25 @@
for: '00:02:00' for: '00:02:00'
action: action:
- service: input_boolean.turn_on
entity_id:
- input_boolean.responsibilities
- service: script.Voice_notify - service: script.Voice_notify
data_template: data_template:
value1: > personarriving: >
{% set person = trigger.entity_id.split('.')[1]|replace('_', ' ')%} {% set person = trigger.entity_id.split('.')[1]|replace('_', ' ')%}
{%- macro greeting_sentence(person) -%} {%- macro greeting_sentence(person) -%}
{{ [ {{ [
"Welcome back home " ~ person, "Welcome back home " ~ person,
"Guess who is home? " ~ person +" is!", "Guess who is home? " ~ person +" is!",
"Attention! " ~ person + " is now in the house.", person + " is now in the house.",
"Welcome Home " ~ person + ". We've missed you. Or at least Molly did.", "Welcome Home " ~ person + ". We have missed you. Or at least Molly did.",
"Our home is now complete, Rest your head and relax your feet! Welcome Back " ~ person, "Our home is now complete, Rest your head and relax your feet! Welcome Back " ~ person,
"Life is like a song, youre back where you belong. Welcome home " ~ person, "Life is like a song, youre back where you belong. Welcome home " ~ person,
"Hey there " ~ person + " Welcome Home!", "Hey there " ~ person + " Welcome Home!",
"Knock Knock. Who is There? " ~ person +" is!", "Knock Knock. Who is There? " ~ person +" is!",
person ~ "! You're home!" person ~ "! You are home!"
] | random }} ] | random }}
{%- endmacro -%} {%- endmacro -%}
"{{greeting_sentence(person)}}" "{{greeting_sentence(person)}}"

View File

@@ -15,7 +15,7 @@
- service: script.Voice_notify - service: script.Voice_notify
data_template: data_template:
value1: "The {{ trigger.entity_id.split('.')[1]|replace('_', ' ') }} has been {{ (trigger.to_state.state)|replace('_', ' ') }}." DoorOpened: "The {{ trigger.entity_id.split('.')[1]|replace('_', ' ') }} has been {{ (trigger.to_state.state)|replace('_', ' ') }}."
- service: script.ifttt_notify - service: script.ifttt_notify
data_template: data_template:

View File

@@ -64,11 +64,7 @@ voice_notify:
0.20 0.20
{% endif %} {% endif %}
- service: mqtt.publish
data_template:
payload: '{{ value1 }}'
topic: 'polly/lastmsg'
retain: true
- service: tts.amazon_polly_say - service: tts.amazon_polly_say
entity_id: media_player.livingroomCC entity_id: media_player.livingroomCC
@@ -82,6 +78,8 @@ voice_notify:
"Good evening. "Good evening.
{% endif %} {% endif %}
{{ personarriving }}
{%- macro responsibilities() -%} {%- macro responsibilities() -%}
{%if now().strftime("%a") == 'Wed' or now().strftime("%a") == 'Sun'%} {%if now().strftime("%a") == 'Wed' or now().strftime("%a") == 'Sun'%}
Today is {{now().strftime("%A")}} and {{now().strftime("%A")}} is garbage day. Today is {{now().strftime("%A")}} and {{now().strftime("%A")}} is garbage day.
@@ -99,10 +97,17 @@ voice_notify:
{% if is_state('input_boolean.responsibilities', 'on') %} {% if is_state('input_boolean.responsibilities', 'on') %}
{{responsibilities()}} {{responsibilities()}}
{%endif%} {%endif%}
{{ DoorOpened }}
{{ value1 }}" {{ value1 }}"
cache: true cache: true
- service: mqtt.publish
data_template:
payload: '{{ value1 }}'
topic: 'polly/lastmsg'
retain: true
- service: input_boolean.turn_off - service: input_boolean.turn_off
entity_id: entity_id:
- input_boolean.last_message - input_boolean.last_message