Tuya Power Socket via MQTT, consumption

Hey Forum,
I tried to configure a Tuya Smart Power Socket with TuyApi and MQTT. Following the instructions here in the forums I managed to get it up and running, but now I am stuck with following problem(s).
1.) The Power submitted is tenfold too big. So if he real power is 150,7W it shows 1507. I tried state descriptions in hundreds of different ways, somehow I don’t get it to work.
The item is Number:Power, class is Equipment_PowerOutlet.
Adding “%d W” to state description does not work, so I tried the metric prefixes. %d kW gives the right number (150,7) but then the unit is incorrect (it is shown as kW, but in real it’s W). The strange thing: next time the item is updated it kind of looses the calculation but still displays the wrong Unit (so if in real world it updates from 150,7 W to 160 W it shows 150,7 kW to 1600 kW in Openhab). What am I missing?

2.) The power socket is also reporting kWh to the Tuya Cloud. That is done via DP ID 17. It’s identifier is “add_ele” and that’s what it does. It reports every now and then how much kWh was used and sends that to the Tuya server (where it is stored and can be made visible via their smart life app). I’d love to use that in openhab, too. I don’t know how to set the item up so that it aggregates the data.

Would love to hear your input, I don’t see the wood for the trees…

Add a JavaScript transformation and divide the value by 10

Wow, that was indeed an easy solution! Thanks a lot, now it finally shows correct value and correct unit :slight_smile:
Any ideas on the second problem? I thought about InfluxDB+Grafana (used that with Openhab2 and Temperature), but then still I’d need to reset the items value and midnight to 0 (and I have no clue how to do that)