Morning Weather Notification | With daily high temperature šŸ„ŗ

We use the smart speaker as well, but we only have one in the living room, and she prefers to check the weather before getting dressed and going out of the bedroom. Not more than 20 steps to ask Alexa, but this is about small improvements. :slight_smile:

My whole home automation has been built on a series of small improvements over the past 25+ years of doing home automation (starting with X10). Some big ideas get implemented out of the gate, but mostly as a developer I just put in the basics and build upon it. My One Awake/All Awake system was bull on that, it just started as a way to control the thermostat but has evolved to an entire system.

The automatic morning announcement is a pretty beefy Jinja script with tons of conditions, like if itā€™s going to be over or under a certain temperature and reading the wind forecast to see when the best time to go for a run is to reading out the first scheduled task of the day - all this gets wrapped into what the house tells you about when you wake up.

This is why I love HomeAssistant, itā€™s so flexible to do these kinds of things. I even use different TTS voices for different things, all on the fly via scripting.

1 Like

I assume ā€œone awakeā€ when the (downstairs) hallway motion sensor detects movement for the 1st time after 6am. Anything before that and it assumes still ā€œasleepā€.

How does 'Napping" mode work? Does it lower volumes throughout the house and how do you trigger it?

One awake is when the bedroom motion sensor picks up motion and then the next room detects motion within 2 minutes, then one is awake. The next time the bedroom picks up motion, now itā€™s just fully awake, the rest of the drapes open, heat goes up, so and and so forth. Then, again, motion in the bedroom turns it off, opens the drapes and reverses the process.

Napping is easy, it turns off all the lights in the bedroom, closes the curtains, quits out of certain apps on my PC, turns off all non home automation sounds and done. All my home automation voice prompts bear the condition of ā€œif Sleep Mode == Awakeā€ so that itā€™s never talking when one or more people are sleeping or napping or whatever.

1 Like

I do something similar for nap mode. Nap mode is an input boolian that can be triggered via the UI, Alexa ā€œturn on nap modeā€ or by pressing the ā€˜nap mode onā€™ button in our nursery.
Nap mode puts all Alexas into Do-not-disturb mode, and turns on a night light in the nursery. Then the automation turns this off after an input-number amount of minutes.

Why did you used tomorrow.io weather service? Is it the best choice? I guess Accuweather is the most accurate or?

Tomorrow.io has the hourly forecast that I used to calculate the daily average temperature. I donā€™t think AccuWeather had that at the time.

Inspired by your work I was able to do it with OpenWeatherMap service. I just had to add two integrations, one for hourly and one for daily (to be able to add both, I changed last digit of Latitude when adding second one).

