Hi, I have set up a Google Calendar and it shows, and my events sync as it should.
What I’m trying to do is create calendar appointments to control any switch in the house.
The easiest way I could figure out, was to use the appointment title for the entity name, and the message for the service to call.
My calendar appointment would look like:
Title: switch.test_heater
Description: switch.turn_
(Yes truncated, the on or off will come from the calendar event start and end triggers)
Here is my automation:
- id: '1559876102751'
alias: Calendar Events Stop Start
trigger:
- entity_id: calendar.home_assistant
platform: state
from: 'off'
to: 'on'
- entity_id: calendar.home_assistant
platform: state
from: 'on'
to: 'off'
condition: []
action:
- data_template:
entity_id: '{{states.calendar.home_assistant.attributes.message}}'
service_template: '{{states.calendar.home_assistant.attributes.description}}{{states.calendar.home_assistant.state}}'
The above runs fine for turning ON my switch.
The problem is with the OFF trigger. It runs but it doesn’t run with the appointment details that is ending. It looks like it’s probably running with the NEXT appointment’s details (in my case, there is no next appointment, so things just break).
Log Details (ERROR)
Fri Jun 14 2019 07:50:10 GMT+1200 (New Zealand Standard Time)
Error while executing automation automation.calendar_events_stop_start. Invalid data for call_service
at pos 1: Service Noneoff does not match format <domain>.<name>
You see that the Service is Noneoff
. So it gets the off part from the event end, which is fine, but it doesn’t have the calendar appointments description value which should be switch.turn_
.
Is this a bug with the calendar component?
I’d love to keep it this simple, where you just create events that are the duration of how long the switch should be on. That way I have a pretty good scheduler, and can easily set up schedules and pseudo-timers. I did think of having two appointments, one for turning on, and one for turning off. But that sucks.
(Also, c’mon, it’d be great to have a scan_interval
parameter for the calendar component, instead of hard coding to 15 minutes. How do you force a calendar update? It’s damn hard work trying to set up and debug your automations if you have to wait for it…)
Cheers!