Activate
(HJE Kottier)
November 19, 2023, 7:30pm
1
hello,
I have a litlle problem wit an automation for a heater.
On saturday and sunday I want it on at 9 and off at 23:00.
This is what I made in YAML :
alias: WC Weekend
service : climate.wc
description: switch.turn_on
trigger:
platform: time
at: “09:00:00”
id: Inschakelen
platform: time
at: “23:00:00”
id: Uitschakelen
condition:
condition: time
weekday:
if:
condition: trigger
id: Inschakelen
then:
device_id: b03762317aaa891d032fff86fda5e857
domain: climate
entity_id: 756c8f99f5c303de90a02e7ada58bee3
type: set_hvac_mode
hvac_mode: heat
if:
condition: trigger
id: Uitschakelen
then:
device_id: b03762317aaa891d032fff86fda5e857
domain: climate
entity_id: 756c8f99f5c303de90a02e7ada58bee3
type: set_hvac_mode
hvac_mode: “off”
mode: single
I am getting this fault :
Message malformed: extra keys not allowed @ data[‘service’]
I am thinking that I must not use the Climate.wc?
How can I set the temperature to 19 C?
Wich one must I use?
Thanks in advance,
You have to do a call service to set the temp
service: climate.set_temperature
data:
temperature: 70
hvac_mode: heat
target:
entity_id: climate.living_room
Activate
(HJE Kottier)
November 19, 2023, 7:58pm
3
Thanks for the answer,
Tried this :
alias: WC Weekend
service: climate.set_temperature
data:
temperature: 19
target:
entity_id: climate.wc
description: switch.turn_on
trigger:
platform: time
at: “09:00:00”
id: Inschakelen
platform: time
at: “23:00:00”
id: Uitschakelen
condition:
condition: time
weekday:
if:
condition: trigger
id: Inschakelen
then:
device_id: b03762317aaa891d032fff86fda5e857
domain: climate
entity_id: 756c8f99f5c303de90a02e7ada58bee3
type: set_hvac_mode
hvac_mode: heat
if:
condition: trigger
id: Uitschakelen
then:
device_id: b03762317aaa891d032fff86fda5e857
domain: climate
entity_id: 756c8f99f5c303de90a02e7ada58bee3
type: set_hvac_mode
hvac_mode: “off”
mode: single
Still the same error.
I edited my original response to include HVAC mode and temp in the same call
The reason you’re still getting an error is because I didn’t address that part. I only answered your question about the temp setting
Activate
(HJE Kottier)
November 19, 2023, 8:04pm
5
Ok So the temp part must be good then.
Now I have to find out what is wrong with the YAML code.
123
(Taras)
November 19, 2023, 8:40pm
6
Proper indentation is critical for valid YAML. Unfortunately it’s challenging to help you identify improper indentation in your example because you didn’t post it as formatted YAML.
Refer to the following guideline and then post your automation with properly formatted YAML.
FAQ Guideline 11: Format it properly
Activate
(HJE Kottier)
November 19, 2023, 8:46pm
7
Thanks again,
I hae read the format it properly but I don not know hoe to plave it right, so I have made a screenshot :
Hopefully this will help?
Tamsy
(Tamsy)
November 20, 2023, 5:35am
9
Try this:
alias: WC Weekend
description: 'Switch WC heater to 19°C from 09:00 to 23:00 on Saturdays and Sundays.'
trigger:
- platform: time
at: '09:00:00'
id: Inschakelen
- platform: time
at: '23:00:00'
id: Uitschakelen
condition:
condition: time
weekday:
- sat
- sun
action:
- choose:
- conditions:
- condition: trigger
id: Inschakelen
sequence:
- service: climate.turn_on
target:
entity_id: climate.wc
- service: climate.set_hvac_mode
data:
entity_id: climate.wc
hvac_mode: heat
- service: climate.set_temperature
data:
entity_id: climate.wc
temperature: 19
- conditions:
- condition: trigger
id: Uitschakelen
sequence:
- service: climate.turn_off
target:
entity_id: climate.wc
data:
hvac_mode: 'off'
default: []
123
(Taras)
November 20, 2023, 5:59am
10
alias: WC Weekend
description: >-
Switch WC heater to 19°C from 09:00 to 23:00 on Saturdays and Sundays.
trigger:
- platform: time
at:
- '09:00:00'
- '23:00:00'
condition:
- condition: time
weekday:
- sat
- sun
action:
- if:
- condition: template
value_template: "{{ now().hour == 9 }}"
then:
- service: climate.set_temperature
target:
entity_id: climate.wc
data:
temperature: 19
hvac_mode: 'heat'
else:
- service: climate.set_hvac_mode
target:
entity_id: climate.wc
data:
hvac_mode: 'off'
1 Like
Activate
(HJE Kottier)
November 20, 2023, 7:29am
11
Thanks for the reply, I am getting this error:
Tamsy
(Tamsy)
November 20, 2023, 8:04am
12
Activate:
I am getting this error
Try Tara’s more shortened automation then
Activate
(HJE Kottier)
November 20, 2023, 9:18am
13
I have put the code in HA, no errors yet, hope it will work!
vso1
(Victor)
November 20, 2023, 9:53am
14
the error you are getting is most likely because the indentation (number of spaces) in YAML matters.
instead of doing it by code, use an automation to setup the bulk
(in dutch) om code hier te laten zien moet je een 3x Accent grave(EN: Backtik) voor / na de code zetten " ` " hierdoor laat je de tekst zien zoals bedoelt
#example
nospace
2spacesinfront
see Markdown Cheatsheet · adam-p/markdown-here Wiki · GitHub sectie " Code and Syntax Highlighting" where they say javascript/python you put here YAML (note the caps)
123
(Taras)
November 20, 2023, 1:36pm
15
The error message is caused by a block of YAML, representing a service call to set temperature, that’s in the wrong place. It belongs within the automation’s action
section.
However, even if it was moved to the correct place, it would still cause an error because, as you explained, indentation is important and those five lines don’t have valid indentation.
1 Like