# Alerts Package

# -----------------------------------------------------------------------------
# Alert Automations
automation:
  - alias: Notify if Leak Sensors Trigger
    mode: queued
    trigger:
      - platform: state
        entity_id: binary_sensor.dishwasher_leak_detected
        to: 'on'
      - platform: state
        entity_id: binary_sensor.washer_leak_detected
        to: 'on'
    action:
      - service: notify.everyone
        data:
          message: "{{ trigger.to_state.name }} Triggered"

  - alias: Notify if Garage Fridge Temperature is High
    mode: queued
    trigger:
      - platform: numeric_state
        entity_id: sensor.garage_fridge_refrigerator_temperature
        above: 26.0
      - platform: numeric_state
        entity_id: sensor.garage_fridge_freezer_temperature
        above: 26.0
    action:
      - service: notify.everyone
        data:
          message: "{{ trigger.to_state.name }} is too high, check the power and doors."

  - alias: Notify if Garage Fridge Sensor is Unavailable
    mode: queued
    trigger:
      - platform: state
        entity_id:
          - sensor.garage_fridge_refrigerator_temperature
          - sensor.garage_fridge_freezer_temperature
        to:
          - 'none'
          - 'unavailable'
          - 'unknown'
        for: '00:05:00'
    action:
      - service: notify.everyone
        data:
          message: "{{ trigger.to_state.name }} is unavilable, check the power."

  - alias: Notify if Garage Door Left Open
    mode: queued
    trigger:
      - platform: numeric_state
        entity_id: sun.sun
        attribute: elevation
        below: -4.0
      - platform: state
        entity_id: binary_sensor.house_presence
        to: 'off'
    condition:
      - "{{ is_state('binary_sensor.garage_door', 'on') }}"
    action:
      - service: notify.everyone
        data:
          message: Garage Door is Open
