automation:
  - alias: Lighting · Kitchen · Motion on
    trigger:
      platform: state
      entity_id: binary_sensor.kitchen_motion_occupancy
      to: "on"
    condition:
      condition: state
      entity_id: binary_sensor.georgi_home
      state: "on"
    action:
      - choose:
        # Day Mode
        - conditions:
            - condition: state
              entity_id: input_select.house_mode
              state: 'day'
          sequence:
            - service: light.turn_on
              entity_id: light.browser_kitchen
              data:
                brightness_pct: 100
            - condition: or
              conditions:
                - condition: sun
                  after: sunset
                  after_offset: "-01:00:00"
                - condition: numeric_state
                  entity_id: sensor.dark_sky_cloud_coverage
                  above: 80
            - service: light.turn_on
              entity_id: light.kitchen
              data:
                brightness_pct: 100
        # Night Mode
        default:
          - service: light.turn_on
            entity_id:
              - light.ledvance_1
              - light.hue_ambiance_1
              - light.browser_kitchen
            data:
              brightness_pct: 1

  - alias: Lighting · Kitchen · Motion off
    trigger:
      platform: state
      entity_id: binary_sensor.kitchen_motion_occupancy
      to: "off"
      for:
        minutes: 30
    action:
      - choose:
        # Day Mode
        - conditions:
            - condition: state
              entity_id: input_select.house_mode
              state: 'day'
          sequence:
            - service: light.turn_off
              entity_id: light.kitchen
            - service: light.turn_on
              entity_id: light.browser_kitchen
              data:
                brightness_pct: 1
        # Night Mode
        default:
          - service: light.turn_on
            entity_id:
              - light.ledvance_1
              - light.hue_ambiance_1
            data:
              brightness_pct: 100
          - service: light.turn_off
            entity_id:
              - light.ledvance_1
              - light.hue_ambiance_1
          - service: light.turn_on
            entity_id: light.browser_kitchen
            data:
              brightness_pct: 1
