I'm not sure if I should be converting from a string to a number or just stripping out some characters.
Any help would be greatly appreciated
.
I'm not sure if I should be converting from a string to a number or just stripping out some characters.
Any help would be greatly appreciated
.
I'm looking at statusCode
so my guess is, you're using the HTTP Request
Node?
if so, set it to output an object
not much to go on given your description, but its the best I can do.
Yes I am pulling the data using HTTP Request from our hydro utility. If I do set it to JSON I get a parse error, the error is when I'm sending it to a BACnet AV, I can send a standard number, but not this one
Ok, you need to supply the original payload that you receive from the HTTP Request.
Currently, we do not have enough information.
Please provide payload between that you need to convert between 3 back ticks
```
Original Payload
```
OR as a quick win.
if you are already extracting the number value, convert it before sending to BACnet
/* Based on your 14,628 MW value */
msg.payload = parseFloat(msg.payload.substring(0,msg.payload.length-3).replace(",","."))
return msg
[{"id":"3ec6499fe536f81c","type":"inject","z":"2d7bf6e3.84c97a","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"14,628 MW","payloadType":"str","x":340,"y":820,"wires":[["02d5ce2081c95338"]]},{"id":"6f43d1a951073d77","type":"debug","z":"2d7bf6e3.84c97a","name":"debug 2","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":795,"y":820,"wires":[]},{"id":"02d5ce2081c95338","type":"function","z":"2d7bf6e3.84c97a","name":"Convert","func":"/* Based on your 14,628 MW value */\nmsg.payload = parseFloat(msg.payload.substring(0,msg.payload.length-3).replace(\",\",\".\"))\nreturn msg","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":525,"y":820,"wires":[["6f43d1a951073d77"]]}]
Thank you, works perfectly...
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.