iOS device tracking

Allright. I’ve searched several topics and I’m new to Hass.io. For now it’s a lot of fun, but I’m stuck on something - I guess - easy for you guys.

I want just a simpe thing to start with.

  • When I’m at home and the sun is down, turn on the lights. So far so good with this automation:
- action:
  - data:
      entity_id: light.tradfri_group_4
    service: homeassistant.turn_on
  alias: Thuis na zonsondergang
  condition:
  - condition: state
    entity_id: device_tracker.xxx
    state: home
  id: 'xxx'
  trigger:
  - event: sunset
    platform: sun

But I also want, when I’m not at home for example five minutes, to turn the lights out. I’ve found something like this, But I’m not able to get this working:

condition:
  condition: state
  entity_id: device_tracker.paulus
  state: not_home
  # optional: trigger only if state was this for last X time.
  for:
    hours: 1
    minutes: 10
    seconds: 5

Never mind; got it working finally

- action:
  - data:
      entity_id: light.tradfri_group_4
    service: homeassistant.turn_on
  alias: Thuis na zonsondergang
  condition:
  - condition: state
    entity_id: device_tracker.xxxxxx
    state: home
  id: '15131281266523'
  trigger:
  - event: sunset
    offset: -00:45:00
    platform: sun
- action:
  - data:
      entity_id: group.all_lights
    service: homeassistant.turn_off
  alias: Lampen uit als ik weg ben
  condition: []
  id: '15134121122964'
  trigger:
  - entity_id: device_tracker.xxxxxx
    from: home
    platform: state
    to: not_home
- action:
  - data:
      entity_id: media_player.huiskamer
    service: homeassistant.turn_off
  alias: TV aan = Sonos uit
  condition: []
  id: '151312121292312'
  trigger:
  - entity_id: media_player.tv_woonkamer
    platform: state
    to: playing