Hi,
After trying the other versions around I came to the conclusion I could either have my CyberPower UPS in Home Assistant or have the default Web UI.
This is how I managed to have my cake and eat it.
Web UI, useful for changing settings etc…
We need to get our Bearer token to integrate with Home Assistant.
I used chrome for this but I’m sure other browsers have similar options.
In Chrome go to the View menu - Developer - Developer Tools and the Dev panel should open to the right hand side. Under the Network Tab then Headers Tab you will see the Request Headers Section, your Authorization token can be found here. Copy this for use later.
Note: If you click on the Response tab, you will find all the available status options (attributes) available which can be added as sensors.
Lets set up some sensors!
The main status sensor to which child sensors can be created.
- platform : rest
resource: http://<IPADRESS>:3052/local/rest/v1/ups/status
name: Server UPS
headers:
Authorization: <BEARER-TOKEN-COPIED-EARLIER>
User-Agent: Home Assistant
Content-Type: application/json
value_template: '{{ value_json["battery"]["stateText"] }}'
json_attributes:
- input
- output
- battery
- bypass
- system
- onlyPhaseArch
- communicationAvaiable
- <Add any other attributes found in response tab>
Now we can create seperate sensors like this using our above main sensor.
- platform: template
sensors:
ups_mains_voltage:
friendly_name: UPS Mains Voltage
unit_of_measurement: "V"
value_template: "{{ state_attr('sensor.server_ups', 'input')['voltages'][0] | replace(' V','') | float | round(0)}}"
ups_load_percent:
friendly_name: UPS Load Percent
unit_of_measurement: "%"
value_template: "{{ state_attr('sensor.server_ups', 'output')['loads'][0] | replace(' %','') | float | round(0)}}"
ups_load_watts:
friendly_name: UPS Load Watts
unit_of_measurement: "W"
value_template: "{{ states('sensor.ups_load_percent') | float / 100 * 550 | round(0)}}"
ups_battery_voltage:
friendly_name: UPS Battery Voltage
unit_of_measurement: "V"
value_template: "{{ state_attr('sensor.server_ups', 'battery')['voltage'] | replace(' V','') | float | round(0)}}"
ups_battery_capacity:
friendly_name: UPS Battery Capacity
unit_of_measurement: "%"
value_template: "{{ state_attr('sensor.server_ups', 'battery')['capacity'] | replace(' %','') | float | round(0)}}"
ups_battery_runtime:
friendly_name: UPS Battery Runtime
unit_of_measurement: "min"
value_template: "{{ state_attr('sensor.server_ups', 'battery')['remainingRunTimeInSecs'] | float / 60 | round(0)}}"
I hope someone finds this useful.