[Solved] Light on at sunset automation problem

So I have had this automation working in the past, and the on a recent update and restart, it just stopped. I do not see anything in the logs stating there is an issue with the markup, so I am at a loss of what is going on.

- id: turn_office_light_on_night_motion
  alias: Office light on when motion at night
  trigger:
    platform: state
    entity_id: sensor.office_motion
    to: 'detected'
  condition:
    condition: sun
    after: sunset
    after_offset: "-00:45:00"
  action:
    service: light.turn_on
    entity_id: light.office_light_level

(note: sensor.office_motion does change to “detected” properly)

Full automations.yaml https://github.com/grikka/Home-AssistantConfig/blob/master/automations.yaml
If anyone has any thoughts, I am all ears.

Can you trigger it manually from the automation card, if you can the problem is either in the condition or the trigger, if you can’t the problem could be in any part but most likely the action. Has the office_light_level changed it’s name? You can check in dev-tools-> states.

1 Like

I have a similar setup that’s working on 0.59 but mine looks a little different to yours;

- action:
  - alias: Turn the lounge lamp on
    data:
      entity_id: light.lounge_lamp
    service: light.turn_on
  alias: Turn on Lights Before Sunset
  condition:
  - condition: state
    entity_id: group.all_devices
    state: home
  - after: '14:30:00'
    before: '23:59:00'
    condition: time
  id: '1506081676552'
  trigger:
  - entity_id: group.all_devices
    platform: state
    to: home
  - event: sunset
    offset: -01:00:00
    platform: sun

Obviously you’re looking for sunset as a condition rather than an event. I wonder if there has been a change where sunset is not being recognised as a condition. Could you try rewriting the condition using a template as in the example here? By which I mean using the elevation of the sun as a condition, rather than the sunset event with an offset.

Only thing I can think of is to check to make sure your sensor’s component hasn’t changed to a binary sensor since update.

I know my motion sensor (WeMo) uses the binary_sensor platform, and ‘off’ and ‘on’ as state.

I thought about the sensor. vs binary_sensor. and that didn’t change. The light.office_light_level manual function for turning it on and off works fine.

I am beginning to think it has something to do with the sunset offset. I didn’t see any depreciated/breaking changes about that, so I may have to go the template route like @reclusivemonkey suggested. It is more heavy handed then what I had working previously though. Seems odd though that it works on one version with supported docs and then a few version after, still same supported docs and is broken.

To note, I am on .60 now, and issue is the same.

I seem to have fixed it in my latest commit (https://github.com/grikka/Home-AssistantConfig/commit/b6e5ba9c6158602ea564fa2409247d0d689943f5)

Looks to have been a markup issue, or order issue?

All of those automations fire correctly now with those changes, thanks all!