Hey, I just configured the Google Calender integration. I want to set Calender Events as Condition in automations.
So: If there is a event with “Urlaub” in the title, I dont want the automation to run.
I’m pretty new to HASS and I can’t get it to work. My automation for just starting the vacuum at weekdays was fine. But now I need another condition and Iam not sure, what Iam doing wrong…
I found some threads and I tested a lot… Thats my full automation YAML now:
If I test the condition in the visual editor, its not passing. And I have a event in my calendar, starting yesterday and ending at the start of january with the title “Urlaub: XXX”.
Do I need to do something special, if I use 2 platforms? So the value template “knows” which entity he has to check?! Or something like that?!
Hey, thanks for the reply. You are using “state”, not “template”. Its good to know, that I really dont have to add the platform stuff for the calendar for the use case.
But I cant add the entity_id in the condition: template part…
This works great for an automation I have with our kid’s school calendar. They publish all-day events that contain “Non-student day” on days the kids are off, so I built a binary sensor using Acanis87’s binary sensor to look for that condition for the sensor, then can use that sensor for the automation condition to determine if it should run or not. Amazing automation now where the kiddo won’t get woken up on a day that they don’t have school!
Hi there, this is useful thanks all for discussing this. I have now a different use case where “now” I need to check if an event is in the calendar in “now+1h”. With the binary sensor configured like you described I can check only “now”, is there a way to specify a different time do you think?
My use case: I want to turn on the heating on earlier some days, when it happens that I have an early morning meeting
{% set next_event = state_attr('calendar.mycalendar', 'start_time') %}
{% set next_event_day = next_event[:10] %}
{% set next_event_hour = next_event[11:13] %}
{% set today = (as_timestamp(now())) | timestamp_custom('%Y-%m-%d %H', True) %}
{% set today_date = today[:10] %}
{% set today_hour = today[11:13] %}
{% set seven = today_hour == '07' and next_event_day == today_date and next_event_hour == '08' %}
{% set eight = today_hour == '08' and next_event_day == today_date and next_event_hour == '09' %}
{% set nine = today_hour == '09' %}
{{ seven or eight or nine }}
this goes in the condition and I’ve got 3 triggers, one at 7, one at 8, one at 9. Then the template checks if the next event in the calendar is today and in the hour after.
Could probably be done more elegantly but it seems to do the job for me.