Heyhey
I want to use the calendar.get_events Event to build an automation that does the following:
Check the calendar “vertreter” (and two other calendars) for events.
If there is one or more events
publish them in ToDo list
and if its a workday (workday sensor ‘on’) give me a telegram message telling me those events.
if there is no event:
give me a telegram message saying “Vertreter: none”, but only if its a workday.
Here is my automation, but it always tells me there are no events (“Vertreter: none”).
I dont know why.
The response variable does not have a property named events. The service calendar.get_events can return values from multiple source calendars, so its properties are named for each source calendar. You need to specify the source in you templates. This can be done for each instance of vertretertasks like:
Or you can set the value to a new variable prior to your first If/Then action.
Also, your for each needs to be a dictionary or list. You can’t just append the string "Vertreter: " to the list of events, you need to move that to the todo.add_item action.
But I still got one question.
You are using the “condition:state” (Confirm workday sensor is an testen) which I never did before.
But obviously it makes the code much more readable than my version.
Is this condition:state ment as following:
If the condition is not true all following lines (within a section) will be ognored?
Like this:
If {{today is wednesday} then
sendtelegrammessage
condition:state = true
do x
do y
condition:state = false
do z
In this silly example all commands are done (sending telegram message, do x, do z) and the last one (do z) - and all that follows up here, are skipped?
So basically if the condition is not true its exact the same as a stop command?
Yes, it’s essentially a guard clause just like those in the Conditions block of the automation. Any actions after the failed condition will not be executed.