Openhab and node-red

@bernd1109
We use this post for your problem

@crxporter

hey, great. i´m just installing node-red throw the openhabian-config tool…

ok…node-red is running…

Install Manage Palette
image

1 Like

I’ll start off with a quick rundown on how to setup your very first nodered test.

Step one: install nodered

sudo openhabian-config

I see you’ve done that. To access nodered go to the openhab dashboard and click nodered. Easy.

Step 2: setup your openhab configuration
At the very bottom of the left column you’ll see these items:


You’ll want to drag one of the first (openhab2 in) over to the grid on the right.

Double-click that guy and you will see a drop-down with “add new openhab2 controller” go ahead and click the pencil just to the right of that drop down.

This is my setup, yours should be identical since you’re running openhabian.


Click “add”

Step 3: link that node to any openhab item:


You can choose whichever item you like. All state updates will “come out” of it. go ahead and choose one and save it

Step 4: drag in a “debug”


And drag a wire across just like this.

Step 5: click “deploy”

And watch the debug tab on the right - as you change whichever item you choose, the state updates should show up in the debug panel.

From there you can see that nodered is working, I’d recommend reading through my tutorial on the other page next then come back here or post questions there! If I’ve missed anything, let me now (I’m quite used to this setup by now :rofl:)

2 Likes

…in the manage pallette i only can see the node-red-contrib-openhab2.
the homekit-bridged node is missing…

You’ll have to add that one - there are 2 tabs at the top of the pallette manager one showing “nodes” and one showing “install”

Use the install one to search for and install the homekit.

Let’s see if me or @gozilla01 clicks “reply” first!

2 Likes

Menu - Import - Clipboard - Paste

[{"id":"bc94eddc.57958","type":"function","z":"4371b87a.115948","name":"Target Position","func":"var input = 100 - parseFloat(msg.payload)\nvar delay = {payload:0};\nif(input < 101){\n    msg.payload = {\n        \"TargetPosition\": input\n    };\n    delay.payload = {\n        \"CurrentPosition\": input\n    };\n    return [msg,delay];\n}","outputs":2,"noerr":0,"x":290,"y":50,"wires":[["f1e018b9.45b428"],["dde3f721.506588"]]},{"id":"f1e018b9.45b428","type":"homekit-service","z":"4371b87a.115948","bridge":"555238e4.b364d8","name":"Tapparella Sala","serviceName":"WindowCovering","manufacturer":"Hayley","model":"Lamp","serialNo":"2","characteristicProperties":"{\"Brightness\":true}","x":576,"y":42,"wires":[["f8b3901e.ee8a2"]]},{"id":"dde3f721.506588","type":"delay","z":"4371b87a.115948","name":"","pauseType":"delay","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":439,"y":108,"wires":[["f1e018b9.45b428"]]},{"id":"2a23820d.16d3be","type":"openhab2-in","z":"4371b87a.115948","name":"Tapparella Sala","controller":"93cadc2.e96f72","itemname":"Tapparella_Sala","x":101,"y":48,"wires":[["bc94eddc.57958"],[]]},{"id":"f8b3901e.ee8a2","type":"function","z":"4371b87a.115948","name":"Curtain Out","func":"var t = context.get('t')||0;\nvar delay = {payload:0}\nif(msg.payload.TargetPosition){\n    t = msg.payload.TargetPosition;\n    context.set('t',t);\n    msg.payload=100 - t\n}\nif(msg.payload.TargetPosition === 0){\n    t = msg.payload.TargetPosition;\n    context.set('t',t);\n    msg.payload=100 -t\n}\nif (msg.hap.context !== undefined){\n    delay.payload = {\n        \"CurrentPosition\": 100 - t\n    };\n    return [msg,delay]\n}","outputs":2,"noerr":0,"x":765,"y":43,"wires":[["b647580a.298168"],["95e1dcd3.e53df"]]},{"id":"4a1b7531.cc012c","type":"link in","z":"4371b87a.115948","name":"","links":["95e1dcd3.e53df"],"x":321,"y":107,"wires":[["dde3f721.506588"]]},{"id":"b647580a.298168","type":"openhab2-out","z":"4371b87a.115948","name":"Tapparella Sala","controller":"93cadc2.e96f72","itemname":"Tapparella_Sala","topic":"ItemCommand","payload":"","x":940,"y":40,"wires":[[]]},{"id":"95e1dcd3.e53df","type":"link out","z":"4371b87a.115948","name":"","links":["4a1b7531.cc012c"],"x":822,"y":109,"wires":[]},{"id":"555238e4.b364d8","type":"homekit-bridge","z":"","bridgeName":"Casa","pinCode":"550-00-820","port":"","manufacturer":"Gozilla","model":"Pi3","serialNo":"Rev.1"},{"id":"93cadc2.e96f72","type":"openhab2-controller","z":"","name":"Openhab","protocol":"http","host":"localhost","port":"8080","path":"","username":"","password":""}]

