Node-RED as a rule/script engine for openHAB

One easy option to facilitate that solution is to add updates of existing packages to the nodered openHABian routine. If you agree, please open an issue in the openHABian issue tracker

yes makes sense. Just opened issue. Thanks !!

https://github.com/openhab/openhabian/issues/213

@rgerrans any chance you could join the discussion?

I’ll take a look later today/this evening to see if I can help. I have the same issue with some of the default nodes (like RBE just updated) included in a regular node-red install and it’s been on my to-do list to go figure out how to update them independent of a full node-red update.

Hi all,

I found this thread while searching for a hint for my rule issue. However, node-Red looks interesting to me.
Maybe a stupid question, but I wonder how to setup it in my current installation (I’m not using openhabian).
Do I have to setup a node red installation and then install this openhab conrtribution?

Is there any tutorial to setup everything from scratch in a openhab 2 installation on ubuntu?

Thanks in advance.

BR Marcel

Here you go. Here are the official docs on how to get it up and running. Feel free to throw out any questions as you get it going. - https://nodered.org/docs/getting-started/installation

Here is the tutorial I put together on how to replace your OH rules functionality with Node-Red equivalents:

Thanks that helped me. Installed it so far. After vacation I will try to convert my rules.

Hi,

I wanted to implement the first flow. Somehow I don’t get any item in the controller node. I have checked the REST API via browser and I found and error the JSON error tells me

{"schemaValidationMessages":[{"level":"error","message":"Can't read from file http://192.168.0.10:8080/rest/swagger.json"}]}

I’m on OpenHab 2.1 stable release. Do you think this is related to this? Basic UI and everything else works fine.

Thanks for your help.

BR Marcel

Ok, I found the problem. I have some items with state null. Then I have to save first my flow as described here. Now I can select items. :slight_smile:

1 Like

@rgerrans just updated my node-red modules and my OH2 install and it broke the openhab 2 write node. the read nodes are working fine.

The write nodes that were working fine before now report “request error ‘Error: Argument error, options.body.’ on ‘http://127.0.0.1:8080/rest/items/OH2_Watchdog/state’” and they’ve made all the other nodes in my flow start acting all wonky until I deleted them

When I visit the above rest URL it displays “NULL” as expected as the item hasn’t been updated yet by Node-Red (since the write node is failing). I thought it might be a bug trying to write to items with a state of NULL, but I also tested writing to items with a state such as a number, still getting same error.

Did the OH2 REST interface change or something? my phone apps using the rest API are still working fine

node-red-contrib-openhab2@1.0.7
OH2 version: 2.2.0-SNAPSHOT Build #1072

Unfortunately, I don’t think I can be of much help. I switched from the OH nodes MQTT. I had some issues back in July -

Not sure if they are similar but from my responses I think I got things to clear up with a reboot.

Otherwise, you probably need to reach out to @Peter_De_Mangelaere who developed the nodes.

Oops sorry! Thought you were the dev :stuck_out_tongue: Sadly not affected by a reboot

I forgot to document a change in 1.0.6 : the openhab2-out node now doesn’t translate the input payload anymore to ‘ON’ or ‘OFF’. Maybe that explains the openhab2-out warnings.
I created a subflow with a function node containing following code and reuse it in front of several openhab2-out nodes:

switch (msg.payload)
{
    case 0:
    case "0":
    case false:
    case "false":
    case "FALSE":
    case "off":
    case "OFF":
        msg.payload = "OFF";
        break;
    case 1:
    case "1":
    case true:
    case "true":
    case "TRUE":
    case "on":
    case "ON":
        msg.payload = "ON";
        break;
        
    default:
        break;
}
return msg;

I’m not sending on/off, I’m sending a string/number that counts up from 1. Some other nodes are sending other Strings such as electricity cost. Have you tried the out node with the latest 2.2 snapshot? I’m worried the rest API formatting changed or something, because the error in node red is “request error ‘Error: Argument error, options.body.’ on ‘http://127.0.0.1:8080/rest/items/OH2_Watchdog/state’”

I’m still on a release version OH2-2.1 (I don’t want to run my home automation on non-release versions).
I’ll install the 2.2 snapshot on a separate machine to run some tests.

If it’s too much trouble for you to debug I can just switch to stable branch, unless others start reporting the same issue of course. I initially only meant to use the snapshot branch while oh2 was just coming out, but by now all the features I need are in stable

Found the error and fixed it locally.
I’ll try to push an update tomorrow.
Thanks for helping me to the right spot!

1 Like

awesome news! Did it turn out to be some change on openhabs side?

No … by fixing something else, I introduced this bug.

1 Like

Fixed in version 1.0.8