automation:
  - id: simon_work_home
    alias: Simon – works from home
    trigger:
      - platform: state
        entity_id:
          - device_tracker.rd0203606
          - device_tracker.simon_jobbdator
    condition:
      - condition: time
        after: "08:00:00"
        before: "17:00:00"
        weekday:
          - mon
          - tue
          - wed
          - thu
          - fri
      - condition: or
        conditions:
          - condition: state
            entity_id: device_tracker.rd0203606
            state: "home"
          - condition: state
            entity_id: device_tracker.simon_jobbdator
            state: "home"
    action:
      - service: input_select.select_option
        target:
          entity_id: input_select.simon_work_state
        data:
          option: "Hemma"

  - id: simon_work_office
    alias: Simon – works at office
    trigger:
      - platform: state
        entity_id:
          - device_tracker.rd0203606
          - device_tracker.simon_jobbdator
    condition:
      - condition: time
        after: "08:00:00"
        before: "17:00:00"
        weekday:
          - mon
          - tue
          - wed
          - thu
          - fri
      - condition: and
        conditions:
          - condition: state
            entity_id: device_tracker.rd0203606
            state: "not_home"
          - condition: state
            entity_id: device_tracker.simon_jobbdator
            state: "not_home"
    action:
      - service: input_select.select_option
        target:
          entity_id: input_select.simon_work_state
        data:
          option: "På jobbet"
