Did you remember ….? It is not always easy to remember all the things that need to be done. But if you put them in a calendar, then it is possible to have Home Assistant remind you of this. For example, if there is training today, or if the favorite football team is playing a match (so you can hang out your football flag).
In the example below, we have added the term calendar of the favorite team into the Google calendar. The Google calendar is already integrated into the Home Assistant and thus all the matches of the team appear.
What we then have to do is check if there is actually a match today, and then send one notification to the mobile phone that it is match day.
For the sake of simplicity, we make automation that runs every day at 10 o’clock
Then we put a condition in the automation. It checks that we are at home and if there is a match in our calendar. If both are correct, then automation will continue.
To check if there is a match in the calendar, we create a template. This will be “true” if there is an activity in the calendar for the next 14.5 hours (52200 seconds). Here you can enter another number if you do not want to check so far in advance.
{{ ((as_timestamp(states.calendar.terminliste_rosenborg.attributes.start_time) - as_timestamp(now())) < 52200) and ((as_timestamp(states.calendar.terminliste_rosenborg.attributes.start_time) - as_timestamp(now())) > 0) }}
If it is match day, and we are at home, the automation can send one notification on the mobile phone.
To get a little more information in the push notification, we also include a couple of attributes from the calendar entry. In this case, there is information about who is playing and when the match starts.
The entire automation
alias: Match day!
description: ''
trigger:
- platform: time
at: '10:00:00'
condition:
- condition: and
conditions:
- condition: state
entity_id: person.lars
state: home
- condition: template
value_template: >-
{{
((as_timestamp(states.calendar.terminliste_rosenborg.attributes.start_time)
- as_timestamp(now())) < 52200) and
((as_timestamp(states.calendar.terminliste_rosenborg.attributes.start_time)
- as_timestamp(now())) > 0) }}
action:
- service: notify.mobile_app_lars_sin_iphone_11
data:
message: >-
Today {{states.calendar.terminliste_rosenborg.attributes.message}} plays
match, it starts at
{{states.calendar.terminliste_rosenborg.attributes.start_time}}
title: 🏳🏴 Matchday! 🏳🏴
mode: single