Device delivering Wh, not kWh, how to deal with, scaling factor

Hello,

I have a Smart Meter, which I read with SMLReader from Github, delivering the data via MQTT.
It is pushing the power meter data in Wh, not kWh.
Of course, it is open source and I could change it, but is there another way to change it in Homey?
What would be the best way? A virtual device with some flow?
For me the easiest way would be a scaling factor in the MQTT device, but I don’t see this possibility.

Regards, Metatron

You’re not the first to ask for this functionality in the MQTT Device. I’ll consider adding mathjs to the mix. So allow a calculation/expression somehow to transform the incoming message to the correct capability format.

In case of using a flow, you could do this
Create a variable, type numeric
I named it 'Watth 2 kWh

In the example flow, the trigger is “If power changed” from my converter.

Then I calculate ‘Watth 2 kWh’ as ‘vermogen’ (=power) divided by 1,000

Example flow

Using a flow, the case of @Metatron would be:

  1. Create a virtual device with the measure_power capability
  2. Use the ‘on message received’ flow card from the MQTT Client app, to listen to the mqtt topic containing the power value.
  3. (If JSON) grab the value from the JSON input
  4. Convert Wh to kWh
  5. Update the capability of the virtual device
  6. Repeat for all capabilities of the device

This is exactly what the MQTT device from the MQTT Hub handles for you. Of course with the exception of the conversion (step 4), hence this thread. Adding this as a configuration option for the MQTT Device is a valid request.

@Metatron math expressions are implemented in MQTT Hub v3.4.0.

For an example see:

This is exactly what I wanted/needed, thank you!
So fast, I am impressed!