Closed jtmoderate876 closed 7 years ago
This should be a plain JSON object, not a string containing JSON. I'll fix this as soon as possible.
I think github modifies the my payload when I paste so here is an image:
And here it is with via "insert code":
{ "topic": "smarthome/items/OutHoliday322AOF/statechanged", "payload": "{\"type\":\"OnOffType\",\"value\":\"OFF\",\"oldType\":\"OnOffType\",\"oldValue\":\"ON\"}", "type": "ItemStateChangedEvent", "_msgid": "647d15ec.9b82ec" }
Thanks for looking into it and again - I could just be doing something wrong
It was an issue in the code. The payload is delivered as String by openhab, and not as JSON object. I've fixed this in version 0.0.4 of the nodes. Please update your nodes.
I upgraded the node-red-contrib-openhab to 0.0.4 but still get strange payload of
{ "topic": "OutHoliday322AOF", "payload": "{\"type\":\"OnOffType\",\"value\":\"ON\"}", "type": "ItemStateEvent", "_msgid": "cb70f70f.348f08" }
What am I doing wrong?
Where do you copy this code from? Try adding an openhab input node, only connected to a debug node. Take a look in your debug console. Is the payload field expandable, or is it just a string?
I copied the msg from the debug menu as you suggest - but my Node_RED with PI doesn't have the debug Expand feature.
I wonder if it has something to do with that I am using the node_RED version that comes with Raspberry Pi - which is not the latest.
In this version it doesn't have the expandable payload functionality in the debug menu that the latest node-RED has.
I'll try an upgrade from Pi Node-RED to latest node-RED and report back.
Thx for your continued attention.
Michael, it was my version of either node-RED, node.js or something else - I suspect node.js. I am sorry I wasted your cycles on this but hopefully someone else will find this.
I upgraded my RPI node_RED using:
upgrade-nodejs-and-nodered
from command prompt and 20 minutes later everything was working including payload format and upgraded node-RED debut window:
Thank you.
Hi Jeff,
glad you found the issue :-)
Michael,
Why does the payload format have odd (escape?) characters and how do I handle those in Node-RED? For example:
{ "topic": "smarthome/items/OutHoliday322AOF/state", "payload": "{\"type\":\"OnOffType\",\"value\":\"ON\"}", "type": "ItemStateEvent", "_msgid": "a3bdd06.f5c423" }
I'm not a seasoned javascript nor Node-RED guy so please share even if the answer is obvious to you.