After having 2 OpenWeatherMap integrations in place, I created 3 sensors, one for next precipitation start, one for end of precipitation and generic summary.

    - name: 'OpenWeatherMap hourly Next Percipitation Start'
      unique_id: 'openweathermap_hourly_next_percipitation_start'
      device_class: timestamp
      state: >
        {{ (state_attr('weather.openweathermap_hourly', 'forecast')
          | selectattr('condition', '==', 'rainy')
          | list | first | default).datetime | default
        }}

    - name: 'OpenWeatherMap hourly Next Percipitation End'
      unique_id: 'openweathermap_hourly_next_percipitation_end'
      device_class: timestamp
      state: >
        {{ (state_attr('weather.openweathermap_hourly', 'forecast')
          | rejectattr('condition', '==', 'rainy')
          | selectattr('datetime', '>', states('sensor.openweathermap_hourly_next_percipitation_start'))
          | list | first | default).datetime | default
        }}

    - name: 'OpenWeatherMap Summary'
      unique_id: 'openweathermap_summary'
      state: ''
      attributes:
        content: >
          Currently {{ states('sensor.openweathermap_hourly_temperature') | round(1) }}{{ states.sensor.openweathermap_hourly_temperature.attributes.unit_of_measurement }}
          feels like {{ states('sensor.openweathermap_hourly_feels_like_temperature') | round(1) }}{{ states.sensor.openweathermap_hourly_feels_like_temperature.attributes.unit_of_measurement }}
          {{ states('weather.openweathermap_hourly') }}.
          Today
          {{ states('sensor.openweathermap_daily_forecast_temperature') | round(1) }}{{ states.sensor.openweathermap_daily_forecast_temperature.attributes.unit_of_measurement }}
          / {{ states('sensor.openweathermap_daily_forecast_temperature_low') | round(1) }}{{ states.sensor.openweathermap_daily_forecast_temperature_low.attributes.unit_of_measurement }}
          {{ states('sensor.openweathermap_daily_forecast_condition') }}, humidity {{ state_attr('weather.openweathermap_daily', 'humidity') }}%
          with
          {%- if states('sensor.openweathermap_daily_forecast_condition') == 'rainy' -%}
            {{ ' precipitation of ' ~ states('sensor.openweathermap_daily_forecast_precipitation_probability') }}{{ states.sensor.openweathermap_daily_forecast_precipitation_probability.attributes.unit_of_measurement -}}
            {{ ' starting at ' ~ states('sensor.openweathermap_hourly_next_percipitation_start') | as_timestamp(default) | timestamp_custom('%H:%M', default='') -}}
            {{ ' until ' ~ states('sensor.openweathermap_hourly_next_percipitation_end') | as_timestamp(default) | timestamp_custom('%H:%M', default='') }}.
          {%- else -%}
            {{ ' no precipitation.' }}
            {%- if states('sensor.openweathermap_hourly_next_percipitation_start') != 'unknown' -%}
              {{ ' Next precipitation forcast is on ' ~ states('sensor.openweathermap_hourly_next_percipitation_start') | as_timestamp(default) | timestamp_custom('%A %d. at %H:%M', default='') -}}
              {{ ' until ' ~ states('sensor.openweathermap_hourly_next_percipitation_end') | as_timestamp(default) | timestamp_custom('%H:%M', default='') }}.
            {%- endif %}
          {%- endif %}

And this is how my summary looks like together with weather-card, I can of course now send summary whenever to my mobile phone.

I must say, that I am very happy about OpenWeatherMap accuracy so far, it is really precise (at least in Germany). The configuration is very generic and can be easily used on any Latitude and Longitude. Previously I used DWD and it was not that accurate, also was not satisfied with Tomorrow service.

6 Likes

There was a recent post related to your work that I wanted to share hereā€¦ They use *drumroll ChatGPT! #AI #trendy yes, but still an amazing idea that Iā€™ll probably soon try once we move to a new house and I rebuild Home Assistant.

Just what I was looking for! Thanks! :slight_smile:

Maybe I will try to add a list of timings when it should rain. An example is, it could rainy at 12:00, then maybe jump to 15:00 and then to 20:00. Also using the precipitation_probability attribute.

So that when I send this message in the morning, I know the hours it could rain.

2 Likes

Thanks for this! I was struggling with how to pull out the ā€˜sub attributesā€™ too, so this was really helpful :slight_smile:

I set it up with Discord instead as I have all my notifications sent there.

Untitled

2 Likes

Very nice message format, would you mind sharing your code?

Thank you!
Norm

Will you share the yaml code for this view?

Sure, here you go.

type: vertical-stack
cards:
  - type: custom:vertical-stack-in-card
    title: ''
    cards:
      - type: custom:weather-card
        entity: weather.openweathermap_city_hourly
        name: City Name
        forecast: false
        number_of_forecasts: '5'
        card_mod:
          style: |
            ha-card .temp {
              font-size: 2.9em;
              right: 1.25em;
              top:0.8em;
            }
            ha-card .title {
              font-size: 2.1em;
              left: 3.9em;
              top: 1.2em;
            }
      - type: markdown
        title: ''
        content: >-
          <center>{{ state_attr('sensor.openweathermap_city_summary',
          'content') or '' }}</center>
      - type: custom:weather-card
        entity: weather.openweathermap_city_hourly
        number_of_forecasts: '6'
        details: false
        current: false
        hourly_forecast: true
      - type: custom:weather-card
        entity: weather.openweathermap_city_daily
        number_of_forecasts: '6'
        details: false
        current: false
        hourly_forecast: false
