Help needed for simple automation

Hi all,

I would like to turn my entrance lights on when I open my front door whist its dark, could anyone let me know where I’ve gone wrong with this?

I am getting this error message;

Configuration invalid
Error loading /config/configuration.yaml: while parsing a block collection
in “/config/automations.yaml”, line 1, column 3
expected , but found ‘?’
in “/config/automations.yaml”, line 31, column 3

Easy, these three lines need pushing in two spaces…

  condition:
    condition: and
    conditions:

At a guess “line 31, column 3” in the errors coincides with the ‘c’ in the first ‘condition:’, use an editor that shows line numbers and it’s easy to find where errors like that are.

1 Like

That will get the configuration to pass. however, can you guarantee that the binary_sensor.door_window_xxxx will trigger before or after sunset?

To me, I don’t think its guaranteed.

1 Like

True, I use…

- condition: state
  entity_id: sun.sun
  state: below_horizon

…for one of my HC automations.

1 Like

I don’t use a sensor to handle my lights, so I donno. I mean it could make sense to have those conditions. I’ve never really thought about needing the light on in the daytime with cloud cover.

Thanks for your help, could you also point me in the right direction with this one? I want to turn some lights one when the first person arrives home if its dark. I have added this but if someone else is already home it still turns the lights on. How do I make it only turn the lights on for the first one home?

  • alias: Turn the lamps on after dark when arriving home
    initial_state: True
    hide_entity: False
    trigger:
    • platform: state
      entity_id: group.all_door_sensors
      to: ‘on’
      condition:
      condition: and
      conditions:
      • condition: sun
        after: sunset
        after_offset: “-00:30:00”
      • condition: state
        entity_id: group.all_devices
        state: ‘home’
        action:
    • service: homeassistant.turn_on
      entity_id: group.living_room_lamps

can you use the code block when posting? Can’t really help if the code isn’t formatted correctly. The documentation is at the top of the page.

Hi Petro,

Sorry but I new to this, I’ve been trying to work out how to do it like everyone else does, how do you do that?

at the top of the page, it describes how to do it in the link. Take a look at the previous photo that I posted and click on that link.

Maybe it’s just me, but that link seems to have disappeared.

WTF?? yeah me too… well I don’t have that link.

EDIT: It’s not even covered in the FAQ…

sorry man, here’s the link. Not sure why it’s gone.

1 Like

Thanks for that, it’s been doing my head in since I started on here.

Simplest way is to highlight the relevant text and hit the ‘</>’ button in the toolbar.