Calculate the difference with adjusted values

Hello everyone,
I would like to measure how much real green electricity I put into my car. I currently have 2 values ​​available to me.
Value 1
comes per second and is quite ok so far. E.g. I have a surplus, the value looks like this: -123 <- This means that I currently have a surplus of -123 watts.
123 would mean that I don't have any surplus and that I currently get my electricity from the power grid.
Unfortunately, the second value is currently a bit complicated. I get it from my socket. The value is always positive because I charge my car there. The problem is that the value currently looks like this in reference to above:
The actual wattage is followed by another 3 digits. First I would have to manage to shorten this number by 3 digits.
Since I would then have the value that the car is charging, I could use this value to check whether I am currently refueling green, half green or not at all via the solar system.
Can someone tell me how I can do this? It would be enough if I managed to put a comma in three places at the end! It would be important from behind because the value in front of it can also have several digits

Is 123555 a string or a number? and is -123 a string or a number? show debug outputs of these. strings would be red and numbers blue.

anyone arte blue...

Then using a change node and JSONata

[{"id":"e11d3d5bc71875ce","type":"inject","z":"d1395164b4eec73e","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"charge","payload":"123555","payloadType":"num","x":180,"y":1460,"wires":[["d6bec0522bf975dc"]]},{"id":"d6bec0522bf975dc","type":"change","z":"d1395164b4eec73e","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"$floor($$.payload/1000)","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":360,"y":1460,"wires":[["b195995ea937cdde"]]},{"id":"b195995ea937cdde","type":"debug","z":"d1395164b4eec73e","name":"debug 2456","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":610,"y":1380,"wires":[]}]

If you divide 123555 by 1000 and $floor() it, result is 123

You could also use JSONata direct in a switch node property config.

Thank you! it works fine

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.