###################################
##  Late Night lights Section
# @CCOSTAN
# Original Repo : https://github.com/CCOSTAN/Home-AssistantConfig
###################################
- alias: 'Late Night Helper'
  id: acacc9b4-b66d-46d2-bf6d-47b75afddb57
  trigger:
    - platform: state
      entity_id: binary_sensor.downstairs_nest_away
      to: 'off'
    - platform: state
      entity_id: group.family
      to: 'home'

  condition:
    condition: and
    conditions:
      - condition: state
        entity_id: sun.sun
        state: 'below_horizon'
      - condition: state
        entity_id: group.bed
        state: 'off'

  action:
    - service: light.turn_on
      entity_id:
        - light.living_room_slider
        - light.foyer_door
        - light.fridge
        - light.M1_front_right
        - light.S1
        - light.S4
    - service: light.turn_on
      entity_id:
        - light.outdoor_bathroom
      data:
        brightness: 10
    - service: switch.turn_on
      entity_id:
        - group.kitchen_Accents
    - delay: '00:05:00'
    - service: light.turn_off
      entity_id:
        - light.S1
        - light.S4
        - light.foyer_door
        - light.fridge
        - light.living_room_slider
        - light.M1_front_right

    # Only Disarm if armed.  Otherwise, Exit out.
    - condition: state
      entity_id: alarm_control_panel.alexa_guard
      state:
        - armed_away
        - armed_home
        - armed

    - service: alarm_control_panel.alarm_disarm
      entity_id: alarm_control_panel.alexa_guard