:rofl::rofl::rofl::rofl::rofl::rofl::rofl::rofl::rofl::rofl::rofl::rofl::rofl:

1 Like

Note the paste only works if you’ve already installed all of the required nodes… It won’t install the homekit node (or openhab… I tested just now on a non-openhab pi)

what is this for?

That’s what it looks like when you share nodered code. It’s been copied from Michele’s computer - you could paste it into your nodered if you like.

It’s the blinds node of @crxporter , I modified it because I was inverted up and down

Edit: I use protocol Openwebnet 2.x

…installed

Alright, I’m out for the day. It’s 2:30 AM in Texas and I have work in a few hours.

Bernd - I recommend doing that quick test of nodered to verify that your basic connections are working (watch the debug tab!) then running through my tutorial post for the items you’re working on.

There’s a bit of learning and head banging - I’ll check back tomorrow to see how it’s going.

1 Like

Light

[{"id":"4371b87a.115948","type":"tab","label":"Flow 1","disabled":false,"info":""},{"id":"2ac6a9c.39c2f56","type":"function","z":"4371b87a.115948","name":"OpenHAB to HomeKit","func":"if (msg.payload == \"ON\") {\n    msg.payload = {\n        \"On\": true\n    };\n} else {\n    msg.payload = {\n        \"On\": false\n    };\n}\nreturn msg;\n","outputs":1,"noerr":0,"x":324,"y":54,"wires":[["1deb4e71.390212"]]},{"id":"276c40b2.ee861","type":"openhab2-in","z":"4371b87a.115948","name":"Sala","controller":"93cadc2.e96f72","itemname":"Luce_sala","x":94,"y":52,"wires":[["2ac6a9c.39c2f56"],[]]},{"id":"1deb4e71.390212","type":"homekit-service","z":"4371b87a.115948","bridge":"555238e4.b364d8","name":"Sala","serviceName":"Switch","manufacturer":"Hayley","model":"Outlet","serialNo":"1","characteristicProperties":"{}","x":514,"y":54,"wires":[["751947c.a5be5b8"]]},{"id":"751947c.a5be5b8","type":"function","z":"4371b87a.115948","name":"HomeKit to OpenHAB","func":"if (msg.hap.context !== undefined )\n{\nif(msg.payload.On === false){\n    msg.payload = \"OFF\";\n}\nelse {\n    if(msg.payload.On === true){\n    msg.payload = \"ON\";\n}\n}\nreturn msg;\n}\n","outputs":1,"noerr":0,"x":744,"y":54,"wires":[["b8f50144.e6b72"]]},{"id":"b8f50144.e6b72","type":"openhab2-out","z":"4371b87a.115948","name":"Sala","controller":"93cadc2.e96f72","itemname":"Luce_sala","topic":"ItemCommand","payload":"","x":932,"y":54,"wires":[[]],"inputLabels":["msg.payload"],"outputLabels":["msg.payload"]},{"id":"93cadc2.e96f72","type":"openhab2-controller","z":"","name":"Openhab","protocol":"http","host":"localhost","port":"8080","path":"","username":"","password":""},{"id":"555238e4.b364d8","type":"homekit-bridge","z":"","bridgeName":"Casa","pinCode":"550-00-820","port":"","manufacturer":"Gozilla","model":"Pi3","serialNo":"Rev.1"}]

Modify items Openhab ( modify in e out)
image

Modify node HomeKit
image

Thanks very much for your support, Garrett. :+1:good night

Once everything is installed and the nodes are created and modified, press desploy.
Go to Home is configure the new bridge

before that…should i remove the openhab-homekit binding (org.openhab.io.homekit-2.3.0.jar) or any other bindings in the openhab2 environment?

Last post today I promise! No this will act completely separate from anything you already have. You can even add both to the same homekit.

Very good for testing.