Blueprints for UPS automations

Anyone who has a blueprint for below cases:

  • Notification when grid loses power and UPS is on battery
  • Trigger script/automation when UPS battery is below x%
  • Notification when grid power is back and UPS is back on charging
  • Trigger script/automation when grid power is back and UPS is back on charging battery
  • Trigger script/automation when UPS battery is charging and going from below x% to above x%
1 Like

No blueprint but i’m building the automations.

alias: UPS - loss netpower
description: ""
trigger:
  - platform: state
    entity_id:
      - sensor.myups_status
    to: OB DISCHRG
    for:
      hours: 0
      minutes: 2
      seconds: 0
condition: []
action:
  - service: notify.telegram
    data:
      message: Power loss!!!! ⚡⚡⚡⚡⚡⚡⚡
mode: single

`

Alerts while runtime is lowering.
Critical msg and shutdown when below setpoint.

Using multiple triggers allows for multiple alerts throughout the countdown.

alias: UPS - Lowering runtime
description: ""
trigger:
  - platform: numeric_state
    entity_id: sensor.myups_battery_runtime
    below: 1800
    above: 1001
  - platform: numeric_state
    entity_id: sensor.myups_battery_runtime
    below: 1000
    above: 601
  - platform: numeric_state
    entity_id: sensor.myups_battery_runtime
    below: 600
    above: 301
  - platform: numeric_state
    entity_id: sensor.myups_battery_runtime
    below: 300
    above: 201
  - platform: numeric_state
    entity_id: sensor.myups_battery_runtime
    below: 200
condition: []
action:
  - if:
      - condition: numeric_state
        entity_id: sensor.myups_battery_runtime
        below: 200
    then:
      - service: notify.telegram_jan
        data:
          message: "Shutting down  🙋‍♂️ "
          title: "Critical UPS runtime  ⚠️⚠️⚠️ "
        alias: Send bye msg
      - delay:
          hours: 0
          minutes: 0
          seconds: 10
          milliseconds: 0
        alias: Delay to get msg sent
      - service: hassio.host_shutdown
        data: {}
        alias: Shutdown
    else:
      - service: notify.telegram
        data:
          message: >-
            Low UPS runtime:  {% set time =
            (states.sensor.myups_battery_runtime.state | int) | int %}{% set
            minutes = ((time % 3600) / 60) | int %}{% set hours = ((time %
            86400) / 3600) | int %}{% set days = (time / 86400) | int %}{%- if
            time < 60 -%}Less than a minute{%- else -%}{%- if days > 0 -%}{{
            days }}d{%- endif -%}{%- if hours > 0 -%}{%- if days > 0 -%}{{ ' '
            }}{%- endif -%}{{ hours }}h{%- endif -%}{%- if minutes > 0 -%}{%- if
            days > 0 or hours > 0 -%}{{ ' ' }}{%- endif -%}{{ minutes }}m{%-
            endif -%} {%- endif -%}{{ ' left' }}. 
        alias: Alert MSG
    alias: Filter Criticality
mode: single

Msg on power restore

alias: UPS - Power restored
description: ""
trigger:
  - platform: state
    entity_id:
      - sensor.myups_status
    to: OL CHRG
condition: []
action:
  - service: notify.telegram_jan
    data:
      message: Power has been restored!
mode: single
1 Like

Thanks for this, I just migrated over to Home Assistant (from Domoticz) and are quickly getting my head around HA. I changed the power restore automation a little:

alias: UPS Mancave - power restored
description: “”
trigger:

  • platform: state
    entity_id:
    • sensor.ups_status
      to: Online
      condition:
      action:
  • service: notify.hans
    data:
    message: >-
    UPS Mancave power has been restored, battery level at
    {{states(“sensor.ups_battery_charge”)}}% {{states(“sensor.ups_status”)}}
    mode: single