Can we please add device_class: reactive_energy in sensor

I have an Eastron SDM120M modbus meter which has a couple of entities which cannot be correctly defined in HA, as per:

  - name: ee11_01
    type: rtuovertcp
    host: 192.168.1.51
    port: 8888
    delay: 0
    message_wait_milliseconds: 30
    timeout: 5
    sensors:

    - name: "EV Charger Import Reactive Energy"
      unique_id: "EV Charger Import Reactive Energy"
      address: 76
      input_type: input
      slave: 100
      precision: 2
      data_type: float32
      unit_of_measurement: kvarh
      device_class: energy
# why is there no reactive_energy !?!?!
      state_class: total_increasing

    - name: "EV Charger Export Reactive Energy"
      unique_id: "EV Charger Export Reactive Energy"
      address: 78
      input_type: input
      slave: 100
      precision: 2
      data_type: float32
      unit_of_measurement: kvarh
      device_class: energy
# why is there no reactive_energy !?!?!
      state_class: total_increasing

    - name: "EV Charger Total Reactive Energy"
      unique_id: "EV Charger Total Reactive Energy"
      address: 344
      input_type: input
      slave: 100
      precision: 2
      data_type: float32
      unit_of_measurement: kvarh
      device_class: energy
# why is there no reactive_energy !?!?!
      state_class: total_increasing

The units etc for the SDM120M can be seen here on page 3:

The units should be: “varh” and “kvarh”

Need to update this to include reactive_energy with “varh” and “kvarh”

Reviewing other power/energy units defined I also see a gap which should be fixed also:

SensorDeviceClass.REACTIVE_POWER only has “var” and should also have “kvar”
SensorDeviceClass.APPARENT_POWER only has “VA” and should also have “kVA”

This is the (same?) issue link which doesnt seem to have been actioned:

This is the error as per current defined “energy”

Logger: homeassistant.components.sensor
Source: components/sensor/__init__.py:731
integration: Sensor ([documentation](https://www.home-assistant.io/integrations/sensor), [issues](https://github.com/home-assistant/core/issues?q=is%3Aissue+is%3Aopen+label%3A%22integration%3A+sensor%22))
First occurred: 15:15:58 (3 occurrences)
Last logged: 15:15:58

* Entity sensor.ev_charger_import_reactive_energy (<class 'homeassistant.components.modbus.sensor.ModbusRegisterSensor'>) is using native unit of measurement 'kvarh' which is not a valid unit for the device class ('energy') it is using; expected one of ['MJ', 'MWh', 'kWh', 'GJ', 'Wh']; Please update your configuration if your entity is manually configured, otherwise create a bug report at https://github.com/home-assistant/core/issues?q=is%3Aopen+is%3Aissue+label%3A%22integration%3A+modbus%22
* Entity sensor.ev_charger_export_reactive_energy (<class 'homeassistant.components.modbus.sensor.ModbusRegisterSensor'>) is using native unit of measurement 'kvarh' which is not a valid unit for the device class ('energy') it is using; expected one of ['MJ', 'MWh', 'kWh', 'GJ', 'Wh']; Please update your configuration if your entity is manually configured, otherwise create a bug report at https://github.com/home-assistant/core/issues?q=is%3Aopen+is%3Aissue+label%3A%22integration%3A+modbus%22
* Entity sensor.ev_charger_total_reactive_energy (<class 'homeassistant.components.modbus.sensor.ModbusRegisterSensor'>) is using native unit of measurement 'kvarh' which is not a valid unit for the device class ('energy') it is using; expected one of ['MJ', 'MWh', 'kWh', 'GJ', 'Wh']; Please update your configuration if your entity is manually configured, otherwise create a bug report at https://github.com/home-assistant/core/issues?q=is%3Aopen+is%3Aissue+label%3A%22integration%3A+modbus%22

Can we add this please?

Thanks

Convert unit?

1 varhour (varh) = 3.6 kJ

and

1J = 2.77778e-7 kWh

Then

1 varh = 3600J = 0.001 kWh = 1Wh

So you can simply use the unit Wh

unit_of_measurement: Wh

1 Like

no this is what the meter has measured as reactive power ie:

Reactive power is power that is reflected back to the grid — as opposed to active power, which is power that is consumed by the load.

These are all the different units that this meter (and most meters) measure:

image

This is another explaination:
https://www.allaboutcircuits.com/textbook/alternating-current/chpt-11/true-reactive-and-apparent-power/

Because it is not important in home consumer billing. It is generally only important in big industry consumer billing so was not considered by the developer.

Note: I am not discounting your FR. I’m just explaining why it has not been considered yet. The units VAh, VAhr and their SI multiples (k, M G) should be added to the energy device class.

1 Like

I understood that, but you could still go down the route of using the unit in Wh or kWh. Then the sensor would work.
You have the name reactive power

1 Like

@apreick - Yes I have done, infact the sensor works and collects data fine it’s just that we get the error in the log and it’s using factually incorrect units (should be “varh”) so needs to be added.

@tom_l - Yes ok great, and agreed this is normally only important in big industry but:

  1. I have seen a number of videos where energy monitoring has been implemented in shared blocks of flats where they had power factor issues so think this is relevant to HA.

  2. These Easton meters are now becoming commonplace in renewable / EV etc situations and the parameters in my post above are all exposed via Modbus so it would be nice to capture + report that into HA (some of it will be useful).

Hope this helps justify this addition to HA.

So double checking the docs here:

we have these for power:

SensorDeviceClass.APPARENT_POWER - VA *
SensorDeviceClass.POWER - W, kW *
SensorDeviceClass.REACTIVE_POWER - var *

(* - as you say @tom_l these seem to be missing other units as per energy below)

and these for energy:

SensorDeviceClass.ENERGY - J, kJ, MJ, GJ, Wh, kWh, MWh, cal, kcal, Mcal, Gcal
SensorDeviceClass.ENERGY_STORAGE - J, kJ, MJ, GJ, Wh, kWh, MWh, cal, kcal, Mcal, Gcal

So nothing for:
SensorDeviceClass.REACTIVE_ENERGY - varh, kvarh (+other sizes)

Thanks in advance :slight_smile:

Correct me if I am wrong Tom, but for adding and/or adapting device_classes, dont we need an architecture discussion?

if you open it there, including example integrations that would benefit in HA, you might be successful.
you would have to open those PR’s yourself though, as that is what is expected from the autor opening an Architecture discussion

Template Helper (Sensor)

No idea. Units have been added to existing device classes after a FR before though.

1 Like