# Vacation Package

# -----------------------------------------------------------------------------
# Vacation Helpers
input_boolean:
  vacation_mode:
    name: Vacation Mode

# -----------------------------------------------------------------------------
# Vacation Automations
automation:
  - alias: Vacation - Turn On Vacation Mode
    trigger:
      - platform: state
        entity_id: input_select.house_presence_state
        to: 'Extended Away'
      - platform: state
        entity_id: alarm.alarm_control_panel
        to: armed_vacation
    action:
      - service: input_boolean.turn_on  
        target:
          entity_id: input_boolean.vacation_mode

  - alias: Vacation - Turn Off Vacation Mode
    trigger:
      - platform: state
        entity_id: input_select.house_presence_state
        to: 'Just Arrived'
      - platform: state
        entity_id: input_select.house_presence_state
        to: 'Home'
    action:
      - service: input_boolean.turn_off
        target:
          entity_id: input_boolean.vacation_mode

  - alias: Vacation - Turn On Dining and Kitchen Lights at Sunset
    trigger:
      - platform: sun
        event: sunset
        offset: '-00:30:00'
    condition: "{{ is_state('input_select.house_presence_state', 'Extended Away') }}"
    action:
      - delay: "00:{{ range(0,59)|random|int }}:00"
      - service: light.turn_on
        target:
          entity_id: light.dining_room_light
      - service: light.turn_on
        target:
          entity_id: light.kitchen_light
      - delay: '02:00:00'
      - service: light.turn_off
        target:
          entity_id: light.dining_room_light
      - service: light.turn_off
        target:
          entity_id: light.kitchen_light


  - alias: Vacation - Turn On Living Room Lights after Dinner
    trigger:
      - platform: time
        at: '18:30:00'
    condition: "{{ is_state('input_select.house_presence_state', 'Extended Away') }}"
    action:
      - delay: "00:{{ range(0,59)|random|int }}:00"
      - service: light.turn_off
        target:
          entity_id: light.dining_room_light
      - service: light.turn_off
        target:
          entity_id: light.kitchen_light
      - service: light.turn_on
        target:
          entity_id: light.living_room_light
      - delay: '02:00:00'
      - service: light.turn_off
        target:
          entity_id: light.living_room_light

  - alias: Vacation - Turn Off Living Room Lights at Bedtime
    trigger:
      - platform: time
        at: '20:30:00'
    condition: "{{ is_state('input_select.house_presence_state', 'Extended Away') }}"
    action:
      - delay: "00:{{ range(0,59)|random|int }}:00"
      - service: light.turn_off
        target:
          entity_id: light.living_room_light
