  - alias: 'Lys soveværelse dag - arbejdsdag - sunrise'
    trigger:
      platform: time
      at: '06:00:00'
    condition:
      - condition: state
        entity_id: binary_sensor.arbejdsdag
        state: 'on'
    action:
      - service: script.sunrise


  - alias: 'Lys soveværelse dag - arbejdsdag'
    trigger:
      platform: state
      entity_id: binary_sensor.hue_motion_sensor_1_motion_2
      to: 'on'
    condition:
      - condition: numeric_state
        entity_id: sensor.hue_motion_sensor_1_illuminance_2
        below: 90
      - condition: state
        entity_id: binary_sensor.arbejdsdag
        state: 'on'
      - condition: time
        after: '06:30:00'
        before: '20:00:00'
    action:
      - service: homeassistant.turn_on
        target: 
          entity_id: light.sovevaerelse_2
        data:
          brightness_pct: 100

  - alias: 'Lys soveværelse dag - ikke arbejdsdag'
    trigger:
      platform: state
      entity_id: binary_sensor.hue_motion_sensor_1_motion_2
      to: 'on'
    condition:
      - condition: numeric_state
        entity_id: sensor.hue_motion_sensor_1_illuminance_2
        below: 90
      - condition: state
        entity_id: binary_sensor.arbejdsdag
        state: 'off'
      - condition: time
        after: '10:00:00'
        before: '20:00:00'
    action:
      - service: homeassistant.turn_on
        target: 
          entity_id: light.sovevaerelse_2
        data:
          brightness_pct: 100
          
  - alias: 'Lys soveværelse aften'
    trigger:
      platform: state
      entity_id: binary_sensor.hue_motion_sensor_1_motion_2
      to: 'on'
    condition:
      - condition: numeric_state
        entity_id: sensor.hue_motion_sensor_1_illuminance_2
        below: 90
      - condition: time
        after: '20:00:01'
        before: '21:00:00'
    action:
      - service: homeassistant.turn_on
        target: 
          entity_id: light.sovevaerelse_2
        data:
          brightness_pct: 50

  - alias: 'Lys soveværelse godnat'
    trigger:
      platform: state
      entity_id: binary_sensor.hue_motion_sensor_1_motion_2
      to: 'on'
    condition:
      - condition: numeric_state
        entity_id: sensor.hue_motion_sensor_1_illuminance_2
        below: 90
      - condition: time
        after: '21:00:01'
        before: '22:00:00'
    action:
      - service: scene.apply
        data: 
          entities:
            light.sov_dor:
              state: "on"
              brightness_pct: 30
              rgb_color:  [255, 7, 129]          
            light.sov_midt:
              state: "on"
              brightness_pct: 30
              rgb_color:  [255, 7, 129]          
            light.sov_vindue:
              state: "on"
              brightness_pct: 30
              rgb_color:  [255, 7, 129]          

  - alias: 'Lys soveværelse godnat 2'
    trigger:
      platform: state
      entity_id: binary_sensor.hue_motion_sensor_1_motion_2
      to: 'on'
    condition:
      - condition: numeric_state
        entity_id: sensor.hue_motion_sensor_1_illuminance_2
        below: 90
      - condition: time
        after: '22:00:01'
        before: '23:00:00'
    action:
      - service: scene.apply
        data: 
          entities:
            light.sov_dor:
              state: "on"
              brightness_pct: 25
              rgb_color:  [255, 7, 129]          
            light.sov_vindue:
              state: "on"
              brightness_pct: 25
              rgb_color:  [255, 7, 129]          

  - alias: 'Lys soveværelse godnat 3'
    trigger:
      platform: state
      entity_id: binary_sensor.hue_motion_sensor_1_motion_2
      to: 'on'
    condition:
      - condition: numeric_state
        entity_id: sensor.hue_motion_sensor_1_illuminance_2
        below: 90
      - condition: time
        after: '23:00:01'
        before: '23:30:00'
    action:
      - service: scene.apply
        data: 
          entities:
            light.sov_midt:
              state: "on"
              brightness_pct: 1
              color_temp: 500
              rgb_color:  [255, 7, 129]          
          

  - alias: 'Sluk lys i soveværelse'
    trigger:
      platform: state
      entity_id: binary_sensor.hue_motion_sensor_1_motion_2
      to: 'off'
      for:
        minutes: 5
    condition:
      - condition: time
        after: '06:30:00'
        before: '22:00:00'
    action:
      - service: homeassistant.turn_off
        data:
          entity_id:
            - light.sovevaerelse_2

