I’m relatively new to this software and I’m currently trying to get an automation working that should turn on a scene in the morning, but only in the presence of a certain phone.
- alias: 'Lighting up Livingroom'
trigger:
- platform: state
entity_id: device_tracker.70700d106398
state: 'home'
- platform: sun
event: 'sunrise'
offset: '-0:30:00'
condition: use_trigger_values
action:
service: scene.turn_on
entity_id: scene.GoldenSun
Checking the config with this file included results in an error:
17-01-02 17:56:24 ERROR (MainThread) [homeassistant.bootstrap] Invalid config for [automation]: expected a dictionary @ data[‘condition’][0]. Got None. (See ?:?). Please check the docs at https://home-assistant.io/components/automation/
Failed config
automation:
- action: [source /home/pi/.homeassistant/includes/automation/wake_up_living.yaml:12]
entity_id: scene.GoldenSun
service: scene.turn_on
alias: Lighting up Livingroom
condition: use_trigger_values
trigger: [source /home/pi/.homeassistant/includes/automation/wake_up_living.yaml:2]
- platform: state
entity_id: device_tracker.70700d106398
state: home
I assume it’s something simple, maybe someone can point me to my stupid configuration error?
I haven’t tried out an automation like that just yet, however it would seem to me that the trigger should be the sunrise, with the condition being that the device is home. This way you aren’t triggering the automation everytime the device goes from (other state) to home. Maybe something like this:
- alias: 'Lighting up Livingroom'
trigger:
platform: sun
event: 'sunrise'
offset: '-0:30:00'
condition:
platform: state
entity_id: device_tracker.70700d106398
state: 'home'
action:
service: scene.turn_on
entity_id: scene.GoldenSun
Make sure you have 2 spaces after your trigger for the platform. In the code you pasted above, there is only one. Here’s an excerpt from one of my automations that is working. Note that I have 2 triggers, one being a startup of HASS. The other thing is that my conditions are set such that the light will not turn on if I restart HASS after 11:00 pm.:
alias: "Porch Lights On At Sunset"
trigger:
- platform: sun
event: sunset
offset: "-00:30:00"
- platform: event
event_type: homeassistant_start
condition:
condition: and
conditions:
- condition: sun
after: sunset
after_offset: "-00:30:00"
- condition: time
before: "23:00:00"
action:
- service: homeassistant.turn_on
entity_id: switch.ZAP3
- service: notify.pushbullet
data:
message: "Porch Lights On"
At the risk of sounding obvious, do you have the sun component loaded in your configuration.yaml? It’s not “part” of HA and has to be configured/enabled like any other platform. If your configuration doesn’t have a line like this:
sun:
That might be the problem. A lot of people (including me when I started out) don’t realize that the sun component isn’t enabled in HA by default.