I have cobbled together code from all over the forums and I am pretty sure this will work, but as I have no way to test it until the morning (and if it doesn’t work, I’m in trouble), can someone look this over and confirm if it works or not?
Basically, I created a google calendar with all day events that say school on the days my kids have school and is blank if they don’t. Thus, if the calendar says school, I want my kids lights to change colors at 7am. If the calendar doesn’t say school (IE holiday or weekend), then the kids lights change colors at 8am.
For sake of security, I have switched all identifiers to generic placeholders. The sensor currently reads “True” today.
- cal_id: [email protected]
entities:
- device_id: school
ignore_availability: true
name: school
track: true
search: "school"
# Is Today a School Day?
school_day:
friendly_name: Is it a school day?
value_template: "{{ is_state('calendar.school', 'on') }}"
# Is Today a School Day?
school_day:
friendly_name: Is it a school day?
value_template: "{{ is_state('calendar.school', 'on') }}"
If you use the above to create binary_sensor, I think the state can either be on or off if you check it in the Developer Tools —> States —> binary_sensor.school_day.
Where did you check it? According to the documentation-
The sensor is on if the template evaluates as True and off otherwise. The actual appearance in the frontend (Open /Closed , Detected /Clear etc) depends on the sensor’s device_class value.
Also, you need to replace sensor.school_day with binary_sensor.school_day.
Is that part really needed?
If the light did not turn on at 7, then it will turn on at 8.
The only collision is when the light turns on at 7 and manually turned off at 7:30.
However, you don’t actually have to check if the minute equals 30. The two triggers occur at different hours so simply checking the hour is sufficient to differentiate between the two. If they both triggered at the same hour but at a different minute then you would only need to check the minute to tell them apart.
In other words, unless the two trigger times are at the same hour, you don’t have to change the template I posted.
It doesn’t contain an id so there will be no trace available to examine. Go to Configuration > Automations and find the automation. Next to it will be a date and time representing the last time the automation was triggered. Let us know what it says.
Also, did you use the Automation Editor to create the automation or did you use a text editor to add it directly into automations.yaml? If you used a text editor, did you execute Reload Automations?
Minor point: there’s no need to use queued mode. This automation won’t ever be triggered more than once at the same time. The default single mode is sufficient.