Please give me some pointers. I have searched the forums and see that typical errors are indentation or using state instead of to, but I can’t find these errors in my code.
automation:
trigger:
platform: state
entity_id: device_tracker.stian_phone
to: 'home'
action:
- service: notify.push
data:
message: Stian is home
Error:
Oct 13 21:46:30 ha hass[28449]: Failed config
Oct 13 21:46:30 ha hass[28449]: automation:
Oct 13 21:46:30 ha hass[28449]: - action: [source /opt/ha/cfg/packages/automation/test_notification.yaml:14]
Oct 13 21:46:30 ha hass[28449]: - data: [source /opt/ha/cfg/packages/automation/test_notification.yaml:16]
Oct 13 21:46:30 ha hass[28449]: message: Stian is home
Oct 13 21:46:30 ha hass[28449]: service: notify.push
Oct 13 21:46:30 ha hass[28449]: trigger: [source /opt/ha/cfg/packages/automation/test_notification.yaml:10]
Oct 13 21:46:30 ha hass[28449]: platform: state
Oct 13 21:46:30 ha hass[28449]: entity_id: device_tracker.stian_phone
Oct 13 21:46:30 ha hass[28449]: to: home
Oct 13 21:46:30 ha hass[28449]: Successful config (partial)
Oct 13 21:46:30 ha hass[28449]: automation:
Oct 13 21:46:30 ha hass[28449]: - action: ?
Oct 13 21:46:30 ha hass[28449]: - data: [source /opt/ha/cfg/packages/automation/test_notification.yaml:16]
Oct 13 21:46:30 ha hass[28449]: message: Stian is home
Oct 13 21:46:30 ha hass[28449]: service: notify.push
Oct 13 21:46:30 ha hass[28449]: hide_entity: False
Oct 13 21:46:30 ha hass[28449]: trigger: ?
Oct 13 21:46:30 ha hass[28449]: - platform: state
Oct 13 21:46:30 ha hass[28449]: entity_id: ?
Oct 13 21:46:30 ha hass[28449]: - device_tracker.stian_phone
Oct 13 21:46:30 ha hass[28449]: to: home
- alias: 'Stian is Home'
trigger:
platform: state
entity_id: device_tracker.stian_phone
to: 'home'
action:
- service: notify.push
data:
message: Stian is home
Thanks. I assume you mean including the automation keyword. I will also post the rest of the file.
script:
test_notification:
alias: Test notification
sequence:
service: notify.push
data:
message: Testing push notifications
automation:
- alias: 'Stian is Home'
trigger:
platform: state
entity_id: device_tracker.stian_phone
to: 'home'
action:
- service: notify.push
data:
message: Stian is home
I still get errors:
2017-10-14 12:35:21 ERROR (MainThread) [homeassistant.config] Invalid config for [automation]: required key not provided @ data['action']. Got None
required key not provided @ data['trigger']. Got None. (See ?, line ?). Please check the docs at https://home-assistant.io/components/automation/
...
provided @ data['action']. Got None
required key not provided @ data['trigger']. Got None. (See ?, line ?). Please check the docs at https://home-assistant.io/components/automation/
...
Failed config
automation:
- action: [source /opt/ha/cfg/packages/automation/test_notification.yaml:15]
- data: [source /opt/ha/cfg/packages/automation/test_notification.yaml:17]
message: Stian is home
service: notify.push
alias: Stian is Home
trigger: [source /opt/ha/cfg/packages/automation/test_notification.yaml:11]
platform: state
entity_id: device_tracker.stian_phone
to: home
Successful config (partial)
automation:
- action: ?
- data: [source /opt/ha/cfg/packages/automation/test_notification.yaml:17]
message: Stian is home
service: notify.push
alias: Stian is Home
hide_entity: False
trigger: ?
- platform: state
entity_id: ?
- device_tracker.stian_phone
to: home
Maybe using appdaemon would be easier, but I hoped to learn to use HA’s built-in automations for simple stuff.
automation:
- alias: 'Stian is Home'
trigger:
platform: state
entity_id: device_tracker.stian_phone
to: 'home'
action:
- service: notify.push
data:
message: Stian is home
I have the same packages include in my configuration and it works.
Oct 14 17:40:40 ha hass[12769]: 2017-10-14 17:40:40 ERROR (MainThread) [homeassistant.config] Invalid config for [automation]: required key not provided @ data['action']. Got None
Oct 14 17:40:40 ha hass[12769]: required key not provided @ data['trigger']. Got None. (See ?, line ?). Please check the docs at https://home-assistant.io/components/automation/
...
Oct 14 17:40:40 ha hass[12769]: Failed config
Oct 14 17:40:40 ha hass[12769]: automation:
Oct 14 17:40:40 ha hass[12769]: - action: [source /opt/ha/cfg/packages/automation/test_notification.yaml:15]
Oct 14 17:40:40 ha hass[12769]: - data: [source /opt/ha/cfg/packages/automation/test_notification.yaml:17]
Oct 14 17:40:40 ha hass[12769]: message: Stian is home
Oct 14 17:40:40 ha hass[12769]: service: notify.push
Oct 14 17:40:40 ha hass[12769]: alias: Stian is Home
Oct 14 17:40:40 ha hass[12769]: trigger: [source /opt/ha/cfg/packages/automation/test_notification.yaml:11]
Oct 14 17:40:40 ha hass[12769]: platform: state
Oct 14 17:40:40 ha hass[12769]: entity_id: device_tracker.stian_phone
Oct 14 17:40:40 ha hass[12769]: to: home
Oct 14 17:40:40 ha hass[12769]: Successful config (partial)
Oct 14 17:40:40 ha hass[12769]: automation:
Oct 14 17:40:40 ha hass[12769]: - action: ?
Oct 14 17:40:40 ha hass[12769]: - data: [source /opt/ha/cfg/packages/automation/test_notification.yaml:17]
Oct 14 17:40:40 ha hass[12769]: message: Stian is home
Oct 14 17:40:40 ha hass[12769]: service: notify.push
Oct 14 17:40:40 ha hass[12769]: alias: Stian is Home
Oct 14 17:40:40 ha hass[12769]: hide_entity: False
Oct 14 17:40:40 ha hass[12769]: trigger: ?
Oct 14 17:40:40 ha hass[12769]: - platform: state
Oct 14 17:40:40 ha hass[12769]: entity_id: ?
Oct 14 17:40:40 ha hass[12769]: - device_tracker.stian_phone
Oct 14 17:40:40 ha hass[12769]: to: home
I would like to keep the structure where I can group related configuration for different components in the same file, but I’ll try the Automation config tool, thanks!
I think for different grouping you need to use different formats.
When i read this: Splitting up the configuration - Home Assistant
it seems that there are several different version availble which require each a different layout.
I can confirm that the automation i posted works for me in an FILENAME.yaml with this:
Just a thought, can you move your test_notification.yaml directly in the packages folder?
Without the automation subfolder.
I think the packages implementation is a little buggy, because reload customizing, groups, scripts and automations never works with packages.
I always have to restart HA on changes.