Light on after sensor trigger after sunset - Issue

Hello,

I’m having issue making an automation works.
I’d like to have an hallway light turn on after the motion sensor is triggered, but only if the sun has set.

Here’s what I have so far :

#AUTOMATION HALLWAY LIGHT MULTISENSOR TRIGGERED AFTER SUNSET
  alias: Turn on hallway after sunset sensor
  hide_entity: True
  trigger:
    platform: state
    entity_id: sensor.aeotec_zw100_multisensor_6_burglar_12_10
    from: '0'
    to: '8'
  condition:
    platform: sun
    before: sunrise
  action:
    service: homeassistant.turn_on
    entity_id: script.sensor_hallway_light

Home Assistant doesn’t get the automation althrough it passes YAML testers. I don’t really know what’s wrong with it but it seems to be the condition :

16-12-06 11:27:40 homeassistant.util.yaml: mapping values are not allowed here
  in "/home/hass/.homeassistant/extraconfig/automation/sensor_hallway.yaml", line 10, column 10

Any advices ?
Thanks !

Change that to

condition: sun
before: sunrise

or it may be

condition: 
  condition: sun
  before: sunrise

conditions are weird sometimes and require the two condition statements.

The second one seems to have done the trick ! (At least, no errors in the log and HA starts).

Thanks a lot silvrr ! :slight_smile:

I did like that:

- alias: 'turn light on'
  trigger:
    - platform: state
      entity_id: sensor.sensor_corridor
      from: 'still'
      to: 'motion'
  condition: 
    - condition: state
      entity_id: sun.sun
      state: 'below_horizon'
  action:
    - service: light.turn_on
      entity_id: light.hue_white_lamp_1
 
- alias: 'turn light off'
  trigger:
    - platform: state
      entity_id: sensor.sensor_corridor
      from: 'motion'
      to: 'still'
  condition: 
    - condition: state
      entity_id: light.hue_white_lamp_1
      state: 'on'
  action:
    - service: light.turn_off
      entity_id: light.hue_white_lamp_1`Preformatted text`
3 Likes