I have no available events in Automation constructor, although there are ones created within Calendar Integration.
What may be wrong?
I have no available events in Automation constructor, although there are ones created within Calendar Integration.
What may be wrong?
A calendar type trigger triggers off any event in the selected calendar. You don’t select a particular event, then the trigger would be useless after that event had passed.
Hm… OK, thanks! I though there was some manual planner/calendar, which would invoke automation based on calendar events.
What are you trying to do? Like what is your actual use case?
From the start to the end of specific calendar events, some automation should be triggered.
I know it’s easy to realize directly in the automation, but I need to give calendar access to the user & for him, it’s much easier to understand how to input calendar events rather than making adjustments within automation.
Hm that makes sense. Maybe what you could have your friend do then is this:
Script: <script id>
for exampleThen you make one automation with a calendar trigger. Have your automation look at the event metadata and find the listed script. If it finds one then it runs the specified script.
That way your friend doesn’t have to figure out calendar triggers but it still works. Bit ugly but more approachable for a new person.
I don’t understand how this can react to a Calendar event creation/change…
Could you please show an example?
My automation with {{ trigger.calendar_event.summary }}
could not work out.
Simply triggered by a calendar event it was supposed to show a Telegram message. But it didn’t.
automation:
trigger:
- platform: calendar
# Possible values: start, end
event: start
# The calendar entity_id
entity_id: calendar.light_schedule
# Optional time offset
offset: "-00:05:00"
action:
service: notify.me
data:
message: "{{ trigger.calendar_event.summary }}"
5 minutes before any event begins on the light schedule calendar this will send a notification to me. The message will be the summary of the event about to begin.
EDIT:
Wait, “creation/change”? No, it doesn’t react to that. It reacts to an event on the calendar about to begin. Like in my example above if there is an event on the light schedule calendar at 9AM on 1/19/23 then that automation will trigger at 8:55AM on 1/19/23. 5 minutes before that event begins.
There is no way to trigger off creation/modification of an event on a calendar. Why would you want to?
Ah, you propose to create different calendars and make automation react to virtually any event?
I mean, if I create a calendar named AirConditioner responsible for switching aircons, then I need to have an automation sequence for that calendar that should work specifically for aircon calendar events. And so on - lights and other switches.
So, in the end, a novice user can simply create any event in any dedicated calendar and observe automation’s reaction.
Yes. That’s how the calendar trigger works, it reacts to any event on the chosen calendar.
If you want to use the same calendar for multiple types of things you could look for a search term. For example if you had a calendar for heat/cooling schedule and your house had multiple zones and you wanted to use one calendar for both could do something like this:
trigger:
- platform: calendar
event: start
entity_id: calendar.heat_cool
action:
- service: climate.set_temperature
data:
entity_id: "climate.{{ "zone_1" if "#zone1" in trigger.calendar_event.summary else "zone_2" }}"
temperature: "{{ trigger.calendar_event.description }}"
So you add #zone1
to the summary of events you want to apply to zone 1 and #zone2
to the ones for zone 2. Then put the target temp in the description and this automation handles the rest. Every time a new event begins it sets the temperature of the specified zone to the specified temperature.
Or have #lights
events on the same calendar and filter those out from this automation to be handled in a separate automation. I think multiple calendars for different types of things is probably easiest personally but whatever works for you.
Yes, according to your code example, I did mine:
alias: Test Calendar
description: ""
trigger:
- platform: calendar
event: start
offset: "0:0:0"
entity_id: calendar.planner
condition: []
action:
- service: light.turn_on
data: {}
target:
entity_id: >-
light.{{ "led_kitchen" if "#houselight" in
trigger.calendar_event.summary else "led_livingroom" }}"
mode: single
And my Calendar name is “Planner”
I made it for the test and waited until time 19:45, but my supposed light.led_kitchen
has not been switched on.
What is wrong then?
Thanks!
You have an extra quotation mark at the end of this template. So what’s coming out of it isn’t a valid entity ID.
@CentralCommand
Sorry for the typo. After I removed that ending quotation mark, I still couldn’t get it working.
Before you posted your code suggestion I experimented with the same kind of automation, but I just tried to use notify.telegram
service, which was supposed to just send me a message when the Calendar was triggered. Nothing works, thus I think the calendar doesn’t trigger. Maybe there’s another way to check it?
What does the trace say is happening? Is it firing and failing or not firing at all?
Ok but what does the trace say for the automation?
It’s strange because I see a trace of last event at 19:40 when there was a quotation mark typo that invoked the error:
Stopped because an error was encountered at January 20, 2023 at 19:40:00 (runtime: 0.01 seconds)
But after that, I tried 3-4 times after creating new calendar events with a later time, but nothing is registered and automation doesn’t seem to be triggered at all