Mango still not recognizing kWh
-
How come kWh is not recognized? I would think this is one of the most used units in Mango applications.
kW/h is recognized but it is not the same: kiloWatts per hour and kiloWatt hours not the same.
-
The unit of Watts already contains time (Joules/second) so kW/h is most definitely a typo. It should be kWh.
-
I am not so sure that it is a typo, mihairosu. I think sjobbe's interpretation is correct. I see no such kWh in javax.measure.unit and I believe it will try to parse operations in constructing a unit. It really is thinking in terms of kilowatts per hour when you type kW/h. You can just keep adding divisors! Like, kW/h/g is kilowatts per gram-hour. This stuff is in javax.measure.unit, not our code. We can, however, create custom labels.
To get a kWh unit, what needs to be done is add:
public static final Unit<Energy> kWh = SI.JOULE.times(3600000);
and
localFormat.label(kWh, "kWh");
to the obvious places in com.serotonin.m2m2.util.UnitUtil.java and recompileI suspect this is something we'll want to have for everyone, so I have made a github issue for it.
https://github.com/infiniteautomation/ma-core-public/issues/597 -
The other solution is to not use the unit as the suffix. If you are not relying on the "convert for display" option then you can use the suffix property of the Text Renderer to set a suffix of " kWh" for display purposes. Be sure to uncheck the "Use unit as suffix" box!
Edit: Just an edit not to bump, but to Pedro's point kWh --> kW*h
-
Meanwhile, you could type kW*h into the unit field. It is then displayed as kW·h. I use it all the time in the integral field since it is more useful than the default kW·s.
However, if Mango considers kW/h to be an alias for kWh, that should definitely be corrected, as it could cause undetected incorrect numerical conversion issues. In fact, just today I was thinking of writing a function that used kW/s, so the possibility that someone may use kW/h is not out of the question.