Units of Measurement (UoM) missing: g/m² and Wh/m² (for solar panels monitoring)

Dear openHAB maintainers,

I’ve searched the documentation and the forums, but unfortunatly I can’t find two units of measurement.

I have a sensor returning values in g/m² (for a snow load on photovoltaic panels). The unit is therefore a unit of surface mass, which should be in ArealDensity. Unfortunately, there’s only the DU unit (which I don’t know how to convert into g/m²).
This sensor also provides information in W/m² (Quantity: Intensity, Unit Irradiance), so no problem for this one, but also energy in Wh/m². I can’t find this type of unit either.

What would be a possible solution for specifying these units in openHAB 4?

Thanks in advance for any help.

Stéphane

Have you tried using g/m² with ArealDensity? Units like that often are supported by the UoM library even if not explicitly listed in the docs as supported.

If not file an issue on openhab-core to see if it can be added.

I’m not sure we have a dimension that supports that so definitely file an issue to get that supported. But in a rule if you did the calculation (i.e. divide Wh by m²) the result will have the proper units. I just don’t know if there is an Item that supports that unit.

In the mean time, you can just use a regular old Number Item and set the State Description pattern to show the units in the UI with units. In your rules you can add on the unit before doing any calculations. E.g. in JS Scripting:

var WhPerSqM = Quantity(items.EnergyPerSqM.numericState, 'Wh/m²');

Yes, I tried it before posting, but wihtout any sucess. here is the message in the openhab.log.

Unit 'g/m²' could not be parsed to a known unit. Keeping old unit 'DU' for item 'pv_t7_snow_load1'

Thanks for the second tip. I will tru this (this Wh/m² unit is only use once in my config files which contains around 2600 items).

OK, so I wil post two issues on openhab-core (one for g/m² and one for Wh/m²).

You can operate at unit level too. Its just a bit more complicated - try getting reference to first unit you need - Wh and then divide it by area.

Unit<?> myCustomUnit = org.openhab.core.library.unit.Units.WATT_HOUR.divide(tec.uom.se.unit.Units.SQUARE_METRE) (or similar)