OpenHab & Node RED

Hi all.

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[2]

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?


there are very good tutorials

this is one of them…


Do you mean that you are actually typing in that text?

Or leaving the field blank, so that it defaults to using the msg.payload?

For example

This will send out whatever the msg.payload contains (IE the payload of the trigger.)

Whereas the output of this version will send out a string containing the text “msg.payload” regardless of what the incoming payload is.

Meaning that however you trigger that node, the output will be whatever is typed into the last field box.

Valid entries in that field might be

  • ON

  • OFF

  • 0

  • 85

  • 160,100,100


Or whatever the openHAB2 Item accepts.

1 Like

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!!!

1 Like

Thanks Brian.

Congratulations on finding the cause and solution so quickly.

I didn’t know there was an UPPERCASE node, that’ll save a bunch of Change nodes that I’ve got in a few flows.


1 Like