I hope someone can help me with a basic automation using local calendar and my trv switches. I am trying to turn my heating on at a certain time.
I have configured the event in local calendar. I can run the automation using Traces/Run and the trv’s switch on. However leaving the automation to run by itself does not work. I can see the local calendar event become active in the logbook but the automation does start.
This is my yaml file for the automation.
Help much appreciated as going around in circles with this.
alias: Switch on Central Heating at 1700
description: ""
trigger:
- platform: calendar
event: start
entity_id: calendar.heating
condition:
- condition: template
value_template: "value_template: \"{{ 'PM heating on' in trigger.calendar_event.summary }}\""
action:
- service: climate.set_hvac_mode
data:
hvac_mode: heat
target:
device_id:
- afac8579a578a9bb35aa37137708c2b4
- aa7394145e113233963d890831e64171
- 74fccde01387612615df506ca42f2e6c
- d6d78fb1120b69a7c8a52b057dc66a72
- 68f47d5ce09cb8a25af5ae5efd1d23f7
mode: single
123
(Taras)
November 27, 2023, 4:01pm
2
condition:
- condition: template
value_template: "{{ 'PM heating on' in trigger.calendar_event.summary }}"
That command only executes the automation’s actions. It doesn’t exercise the trigger or condition so it didn’t run your automation’s faulty Template Condition.
@123 thanks for your reply, I made the changes but I am still having issues.
Is it best to create automations in the UI or direct into automations.yaml?
I see the condition in the UI as this
{{ 'PM heating on' in trigger.calendar_event.summary }}
In the UI with edit in yaml:
condition: template
value_template: "{{ 'PM heating on' in trigger.calendar_event.summary }}"
|In automations.yaml I see this:
- id: '1701114272029'
alias: Switch on Central Heating at 1700
description: ''
trigger:
- platform: calendar
event: start
offset: 0:0:0
entity_id: calendar.heating
condition:
- condition: template
value_template: "{{ 'PM heating on' in trigger.calendar_event.summary }}"
action:
- service: climate.set_hvac_mode
data:
hvac_mode: heat
target:
device_id:
- aa7394145e113233963d890831e64171
- 74fccde01387612615df506ca42f2e6c
- d6d78fb1120b69a7c8a52b057dc66a72
- afac8579a578a9bb35aa37137708c2b4
mode: single
I am now very confused as when I look at TRACES and Automations.yaml again I see changes to the value_template that were not made by me…
I am not sure what is happening.
condition: template
value_template: '"{{ ''PM heating on'' in trigger.calendar_event.summary }}"'
Automations.yaml
- id: '1701114272029'
alias: Switch on Central Heating at 1700
description: ''
trigger:
- platform: calendar
event: start
offset: 0:0:0
entity_id: calendar.heating
condition:
- condition: template
value_template: '{{ ''PM heating on'' in trigger.calendar_event.summary }}'
action:
- service: climate.set_hvac_mode
data:
hvac_mode: heat
target:
device_id:
- aa7394145e113233963d890831e64171
- 74fccde01387612615df506ca42f2e6c
- d6d78fb1120b69a7c8a52b057dc66a72
- afac8579a578a9bb35aa37137708c2b4
mode: single
123
(Taras)
November 27, 2023, 8:44pm
6
The Automation Editor’s preference is to a single quote and double single quotes (not the same as a double quote).
In other words, it uses:
'
''
instead of:
'
"
So when you manually enter a double quote character, upon saving the automation the Automation Editor will convert it conform to its formatting rules.
123
(Taras)
November 27, 2023, 8:48pm
7
What are the issues?
Currently, your automation has a Calendar Trigger that triggers whenever it detects the start of a scheduled calendar event. It then checks if the event’s summary contains the string PM heating on
. If it doesn’t then it ends. If it does, it sets several devices to heat
mode.
Be advised that if you are testing it by adding a calendar event that occurs less than 15 minutes in the future, it is likely that it won’t be detected (due to the polling frequency for calendar events).
1 Like
I have a similar automation that has a calendar input, plus a temp check to turn on a heater.
Maybe you can check your formatting vs mine.
alias: Heat Barn
description: ""
trigger:
- platform: time
at: "06:45:00"
condition:
- condition: template
value_template: "{{ state_attr('weather.pirateweather', 'temperature') < 40}}"
alias: Check Temperature
action:
- if:
- condition: or
conditions:
- condition: template
value_template: >-
{{ ('No School' in state_attr('calendar.bartley_events',
'message')) }}
alias: Check No School
- condition: time
weekday:
- sat
- sun
then:
- delay:
hours: 1
minutes: 15
seconds: 0
milliseconds: 0
- type: turn_on
device_id: 47357ad8eb549596fc5ab50f1c2a3164
entity_id: acabf96a71858d8335d1b3782886c807
domain: switch
- delay:
hours: 1
minutes: 30
seconds: 0
milliseconds: 0
- type: turn_off
device_id: 47357ad8eb549596fc5ab50f1c2a3164
entity_id: acabf96a71858d8335d1b3782886c807
domain: switch
else:
- type: turn_on
device_id: 47357ad8eb549596fc5ab50f1c2a3164
entity_id: acabf96a71858d8335d1b3782886c807
domain: switch
- delay:
hours: 1
minutes: 30
seconds: 0
milliseconds: 0
- type: turn_off
device_id: 47357ad8eb549596fc5ab50f1c2a3164
entity_id: acabf96a71858d8335d1b3782886c807
domain: switch
mode: single
1 Like
123
(Taras)
November 28, 2023, 2:00am
9
FYI
You replied to my post but I’m not the topic’s author (mauriceatkinson).
@mauriceatkinson
If you don’t care for how the Automation Editor automatically reformats things, the other option is to use a text editor and keep your automations separate from those created using the Automation Editor . However you must become comfortable with YAML to go that route.