Node-Red Dashboard Nodes

hi,
i´m completely new in node.
i´ve got this node to control my rollershutters.
And i want to control the rollershutter also with a slider-Node (UI) and tried it like this.

But nothing happens. when i slide the state is changing, but the rollershutter won´t move.

Any ideas?

Do you have a line something like this in the function on the right?

if (msg.hap.context !== undefined)

If so that will prevent this message from getting to openhab. Move your UI slider between “rollo out” and openhab.

yes, there is that line. but i also tried it like this and then it worked but i won´t get the (slider-) state in homekit.

Any reason not to send the UI item into both places while you troubleshoot?

A little more information on my comment above - the msg.hap.context is a check to see if the message originated in homekit. The homekit nodes pass through all messages so if you don’t have this check you will likely end up with a loop sending to openhab, getting updates, going through homekit, and repeat.

Did you put some kind of check like this to the left? You need to get well acquainted with the “debug” node. I recommend putting one on your far left openhab node (which I believe works?) and on the output of the UI. You’ll want to make sure they are EXACTLY the same output. If they’re not then your UI item isn’t sending the right information into your function.

Just run back through everything with debug nodes all over the place. You’ll eventually catch some difference or reason it’s being stopped.

If you can’t figure it out post a copy of that whole flow - I’ll be home in a few hours and I’d be happy to look at what you’re doing to see if I catch anything.

ok, Garret…
i put in 2 debug - Nodes to compare the output.
This is, what i figured out:
23
33
It seems, that the UI gives back a number while OH generates a String.
Could it be the solution to convert the number into a string?

…tried to convert the number into a string with this function-node after the ui-output:

msg.payload = String(msg.payload);
return msg;

now i´m getting a string back - but nothing moves :weary:

00

Post your code! This is an interesting thing, I want to see it all for myself.

Select all of these items, click “export” and copy the code over.

here is the Code for this

[{"id":"8884713c.f1ca2","type":"openhab2-out","z":"7d024f37.e6227","name":"Rollo Büro","controller":"9229bb56.9abe78","itemname":"rollo_ost_buero","topic":"ItemCommand","payload":"","x":1331,"y":1082,"wires":[[]]},{"id":"600930c8.32a18","type":"function","z":"7d024f37.e6227","name":"Rollo 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":1,"noerr":0,"x":910.5,"y":1082,"wires":[["8884713c.f1ca2"]]},{"id":"c469f00b.9ec3d","type":"homekit-service","z":"7d024f37.e6227","bridge":"a7511ed2.bcd4f","name":"Rollo Büro","serviceName":"WindowCovering","manufacturer":"Hager","model":"Default Model","serialNo":"Default Serial Number","characteristicProperties":"{}","x":606.5,"y":1081,"wires":[["600930c8.32a18"]]},{"id":"7a4467fa.f958c8","type":"function","z":"7d024f37.e6227","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":392.5,"y":1080,"wires":[["c469f00b.9ec3d"],["c469f00b.9ec3d"]]},{"id":"804ef6c.e48e008","type":"function","z":"7d024f37.e6227","name":"MSG to String","func":"msg.payload = String(msg.payload);\nreturn msg;","outputs":2,"noerr":0,"x":508,"y":1322,"wires":[["7a4467fa.f958c8","875206d9.9013c8"],[]]},{"id":"eda1a4cd.64a378","type":"ui_slider","z":"7d024f37.e6227","name":"","label":"Rolladen Büro","tooltip":"","group":"bf8230b.1d3e1d","order":3,"width":0,"height":0,"passthru":true,"outs":"end","topic":"","min":0,"max":"100","step":1,"x":291.5,"y":1322,"wires":[["804ef6c.e48e008"]]},{"id":"875206d9.9013c8","type":"debug","z":"7d024f37.e6227","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":884.5,"y":1342,"wires":[]},{"id":"4c16a69c.3c87f8","type":"openhab2-in","z":"7d024f37.e6227","name":"Rollo Büro","controller":"9229bb56.9abe78","itemname":"rollo_ost_buero","x":98,"y":1081,"wires":[["eda1a4cd.64a378"],[]]},{"id":"9229bb56.9abe78","type":"openhab2-controller","z":"","name":"Grimms Openhab2","protocol":"http","host":"localhost","port":"8080","path":"","username":"","password":""},{"id":"a7511ed2.bcd4f","type":"homekit-bridge","z":"","bridgeName":"Homekit-Bridge","pinCode":"031-45-154","port":"","manufacturer":"Default Manufacturer","model":"Default Model","serialNo":"Default Serial Number"},{"id":"bf8230b.1d3e1d","type":"ui_group","z":"","name":"Büro","tab":"43fe1c2a.2178e4","order":2,"disp":true,"width":"6","collapse":false},{"id":"43fe1c2a.2178e4","type":"ui_tab","z":"","name":"Obergeschoss","icon":"dashboard","order":3}]

