- id: skab_claus_motion_lys
  alias: Lys skab Claus
  mode: restart

  trigger:
    - platform: state
      entity_id: binary_sensor.hue_motion_sensor_1_motion
      to: "on"

  condition:
    - condition: numeric_state
      entity_id: sensor.hue_motion_sensor_1_illuminance
      below: 90

  action:
    - choose:
        - conditions:
            - condition: time
              after: "06:00:00"
              before: "23:59:00"
          sequence:
            - service: light.turn_on
              target:
                entity_id: light.skab_1
              data:
                brightness_pct: 100
                rgb_color: [20, 255, 127]
      default:
        - service: scene.turn_on
          target:
            entity_id: scene.skab_daempet

- id: skab_claus_motion_sluk
  alias: Sluk lys i skab Claus
  mode: restart

  trigger:
    - platform: state
      entity_id: binary_sensor.hue_motion_sensor_1_motion
      to: "off"

  action:
    - wait_for_trigger:
        - platform: state
          entity_id: binary_sensor.hue_motion_sensor_1_motion
          to: "on"
      timeout: "00:01:00"
      continue_on_timeout: true
    - condition: state
      entity_id: binary_sensor.hue_motion_sensor_1_motion
      state: "off"
    - service: light.turn_off
      target:
        entity_id: light.skab_1

- id: skab_anne_motion_lys
  alias: Lys skab Anne
  mode: restart

  trigger:
    - platform: state
      entity_id: binary_sensor.motion
      to: "on"

  condition:
    - condition: numeric_state
      entity_id: sensor.hue_motion_sensor_1_illuminance_2
      below: 90

  action:
    - choose:
        - conditions:
            - condition: time
              after: "06:00:00"
              before: "23:59:00"
          sequence:
            - service: light.turn_on
              target:
                entity_id: light.skab_1
              data:
                brightness_pct: 100
                rgb_color: [254, 11, 255]
      default:
        - service: scene.turn_on
          target:
            entity_id: scene.skab_daempet

- id: skab_anne_motion_sluk
  alias: Sluk lys i skab Anne
  mode: restart

  trigger:
    - platform: state
      entity_id: binary_sensor.motion
      to: "off"

  action:
    - wait_for_trigger:
        - platform: state
          entity_id: binary_sensor.motion
          to: "on"
      timeout: "00:01:00"
      continue_on_timeout: true
    - condition: state
      entity_id: binary_sensor.motion
      state: "off"
    - service: light.turn_off
      target:
        entity_id: light.skab_1
