Hi all,
Do you know if it’s possible to create an automation to do something 5 minutes before calendar event ?
My goal is to open a garage door for my lawn mower 5 minutes before next schedule.
I’m using husqvarna automower add on who provides me calendar for the automower
But I can’t find how can I do that
Thanks a lot
This template trigger should do what you want. Obviously replace calendar.lawnmower
with the proper entity_id. Calendar dates (at least mine) aren’t tz aware so |as_local is there to add a tz to the start_time datetime object
trigger:
- platform: template
value_template: >
{% if state_attr('calendar.lawnmower','start_time') != none %}
{% set start = state_attr('calendar.lawnmower','start_time')|as_datetime|as_local %}
{{ start - now() < timedelta(minutes=5) }}
{% endif %}
1 Like
iMiMx
(iMx)
May 10, 2023, 1:41pm
3
Thanks for this - needed something similar, for when our cleaner is due to arrive (and when she should have left).
The house sets ‘Cleaner’ mode if the doorbell rings, and/or her phone connects to our guest wifi, up to 10 minutes before the start_time
… and then goes back to ‘normal’ mode after the end_time (when the template goes to ‘false’) and if her phone has disconnected from the wifi, etc.
{% if state_attr('calendar.cleaner','start_time') != none %}
{% set start = state_attr('calendar.cleaner','start_time')|as_datetime|as_local %}
{{ start - now() < timedelta(minutes=10) }}
{% endif %}
Set up as a template binary_sensor:
template:
binary_sensor:
- name: Cleaner Due
state: >
{% if state_attr('calendar.cleaner','start_time') != none %}
{% set start = state_attr('calendar.cleaner','start_time')|as_datetime|as_local %}
{{ start - now() < timedelta(minutes=10) }}
{% endif %}