ScottS
October 17, 2020, 4:18pm
1
I continue to receive the following error and have no idea where the error is occurring.
Logger: homeassistant.config
Source: config.py:413
First occurred: 9:31:18 AM (8 occurrences)
Last logged: 11:00:33 AM
Invalid config for [automation]: must contain at least one of service, service_template. @ data[‘action’][0]. Got None. (See ?, line ?).
Below is the only automation I see that has a service template type…
- id: '1572100349280'
alias: Sunrise
trigger:
- event: sunrise
offset: +00:10:00
platform: sun
action:
- service: >
'{% if is_state ("weather.home", "sunny") %} light.turn_off {%endif%}'
entity_id: light.living_room_shelf_lamp
- service: light.lifx_set_state
entity_id: light.office_desk_lamp
data:
brightness_pct: 100
mode: single
Tinkerer
(aka DubhAd on GitHub)
October 17, 2020, 4:24pm
2
It’s telling you that an automation is missing both service
and service_template
.
ScottS
October 17, 2020, 4:31pm
3
Ok. Shall I post my Automation.yaml herein, else I cannot figure out where I’m missing either.
123
(Taras)
October 17, 2020, 4:56pm
4
The problem is caused by this template:
- service: >
'{% if is_state ("weather.home", "sunny") %} light.turn_off {%endif%}'
When the weather is sunny, the template produces “light.turn_off”. What happens if the weather is not sunny? The template produces nothing and that’s not an acceptable value for the service
option.
Re-arrange the order of the two services and add a condition
between them:
- id: '1572100349280'
alias: Sunrise
trigger:
- event: sunrise
offset: +00:10:00
platform: sun
action:
- service: light.lifx_set_state
entity_id: light.office_desk_lamp
data:
brightness_pct: 100
- condition: state
entity_id: weather.home
state: 'sunny'
- service: light.turn_off
entity_id: light.living_room_shelf_lamp
mode: single
At sunrise+10 minutes it will set the brightness of the desk lamp to 100% and then, only if it is sunny , it will also turn off the shelf lamp.
1 Like
ScottS
October 17, 2020, 5:38pm
5
Thank you for the rewrite, though I still receive that error.
123
(Taras)
October 17, 2020, 5:52pm
6
You don’t find it odd that a redesigned automation produces the same error?
I changed the example’s entity names to match what I have in my home, triggered the automation manually, and it works perfectly (no error messages).
You need to double-check what you did because there’s nothing wrong with the revised automation.
EDIT
Is this the only automation you have that fails to provide service
with a value or are there others?
1 Like
ScottS
October 17, 2020, 6:09pm
7
I removed automations one-by-one until I identified the culprit. What service/service_template may I be missing in this? This is weird as I’ve had this Automation for months.
- id: '1234567890'
alias: IFTTT received
trigger:
- event_data:
action: call_service
event_type: ifttt_webhook_received
platform: event
action:
- data_template:
entity_id: '{{ trigger.event.data.entity_id }}'
- service: '{{ trigger.event.data.service }}'
123
(Taras)
October 17, 2020, 6:31pm
8
This strikes me as being peculiar:
action:
- data_template:
entity_id: '{{ trigger.event.data.entity_id }}'
- service: '{{ trigger.event.data.service }}'
See the two hyphens? That’s two separate actions. The first one has no service
and the second one has no entity_id
.
It should be a single action like this:
action:
- service_template: '{{ trigger.event.data.service }}'
data_template:
entity_id: '{{ trigger.event.data.entity_id }}'
EDIT
If you are using 0.116.X then you can leave out “_template” because it is no longer necessary.
action:
- service: '{{ trigger.event.data.service }}'
data:
entity_id: '{{ trigger.event.data.entity_id }}'