Hi everybody,
below is an automation I just created for watering my plants in the morning. It will not work, but I cannot figure out the problem. When I reload my automations, I don’t get any identifiable error, but the automation will not be found (should be automation.bewasserung_morgens
.
Can you please help me fix this?
Thank you in advance for your ideas
automation:
#--------------------------------------------------------------------#
# MORGENS # {{{
#--------------------------------------------------------------------#
- alias: "Bewässerung Morgens"
variables:
pausendauer: 1
trigger:
- platform: time
at: input_datetime.festlegen_pflanzen_bewasserung_zeit_morgens
condition:
condition: state
entity_id: binary_sensor.bewaesserung_condition
state: "on"
action:
- alias: "Zuerst Pumpe einschalten"
service: switch.turn_on
entity_id: switch.dr_wasser
- delay: "{{ pausendauer }}"
- alias: "Gießen Freddy"
service: switch.turn_on
entity_id: switch.draussen_bewaesserung_main_relay_01_ch3
- delay:
minutes: input_number.festlegen_pflanzen_bewaesserung_freddy_dauer_morgens
- alias: "Gießen Freddy"
service: switch.turn_off
entity_id: switch.draussen_bewaesserung_main_relay_01_ch3
- delay: "{{ pausendauer }}"
- alias: "Gießen Rasen"
service: switch.turn_on
entity_id: switch.draussen_bewaesserung_main_relay_01_ch2
- delay:
minutes: input_number.festlegen_pflanzen_bewaesserung_rasen_dauer_morgens
- alias: "Gießen Rasen"
service: switch.turn_off
entity_id: switch.draussen_bewaesserung_main_relay_01_ch2
- delay: "{{ pausendauer }}"
- alias: "Gießen Hinten"
service: switch.turn_on
entity_id: switch.draussen_bewaesserung_main_relay_01_ch1
- delay:
minutes: input_number.festlegen_pflanzen_bewaesserung_unterstand_dauer_morgens
- alias: "Gießen Hinten"
service: switch.turn_off
entity_id: switch.draussen_bewaesserung_main_relay_01_ch1
- delay: "{{ pausendauer }}"
- alias: "Zum Schluss Pumpe ausschalten"
service: switch.turn_off
entity_id: switch.dr_wasser
# }}}
calisro
(Rob)
June 23, 2022, 2:32pm
2
Well. You can’t do this:
- delay:
minutes: input_number.festlegen_pflanzen_bewaesserung_rasen_dauer_morgens
It needs to be {{ states(‘input_number.festlegen_pflanzen_bewaesserung_rasen_dauer_morgens’) }}
calisro
(Rob)
June 23, 2022, 2:32pm
3
And your indenting on minutes is off.
alias: "Bewässerung Morgens"
variables:
pausendauer: 1
trigger:
- platform: time
at: input_datetime.festlegen_pflanzen_bewasserung_zeit_morgens
condition:
condition: state
entity_id: binary_sensor.bewaesserung_condition
state: "on"
action:
- alias: "Zuerst Pumpe einschalten"
service: switch.turn_on
entity_id: switch.dr_wasser
- delay: "{{ pausendauer }}"
- alias: "Gießen Freddy"
service: switch.turn_on
entity_id: switch.draussen_bewaesserung_main_relay_01_ch3
- delay:
minutes: '{{ states(''input_number.festlegen_pflanzen_bewaesserung_rasen_dauer_morgens'') }}'
- alias: "Gießen Freddy"
service: switch.turn_off
entity_id: switch.draussen_bewaesserung_main_relay_01_ch3
- delay: "{{ pausendauer }}"
- alias: "Gießen Rasen"
service: switch.turn_on
entity_id: switch.draussen_bewaesserung_main_relay_01_ch2
- delay:
minutes: '{{ states(''input_number.festlegen_pflanzen_bewaesserung_rasen_dauer_morgens'') }}'
- alias: "Gießen Rasen"
service: switch.turn_off
entity_id: switch.draussen_bewaesserung_main_relay_01_ch2
- delay: "{{ pausendauer }}"
- alias: "Gießen Hinten"
service: switch.turn_on
entity_id: switch.draussen_bewaesserung_main_relay_01_ch1
- delay:
minutes: '{{ states(''input_number.festlegen_pflanzen_bewaesserung_rasen_dauer_morgens'') }}'
- alias: "Gießen Hinten"
service: switch.turn_off
entity_id: switch.draussen_bewaesserung_main_relay_01_ch1
- delay: "{{ pausendauer }}"
- alias: "Zum Schluss Pumpe ausschalten"
service: switch.turn_off
entity_id: switch.dr_wasser
``
calisro
(Rob)
June 23, 2022, 2:33pm
4
Also this:
- platform: time
at: input_datetime.festlegen_pflanzen_bewasserung_zeit_morgens
You always need to get the values of entities rather than the entities themselves when templating. Take a look at teh templating page:
I’d suggest you pop it into a UI editor so you can see the issues it has or check your logs when you load an automation.
Edwin_D
(Edwin D.)
June 23, 2022, 2:35pm
5
Also, remove the line automation: on the top line and decreasing all indentation one step. Most likely that line is taken care of outside the file. But it all depends on where you put this and how your configuration.yaml is set up. If this is not in automations.yaml but included another way, reloading automations might not load this without a full restart.
petro
(Petro)
June 23, 2022, 2:50pm
6
Couple of things (listed above)
You need to use templates to extract the number into your delay, what calisro said
You need to remove the random {{{ and }}} that you had
Your indentation was wrong for delay:
when you were including minutes:
automation:
#--------------------------------------------------------------------#
# MORGENS
#--------------------------------------------------------------------#
- alias: "Bewässerung Morgens"
variables:
pausendauer: 1
trigger:
- platform: time
at: input_datetime.festlegen_pflanzen_bewasserung_zeit_morgens
condition:
condition: state
entity_id: binary_sensor.bewaesserung_condition
state: "on"
action:
- alias: "Zuerst Pumpe einschalten"
service: switch.turn_on
entity_id: switch.dr_wasser
- delay: "{{ pausendauer }}"
- alias: "Gießen Freddy"
service: switch.turn_on
entity_id: switch.draussen_bewaesserung_main_relay_01_ch3
- delay:
minutes: "{{ states('input_number.festlegen_pflanzen_bewaesserung_freddy_dauer_morgens') }}"
- alias: "Gießen Freddy"
service: switch.turn_off
entity_id: switch.draussen_bewaesserung_main_relay_01_ch3
- delay: "{{ pausendauer }}"
- alias: "Gießen Rasen"
service: switch.turn_on
entity_id: switch.draussen_bewaesserung_main_relay_01_ch2
- delay:
minutes: "{{ states('input_number.festlegen_pflanzen_bewaesserung_freddy_dauer_morgens') }}"
- alias: "Gießen Rasen"
service: switch.turn_off
entity_id: switch.draussen_bewaesserung_main_relay_01_ch2
- delay: "{{ pausendauer }}"
- alias: "Gießen Hinten"
service: switch.turn_on
entity_id: switch.draussen_bewaesserung_main_relay_01_ch1
- delay:
minutes: "{{ states('input_number.festlegen_pflanzen_bewaesserung_freddy_dauer_morgens') }}"
- alias: "Gießen Hinten"
service: switch.turn_off
entity_id: switch.draussen_bewaesserung_main_relay_01_ch1
- delay: "{{ pausendauer }}"
- alias: "Zum Schluss Pumpe ausschalten"
service: switch.turn_off
entity_id: switch.dr_wasser
1 Like
Thank you @petro , the automation you posted works
You need to remove the random {{{ and }}} that you had
Those are not random. I ues neovim
and these marks let me fold the text. I have them in all sorts of Home Assistant package files, and they don’t mess with the code.
@Edwin_D I use a packages
directory, so that I can have files including automations, sensors, templates, etc.; so the file structure itself was fine. Reloading works as well, my code was just wrong (I could load it after using petro’s version without a restart).
@calisro
check your logs when you load an automation
Unfortunately, the logs don’t show what exactly is wrong there. Usually they’d display what particular file has an error, and (I believe?) in what line it is. Here, it just tells me there is something wrong with an automation, and when I click on it, it doesn’t provide the details I expected.
calisro
(Rob)
June 23, 2022, 3:11pm
8
prankousky:
Unfortunately, the logs don’t show what exactly is wrong there. Usually they’d display what particular file has an error, and (I believe?) in what line it is. Here, it just tells me there is something wrong with an automation, and when I click on it, it doesn’t provide the details I expected.
When I pasted your automation into an editor, it gave me:
Message malformed: extra keys not allowed @ data[‘action’][3][‘minutes’]
If you look at your automation, you can navidate that tree and see the spot its failing on.
calisro
(Rob)
June 23, 2022, 3:14pm
9
btw, Petro’s automation has this. you would need to fix this line even though it won’t error.
Disregard. I see this is allowed.
calisro
(Rob)
June 23, 2022, 3:19pm
11
That’s interesting. The documentation doesn’t articulate that well. THanks.
Ohhh I see it now in the example:
- trigger:
- platform: time
at: input_datetime.turn_off_ac
I used to always use the template variant as well… now that you can use the at: input_datetime.etc
syntax, I just assumed that it would work for minutes:
as well.