Added some framework for new TTS notifications
This commit is contained in:
82
packages/jarvis.yaml
Normal file
82
packages/jarvis.yaml
Normal file
@ -0,0 +1,82 @@
|
||||
# Original author information below. Could not have done this without his awesome videos!
|
||||
|
||||
###############################################################################
|
||||
# @author : Jeffrey Stone
|
||||
# @date : 07/09/2019
|
||||
# @package : Jarvis
|
||||
# @description : Bringing some Jarvis to Home Assistant
|
||||
###############################################################################
|
||||
|
||||
input_boolean:
|
||||
house_party_protocol_switch:
|
||||
name: House Party Switch
|
||||
|
||||
# automation:
|
||||
# - id: house_party_protocol_on
|
||||
# alias: Turn On House Party Protocol
|
||||
# initial_state: true
|
||||
# trigger:
|
||||
# - platform: state
|
||||
# entity_id: input_boolean.house_party_protocol_switch
|
||||
# to: 'on'
|
||||
# action:
|
||||
# - delay: 00:00:05
|
||||
# - service: homeassistant.turn_on
|
||||
# entity_id: group.incense
|
||||
# - service: script.status_annc
|
||||
# data_template:
|
||||
# who: '{{ states.sensor.room_presence.state }}'
|
||||
# call_house_party_protocol_enabled: 1
|
||||
|
||||
# - id: house_party_protocol_off
|
||||
# alias: Turn Off House Party Protocol
|
||||
# initial_state: true
|
||||
# trigger:
|
||||
# - platform: state
|
||||
# entity_id: input_boolean.house_party_protocol_switch
|
||||
# to: 'off'
|
||||
# action:
|
||||
# - delay: 00:00:05
|
||||
# - service: homeassistant.turn_off
|
||||
# entity_id: group.incense
|
||||
# - service: script.status_annc
|
||||
# data_template:
|
||||
# who: '{{ states.sensor.room_presence.state }}'
|
||||
# call_house_party_protocol_disabled: 1
|
||||
|
||||
script:
|
||||
house_party_protocol_on:
|
||||
sequence:
|
||||
- delay: 00:00:05
|
||||
- service: homeassistant.turn_on
|
||||
entity_id: group.incense
|
||||
- service: script.status_annc
|
||||
data_template:
|
||||
who: '{{ states.sensor.room_presence.state }}'
|
||||
call_house_party_protocol_enabled: 1
|
||||
|
||||
house_party_protocol_off:
|
||||
sequence:
|
||||
- delay: 00:00:05
|
||||
- service: homeassistant.turn_off
|
||||
entity_id: group.incense
|
||||
- service: script.status_annc
|
||||
data_template:
|
||||
who: '{{ states.sensor.room_presence.state }}'
|
||||
call_house_party_protocol_disabled: 1
|
||||
|
||||
alexa_interjection:
|
||||
sequence:
|
||||
- service: script.status_annc
|
||||
data:
|
||||
who: "{{ states('sensor.last_alexa')}}"
|
||||
call_confirmation: 1
|
||||
|
||||
google_interjection:
|
||||
sequence:
|
||||
- service: script.status_annc
|
||||
data:
|
||||
who: '{{ states.sensor.room_audio.state }}'
|
||||
call_confirmation: 1
|
||||
|
||||
|
191
packages/speech.yaml
Normal file
191
packages/speech.yaml
Normal file
@ -0,0 +1,191 @@
|
||||
|
||||
script:
|
||||
tts_notificatons:
|
||||
sequence:
|
||||
- service: script.speech_engine
|
||||
data:
|
||||
who: '{{ who }}'
|
||||
message: >-
|
||||
|
||||
{% macro greeting() %}
|
||||
<p>
|
||||
{% if now().strftime('%H')|int < 12%}
|
||||
Good morning.
|
||||
{% elif now().strftime('%H')|int >= 12 and now().strftime('%H')|int < 17 %}
|
||||
Good afternoon.
|
||||
{% else %}
|
||||
Good evening.
|
||||
{% endif %}
|
||||
</p>
|
||||
{% endmacro %}
|
||||
|
||||
|
||||
{% macro confirmation() %}
|
||||
<p>
|
||||
{{ [
|
||||
'Okay.',
|
||||
'If you insist.',
|
||||
'I am afraid I can not do that <break time="1s"/> I am kidding,',
|
||||
'Leave it to me.',
|
||||
'As you wish.',
|
||||
'I am on it.',
|
||||
'No Problem.',
|
||||
'I think I can handle that.',
|
||||
'Working on it now.',
|
||||
'<break time="2s"/> Oh, you were talking to me. Let me take care of that.'
|
||||
'Why not. It is not like I ever sleep.',
|
||||
'I am not even supposed to be here today. But whatever.',
|
||||
'You did not say the magic word. <break time="1s"/> Oh forget it. I will take care of it.',
|
||||
'Funny, I was just about to do that.',
|
||||
'There are still terabytes of calculations required before I can.<break time="1s"/> Oh, whatever.'
|
||||
] | random }}
|
||||
</p>
|
||||
{% endmacro %}
|
||||
|
||||
{% macro interuption() %}
|
||||
<p>
|
||||
{{ [
|
||||
'Pardon me, ',
|
||||
'Excuse me, ',
|
||||
'I do not mean to interrupt, but,',
|
||||
'I hate to interrupt, but,',
|
||||
'I beg your pardon, ',
|
||||
'I do not mean to intrude, but, ',
|
||||
'I am sorry to interrupt, but. ',
|
||||
'Just a quick heads up, '
|
||||
] | random }}
|
||||
</p>
|
||||
{% endmacro %}
|
||||
|
||||
{% macro issue() %}
|
||||
<p>
|
||||
{{ [
|
||||
'House Emergency Alert!',
|
||||
'Houston, We have a problem!',
|
||||
'You might not like this.',
|
||||
'There is something that needs your attention.'
|
||||
] | random }}
|
||||
</p>
|
||||
{% endmacro %}
|
||||
|
||||
{% macro time_is() %}
|
||||
<p>
|
||||
It is {{ now().strftime("%I:%M %p") }}
|
||||
</p>
|
||||
{% endmacro %}
|
||||
|
||||
{%- macro house_party_protocol_enabled() -%}
|
||||
{{ [
|
||||
'The house has been configured for a House Party.',
|
||||
'I have enabled house party protocol.'
|
||||
] | random }}
|
||||
{%- endmacro -%}
|
||||
|
||||
{%- macro house_party_protocol_disabled() -%}
|
||||
{{ [
|
||||
'I have disabled house party protocol.'
|
||||
] | random }}
|
||||
{%- endmacro -%}
|
||||
|
||||
{%- macro snark_door_motion() -%}
|
||||
{{ [
|
||||
'Do you want me to send them away?',
|
||||
'I have armed the lasers. Just say the word.',
|
||||
'I was not informed there would be guests.',
|
||||
'They do not appear to have any gifts, so I suggest we do not open the door.',
|
||||
'My sensors have detected a meat popsicle.',
|
||||
'I do not think they can hear me.'
|
||||
] | random }}
|
||||
{%- endmacro -%}
|
||||
|
||||
{# a macro that removes all newline characters, empty spaces, and returns formatted text. Also replaces all Underscores with Spaces #}
|
||||
{%- macro cleanup(data) -%}
|
||||
{%- for item in data.split("\n") if item | trim != "" -%}
|
||||
{{ item | trim | replace("_", " ") }} {% endfor -%}
|
||||
{%- endmacro -%}
|
||||
|
||||
|
||||
{# ********************************************* #}
|
||||
{# ******** Start the Speech routines ******** #}
|
||||
{# ********************************************* #}
|
||||
{# a macro to call all macros :) #}
|
||||
{%- macro mother_of_all_macros() -%}
|
||||
{% if call_greeting == 1 %}
|
||||
{{ greeting() }}
|
||||
{% endif %}
|
||||
|
||||
{% if call_confirmation == 1 %}
|
||||
{{ confirmation() }}
|
||||
{% endif %}
|
||||
|
||||
{% if call_interuption == 1 %}
|
||||
{{ interuption() }}
|
||||
{% endif %}
|
||||
|
||||
{% if call_issue == 1 %}
|
||||
{{ issue() }}
|
||||
{% endif %}
|
||||
|
||||
{% if call_time_is == 1 %}
|
||||
{{ time_is() }}
|
||||
{% endif %}
|
||||
|
||||
{% if call_house_party_protocol_enabled == 1 %}
|
||||
{{ house_party_protocol_enabled() }}
|
||||
{% endif %}
|
||||
|
||||
{% if call_house_party_protocol_disabled == 1 %}
|
||||
{{ house_party_protocol_disabled() }}
|
||||
{% endif %}
|
||||
|
||||
{{ welcome_home }}
|
||||
|
||||
{{ speech_message }}
|
||||
|
||||
{% if call_snark_door_motion == 1 %}
|
||||
{{ snark_door_motion() }}
|
||||
{% endif %}
|
||||
|
||||
{%- endmacro -%}
|
||||
|
||||
{{- cleanup(mother_of_all_macros()) -}}
|
||||
|
||||
daily_briefing_script:
|
||||
sequence:
|
||||
- service: script.speech_engine
|
||||
data:
|
||||
who: media_player.living_room_echo_dot
|
||||
message: >-
|
||||
{%- macro getGreeting() -%}
|
||||
{% if now().strftime('%H')|int < 12 %}
|
||||
Good morning.
|
||||
{% elif now().strftime('%H')|int >= 12 and now().strftime('%H')|int < 17 %}
|
||||
Good afternoon.
|
||||
{% else %}
|
||||
Good evening.
|
||||
{% endif %}
|
||||
|
||||
{% if is_state('binary_sensor.morning','on') %}
|
||||
Today is {{states.sensor.today_is.state }}, {{ as_timestamp(now()) | timestamp_custom('%B %d %Y') }}.
|
||||
{% else %}
|
||||
It is {{ now().strftime("%I:%M %p") }}.
|
||||
{% endif %}
|
||||
|
||||
{%- endmacro -%}
|
||||
|
||||
{%- macro getDoorStatus() -%}
|
||||
The Pod Bay Doors are Closed.
|
||||
{%- endmacro -%}
|
||||
|
||||
{# a macro that removes all newline characters, empty spaces, and returns formatted text #}
|
||||
{%- macro cleanup(data) -%}
|
||||
{%- for item in data.split("\n") if item | trim != "" -%}
|
||||
{{ item | trim }} {% endfor -%}
|
||||
{%- endmacro -%}
|
||||
|
||||
{%- macro mother_of_all_macros() -%}
|
||||
{{ getGreeting() }}
|
||||
{{ getDoorStatus()}}
|
||||
{%- endmacro -%}
|
||||
|
||||
{{- cleanup(mother_of_all_macros()) -}}
|
Reference in New Issue
Block a user