Wondering if anyone has a working setup for adding NUTS / UPS to their home assistant energy tab? I was able to do it once, but after a restart home assistant energy complains “unexpected device class”
When I go to the dev tools to query those sensors I get:
sensor.rackups_power_usage
state: 9.0
attributes:
unit_of_measurement: W
friendly_name: deskups_power_usage
device_class: energy
sensor.lab_power_usage
state: unknown
attributes:
state_class: total
source: sensor.deskups_power_usage
friendly_name: desk_power_usage
icon: mdi:chart-histogram
I know that lab_power_usage should be in kWh, but that field is missing.
Every time I restart home assistant I get the log:
Logger: homeassistant.components.integration.sensor
Source: components/integration/sensor.py:132
Integration: integration (documentation, issues)
First occurred: 11:49:09 AM (1 occurrences)
Last logged: 11:49:09 AM
Could not restore last state: [<class ‘decimal.ConversionSyntax’>]
So, I’m wondering if anyone has a working NUTS/UPS config they could share, that hooks into the energy panel?
I have this configured for my light switches but it doesn’t recognize the NUT UPS device type. I wonder if it would be considered a linear power type since the wattage can be anywhere from 0 to max the unit provides.
@Tarlak The example I gave in my post above is working for me. From what I’ve read the legacy method that you’ve used doesn’t play nice with the energy dashboard but the new template integration does.
@Tarlak I can’t say that I really understand the differences either but from my post above here is a link with some discussion on the difference between the legacy template method and the newer template integration. Here is my config, I keep it in configuration.yaml, it’s been working for me.
template:
- sensor:
- name: ups_power_usage
device_class: power
unit_of_measurement: W
state_class: measurement
state: >
{% if states('sensor.ups_status_data') in ['OL', 'OL CHRG'] -%}
{{ (states('sensor.ups_load') | float) / 100 * (states('sensor.ups_nominal_real_power') | float) }}
{%- else -%}
0
{%- endif %}
sensor:
- platform: integration
name: Closet Energy
source: sensor.ups_power_usage
unit_prefix: k
Thank you! This mostly worked as-is - I had to modify the nominal power name to match the states my NUT instance created, and I included my UPS power factor (0.6 from Tripp technical specifications) in the equation.
The sensor above can be added to an usual card but the Energy dashboard ignores it as it is “W” and “measurement” and not “total_increasing”/“kWh”. How do I convert the former to the latter? It needs to accumulate the increasing value somewhere…
Thanks, lets see how it goes!
A couple of questions - does it have to be kW (and not just W) and “hours” (not minutes)? Trying to get my mind around energy sensors requirements in HA.
I wonder if this is the way to fix my Xiaomi power meter from Energy usage calculations do not match
Tried and confused. The energy bashboard says the dishwasher used today 0.15kWh when hovering mouse on top of that item in “monitor individual device”. However, when I click on that sensor, a detailed window opens with the very same sensor with a graph saying 0.81kWh consumed, all today.
Soooo confusing :-/