Turn on lights when i come home after sunset whit offset

My lights are turning on but nog whit the sunset condition and offset.

alias: 'Licht aan bij thuiskomst Jos en donker '
description: ''
trigger:
  - platform: device
    device_id: 51c161782681b562ab5b521a547b747b
    domain: device_tracker
    entity_id: device_tracker.iphone_van_jc
    type: enters
    zone: zone.home
condition:
  - condition: sun
    before: sunset
    before_offset: '-01:00:00'
action:
  - service: light.turn_on
    target:
      entity_id: light.dimmable_light_1
mode: single

The language of this condition is always weird… “On condition it is after 1 hour before sunset” :slight_smile:

So, I think you meant to use an after with a negative offset, not a before:

alias: 'Licht aan bij thuiskomst Jos en donker '
description: ''
trigger:
  - platform: device
    device_id: 51c161782681b562ab5b521a547b747b
    domain: device_tracker
    entity_id: device_tracker.iphone_van_jc
    type: enters
    zone: zone.home
condition:
  - condition: sun
    after: sunset
    after_offset: '-01:00:00'
action:
  - service: light.turn_on
    target:
      entity_id: light.dimmable_light_1
mode: single

FYI: An after sunset condition will not work if you get home after midnight. If that is something that you need, you will need both a before and after:

condition:
  - condition: or
      conditions:
        - condition: sun
          after: sunset
          after_offset: '-01:00:00'
        - condition: sun
          before: sunrise
2 Likes