Add Speech. Minor tweaks

This commit is contained in:
2020-03-04 23:09:52 +02:00
parent c9e0063eaf
commit f290470e9e
12 changed files with 379 additions and 45 deletions
+1
View File
@@ -1,2 +1,3 @@
bin/
custom_components/ custom_components/
secrets.yaml secrets.yaml
+72 -7
View File
@@ -4,6 +4,26 @@
# ─── PUBLIC ───────────────────────────────────────────────────────────────────── # ─── PUBLIC ─────────────────────────────────────────────────────────────────────
# #
- id: cube_knock
alias: Go to bed on Cube Knock
trigger:
platform: state
entity_id: sensor.cube_multistate_input
to: "knock"
action:
- service: input_boolean.turn_on
entity_id: input_boolean.sleep_mode
- id: cube_shake
alias: Wake up on Cube Shake
trigger:
platform: state
entity_id: sensor.cube_multistate_input
to: "shake"
action:
- service: input_boolean.turn_off
entity_id: input_boolean.sleep_mode
- id: leaving_home - id: leaving_home
alias: Leaving home alias: Leaving home
trigger: trigger:
@@ -18,6 +38,8 @@
entity_id: media_player.living_room_tv_2 entity_id: media_player.living_room_tv_2
- service: light.turn_off - service: light.turn_off
entity_id: light.living_room_all_lights entity_id: light.living_room_all_lights
- service: input_boolean.turn_off
entity_id: input_boolean.speech_notifications
- id: coming_home - id: coming_home
alias: Coming home alias: Coming home
@@ -29,6 +51,8 @@
- service: script.security_camera_off - service: script.security_camera_off
- service: light.turn_on - service: light.turn_on
entity_id: light.living_room_all_lights entity_id: light.living_room_all_lights
- service: input_boolean.turn_on
entity_id: input_boolean.speech_notifications
- alias: Play welcome music when I come back - alias: Play welcome music when I come back
trigger: trigger:
@@ -71,6 +95,8 @@
entity_id: automation.leaving_home entity_id: automation.leaving_home
- service: automation.turn_off - service: automation.turn_off
entity_id: automation.coming_home entity_id: automation.coming_home
- service: input_boolean.turn_off
entity_id: input_boolean.speech_notifications
- id: disable_guest_mode - id: disable_guest_mode
alias: Disable Guest Mode alias: Disable Guest Mode
@@ -84,6 +110,8 @@
entity_id: automation.leaving_home entity_id: automation.leaving_home
- service: automation.turn_on - service: automation.turn_on
entity_id: automation.coming_home entity_id: automation.coming_home
- service: input_boolean.turn_on
entity_id: input_boolean.speech_notifications
- id: enable_sleep_mode - id: enable_sleep_mode
alias: Enable Sleep Mode alias: Enable Sleep Mode
@@ -93,12 +121,49 @@
from: "off" from: "off"
to: "on" to: "on"
action: action:
- service: media_player.media_stop
entity_id: media_player.master_bedroom
- service: fan.turn_on
entity_id: fan.philips_airpurifier
- service: media_player.turn_off - service: media_player.turn_off
entity_id: media_player.living_room_tv entity_id: media_player.living_room_tv
- service: media_player.turn_off - service: media_player.turn_off
entity_id: media_player.living_room_tv_2 entity_id: media_player.living_room_tv_2
- service: light.turn_off - service: light.turn_off
entity_id: light.living_room_all_lights entity_id: light.living_room_all_lights
- delay: "00:00:02"
- service: media_player.volume_set
entity_id: media_player.master_bedroom
data:
volume_level: 0.1
- service: script.say_discretely
data:
message: "Entering sleep mode. Good night!"
- id: disable_sleep_mode
alias: Disable Sleep Mode
trigger:
platform: state
entity_id: input_boolean.sleep_mode
from: "on"
to: "off"
action:
- service: media_player.volume_set
entity_id: media_player.master_bedroom
data:
volume_level: 0.3
- service: script.sarah_briefing
- delay: "00:00:25"
- service: script.sarah_talk
data:
message: "Here's some music to start the day!"
- delay: "00:00:02"
- service: media_player.select_source
entity_id: media_player.master_bedroom
data:
source: "Evening Chill"
- service: fan.turn_off
entity_id: fan.philips_airpurifier
- alias: Trigger Domestina Start - alias: Trigger Domestina Start
trigger: trigger:
@@ -120,9 +185,10 @@
action: action:
- service: input_boolean.turn_on - service: input_boolean.turn_on
entity_id: input_boolean.guest_mode entity_id: input_boolean.guest_mode
- service: notify.mobile_app_carbon - service: automation.turn_off
data: entity_id: automation.cube_knock
message: "Enabling Domestina Mode" - service: automation.turn_off
entity_id: automation.cube_shake
- alias: Trigger Domestina End - alias: Trigger Domestina End
trigger: trigger:
@@ -145,7 +211,6 @@
- service: input_boolean.turn_off - service: input_boolean.turn_off
entity_id: input_boolean.guest_mode entity_id: input_boolean.guest_mode
- service: automation.turn_on - service: automation.turn_on
entity_id: automation.leaving_home entity_id: automation.cube_knock
- service: notify.mobile_app_carbon - service: automation.turn_on
data: entity_id: automation.cube_shake
message: "Disabling Domestina Mode"
+4
View File
@@ -7,3 +7,7 @@
device_class: safety device_class: safety
value_template: >- value_template: >-
{{ state_attr('camera.amcrest_camera', 'motion_recording') != 'on' }} {{ state_attr('camera.amcrest_camera', 'motion_recording') != 'on' }}
# https://www.home-assistant.io/integrations/iss/
- platform: iss
show_on_map: true
+6 -1
View File
@@ -138,7 +138,7 @@ tts:
aws_access_key_id: !secret aws_polly_client_id aws_access_key_id: !secret aws_polly_client_id
aws_secret_access_key: !secret aws_polly_client_secret aws_secret_access_key: !secret aws_polly_client_secret
region_name: eu-central-1 region_name: eu-central-1
voice: Emma voice: Amy
# https://www.home-assistant.io/integrations/tuya # https://www.home-assistant.io/integrations/tuya
tuya: tuya:
@@ -152,6 +152,11 @@ upnp:
# https://www.home-assistant.io/integrations/wake_on_lan # https://www.home-assistant.io/integrations/wake_on_lan
wake_on_lan: wake_on_lan:
# https://www.home-assistant.io/integrations/weather.darksky
weather:
- platform: darksky
api_key: !secret darksky_key
# https://www.home-assistant.io/integrations/webostv # https://www.home-assistant.io/integrations/webostv
webostv: webostv:
- host: !secret living_room_tv_ip - host: !secret living_room_tv_ip
+8
View File
@@ -0,0 +1,8 @@
sensor.cube_multistate_input:
friendly_name: "Cube Input"
sensor.cube_analog_input:
friendly_name: "Cube Rotation"
sensor.cube_power:
friendly_name: "Cube Battery"
+11
View File
@@ -0,0 +1,11 @@
sensor.bedroom_weather_power:
friendly_name: "Bedroom Weather Battery"
sensor.bedroom_weather_temperature:
friendly_name: "Bedroom Temperature"
sensor.bedroom_weather_pressure:
friendly_name: "Bedroom Pressure"
sensor.bedroom_weather_humidity:
friendly_name: "Bedroom Humidity"
+22
View File
@@ -0,0 +1,22 @@
binary_sensor.living_room_right_window_on_off:
friendly_name: "Living Room Window"
sensor.living_room_right_window_power:
friendly_name: "Living Room Window Battery"
binary_sensor.bedroom_right_window_on_off:
friendly_name: "Bedroom Window"
# TODO: icon_template doesn't work
icon_template: >
{% if is_state('binary_sensor.bedroom_right_window_on_off', 'on') %} mdi:television
{% else %} mdi:television-off
{% endif %}
sensor.bedroom_right_window_power:
friendly_name: "Bedroom Window Battery"
binary_sensor.front_door_on_off:
friendly_name: "Front Door"
sensor.front_door_power:
friendly_name: "Front Door Battery"
+5
View File
@@ -13,3 +13,8 @@ guest_mode:
domestina: domestina:
name: Domestina Time name: Domestina Time
icon: mdi:broom icon: mdi:broom
speech_notifications:
name: Speech Notifications
initial: on
icon: mdi:chat
+1
View File
@@ -1,4 +1,5 @@
# https://www.home-assistant.io/integrations/light # https://www.home-assistant.io/integrations/light
# https://www.home-assistant.io/integrations/light.group/
- platform: group - platform: group
name: Living Room Main Lights name: Living Room Main Lights
+83 -41
View File
@@ -6,8 +6,10 @@ sarah_restart:
service: homeassistant.restart service: homeassistant.restart
security_camera_on: security_camera_on:
alias: Turn Security Camera on alias: Turn security camera on
sequence: sequence:
- service: camera.turn_on
entity_id: camera.amcrest_camera
- service: amcrest.goto_preset - service: amcrest.goto_preset
entity_id: camera.amcrest_camera entity_id: camera.amcrest_camera
data: data:
@@ -20,7 +22,7 @@ security_camera_on:
entity_id: camera.amcrest_camera entity_id: camera.amcrest_camera
security_camera_off: security_camera_off:
alias: Turn Security Camera off alias: Turn security camera off
sequence: sequence:
- service: amcrest.goto_preset - service: amcrest.goto_preset
entity_id: camera.amcrest_camera entity_id: camera.amcrest_camera
@@ -32,54 +34,94 @@ security_camera_off:
entity_id: camera.amcrest_camera entity_id: camera.amcrest_camera
- service: amcrest.disable_audio - service: amcrest.disable_audio
entity_id: camera.amcrest_camera entity_id: camera.amcrest_camera
- service: camera.turn_off
entity_id: camera.amcrest_camera
tv_chill: # tv_chill:
alias: TV Chill # alias: TV Chill
sequence: # sequence:
- service: media_extractor.play_media # - service: media_extractor.play_media
data:
entity_id: media_player.living_room_tv_2
media_content_id: "https://www.youtube.com/watch?v=UgHKb_7884o"
media_content_type: video/youtube
latest_pds:
alias: Play the latest PDS
sequence:
- service: media_extractor.play_media
data_template:
entity_id: media_player.living_room_tv_2
media_content_id: "{{ state_attr('sensor.philip_defranco', 'url') }}"
media_content_type: video/youtube
say:
alias: Sonos TTS
sequence:
- service: sonos.snapshot
data_template:
entity_id: media_player.master_bedroom
- delay: "00:00:03"
# - service: media_player.play_media
# data: # data:
# entity_id: media_player.master_bedroom # entity_id: media_player.living_room_tv_2
# media_content_id: http://REDACTED33:8123/local/sounds/two-tone-chime.mp3 # media_content_id: "https://www.youtube.com/watch?v=UgHKb_7884o"
# media_content_type: music # media_content_type: video/youtube
# - delay: '00:00:02'
# latest_pds:
# alias: Play the latest PDS
# sequence:
# - service: media_extractor.play_media
# data_template:
# entity_id: media_player.living_room_tv_2
# media_content_id: "{{ state_attr('sensor.philip_defranco', 'url') }}"
# media_content_type: video/youtube
say_discretely:
alias: Say discretely
sequence:
- service_template: >
{% if is_state('media_player.master_bedroom', 'playing')
or is_state('input_boolean.guest_mode', 'on')
or is_state('input_boolean.speech_notifications', 'off') %}
script.telegram_say
{% else %}
script.sonos_blast
{% endif %}
data_template:
message: "{{ message }}"
sonos_blast:
alias: Sonos blast
sequence:
- service: tts.amazon_polly_say - service: tts.amazon_polly_say
data_template: data_template:
entity_id: media_player.master_bedroom entity_id: media_player.master_bedroom
message: "{{ what }}" message: "{{ message }}"
- delay: "00:00:03"
sonos_say:
alias: Sonos say
sequence:
- service: sonos.snapshot
data_template:
with_group: yes
entity_id: media_player.master_bedroom
- delay: "00:00:02"
- service: script.sonos_blast
data_template:
message: "{{ message }}"
- delay: "00:00:05"
- service: sonos.restore - service: sonos.restore
data_template: data_template:
with_group: yes
entity_id: media_player.master_bedroom entity_id: media_player.master_bedroom
telegram_say: telegram_say:
alias: Telegram Say alias: Telegram say
sequence: sequence:
- service: notify.telegram - service: notify.telegram
data: data_template:
message: "commands" message: "{{ message }}"
data:
keyboard: sarah_talk:
- "/ping, /alarm" alias: SARAH - Talk
- "/siren" sequence:
- condition: and
conditions:
- condition: state
entity_id: input_boolean.sleep_mode
state: "off"
- condition: time
after: "08:00:00"
before: "23:59:00"
- condition: state
entity_id: input_boolean.speech_notifications
state: "on"
- service: script.say_discretely
data_template:
message: "{{ message }}"
sarah_briefing:
alias: Briefing
sequence:
- service: script.sarah_talk
data_template:
message: !include ./templates/briefing.yaml
+45
View File
@@ -2,6 +2,51 @@
- platform: youtube - platform: youtube
channel_id: UClFSU9_bUb4Rc6OYfTt5SPw channel_id: UClFSU9_bUb4Rc6OYfTt5SPw
- platform: launch_library
- platform: moon
- platform: darksky
api_key: !secret darksky_key
scan_interval: "00:15:00"
forecast:
- 0
- 1
- 2
- 3
- 4
- 5
- 6
monitored_conditions:
- summary
- minutely_summary
- hourly_summary
- daily_summary
- precip_type
- precip_intensity
- precip_intensity_max
- precip_probability
- precip_accumulation
- temperature
- temperature_high
- temperature_low
- apparent_temperature
- apparent_temperature_high
- apparent_temperature_low
- wind_speed
- wind_gust
- wind_bearing
- cloud_cover
- dew_point
- visibility
- icon
- humidity
- pressure
- ozone
- uv_index
- nearest_storm_distance
- nearest_storm_bearing
- alerts
# Philips Purifier sensors # Philips Purifier sensors
- platform: template - platform: template
sensors: sensors:
+125
View File
@@ -0,0 +1,125 @@
>-
{%- macro light_check() -%}
{%- if is_state('light.living_room_all_lights', 'on') -%}
There are
{%- for state in states.light if state.state == 'on' -%}
{%if loop.last %} {{ loop.index }} {% endif %}
{%- endfor -%}
lights on right now.
{%- else -%}
There are no lights on right now.
{%- endif -%}
{%- endmacro -%}
{%- macro window_check() -%}
{%- if is_state('binary_sensor.living_room_right_window_on_off', 'on') -%}
The living room window is opened.
{%- endif -%}
{%- if is_state('binary_sensor.bedroom_right_window_on_off', 'on') -%}
The master bedroom window is opened.
{%- endif -%}
{%- endmacro -%}
{%- macro inside_weather() -%}
In the bedroom, it is {{ states('sensor.bedroom_weather_temperature') }} degrees with around {{ states('sensor.bedroom_weather_humidity') }} percent humidity.
{%- endmacro -%}
{%- macro outside_weather() -%}
Outside, in the next hour it's going to be {{ states('sensor.dark_sky_hourly_summary') }} {{ states('sensor.dark_sky_daily_summary') }}
{%- endmacro -%}
{%- macro iss() -%}
{% if is_state('binary_sensor.iss', 'on') -%}
Here is something interesting. The international space station is above us now. There are {{ states.binary_sensor.iss.attributes['number_of_people_in_space'] }} people in space right now.
{% endif -%}
{%- endmacro -%}
{%- macro moon() -%}
{%- if states.sensor.moon.state == 'Full moon' -%}
{{ [
"Check out the full moon tonight!",
"Hey look, There is the full moon.",
"The moon is huge! And full.",
"If you want to see the full moon, tonight is the night."
] | random }}
{%- endif -%}
{%- endmacro -%}
{%- macro inspirational_quote() -%}
{%- set inspirational_quote = [
"And one more thing, Life is about making an impact, make it a positive one.",
"And one more thing, Whatever the mind of man can conceive and believe, it can achieve.",
"And one more thing, Strive not to be a success, but rather to be of value.",
"And one more thing, I attribute my overall success to never giving or taking an excuse.",
"And one more thing, You miss one hundred percent of the shots you don’t take.",
"And one more thing, The most difficult thing is the decision to act, the rest is merely tenacity.",
"And one more thing, Every strike brings me closer to the next home run.",
"And one more thing, Defining thepurpose is the starting point of all achievement.",
"And one more thing, Life is not about getting and having, it's about giving and being.",
"And one more thing, We become what we think about.",
"And one more thing, Life is ten percent what happens to you and ninety percent of how you react to it.",
"And one more thing, The most common way people give up their power is by thinking they do not have any.",
"And one more thing, The mind is everything. What you think, you will become. ",
"And one more thing, The best time to plant a tree was twenty years ago. The second best time is now.",
"And one more thing, An unexamined life is not worth living.",
"And one more thing, Eighty percent of success is showing up.",
"And one more thing, Your time is limited, so do not waste it living someone elses life.",
"And one more thing, Winning is not everything, but wanting to win is.",
"And one more thing, I am not a product of my circumstances. I am a product of my decisions.",
"And one more thing, You can never cross the ocean until you have the courage to lose sight of the shore.",
"And one more thing, Either you run the day, or the day runs you.",
"And one more thing, Whether you think you can or you think you cannot, you will be right.",
"And one more thing, The two most important days in your life are the day you are born and the day you find out why.",
"And one more thing, Whatever you can do, or dream you can, begin it. Boldness has genius, power, and magic in it.",
"And one more thing, The best revenge is massive success.",
"And one more thing, The universe can’t put good into your hands unless you let go of the bad.",
"And one more thing, People often say that motivation does not last. Well, neither does bathing. That is why we recommend it daily.",
"And one more thing, Life shrinks or expands in proportion to ones courage.",
"And one more thing, If you hear a voice within you say you cannot paint, then by all means paint and that voice will be silenced.",
"And one more thing, There is only one way to avoid criticism: do nothing, say nothing, and be nothing.",
"And one more thing, Ask and it will be given to you; search, and you will find; knock and the door will be opened for you.",
"And one more thing, The only person you are destined to become is the person you decide to be.",
"And one more thing, Go confidently in the direction of your dreams. Live the life you have imagined.",
"And one more thing, Certain things catch your eye, but pursue only those that capture the heart.",
"And one more thing, Believe you can and you are halfway there.",
"And one more thing, Everything you have ever wanted is on the other side of fear.",
"And one more thing, Start where you are. Use what you have. Do what you can.",
"And one more thing, Fall seven times and stand up eight.",
"And one more thing, Everything has beauty, but not everyone can see.",
"And one more thing, Life is not measured by the number of breaths we take, but by the moments that take our breath away.",
"And one more thing, Happiness is not something readymade. It comes from your own actions.",
"And one more thing, If you are offered a seat on a rocket ship, do not ask what seat! Just get on.",
"And one more thing, If the wind will not serve, take to the oars.",
"And one more thing, You can not fall if you do not climb. But there’s no joy in living your whole life on the ground.",
"And one more thing, Too many of us are not living our dreams because we are living our fears.",
"And one more thing, Challenges are what make life interesting and overcoming them is what makes life meaningful.",
"And one more thing, If you want to lift yourself up, lift up someone else.",
"And one more thing, Be nice to others and nice things will happen to you.",
"And one more thing, It is nice to be important, but more important to be nice."
] -%}
{{inspirational_quote|random}}
{%- endmacro -%}
{% if now().strftime('%H')|int < 12 and now().strftime('%H')|int > 6 %}
Good morning.
{% elif now().strftime('%H')|int >= 12 and now().strftime('%H')|int < 17 %}
Good afternoon.
{% else %}
Good evening.
{% endif %}
{{ [
"Here's your briefing for today!",
"Here's what's up!",
"Here are the updates today!"
]|random }}
{{ inside_weather() }}
{{ outside_weather() }}
{{ light_check() }}
{{ window_check() }}
{{ iss() }}
{{ moon() }}
{{ inspirational_quote() }}