I am new in the HA universe and currently I am migration from ioBroker to Home Assistant.
Here I am currently struggling with an automation regarding my vacuum cleaner.
I start every weekday at 10:30 am my vaccum cleaner. A cleaning lady comes to our house at irregular intervals, which we keep as a calendar entry. I have entered the Google calendar in HA for this purpose.
So I want that when the trigger goes off at 10:30, it checks whether there is a calendar entry for today that contains the name “Reinigung”. If this is the case, then don’t start the robot hoover.
Here is my automation that does not work. I have removed other triggers for reasons of clarity. I know that I have to use a template for the condition but I do not know how exactly.
many thanks for your support here. So indeed the lower case is a step forward. I do get a response in the Developer Template Tool.
But here is the catch:
For today I have several entries in the calendar, but the {{ 'Reinigung' in state_attr('calendar.name_of_calendar', 'message') }} only throws out the “all day” entry and not the others from today.
Be aware that there’s a potential problem with using any condition to check a calendar entity.
If you have an all-day event, its details will appear in the calendar entity and not any of the other events scheduled that day.
If you more than one event scheduled at the same time, only one of them will appear in the calendar entity.
That’s why it’s recommended to use a Calendar Trigger to detect the desired calendar event.
In your case, you can create a Trigger-based Template Binary Sensor with a Calendar Trigger that detects if the cleaning lady is scheduled to arrive today. Then your automation can use a State Condition to check the binary_sensor’s state.EDIT see TheFes’s post below
Thank you very much for your feedback. I must admit that I do not understand much of what you are talking about. I am quite new and still trying to find my way around
Do you eventually have an example for me how to set up a trigger-based template binary sensor?
Note, you need to adjust the entity of the calendar in two places. In the service call to get the events, and in the template of the if action.
BTW, there is no need to censor device_id’s. They are randomly generate unique identifiers for the HA backend, nobody can do anything with them.
But I would advice to use entity_id’s instead of device id’s anyway
thank you I will give this a try. But one question. If I set it up like this, then the vacuum will only run when the calendar entry “Reinigung” exists, right? It’s supposed to be the other way around. If calendar entry “Reinigung” exists for today, then do not start cleaning.
With the code above it should always start on the trigger with id 2 and on the right weekdays, as you also have the vacuum.start service call before the if-then action.
But you should be able to tell where it goes wrong from the automation trace
I tried @TheFes way of using the calendar as a condition to turn some lights on at sunset (only if there are guests). But no matter which calendar I use or which word I am searching for, the visual editor always says that the condition is not met.
Hi @TheFes
I wanted to use this script to solve my problem (see this post) but it still gives me false triggers. I think it can be solved by checking whether the current date-time is within the start and end date of the found event.
Could you help me out here?