- id: ups_discharging
  alias: '[UPS] Discharging'
  mode: single
  trigger:
    - platform: state
      entity_id: sensor.myups_status_data
      to: OB DISCHRG
  condition: [ ]
  action:
    - service: notify.mobile_app_iphone
      data:
        title: "UPS Alert"
        message: UPS started discharging
    - service: notify.home_assistant
      data:
        message: >
          UPS Alert ⚠️
          UPS started discharging
          @everyone
        target: [ "1109936159951441960" ]

- id: ups_charging
  alias: '[UPS] Charging'
  mode: single
  trigger:
    - platform: state
      entity_id: sensor.myups_status_data
      to: OL CHRG
  condition: [ ]
  action:
    - service: notify.mobile_app_iphone
      data:
        title: "UPS Alert"
        message: UPS is charging
    - service: notify.home_assistant
      data:
        message: >
          UPS Alert ✅
          UPS is charging
          @everyone
        target: [ "1109936159951441960" ]

- id: ups_power_back
  alias: '[UPS] Power back'
  mode: single
  trigger:
    - platform: numeric_state
      entity_id: sensor.myups_input_voltage
      above: '200'
  condition: [ ]
  action:
    - service: notify.mobile_app_iphone
      data:
        title: "UPS Alert"
        message: UPS power is back
    - service: notify.home_assistant
      data:
        message: >
          UPS Alert ⚠️
          UPS power is back
          @everyone
        target: [ "1109936159951441960" ]

- id: ups_battery_under_100
  alias: '[UPS] Battery Under 100%'
  mode: single
  trigger:
    - platform: numeric_state
      entity_id: sensor.myups_battery_charge
      below: '100'
  condition: [ ]
  action:
    - service: notify.mobile_app_iphone
      data:
        title: "UPS Alert"
        message: UPS battery is below 100%, estimated time on battery 25 min
    - service: notify.home_assistant
      data:
        message: >
          UPS Alert ⚠️
          UPS battery is below 100%, estimated time on battery 25 min
          @everyone
        target: [ "1109936159951441960" ]

- id: ups_battery_under_50
  alias: '[UPS] Battery Under 50%'
  mode: single
  trigger:
    - platform: numeric_state
      entity_id: sensor.myups_battery_charge
      below: '50'
  condition: [ ]
  action:
    - service: notify.mobile_app_iphone
      data:
        title: "UPS Alert"
        message: UPS battery is below 50%, estimated time on battery 12 min
    - service: notify.home_assistant
      data:
        message: >
          UPS Alert ⚠️
          UPS battery is below 50%, estimated time on battery 12 min
          @everyone
        target: [ "1109936159951441960" ]

- id: ups_battery_under_10
  alias: '[UPS] Battery Under 10%'
  mode: single
  trigger:
    - platform: numeric_state
      entity_id: sensor.myups_battery_charge
      below: '10'
  condition: [ ]
  action:
    - service: notify.mobile_app_iphone
      data:
        title: "UPS Alert"
        message: UPS battery is below 10%, estimated time on battery 2 min
    - service: notify.home_assistant
      data:
        message: >
          UPS Alert ⚠️
          UPS battery is below 10%, estimated time on battery 2 min
          @everyone
        target: [ "1109936159951441960" ]