Daily Morning Announcements With Home Assistant

Create morning announcements that play on your speakers to give you a heads-up on what's happening that day using Home Assistant!

Daily Morning Announcements With Home Assistant

Intro

Unless you're a morning person, mornings can be quite difficult, especially if you require a cup or two of some form of caffeine to function. So why not make your mornings that slightly bit easier instead of struggling through until the caffeine manages to work its magic?

You can create yourself a morning announcement that when you go downstairs (or anywhere of your choosing) first thing in the morning, it reads out things like what the weather forecast is, any upcoming events in your calendar or anything you'd like - it's a good way to give you heads up for what's happening that day, can be expanded to include things like important headlines, things you've to do in your calendar (cue that extra cup of coffee) or even just to play some music of your Spotify!

Scroll right the the bottom for the YAML code πŸ‘‡πŸΌ

How It's Done

Requirements

  • A speaker to play the announcement
  • A motion sensor
  • A weather integration (if you want to announce weather information!)

Creating an Input Helper

First we are going to create an input helper - this will allow us to store if the automation has been run that day or not.

In Home Assistant, go to Settings, then Devices & Services and click on Helpers in the top right of your screen.

Then head to "Create Helper" and scroll down to the Toggle option (so it can only be true or false) and name it. Ours is called Kitchen Morning Mode but whatever works for you to suit your needs.

The First Automation

Now we're going to go back to Settings then into Automations & Scenes, Create Automation and name it whatever you like.

Then click "State" from the Triggers drop-down menu and select Kitchen Motion Sensor (or whichever sensor you are using - we are using the Aqara FP1).

Then change the state to "on" so basically when there is motion, the automation will run.

Then we're going to go down to add a Condition and we're going to choose "state" as the type again and select the input helper were created in the first step and state should be "on".

This condition makes sure that the automation will only proceed if the input helper is set to on - we will deal with this setting later.

Then head to Actions and select "Call Service" from the Action Type drop-down menu.

For the service, we're going to select TTS (Text to Speech). Then click on three little dots at the top right and hit "edit in YAML" and paste in following template:

service: tts.google_translate_say
data:
  entity_id: media_player.your_speaker
  message: >-
    {% set state = states('weather.your_weather') %}
    {% set temperature = state_attr('weather.your_weather', 'temperature') %}
    {% set humidity = state_attr('weather.your_weather', 'humidity') %}
    {% set windspeed = state_attr('weather.your_weather', 'wind_speed') %}
    {% set rain = state_attr('weather.your_weather', 'forecast').0.precipitation_probability %}
    {% if state == 'partlycloudy' %}
      {% set state = 'Partly Cloudy' %}
    {% endif %}
    Good Morning! It looks like today the weather will be {{state}}, with a temperature of {{temperature}} degrees,
    humidity of {{humidity}}%, wind speed of {{windspeed}} meters per second and a {{rain}}% chance of rain.
    Enjoy your day!

Please note, this template above is entirely dependant on your weather integration - some integrations contain less information, some contain more. Unfortunately there is no way for me to tell you exactly what to use here as its going to be specific to you. But hopefully the template above gives you a rough idea of what you need to do.

You can verify which information you have by going to developer tools, states and finding your weather information, and then putting it into the above template:

If you want to learn more about how to do templates, check out this video.

Then add another Action to set the Toggle as off - this prevents the announcement from being run every time the motion sensor is triggered and doesn't run again after the first announcement, as so:

Now hit save and that's the first automation done - onto the second one!

Second Automation

This second automation is much simpler and is simply used to reset the state of the input helper every day, so its ready for the morning again.

Create an automation again and give it a name:e

For the trigger, we're going to set a time for the automation to run at and you can choose whatever time suits you best - typically this would be a time when you are in bed. I actually use my bed sensor to do this, but I realise not everyone has one of those so using a time works well too.

There's no condition in this one, so head straight to the actions and select Call Service from the drop-down menu, then for the Service select "input boolean on" then choose your input helper entity created earlier - this turns the toggle on to go again the next morning.

And that is all there is too it! Morning mode is now activated 😎

Next time you walk into your kitchen (or room you have selected) you will be welcomed with weather information for that day. It's worth mentioning you can expand this to anything you wanted, weather information, upcoming events, traffic on the way to work and so much more.

The Code

Finally, here is the code for the two automations for those who prefer YAML.

Morning mode announcement:

alias: 'Notify - Kitchen Morning Announcement '
description: ''
trigger:
  - platform: state
    entity_id:
      - binary_sensor.aqara_fp1_presence
    to: 'on'
condition:
  - condition: state
    entity_id: input_boolean.kitchen_morning_mode
    state: 'on'
action:
  - service: tts.google_translate_say
    data:
      entity_id: media_player.your_speaker
      message: >-
        {% set state = states('weather.your_weather') %} {% set temperature =
        state_attr('weather.your_weather', 'temperature') %} {% set humidity =
        state_attr('weather.your_weather', 'humidity') %} {% set windspeed =
        state_attr('weather.your_weather', 'wind_speed') %} {% set rain =
        state_attr('weather.your_weather',
        'forecast').0.precipitation_probability %} {% if state == 'partlycloudy'
        %}
          {% set state = 'Partly Cloudy' %}
        {% endif %} Good Morning! It looks like today the weather will be
        {{state}}, with a temperature of {{temperature}} degrees, humidity of
        {{humidity}}%, wind speed of {{windspeed}} meters per second and a
        {{rain}}% chance of rain. Enjoy your day!
  - service: input_boolean.turn_off
    data: {}
    target:
      entity_id: input_boolean.kitchen_morning_mode
mode: single

Reset automation:

alias: House - Reset Morning Mode
description: ''
trigger:
  - platform: time
    at: '04:00:00'
condition: []
action:
  - service: input_boolean.turn_on
    data: {}
    target:
      entity_id: input_boolean.kitchen_morning_mode
mode: single