Help turning light on automation

Can someone tell me why this isn’t working?
It was made in the GUI

- id: '1551890449454'
  alias: Turn On OutSide Light
  trigger:
  - event: sunset
    offset: -00:45:00
    platform: sun
  condition: []
  action:
  - data:
      entity_id: switch.outside_light
    service: switch.turn_on

Ultimately I would like to add only week days like this, but I need to get it working without conditions first

- id: '1551890449454'
  alias: Turn On OutSide Light
  trigger:
  - event: sunset
    offset: -00:45:00
    platform: sun
  condition:
    condition: state
    entity_id: 'binary_sensor.workday_sensor'
    state: 'on'
  action:
  - data:
      entity_id: switch.outside_light
    service: switch.turn_on

Any help would be appreciated.

Possibly due to missing quotes for delimiting offset?

Example: Turn on the living room lights 45 minutes before sunset if anyone is at home.

It’s possible but the GUI wont even let you enter in the quotes…
hmmm, it might be something else. I just created this for a test and I see in the LogBook that it was triggered but my light didn’t turn on…

- id: '1552536001752'
  alias: LightTest
  trigger:
  - at: 00:01:00
    platform: time
  condition: []
  action:
  - data:
      entity_id: switch.outside_light
    service: switch.turn_on

Check the entity_id is correct in dev-tools
Also check that you can turn it on/off in dev tools services

I see. In that case, I don’t see anything suspicious in the automation. I would first double-check the automation is enabled and then check if I can turn the switch on/off using the UI or via the Services page.

Your offset needs to be in quotes

offset: "-00:45:00"

I just tried this automation (based on yours but adapted for my environment) and it worked. You’re right, the Automation Editor doesn’t let you delimit the offset with quotes. I didn’t know that (I normally use a text editor). Using Visual Studio Code editor, I omitted the quotes and the automation triggered as expected (9 hours and 50 minutes before sunset). So, sorry about that, the ‘delimited offset’ was a red herring.

- id: '1551890449454'
  alias: Turn On Light
  trigger:
  - event: sunset
    offset: -09:50:00
    platform: sun
  action:
  - data:
      entity_id: light.kitchen
    service: light.turn_on

I would now focus my attention on ensuring the automation is enabled, then ensure the switch works using the UI and/or the Services page. If it does then the next step would be to confirm the host system’s clock is set correctly.

If anyone is following, I figured it out.
As @DavidFW1960 suggested I had the wrong entity.

I forgot that I re-named the devices :man_facepalming:

Thanks for everyone’s help

1 Like

No worries. It happens to everyone.

… but we still send you our invoice.

:wink: