Hello - recently recevied a Glow Display CAD, and have it sending import, export energy and power into MQTT. Somewhat annoyingly however, the value’s unit of measure can switch between watts and kilowatts (and presumably kilowatt hours and megawatt hours). The unit of measure is available in the same JSON object as the value. Is there a simple way of normalising the value’s unit of measure when the MQTT topic is read and income transformation is applied? Or do I need to have an intermediate item which a rule then converts into watts?
Given your JSON above that will return "0.555 kW".
I think you will want to remove the units property from your MQTT Thing if you are using it. But then you will want to make sure to use an appropriate Item type (e.g. Number:Power) and set the unit metadata to what you want to normalize to (e.g. W).
With this configuration your Item will always be converted to W no matter what unit the meter reports.
This could be made into a one-liner to use as an inline transform, but you’ll have to parse the input twice.