Node-Red on OH3

Same here. Waiting for an update on this. :slight_smile:

The NR OH nodes that I’ve used have always supported basic auth, I believe the issue was found to be a change in the REST side of OH. I believe we have to wait for the devs on the NR side to point to the changes on the REST side of OH.

What was posted by someone at github:

subscribtion to events the smarthome has been replaced by openhab:
"/rest/events?topics=smarthome/items", {}); has to become "/rest/events?topics=openhab/items", {});

For anyone following along on NR updates for OH3, looks like node-red-contrib-openhab2 (green nodes) has been updated to connect in with OH3. I have not been successful it making things work on the test system, but a number of other folks have reported success on the github.

1 Like

Correct! I managed as well to get it working. Steps taken:

  • from openhabian install nodered including openhab specific nodes
  • create an api token in OH, use this as username in the config node
  • done!

If not, check you are on version 1.1.8 from the OH node (you can find this in the pallette). If not, reinstall nodered from the openhabian menu.

2 Likes

@lampy Kudos you saved me probably an hour or two trying to figure out how to get the auth to work; as it didn’t occur to me to generate an API and to use that in the username field.

And to also clarify I have the following set on my API Security page, unsure if this is need for NR or the purpose is for something else?

Actually I don’t know if it is really necessary to set the second one, first one is not required.
Mine (default) settings are

For the api security you just use the full token as username and no password? Or do we use the name of the token in user and then the full token within the password? I noticed there is a prefix of oh.username as a part of the token - do we include that text with the rest ?

Thanks for your help! (on and this is for the openhab2 nodes right ? aka green nodes)

Just use the token as username and no password. Yanneck explained it completely here: API
On my phone I can’t make a screenshot of nodered, but you should fill it in when setting up the configuration of the green OH nodes indeed.

To add what @lampy has posted, the password field can be blank with the API token in the user field; and yes you need the prefix of oh.whatIcalledmytoken.random.text.

1 Like

Thanks for all of the help here - something is stuck on my regular install of node-red that was previously going. I think the upgrade or co-existence of my legacy stuff is causing issue. I did a new docker install and everything works perfectly with the new green nodes. Thanks again for your help.

One other question - what is the best way / what is everyone doing to deal with the fact we are now getting UoM with the value on these nodes (ie a dimmer is returning a msg.payload of “67 %” or my current power returns “1.23 kW”) do you just suggest doing a string split based on the space so I can process the number correctly going forward?

In case it helps anyone else - i’ve found that if you happen to have both openhab nodes installed at the same time it doesn’t seem to play nice. My green nodes didn’t return any items until i removed the ‘white nodes’ from the pallete

2 Likes

How can I create the API key in OH3? I have absolutely no experience in REST; I just would like to enable Node Red rule coding in OH3.
Thanks :slight_smile:

Will I get the code from the updated archive when installing Node Red from openhabian?

There is GitHub - QNimbus/node-red-contrib-openhab-v2 vs. GitHub - pdmangel/node-red-contrib-openhab2 where only the latter seems to be the updates one…?

I concur with that. Had to delete all white OH nodes before Greens would work. Many Thanks

1 Like

Please read the link in my post 4 up to yours.

Ah, thanks. Lower left corner… this is hidden very well :wink:

1 Like

My OH3 with Node-Red had issues, the openhab2-get nodes weren’t working, causing “ReferenceError: headers is not defined” error, and I found this alternative OH3 nodeset which you can install from the palette and works without issues: https://flows.nodered.org/node/node-red-contrib-openhab3

I’m liking this Node-Red thing very much. This is the kind of simple visual editing I was looking for to automate the house.

Can anyone vouch the way to get OH3.1 working with nodered again?

I asume the palette that needs to be used is the one with openhab3 in the name (updated last week?)

I can get the event stream but can’t select items…
if you guys have a clear a → b → walkthrough please pin it as an answer :slight_smile:

I used this node via the palette manager:

In OH3 Administration > Settings > System Services > API Security
Verify that Allow Basic Authentication is turned on

Admin (In bottom left) > Create new API token > Create API Token
Create your token, make sure to copy it down before you leave the page

Go into node red and add one of the OH nodes to the flow.
Double click the node
Controller > Click the pencil
Change the OpenHAB version to v3
And paste your token in there.

I think I might have rebooted, then my items started showing up just fine.

2 Likes

Well… I somehow missed the Documentation on how to do this. This will be a better resource and should stay up to date.

1 Like