1 Like

Hi Norm, if you meant my notification then sure! Here you go:

service: notify.mpha
data:
  message: ""
  data:
    embed:
      title: Weather forecast
      description: >-
        šŸŒž Weather forecast

        Today: {{ state_attr('weather.home', 'forecast')[0].condition }}

        Temp: {{ state_attr('weather.home', 'forecast')[0].temperature }} Ā°C //
        {{ state_attr('weather.home', 'forecast')[0].templow }} Ā°C


        Next 5 days: {{ state_attr('weather.home', 'forecast')[1].condition }} |
        {{ state_attr('weather.home', 'forecast')[2].condition }} | {{
        state_attr('weather.home', 'forecast')[3].condition }} | {{
        state_attr('weather.home', 'forecast')[4].condition }} | {{
        state_attr('weather.home', 'forecast')[5].condition }}
      url: http://homeassistant.local:8123/home-dashboard/
      color: 9591962
  target: "1222667194001920020"
enabled: true

Iā€™m using the OpenMeteo integration here, Iā€™ve just moved over to the accuweather one though as there is more information available.

(MPHA is the name of my discord bot)

1 Like

I am using too accuweather and tried to use your notification, but donā€™t understand some thingsā€¦

  1. is this notification for IOS or Android? I am asking this as having Android smartphone i cannot reproduce your notification on my system
  2. i get an error about condition 5 as it says there is no 5 forecast condition
  3. What you mean with ā€˜targetā€™

This is using OpenMeteo which gives you today plus five days of forecast. Iā€™ve changed to using Accuweather now and updated it with some additional attributes (see below).

This is using the discord integration. You need to create a discord server and a bot to use it, the target is the channel ID :slightly_smiling_face:

Improved discord notification with Accuweather:
image

embed:
  title: Weather forecast
  description: >-
    šŸŒž Weather forecast today: {{ states.sensor.home_condition_today.state }}.

    Temp: {{ state_attr('weather.home_2', 'forecast')[0].temperature }} Ā°C // {{
    state_attr('weather.home_2', 'forecast')[0].templow }} Ā°C
     UV Index: {{ state_attr('sensor.home_uv_index','level') }}
     Pollen: {{ state_attr('sensor.home_grass_pollen_today','level') }}
     Mould: {{ state_attr('sensor.home_mould_pollen_today','level') }}
     Tree Pollen: {{ state_attr('sensor.home_tree_pollen_today','level') }}
     Ragweed Pollen: {{ state_attr('sensor.home_ragweed_pollen_today','level') }}
     
    Next 4 days: {{ state_attr('weather.home_2', 'forecast')[1].condition }} |
    {{ state_attr('weather.home_2', 'forecast')[2].condition }} | {{
    state_attr('weather.home_2', 'forecast')[3].condition }} | {{
    state_attr('weather.home_2', 'forecast')[4].condition }}

    Temperature: {{ state_attr('weather.home_2', 'forecast')[1].temperature }}
    Ā°C | {{ state_attr('weather.home_2', 'forecast')[2].temperature }} Ā°C | {{
    state_attr('weather.home_2', 'forecast')[3].temperature }} Ā°C | {{
    state_attr('weather.home_2', 'forecast')[4].temperature }} Ā°C

    Precipitation: {{ state_attr('weather.home_2', 'forecast')[1].precipitation
    }} mm | {{ state_attr('weather.home_2', 'forecast')[2].precipitation }} mm |
    {{ state_attr('weather.home_2', 'forecast')[3].precipitation }} mm | {{
    state_attr('weather.home_2', 'forecast')[4].precipitation }} mm
  url: http://homeassistant.local:8123/home-dashboard/
  color: 14366669

Discord allows you to use some formatting which is why I prefer it for notifications.

That is great, I appreciate the notification code!
Thank you!

1 Like

It looks like there is some interest in your Discord chat notification. Maybe you could turn it into a blueprint? :wink:

2 Likes

Thanks, I thought Iā€™d give it a try so I turned it into a blueprint. It uses the mobile app (as very few people use discord) and itā€™s limited to the common attributes that get_forecasts provides though.

1 Like