node-red-contrib-nest icon indicating copy to clipboard operation
node-red-contrib-nest copied to clipboard

Streaming mode returns stringified data rather than JSON

Open hjespers opened this issue 8 years ago • 7 comments

streaming mode does not parse the data into JSON like the none-streaming mode. Need to fix this datapath to match non-streaming

hjespers avatar Aug 30 '16 19:08 hjespers

Hi, thanks for this great plugin. I'm facing the same problem with the stringified data in streaming mode. Node-red isn't able to turn the string into a valid json object, so i'm not able to use the data generated. Would be nice to see a fix for this bug.

Planning on a node-red nest -> mqtt publisher to make my nest thermostat platform independent.

Besides that; disabling streaming (setting false) still generates the null messages for me. So it appears to be an ignored setting.

rtenklooster avatar Jan 22 '17 11:01 rtenklooster

If I put a node-red json node inline right after the output of my nest node and it converts the stringified data back into JSON for me. I know it's nopt ideal and that streaming and non-streaming modes should produce consistent output formats but at least for now you should be able to use both.

hjespers avatar Jan 23 '17 21:01 hjespers

I see the problem. You can convert back to JSON but the data is now in msg.payload.data instead of msg.payload so you also need change all your downstream logic (or insert another node that copies into contents of msg.payload.data into msg.payload).

hjespers avatar Jan 23 '17 21:01 hjespers

Thanks, i gave it a try, appears to be working indeed thanks a lot :)

rtenklooster avatar Jan 25 '17 18:01 rtenklooster

Sorry that's it so cumbersome and difficult to switch between non-streaming and streaming. That is what this issue is a reminder for me to fix. Also, don't expect that streaming ever stops unless you kill and restart node-red. Once a streaming subscription is made it is not ever destroyed, even if you switch back to non-streaming in the nest node.

hjespers avatar Jan 25 '17 18:01 hjespers

Is there a reason to use streaming mode at all rather than an inject node on an interval?

PaulWieland avatar Jan 04 '18 16:01 PaulWieland

An inject node on an interval will poll for data every interval even if it has not changed. Streaming mode will only send data when there is a change in one of the fields so it's lower latency and less unnecessary polling. Use whichever mode you feel fits your use case, that's why they are both there.

hjespers avatar Jan 04 '18 17:01 hjespers