alias: Turn kitchen nightlight on PM
trigger:
  - platform: state
    entity_id: switch.kitchen
  - platform: state
    entity_id: light.ceiling_fan_1
  - platform: state
    entity_id: light.ceiling_fan_2
  - platform: state
    entity_id: binary_sensor.kitchen
  - platform: state
    entity_id: binary_sensor.lr_motion_sensor_over_utility_closet
condition:
  condition: and
  conditions:
    - condition: state
      entity_id: group.presence
      state: 'home'
    - condition: state
      entity_id: sun.sun
      state: 'below_horizon'
    - condition: time
      after: '21:30:00'
    - condition: state
      entity_id: light.ceiling_fan_1
      state: 'off'
    - condition: state
      entity_id: light.ceiling_fan_2
      state: 'off'
    - condition: state
      entity_id: switch.kitchen
      state: 'off'
action:
  service: switch.turn_on
  entity_id: switch.kitchen_nightlight
