I’m struggling big time with Node-RED and I’m looking for some assistance.
This is my first flow with Node-RED and OpenHAB. I’ve got an Amazon Echo binding, which is working fine, so when I say “Turn on Brian Test” the debug out of the Echo node says:
msg.payload : string
When I put the payload field in the Openhab-Out node to “msg.payload” (assuming now msg.payload = off) and tigger the cycle, I get a 400 error. When I put “off” in the payload statically, Openhab works as expected.
I’m stumped. What am I missing here to get the payload read by the Openhab-Out node properly?
Putting the payload field blank is where I started because I assumed that’s what would happen…whatever is in msg.payload will be sent.
I’m about to fire up some packet captures and see what’s going on “on the wire”. Even in the error message on the openhab2-out node, it says has a content-length header equal to “2”. So “on” makes sense to be in there.
In the 400 error: Problem accessing /rest/items/Great_Room_Fan_1. Reason:\n<pre> Bad Request</pre>
But putting “on” in the payload field works! Logically it must be a malformed incoming payload, but it just doesn’t make sense since msg.payload is a string type of “on”.
Even following the tutorials I THINK I’m doing it all right.
OK. I figured it out. I feel stupid, kinda sorta not really.
Looked at my data and experiments. Payload of “ON” worked. Payload of “on” didn’t work. It appears the openhab2 REST API doesn’t like ON or OFF in lower case. I added an uppercase function in the flow and all is happy!!!