I would set this one up a little differently. Instead of having the UI item “in the middle” - I would put it on the side. Like this:

I added a trigger because the UI item goes into “rapid fire” mode sending tons of messages through while you slide the slider. I also added debugs to everything. You’ll want to start watching Debug1 from OpenHAB and Debug7 which is where I’m putting the UI numbers into the mix. I wasn’t able to see what’s coming out of the openhab rollershutter item since I don’t have any actual rollershutter items.

My best advice is the same every time - watch the debug screen. Then you’ll be able to see where your code is falling apart.

Code for the picture above:

[{"id":"97f5514b.dcd9b","type":"function","z":"210e394a.f9e70e","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":1080,"y":240,"wires":[["8262c6ca.81bf9","d73fcfa2.f9d92"],["8262c6ca.81bf9","455bad8e.e3c59c"]]},{"id":"8262c6ca.81bf9","type":"homekit-service","z":"210e394a.f9e70e","bridge":"f5487faf.eba98","name":"Rollo Büro","serviceName":"WindowCovering","manufacturer":"Hager","model":"Default Model","serialNo":"Default Serial Number","characteristicProperties":"{}","x":1330,"y":240,"wires":[["b66b0057.a31638","c070c6bf.3bae7"]]},{"id":"e5abf35e.bdebd","type":"openhab2-in","z":"210e394a.f9e70e","name":"","controller":"","itemname":"","x":790,"y":240,"wires":[["97f5514b.dcd9b","6b14bc38.8bf314"],[]]},{"id":"455bad8e.e3c59c","type":"debug","z":"210e394a.f9e70e","name":"Debug5","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","x":1270,"y":320,"wires":[]},{"id":"d73fcfa2.f9d92","type":"debug","z":"210e394a.f9e70e","name":"Debug2","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","x":1290,"y":200,"wires":[]},{"id":"65eb4af7.60975c","type":"function","z":"210e394a.f9e70e","name":"MSG to String","func":"msg.payload = String(msg.payload);\nreturn msg;","outputs":2,"noerr":0,"x":1200,"y":480,"wires":[["1e393df4.a436aa","97f5514b.dcd9b"],[]]},{"id":"b66b0057.a31638","type":"function","z":"210e394a.f9e70e","name":"Rollo 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":1,"noerr":0,"x":1520,"y":220,"wires":[["803dba0.876a9c8","e17427f8.b991c8"]]},{"id":"c070c6bf.3bae7","type":"debug","z":"210e394a.f9e70e","name":"Debug3","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","x":1520,"y":280,"wires":[]},{"id":"6b14bc38.8bf314","type":"debug","z":"210e394a.f9e70e","name":"Debug1","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","x":1030,"y":180,"wires":[]},{"id":"1e393df4.a436aa","type":"debug","z":"210e394a.f9e70e","name":"Debug7","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","x":1400,"y":560,"wires":[]},{"id":"88d696fa.f8fb38","type":"trigger","z":"210e394a.f9e70e","op1":"","op2":"","op1type":"nul","op2type":"payl","duration":"250","extend":true,"units":"ms","reset":"","bytopic":"all","name":"","x":1000,"y":480,"wires":[["65eb4af7.60975c"]]},{"id":"803dba0.876a9c8","type":"openhab2-out","z":"210e394a.f9e70e","name":"","controller":"","itemname":"","topic":"ItemCommand","payload":"","x":1740,"y":220,"wires":[[]]},{"id":"e17427f8.b991c8","type":"debug","z":"210e394a.f9e70e","name":"Debug4","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","x":1740,"y":280,"wires":[]},{"id":"270d4255.31ea56","type":"ui_slider","z":"210e394a.f9e70e","name":"","label":"Rolladen Büro","group":"451c1b2a.85ce2c","order":3,"width":0,"height":0,"passthru":true,"topic":"","min":0,"max":"100","step":1,"x":800,"y":480,"wires":[["b50ce67d.42236","88d696fa.f8fb38"]]},{"id":"b50ce67d.42236","type":"debug","z":"210e394a.f9e70e","name":"Debug6","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","x":1200,"y":560,"wires":[]},{"id":"f5487faf.eba98","type":"homekit-bridge","z":"","bridgeName":"Homekit-Bridge","pinCode":"031-45-154","port":"","manufacturer":"Default Manufacturer","model":"Default Model","serialNo":"Default Serial Number"},{"id":"451c1b2a.85ce2c","type":"ui_group","z":"","name":"Büro","tab":"b8235cb8.717308","order":2,"disp":true,"width":"6","collapse":false},{"id":"b8235cb8.717308","type":"ui_tab","z":"","name":"Obergeschoss","icon":"dashboard","order":3}]

Thanks a lot, Garrett. I will test it asap.
My wife told me, to get the towel radiator working FIRST before i´m playing around with rollershutter-ui :wink:
( This now works like a charme in Homekit ).
Node-Red is such a great tool - so many things to dicover - very awesome!
Thanks very much, Garrett for introducing me.