Isn’t it nice to be able to get information about what the weather is like right now when you get up? How hot/cold is it, and what will be the temperature during the day?
We solve this reasonably easily with simple automation in Home Assistant.
There is only one condition that must be in place before this can be solved, and that is to enable an entity in the Weather integration that is included. By default, the hourly weather forecast is disabled – we have to turn it on first.
To do this, go to configuration-> integrations. Then click on “2 entities” under “Home” (from Meterologisk Institutt).
Here you tick the box to “weather.home_hourly” and click on Enable selected at the top right.
When that is done, we have to make the automation itself.
In the example that has been created, we have a trigger on time. This puts you into when you want to get a push notification
Note – in the example of automation, we use the temperature from Netatmo’s weather station here, but this can be replaced with any temperature gauge you have.
The action will then be sending a push notification to your phone that contains the temperature right now, as well as the maximum temperature during the day.
To find out what is the current maximum temperature, then we have to add a little “code” in the message that extracts the maximum temperature from “weather.home_hourly” that you enabled at the start.
The message that you send will look like this:
{% set tomorrow = (as_timestamp(now().date() + timedelta(days=1)) | timestamp_utc)
.replace(' ', 'T') ~ '+00:00' %}
{% set today = state_attr('weather.home_hourly', 'forecast')
| selectattr('datetime', 'lt', tomorrow) | map(attribute='temperature') | list %}
It is now {{states.sensor.netatmo_hjemme_hjemme_ute_temperature.state}} °C
outside. The forecast for today says it will be max {{ today | max }} °C
The entire automation as described will look like
alias: Good morning
description: ''
trigger:
- platform: time
at: '05:35'
condition: []
action:
- service: notify.mobile_app_lars_sin_iphone_11
data:
title: Good morning 😎
message: >-
{% set tomorrow = (as_timestamp(now().date() + timedelta(days=1)) |
timestamp_utc) .replace(' ', 'T') ~ '+00:00' %} {% set today =
state_attr('weather.home_hourly', 'forecast') | selectattr('datetime',
'lt', tomorrow) | map(attribute='temperature') | list %} It is now
{{states.sensor.netatmo_hjemme_hjemme_ute_temperature.state}} °C
outside. The forecast for today says it will be max {{ today | max }} °C
mode: single