Hi,
I have a P1 gatway that sends information to Domoticz to a device I named Energy.
I created also a node red script that is subscribed to domoticz/out. It receives the packages from Energy, but te data I need is in svalue format
"Battery: 255
RSSI: 12
description: ""
dtype: "P1 Smart Meter"
hwid: "84"
id: "1"
idx: 651
name: "Energy"
nvalue: 0
stype: "Energy"
svalue1: "1970425"
svalue2: "1212286"
svalue3: "555504"
svalue4: "1361336"
svalue5: "411"
svalue6: "0"
unit: 1
I would like to sum svalue1 and svalue2 with 3 decimals and display it on a Oled display.
I want to do the same with svalue3 and svalue4. So I need to convert the values to floats, I think.
To test the setup I have a MQTT import device, that actually gets data and a OLED device that displays it. But the normal formula's do not work here.
How can I format the data as described above?
Display string values as floats
Moderators: grovkillen, Stuntteam, TD-er
Re: Display string values as floats
See this part of the docs: https://espeasy.readthedocs.io/en/lates ... red-values
Does that help?
Does that help?
Re: Display string values as floats
This is very helpful, but I am not there yet.
The values I obtain with MQTT device, are the svalue bits in the JSON string.
The come like 1234567, but I want to show them as 1234.567.
I cannot simply divide, because the values are in string format.
On the other hand, I would like to sum two values. For that, I need them in a float format as well.
The values I obtain with MQTT device, are the svalue bits in the JSON string.
The come like 1234567, but I want to show them as 1234.567.
I cannot simply divide, because the values are in string format.
On the other hand, I would like to sum two values. For that, I need them in a float format as well.
Re: Display string values as floats
In the Rules engine of ESPEasy, you can just use these values as if they where floats
/Ton (PayPal.me)
Re: Display string values as floats
Doesn't the import plugin trigger events which you can act on in the rules?
Re: Display string values as floats
It does, but in the current version only when there is a numeric value found (must be convertable to float or else it will be discarded, and no event generated)
/Ton (PayPal.me)
Who is online
Users browsing this forum: No registered users and 3 guests