A YAML script for Home Assistant that will allow you to interface with the Public SNMPv1 to monitor the UPS
Configuration YAML
cyberpower.yaml
sensor: - platform: snmp scan_interval: 60 name: "ups_batterycapacity" host: xxx.xxx.xxx.xxx community: public baseoid: 1.3.6.1.4.1.3808.1.1.1.2.2.1.0 accept_errors: true unit_of_measurement: "%" - platform: snmp scan_interval: 60 name: "ups_load" host: xxx.xxx.xxx.xxx community: public baseoid: 1.3.6.1.4.1.3808.1.1.1.4.2.3.0 accept_errors: true unit_of_measurement: "%" - platform: snmp scan_interval: 60 name: ups_nompower host: xxx.xxx.xxx.xxx community: public baseoid: 1.3.6.1.4.1.3808.1.1.1.4.2.5.0 accept_errors: true unit_of_measurement: W device_class: power - platform: snmp scan_interval: 60 name: ups_nominv host: xxx.xxx.xxx.xxx community: public baseoid: 1.3.6.1.4.1.3808.1.1.1.3.2.1.0 accept_errors: true unit_of_measurement: V device_class: voltage value_template: "{{((value | int) / 10) | int}}" - platform: snmp scan_interval: 60 name: ups_timeleft host: xxx.xxx.xxx.xxx community: public baseoid: 1.3.6.1.4.1.3808.1.1.1.2.2.4.0 accept_errors: true unit_of_measurement: min value_template: "{{((value | int) / 6000) | int}}" - platform: snmp scan_interval: 30 name: ups_status host: xxx.xxx.xxx.xxx community: public baseoid: 1.3.6.1.4.1.3808.1.1.1.4.1.1.0 accept_errors: true value_template: >- {% set status = (value | int) %} {%- if status == 2 -%} Online {%- elif status == 3 -%} On Battery {%- elif status == 4 -%} On Boost {%- elif status == 5 -%} On Sleep {%- elif status == 6 -%} Off {%- elif status == 7 -%} Rebooting {%- elif status == 8 -%} On ECO {%- elif status == 9 -%} On Bypass {%- elif status == 10 -%} On Buck {%- elif status == 11 -%} On Overload {%- else -%} Unknown {%- endif -%} - platform: integration source: sensor.ups_nompower name: ups_nompower_wh unit_time: h method: trapezoidal round: 2 group: ups: name: UPS entities: - sensor.ups_batterycapacity - sensor.ups_load - sensor.ups_status - sensor.ups_nompower - sensor.ups_nominv - sensor.ups_timeleft homeassistant: customize: sensor.ups_batterycapacity: friendly_name: "UPS Battery Capacity" icon: mdi:battery sensor.ups_load: friendly_name: "UPS Load" icon: mdi:percent sensor.ups_nompower: friendly_name: "UPS Nominal Output Power" icon: mdi:flash sensor.ups_nominv: friendly_name: "UPS Nominal Input Voltage" icon: mdi:flash sensor.ups_status: friendly_name: "UPS Status" icon: mdi:information-outline sensor.ups_timeleft: friendly_name: "UPS Time Left" icon: mdi:clock-alert sensor.ups_nompower_wh: friendly_name: "UPS Nominal Output Power wH" icon: mdi:flash unit_of_measurement: Wh device_class: energy
Dashboard YAML
type: vertical-stack cards: - type: markdown content: <h1>Server and Network UPS</h1> - type: horizontal-stack cards: - type: entity entity: sensor.ups_status name: Status - type: entity entity: sensor.ups_batterycapacity name: Battery - type: entity entity: sensor.ups_timeleft name: Time Left - type: horizontal-stack cards: - type: entity entity: sensor.ups_load name: Load - type: entity entity: sensor.ups_nompower name: Consumption
Energy Dashboard
The following sensor can be added to the Energy Dashboard as an Individual Device
- Friendly Name: "UPS Nominal Output Power wH"
- Display Name: "Server & Network"