diff --git a/.gitignore b/.gitignore index 1d978a5..f29c051 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ +bin/ custom_components/ secrets.yaml diff --git a/automations.yaml b/automations.yaml index 198ec6d..a848ffe 100644 --- a/automations.yaml +++ b/automations.yaml @@ -4,6 +4,26 @@ # ─── 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 alias: Leaving home trigger: @@ -18,6 +38,8 @@ entity_id: media_player.living_room_tv_2 - service: light.turn_off entity_id: light.living_room_all_lights + - service: input_boolean.turn_off + entity_id: input_boolean.speech_notifications - id: coming_home alias: Coming home @@ -29,6 +51,8 @@ - service: script.security_camera_off - service: light.turn_on 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 trigger: @@ -71,6 +95,8 @@ entity_id: automation.leaving_home - service: automation.turn_off entity_id: automation.coming_home + - service: input_boolean.turn_off + entity_id: input_boolean.speech_notifications - id: disable_guest_mode alias: Disable Guest Mode @@ -84,6 +110,8 @@ entity_id: automation.leaving_home - service: automation.turn_on entity_id: automation.coming_home + - service: input_boolean.turn_on + entity_id: input_boolean.speech_notifications - id: enable_sleep_mode alias: Enable Sleep Mode @@ -93,12 +121,49 @@ from: "off" to: "on" 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 entity_id: media_player.living_room_tv - service: media_player.turn_off entity_id: media_player.living_room_tv_2 - service: light.turn_off 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 trigger: @@ -120,9 +185,10 @@ action: - service: input_boolean.turn_on entity_id: input_boolean.guest_mode - - service: notify.mobile_app_carbon - data: - message: "Enabling Domestina Mode" + - service: automation.turn_off + entity_id: automation.cube_knock + - service: automation.turn_off + entity_id: automation.cube_shake - alias: Trigger Domestina End trigger: @@ -145,7 +211,6 @@ - service: input_boolean.turn_off entity_id: input_boolean.guest_mode - service: automation.turn_on - entity_id: automation.leaving_home - - service: notify.mobile_app_carbon - data: - message: "Disabling Domestina Mode" + entity_id: automation.cube_knock + - service: automation.turn_on + entity_id: automation.cube_shake diff --git a/binary_sensor.yaml b/binary_sensor.yaml index 6ca4a03..53c48fe 100644 --- a/binary_sensor.yaml +++ b/binary_sensor.yaml @@ -7,3 +7,7 @@ device_class: safety value_template: >- {{ state_attr('camera.amcrest_camera', 'motion_recording') != 'on' }} + +# https://www.home-assistant.io/integrations/iss/ +- platform: iss + show_on_map: true diff --git a/configuration.yaml b/configuration.yaml index 86705e2..07c3e71 100644 --- a/configuration.yaml +++ b/configuration.yaml @@ -138,7 +138,7 @@ tts: aws_access_key_id: !secret aws_polly_client_id aws_secret_access_key: !secret aws_polly_client_secret region_name: eu-central-1 - voice: Emma + voice: Amy # https://www.home-assistant.io/integrations/tuya tuya: @@ -152,6 +152,11 @@ upnp: # https://www.home-assistant.io/integrations/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 webostv: - host: !secret living_room_tv_ip diff --git a/customize/magic_cube.yaml b/customize/magic_cube.yaml new file mode 100644 index 0000000..0791198 --- /dev/null +++ b/customize/magic_cube.yaml @@ -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" diff --git a/customize/weather_sensors.yaml b/customize/weather_sensors.yaml new file mode 100644 index 0000000..9930537 --- /dev/null +++ b/customize/weather_sensors.yaml @@ -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" diff --git a/customize/window_sensors.yaml b/customize/window_sensors.yaml new file mode 100644 index 0000000..820882e --- /dev/null +++ b/customize/window_sensors.yaml @@ -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" diff --git a/input_boolean.yaml b/input_boolean.yaml index 563baa7..7ddd0cf 100644 --- a/input_boolean.yaml +++ b/input_boolean.yaml @@ -13,3 +13,8 @@ guest_mode: domestina: name: Domestina Time icon: mdi:broom + +speech_notifications: + name: Speech Notifications + initial: on + icon: mdi:chat diff --git a/light.yaml b/light.yaml index 29d4873..46c387c 100644 --- a/light.yaml +++ b/light.yaml @@ -1,4 +1,5 @@ # https://www.home-assistant.io/integrations/light +# https://www.home-assistant.io/integrations/light.group/ - platform: group name: Living Room Main Lights diff --git a/scripts.yaml b/scripts.yaml index a1d4943..9b1d5b5 100644 --- a/scripts.yaml +++ b/scripts.yaml @@ -6,8 +6,10 @@ sarah_restart: service: homeassistant.restart security_camera_on: - alias: Turn Security Camera on + alias: Turn security camera on sequence: + - service: camera.turn_on + entity_id: camera.amcrest_camera - service: amcrest.goto_preset entity_id: camera.amcrest_camera data: @@ -20,7 +22,7 @@ security_camera_on: entity_id: camera.amcrest_camera security_camera_off: - alias: Turn Security Camera off + alias: Turn security camera off sequence: - service: amcrest.goto_preset entity_id: camera.amcrest_camera @@ -32,54 +34,94 @@ security_camera_off: entity_id: camera.amcrest_camera - service: amcrest.disable_audio entity_id: camera.amcrest_camera + - service: camera.turn_off + entity_id: camera.amcrest_camera -tv_chill: - alias: TV Chill - sequence: - - 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 +# tv_chill: +# alias: TV Chill +# sequence: +# - 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 +# 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: media_extractor.play_media + - 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: - entity_id: media_player.living_room_tv_2 - media_content_id: "{{ state_attr('sensor.philip_defranco', 'url') }}" - media_content_type: video/youtube + message: "{{ message }}" -say: - alias: Sonos TTS +sonos_blast: + alias: Sonos blast sequence: - - service: sonos.snapshot - data_template: - entity_id: media_player.master_bedroom - - delay: "00:00:03" - # - service: media_player.play_media - # data: - # entity_id: media_player.master_bedroom - # media_content_id: http://REDACTED33:8123/local/sounds/two-tone-chime.mp3 - # media_content_type: music - # - delay: '00:00:02' - service: tts.amazon_polly_say data_template: entity_id: media_player.master_bedroom - message: "{{ what }}" - - delay: "00:00:03" + message: "{{ message }}" + +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 data_template: + with_group: yes entity_id: media_player.master_bedroom telegram_say: - alias: Telegram Say + alias: Telegram say sequence: - service: notify.telegram - data: - message: "commands" - data: - keyboard: - - "/ping, /alarm" - - "/siren" + data_template: + message: "{{ message }}" + +sarah_talk: + alias: SARAH - Talk + 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 diff --git a/sensor.yaml b/sensor.yaml index 94c53d9..029b6ae 100644 --- a/sensor.yaml +++ b/sensor.yaml @@ -2,6 +2,51 @@ - platform: youtube 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 - platform: template sensors: diff --git a/templates/briefing.yaml b/templates/briefing.yaml new file mode 100644 index 0000000..0f67992 --- /dev/null +++ b/templates/briefing.yaml @@ -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() }}