homeassistant:
  customize:
    timer.timer_bathroom_aroma:
      hidden: true
    timer.timer_downstairs_aroma:
      hidden: true
    timer.timer_upstairs_aroma:
      hidden: true

timer:
  timer_bathroom_aroma:
    duration: '00:30:00'
  timer_downstairs_aroma:
    duration: '01:00:00'
  timer_upstairs_aroma:
    duration: '01:00:00'

###############################################################################
#                _                        _   _                 
#     /\        | |                      | | (_)                
#    /  \  _   _| |_ ___  _ __ ___   __ _| |_ _  ___  _ __  ___ 
#   / /\ \| | | | __/ _ \| '_ ` _ \ / _` | __| |/ _ \| '_ \/ __|
#  / ____ \ |_| | || (_) | | | | | | (_| | |_| | (_) | | | \__ \
# /_/    \_\__,_|\__\___/|_| |_| |_|\__,_|\__|_|\___/|_| |_|___/
#                                                                              
###############################################################################

automation:

#
# Automations to start timer when they are switched ON
#
  - alias: Bathroom Aroma Timer Start
    initial_state: true
    trigger:
      - platform: state
        entity_id: switch.downstairs_fragrance
        from: 'off'
        to: 'on'
    action:
      - service: timer.start
        entity_id: timer.timer_bathroom_aroma

  - alias: Bathroom Aroma Timer Finish
    initial_state: true
    trigger:
      - platform: state
        entity_id: switch.downstairs_fragrance
        from: 'on'
        to: 'off'
    action:
      - service: timer.finish
        entity_id: timer.timer_bathroom_aroma

  - alias: Downstairs Aroma Timer Start
    initial_state: true
    trigger:
      - platform: state
        entity_id: switch.downstairs_fragrance
        from: 'off'
        to: 'on'
    action:
      - service: timer.start
        entity_id: timer.timer_downstairs_aroma

  - alias: Downstairs Aroma Timer Finish
    initial_state: true
    trigger:
      - platform: state
        entity_id: switch.downstairs_fragrance
        from: 'on'
        to: 'off'
    action:
      - service: timer.finish
        entity_id: timer.timer_downstairs_aroma

  - alias: Upstairs Aroma Timer Start
    initial_state: true
    trigger:
      - platform: state
        entity_id: switch.upstairs_fragrance
        from: 'off'
        to: 'on'
    action:
      - service: timer.start
        entity_id: timer.timer_upstairs_aroma

  - alias: Upstairs Aroma Timer Finish
    initial_state: true
    trigger:
      - platform: state
        entity_id: switch.upstairs_fragrance
        from: 'on'
        to: 'off'
    action:
      - service: timer.finish
        entity_id: timer.timer_upstairs_aroma

#
# Timer Elapsed Events
#
  - alias: Bathroom Aroma Timer Elapsed
    initial_state: true
    trigger:
      - platform: event
        event_type: timer.finished
        event_data: 
          entity_id: timer.timer_bathroom_aroma    
    action:
      - service: switch.turn_off
        entity_id: switch.downstairs_fragrance

  - alias: Downstairs Aroma Timer Elapsed
    initial_state: true
    trigger:
      - platform: event
        event_type: timer.finished
        event_data: 
          entity_id: timer.timer_downstairs_aroma    
    action:
      - service: switch.turn_off
        entity_id: switch.downstairs_fragrance

  - alias: Upstairs Aroma Timer Elapsed
    initial_state: true
    trigger:
      - platform: event
        event_type: timer.finished
        event_data: 
          entity_id: timer.timer_upstairs_aroma    
    action:
      - service: switch.turn_off
        entity_id: switch.upstairs_fragrance

#
# Turn ON fragrance outlets automatically at specific times of the day
#
  - alias: Turn On Upstairs Aroma
    trigger:
      - platform: time
        at: '08:00:00'
      - platform: time
        at: '20:00:00'
    action:
      - service: switch.turn_on
        entity_id: switch.upstairs_fragrance

  - alias: Turn On Downstairs Aroma
    trigger:
      - platform: time
        at: '17:00:00'
    action:
      - service: switch.turn_on
        entity_id: switch.downstairs_fragrance