Device comes home turn on rear light

g’day i can’t seem to get this to work any advice please? its an iPhone using iOS app and iOS:
its a wemo switch

 #sarah come home turn on rear lights
  - alias: 'Sarah is home'
    trigger:
      platform: state
      entity_id: group.all_devices
      from: 'not_home'
      to: 'home'
      for:
        hours: 0
        minutes: 15
    condition:
        - condition: time
          after: '17:00:00'
          before: '08:00:00'
    action:
      service: switch.turn_on
      entity_id: switch.outside

Try:

 #sarah come home turn on rear lights
  - alias: 'Sarah is home'
    trigger:
      platform: state
      entity_id: group.all_devices
      from: 'not_home'
      to: 'home'
      for:
        minutes: 15
    condition:
        condition: or
        conditions:
          - condition: time
            after: '17:00:00'
          - condition: time
            before: '08:00:00'
    action:
      service: switch.turn_on
      entity_id: switch.outside

Midnight is the change point, so a time can’t be both after ‘17:00:00’ and before ‘08:00:00’.

For similar automations I’ve switched to using the sun condition, so that it tracks sunset and sunrise.

1 Like

thanks @Tinkerer you think this will work then?

# sarah come home turn on rear lights
  - alias: 'Sarah is home'
    trigger:
      platform: state
      entity_id: group.all_devices
      from: 'not_home'
      to: 'home'
      for:
        minutes: 15
    condition:
      condition: sun
      after: sunset
  # Optional offset value
      after_offset: "-1:00:00"
    action:
      service: switch.turn_on
      entity_id: switch.outside

That will turn on switch.outside when the first member of group.all_devices has been home for 15 minutes, between an hour before sunset, to midnight. Unless you have another automation to turn it off, it’ll stay on until you manually turn it off.

Is that what you’re wanting it to do?

1 Like

I’m on mobile so I can’t give you the source code, but I would use the suns altitude angle in a template as the condition. Sunangle less than 0 degrees should do it.

yeah. it has an auto off timer via wemo