How to solve this problem Roll off Roof observatory

I am building Roll of Roof Observatory. I like to move the roof with node-red. I have for that two relays and peace of software. the software is not flexible. If i open the roof relay 1 will be active if i close the roof relay 2 will be active should be the aim. the relays are also trigger by the GPIO of the raspberry
I have the following output which is feed into the GPIOs of a raspberry.

The situation
Roof open I have GPIO(27) (HIGH) and GPIO(34) High
Roof close i have GPIO(34) High
No action when all is LOW (0)

thie issue i have is that requesting the roof open also the the closing relay is activated. this is because GPIO(34) is by open roof also High which is used also for the close trigger

It is more how to solve this problem. can some help me with example flow

Welcome to the forum @calberts.
I am sorry your problem is not entirely clear to me. Do you mean the GPIO pins are outputs that drive the relays in order to move the roof? So in order to close the roof the Pi (is it a Pi?) drives the GPIO pin which activates relay 1 and the roof closes, and to open the roof the Pi drives the other GPIO pin which activates relay 2 and causes the roof to close? Or have I got the problem all wrong?

Thanks for your reaction, almost right. lets make small drawing/flow
inputdeviceA feed both GPIO in

"inputdeviceA => GPIO-y in => PI Node-red flow => GPIO-a out => Relay Roof open"
" inputdeviceA => GPIO-x in => PI Node-red flow => GPIO-b out => Relay Roof close"

input values of GPIO in (given)
Roof open GPIO-y (HIGH) and GPIO-x (High)
Roof close GPIO-x (HIGH)

output must be like below
Open GPIO-a = High and GPIO-b = Low
Closing GPIO-a = Low and GPIO-b = High

The input values of Roof open are giving me the problems to get the right output on the GPIO's out.
How to solve this issue, if you or someone has example flow how to solve it would help me a lot

Small update to have it in other words
if y and x are high then a is high and b low
if y is low and x is high then b is high and a is low

Chris

Hi Calberts,

Can you post an export of your flow to see how you have approached the solution ?
and to better visualize what you have tried until now ?

Instructions of how to post can be found here

by the way .. when the GPIO are open do we have to take in consideration how long they have to be open ? or the relays have a stop trigger ?

In this case, the value of x doesn't matter, and only y controls the opening or closing.

What happens if x is low? Another couple of lines to the above table would give all combinations and make it easier to think about a solution.

PS - fellow astronomer here :wink: If I had space I'd definitely consider a small observatory in my garden.

Here is a flow that does what you asked for, but as @UnborN has pointed out there are some unknown requrements so it may not do what you actually want. Possibly though it will get you going enough to make some progress yourself. It uses a Join node to combine the input pin messages into one message then a function node to work out what to do.

[{"id":"4095c06a.4b6c28","type":"inject","z":"bdd7be38.d3b55","name":"GPIO x high","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"1","payloadType":"num","x":110,"y":3020,"wires":[["1118cd76.d00913"]]},{"id":"40fc8770.90dbd8","type":"inject","z":"bdd7be38.d3b55","name":"GPIO x low","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"0","payloadType":"num","x":100,"y":3060,"wires":[["1118cd76.d00913"]]},{"id":"73acc1bb.ac353","type":"inject","z":"bdd7be38.d3b55","name":"GPIO y high","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"1","payloadType":"num","x":110,"y":3140,"wires":[["5302bbfe.e08a3c"]]},{"id":"70cb38ba.771f8","type":"inject","z":"bdd7be38.d3b55","name":"GPIO y low","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"0","payloadType":"num","x":100,"y":3180,"wires":[["5302bbfe.e08a3c"]]},{"id":"1118cd76.d00913","type":"change","z":"bdd7be38.d3b55","name":"topic=gpiox","rules":[{"t":"set","p":"topic","pt":"msg","to":"gpiox","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":270,"y":3040,"wires":[["a3e59e88.2f91d8"]]},{"id":"5302bbfe.e08a3c","type":"change","z":"bdd7be38.d3b55","name":"topic=gpioy","rules":[{"t":"set","p":"topic","pt":"msg","to":"gpioy","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":270,"y":3160,"wires":[["a3e59e88.2f91d8"]]},{"id":"a3e59e88.2f91d8","type":"join","z":"bdd7be38.d3b55","name":"","mode":"custom","build":"object","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":true,"timeout":"","count":"2","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":430,"y":3100,"wires":[["514edc34.01dbfc"]]},{"id":"514edc34.01dbfc","type":"function","z":"bdd7be38.d3b55","name":"","func":"let gpioa = 0\nlet gpiob = 0\nif (msg.payload.gpiox == 1  && msg.payload.gpioy == 1) {\n    node.send([{payload: 1},{payload: 0}])\n} else if (msg.payload.gpiox == 1  && msg.payload.gpioy === 0) {\n    node.send([{payload: 0},{payload: 1}])\n} else {\n    // illegal combination, so do nothing\n}\n\nreturn      // don't return a message here as have already done it","outputs":2,"noerr":0,"initialize":"","finalize":"","x":560,"y":3100,"wires":[["314f6906.9b12be"],["14ff289d.181f3f"]]},{"id":"314f6906.9b12be","type":"debug","z":"bdd7be38.d3b55","name":"GPIO a","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":580,"y":3040,"wires":[]},{"id":"14ff289d.181f3f","type":"debug","z":"bdd7be38.d3b55","name":"GPIO b","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":580,"y":3160,"wires":[]}]
1 Like

UnborN, By this the flow and yes I have trigger how long it takes to open or close the roof
Molesworth x matters because that is the closing pulse. He mate did you see neowise comet. yes, I am lucky. I live with Schiphol airport in the garden. so now can place my telescope on the darkest place of the Netherlands that cool
Colin thanks for sharing the sample code. I was thinking about the join bust still try to figure out. I think i struggling also with the knowledge of the topic. can you look in the flow see what wrong

thanks in advanced

Chris

[{"id":"215a3733.57e8","type":"tab","label":"DeSterrenwacht","disabled":false,"info":""},{"id":"32e3ec6b.89a654","type":"rpi-gpio out","z":"215a3733.57e8","name":"GPIO(12) - Dak Open Pulse","pin":"12","set":true,"level":"0","freq":"","out":"out","x":1020,"y":200,"wires":[]},{"id":"47f3a08.949c4e","type":"trigger","z":"215a3733.57e8","op1":"1","op2":"0","op1type":"num","op2type":"num","duration":"10","extend":false,"units":"s","reset":"","bytopic":"topic","name":"Open Pulse (1 time then send 0)","x":730,"y":200,"wires":[["32e3ec6b.89a654"]]},{"id":"a292dc8f.ae2c38","type":"rpi-gpio in","z":"215a3733.57e8","name":"LesveDome Relay (Close) (13)","pin":"13","intype":"down","debounce":"25","read":true,"x":140,"y":380,"wires":[["97526d86.ab7b5"]]},{"id":"a0b0b2b8.abe5b8","type":"rpi-gpio in","z":"215a3733.57e8","name":"Limit Switch - Dak is Dicht (24)","pin":"24","intype":"up","debounce":"25","read":true,"x":150,"y":800,"wires":[["c870dd33.c6d758"]]},{"id":"b59df9f7.f90da","type":"rpi-gpio in","z":"215a3733.57e8","name":"Limit Switch - Dak is Open (26)","pin":"26","intype":"up","debounce":"25","read":true,"x":150,"y":860,"wires":[["7c2dc368.312894"]]},{"id":"b7e3a04d.6f76a8","type":"rpi-gpio in","z":"215a3733.57e8","name":"LesveDome Relay (22)","pin":"22","intype":"down","debounce":"25","read":true,"x":120,"y":260,"wires":[["9425dc48.21bba"]]},{"id":"90b3a5a9.0f1f38","type":"rpi-gpio in","z":"215a3733.57e8","name":"Limit Switch - Telescope Parked?","pin":"32","intype":"up","debounce":"25","read":true,"x":150,"y":920,"wires":[["12fbc9b5.ffee6e"]]},{"id":"634de6cd.603f4","type":"ui_text","z":"215a3733.57e8","group":"4c032911.729c6","order":9,"width":2,"height":1,"name":"Dak Status Limit Switch:","label":"Status:","format":"<font color= {{msg.color}} > {{msg.payload}} </font>","layout":"row-left","x":710,"y":820,"wires":[],"inputLabels":["2"]},{"id":"c870dd33.c6d758","type":"function","z":"215a3733.57e8","name":"Color Mapping","func":"switch (msg.payload) {\n\ncase 0 : \n    msg.color = \"Green\";\n    msg.payload = \"Dicht\";\n    break;\n    \ncase 2 : \n    msg.color = \"Red\";\n    msg.payload = \"Open\";\n    break;\n    \ndefault : \n    msg.color = \"Gray\";\n    msg.payload = \"not set\";\n    break;\n}\n\nreturn msg;","outputs":1,"noerr":0,"x":420,"y":800,"wires":[["634de6cd.603f4"]]},{"id":"18cc5be.0af1a24","type":"ui_switch","z":"215a3733.57e8","name":"","label":"12V","tooltip":"","group":"4c032911.729c6","order":15,"width":4,"height":1,"passthru":false,"decouple":"false","topic":"","style":"","onvalue":"1","onvalueType":"num","onicon":"","oncolor":"","offvalue":"0","offvalueType":"num","officon":"","offcolor":"","x":70,"y":1080,"wires":[["29ad7a51.2a269e","315ab6f3.d66c82"]]},{"id":"9e4c6b6a.8c222","type":"ui_switch","z":"215a3733.57e8","name":"","label":"Mount","tooltip":"","group":"4c032911.729c6","order":18,"width":4,"height":1,"passthru":false,"decouple":"false","topic":"","style":"","onvalue":"1","onvalueType":"num","onicon":"","oncolor":"","offvalue":"0","offvalueType":"num","officon":"","offcolor":"","x":70,"y":1200,"wires":[["3fc6b020.f3f408","9ee84ee5.ca93e"]]},{"id":"83a964d1.0b957","type":"ui_switch","z":"215a3733.57e8","name":"Power PC (220V)","label":"Power PC (220V)","tooltip":"","group":"4c032911.729c6","order":21,"width":4,"height":1,"passthru":true,"decouple":"false","topic":"","style":"","onvalue":"1","onvalueType":"num","onicon":"","oncolor":"","offvalue":"0","offvalueType":"num","officon":"","offcolor":"","x":110,"y":1320,"wires":[["6e53b922.8eb64","ef192b37.8aa2e"]]},{"id":"27df4a0a.571f86","type":"ui_switch","z":"215a3733.57e8","name":"","label":"OnFocus","tooltip":"","group":"4c032911.729c6","order":24,"width":4,"height":1,"passthru":true,"decouple":"false","topic":"","style":"","onvalue":"1","onvalueType":"num","onicon":"","oncolor":"","offvalue":"0","offvalueType":"num","officon":"","offcolor":"","x":80,"y":1420,"wires":[["3dadb3c0.eac874","bc5311d5.87c3b"]]},{"id":"4ba80116.02e3e","type":"ui_switch","z":"215a3733.57e8","name":"Flat Screen","label":"Flat Screen","tooltip":"","group":"4c032911.729c6","order":30,"width":4,"height":1,"passthru":true,"decouple":"false","topic":"","style":"","onvalue":"1","onvalueType":"num","onicon":"","oncolor":"","offvalue":"0","offvalueType":"num","officon":"","offcolor":"","x":90,"y":1540,"wires":[["3a65209c.d37f6","ba5e4716.036008"]]},{"id":"29ad7a51.2a269e","type":"function","z":"215a3733.57e8","name":"Color Mapping","func":"switch (msg.payload) {\n\ncase 1 : \n    msg.color = \"Green\";\n    msg.payload = \"Aan\";\n    break;\n    \ncase 0 : \n    msg.color = \"Red\";\n    msg.payload = \"Uit\";\n    break;\n    \ndefault : \n    msg.color = \"Gray\";\n    msg.payload = \"not set\";\n    break;\n}\n\nreturn msg;","outputs":1,"noerr":0,"x":320,"y":1080,"wires":[["1a11b79a.587048"]]},{"id":"3fc6b020.f3f408","type":"function","z":"215a3733.57e8","name":"Color Mapping","func":"switch (msg.payload) {\n\ncase 1 : \n    msg.color = \"Green\";\n    msg.payload = \"Aan\";\n    break;\n    \ncase 0 : \n    msg.color = \"Red\";\n    msg.payload = \"Uit\";\n    break;\n    \ndefault : \n    msg.color = \"Gray\";\n    msg.payload = \"not set\";\n    break;\n}\n\nreturn msg;","outputs":1,"noerr":0,"x":320,"y":1200,"wires":[["494b5a32.8b9cfc"]]},{"id":"6e53b922.8eb64","type":"function","z":"215a3733.57e8","name":"Color Mapping","func":"switch (msg.payload) {\n\ncase 1 : \n    msg.color = \"Green\";\n    msg.payload = \"Aan\";\n    break;\n    \ncase 0 : \n    msg.color = \"Red\";\n    msg.payload = \"Uit\";\n    break;\n    \ndefault : \n    msg.color = \"Gray\";\n    msg.payload = \"not set\";\n    break;\n}\n\nreturn msg;","outputs":1,"noerr":0,"x":320,"y":1320,"wires":[["390a6e63.5329ea"]]},{"id":"3dadb3c0.eac874","type":"function","z":"215a3733.57e8","name":"Color Mapping","func":"switch (msg.payload) {\n\ncase 1 : \n    msg.color = \"Green\";\n    msg.payload = \"Aan\";\n    break;\n    \ncase 0 : \n    msg.color = \"Red\";\n    msg.payload = \"Uit\";\n    break;\n    \ndefault : \n    msg.color = \"Gray\";\n    msg.payload = \"not set\";\n    break;\n}\n\nreturn msg;","outputs":1,"noerr":0,"x":320,"y":1420,"wires":[["56bb4f35.aa4c08"]]},{"id":"3a65209c.d37f6","type":"function","z":"215a3733.57e8","name":"Color Mapping","func":"switch (msg.payload) {\n\ncase 1 : \n    msg.color = \"Green\";\n    msg.payload = \"Aan\";\n    break;\n    \ncase 0 : \n    msg.color = \"Red\";\n    msg.payload = \"Uit\";\n    break;\n    \ndefault : \n    msg.color = \"Gray\";\n    msg.payload = \"not set\";\n    break;\n}\n\nreturn msg;","outputs":1,"noerr":0,"x":320,"y":1540,"wires":[["6b35652d.109384"]]},{"id":"1a11b79a.587048","type":"ui_text","z":"215a3733.57e8","group":"4c032911.729c6","order":16,"width":2,"height":1,"name":"12V Status","label":"Status:","format":"<font color= {{msg.color}} > {{msg.payload}} </font>","layout":"row-left","x":570,"y":1080,"wires":[]},{"id":"494b5a32.8b9cfc","type":"ui_text","z":"215a3733.57e8","group":"4c032911.729c6","order":19,"width":2,"height":1,"name":"Mount Status","label":"Status:","format":"<font color= {{msg.color}} > {{msg.payload}} </font>","layout":"row-left","x":580,"y":1200,"wires":[]},{"id":"390a6e63.5329ea","type":"ui_text","z":"215a3733.57e8","group":"4c032911.729c6","order":22,"width":2,"height":1,"name":"Power PC (220V)","label":"Status:","format":"<font color= {{msg.color}} > {{msg.payload}} </font>","layout":"row-left","x":590,"y":1320,"wires":[]},{"id":"56bb4f35.aa4c08","type":"ui_text","z":"215a3733.57e8","group":"4c032911.729c6","order":25,"width":2,"height":1,"name":"OnFocus","label":"Status:","format":"<font color= {{msg.color}} > {{msg.payload}} </font>","layout":"row-left","x":560,"y":1420,"wires":[]},{"id":"6b35652d.109384","type":"ui_text","z":"215a3733.57e8","group":"4c032911.729c6","order":31,"width":2,"height":1,"name":"Flat","label":"Status:","format":"<font color= {{msg.color}} > {{msg.payload}} </font>","layout":"row-left","x":550,"y":1540,"wires":[]},{"id":"315ab6f3.d66c82","type":"rpi-gpio out","z":"215a3733.57e8","name":"PIN 10","pin":"19","set":true,"level":"0","freq":"","out":"out","x":530,"y":1000,"wires":[]},{"id":"9ee84ee5.ca93e","type":"rpi-gpio out","z":"215a3733.57e8","name":"PIN 11","pin":"21","set":true,"level":"0","freq":"","out":"out","x":550,"y":1160,"wires":[]},{"id":"ef192b37.8aa2e","type":"rpi-gpio out","z":"215a3733.57e8","name":"PIN 19","pin":"37","set":true,"level":"0","freq":"","out":"out","x":550,"y":1280,"wires":[]},{"id":"bc5311d5.87c3b","type":"rpi-gpio out","z":"215a3733.57e8","name":"","pin":"11","set":true,"level":"0","freq":"","out":"out","x":560,"y":1380,"wires":[]},{"id":"ba5e4716.036008","type":"rpi-gpio out","z":"215a3733.57e8","name":"","pin":"15","set":true,"level":"0","freq":"","out":"out","x":560,"y":1480,"wires":[]},{"id":"22b4b9c9.5f1d36","type":"ui_switch","z":"215a3733.57e8","name":"Canon 40d","label":"Canon 40d","tooltip":"","group":"4c032911.729c6","order":27,"width":4,"height":1,"passthru":true,"decouple":"false","topic":"","style":"","onvalue":"1","onvalueType":"num","onicon":"","oncolor":"","offvalue":"0","offvalueType":"num","officon":"","offcolor":"","x":90,"y":1620,"wires":[["9ff84f53.88b03","f92c77e7.779df8"]]},{"id":"df1a9e09.24222","type":"ui_switch","z":"215a3733.57e8","name":"Power Dak","label":"Power Dak","tooltip":"","group":"4c032911.729c6","order":1,"width":4,"height":1,"passthru":true,"decouple":"false","topic":"","style":"","onvalue":"1","onvalueType":"num","onicon":"","oncolor":"","offvalue":"0","offvalueType":"num","officon":"","offcolor":"","x":90,"y":1720,"wires":[["bed82094.0ad898","ff016a48.efb328"]]},{"id":"9ff84f53.88b03","type":"rpi-gpio out","z":"215a3733.57e8","name":"","pin":"33","set":true,"level":"0","freq":"","out":"out","x":560,"y":1580,"wires":[]},{"id":"bed82094.0ad898","type":"rpi-gpio out","z":"215a3733.57e8","name":"","pin":"35","set":true,"level":"0","freq":"","out":"out","x":560,"y":1660,"wires":[]},{"id":"f92c77e7.779df8","type":"function","z":"215a3733.57e8","name":"Color Mapping","func":"switch (msg.payload) {\n\ncase 1 : \n    msg.color = \"Green\";\n    msg.payload = \"Aan\";\n    break;\n    \ncase 0 : \n    msg.color = \"Red\";\n    msg.payload = \"Uit\";\n    break;\n    \ndefault : \n    msg.color = \"Gray\";\n    msg.payload = \"not set\";\n    break;\n}\n\nreturn msg;","outputs":1,"noerr":0,"x":320,"y":1620,"wires":[["12573220.9338b6"]]},{"id":"ff016a48.efb328","type":"function","z":"215a3733.57e8","name":"Color Mappings","func":"switch (msg.payload) {\n\ncase 1 : \n    msg.color = \"Green\";\n    msg.payload = \"Aan\";\n    break;\n    \ncase 0 : \n    msg.color = \"Red\";\n    msg.payload = \"Uit\";\n    break;\n    \ndefault : \n    msg.color = \"Gray\";\n    msg.payload = \"not set\";\n    break;\n}\n\nreturn msg;","outputs":1,"noerr":0,"x":340,"y":1720,"wires":[["37097c2d.45e5bc"]]},{"id":"12573220.9338b6","type":"ui_text","z":"215a3733.57e8","group":"4c032911.729c6","order":28,"width":2,"height":1,"name":"40d","label":"Status:","format":"<font color= {{msg.color}} > {{msg.payload}} </font>","layout":"row-left","x":550,"y":1620,"wires":[]},{"id":"37097c2d.45e5bc","type":"ui_text","z":"215a3733.57e8","group":"4c032911.729c6","order":2,"width":2,"height":1,"name":"","label":"Status:","format":"<font color= {{msg.color}} > {{msg.payload}} </font>","layout":"row-left","x":560,"y":1720,"wires":[]},{"id":"12fbc9b5.ffee6e","type":"function","z":"215a3733.57e8","name":"Color Mapping","func":"switch (msg.payload) {\n\ncase 0 : \n    msg.color = \"Green\";\n    msg.payload = \"Parked\";\n    break;\n    \ncase 1 : \n    msg.color = \"Red\";\n    msg.payload = \"Not Parked\";\n    break;\n    \ndefault : \n    msg.color = \"Gray\";\n    msg.payload = \"not set\";\n    break;\n}\n\nreturn msg;","outputs":1,"noerr":0,"x":420,"y":920,"wires":[["a5c22ef4.b2e1c8"]]},{"id":"a5c22ef4.b2e1c8","type":"ui_text","z":"215a3733.57e8","group":"4c032911.729c6","order":11,"width":4,"height":1,"name":"`Telescope Park","label":"Telescope:","format":"<font color= {{msg.color}} > {{msg.payload}} </font>","layout":"row-left","x":680,"y":920,"wires":[]},{"id":"7c2dc368.312894","type":"function","z":"215a3733.57e8","name":"Color Mapping","func":"switch (msg.payload) {\n\ncase 0 : \n    msg.color = \"Red\";\n    msg.payload = \"Open\";\n    break;\n    \ncase 2 : \n    msg.color = \"Green\";\n    msg.payload = \"Open\";\n    break;\n    \ndefault : \n    msg.color = \"Gray\";\n    msg.payload = \"not set\";\n    break;\n}\n\nreturn msg;","outputs":1,"noerr":0,"x":420,"y":860,"wires":[["634de6cd.603f4"]]},{"id":"fb39ba69.591768","type":"wake on lan","z":"215a3733.57e8","mac":"90-B1-1C-A4-1E-BC","host":"","udpport":9,"name":"WakeUp Obs","x":310,"y":1880,"wires":[]},{"id":"def5286.17fa458","type":"ui_button","z":"215a3733.57e8","name":"","group":"4c032911.729c6","order":4,"width":2,"height":1,"passthru":false,"label":"WakeUp PC","tooltip":"","color":"","bgcolor":"","icon":"","payload":"","payloadType":"str","topic":"","x":90,"y":1880,"wires":[["fb39ba69.591768","9eb92ebf.83b5c8"]]},{"id":"8e6ad9f9.da356","type":"ui_button","z":"215a3733.57e8","name":"","group":"4c032911.729c6","order":6,"width":2,"height":1,"passthru":false,"label":"Opening Roof","tooltip":"","color":"","bgcolor":"","icon":"","payload":"","payloadType":"str","topic":"","x":120,"y":200,"wires":[["47f3a08.949c4e"]]},{"id":"5b9d83ab.0b72d4","type":"ui_button","z":"215a3733.57e8","name":"","group":"4c032911.729c6","order":7,"width":2,"height":1,"passthru":false,"label":"Closing Roof","tooltip":"","color":"","bgcolor":"","icon":"","payload":"","payloadType":"str","topic":"","x":130,"y":420,"wires":[["94ffacc9.0e1448"]]},{"id":"fa37b129.456d5","type":"rpi-gpio out","z":"215a3733.57e8","name":"GPIO(38) - Dak Dicht Pulse","pin":"38","set":true,"level":"0","freq":"","out":"out","x":1040,"y":420,"wires":[]},{"id":"94ffacc9.0e1448","type":"trigger","z":"215a3733.57e8","op1":"1","op2":"0","op1type":"str","op2type":"str","duration":"10","extend":false,"units":"s","reset":"","bytopic":"topic","name":"Clossing Pulse (1 time then send 0)","x":720,"y":420,"wires":[["fa37b129.456d5"]]},{"id":"9eb92ebf.83b5c8","type":"trigger","z":"215a3733.57e8","op1":"1","op2":"0","op1type":"str","op2type":"str","duration":"250","extend":false,"units":"ms","reset":"","bytopic":"topic","name":"","x":320,"y":1840,"wires":[["bb095c96.9bb328"]]},{"id":"bb095c96.9bb328","type":"function","z":"215a3733.57e8","name":"delay to start","func":"switch (msg.payload) {\n\ncase 1 : \n    msg.color = \"Green\";\n    msg.payload = \"Wait Starting PC\";\n    break;\n    \ncase 0 : \n    msg.color = \"Red\";\n    msg.payload = \"PC is on\";\n    break;\n    \ndefault : \n    msg.color = \"Gray\";\n    msg.payload = \"not set\";\n    break;\n}\n\nreturn msg;","outputs":1,"noerr":0,"x":510,"y":1840,"wires":[["ef38847b.e1e888"]]},{"id":"ef38847b.e1e888","type":"ui_text","z":"215a3733.57e8","group":"4c032911.729c6","order":37,"width":0,"height":0,"name":"","label":"status:","format":"<font color= {{msg.color}} > {{msg.payload}} </font>","layout":"row-left","x":670,"y":1840,"wires":[]},{"id":"9425dc48.21bba","type":"change","z":"215a3733.57e8","name":"","rules":[{"t":"set","p":"topic","pt":"msg","to":"","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":360,"y":260,"wires":[["e059ff9d.30ebf"]]},{"id":"97526d86.ab7b5","type":"change","z":"215a3733.57e8","name":"","rules":[{"t":"set","p":"topic","pt":"msg","to":"","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":360,"y":380,"wires":[["e059ff9d.30ebf"]]},{"id":"e059ff9d.30ebf","type":"join","z":"215a3733.57e8","name":"","mode":"custom","build":"object","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":true,"timeout":"","count":"2","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":550,"y":320,"wires":[["c9f478.8905f388"]]},{"id":"c9f478.8905f388","type":"function","z":"215a3733.57e8","name":"If statement","func":"let gpioa = 0\nlet gpiob = 0\nif (msg.payload.gpiox == 1  && msg.payload.gpioy == 1) {\n    node.send([{payload: 1},{payload: 0}])\n} else if (msg.payload.gpiox == 1  && msg.payload.gpioy === 0) {\n    node.send([{payload: 0},{payload: 1}])\n} else {\n    // illegal combination, so do nothing\n}\nreturn \nreturn msg;","outputs":1,"noerr":0,"x":690,"y":320,"wires":[["47f3a08.949c4e","94ffacc9.0e1448"]]},{"id":"4c032911.729c6","type":"ui_group","z":"","name":"Schakelaars","tab":"f4f3f5b4.649508","order":1,"disp":true,"width":8,"collapse":true},{"id":"f4f3f5b4.649508","type":"ui_tab","z":"","name":"DeSterrenWacht","icon":"dashboard","disabled":false,"hidden":false}]

Add debug nodes into your flow and work out at which point it is not doing what you expect. Start by checking the join node output is correct, then check the function outputs are right, and so on till you work out the problem. It might be easier initially to use inject nodes as I did and debug nodes on the output. Work along the flow till it all does what you expect.
If you get stuck then show us just the bit that is failing and show us the debug going into it and the debug coming out and tell us what the output should be doing.

Calbert .. from the flow you posted implementing Colin's solution .. in your change node there is something wrong. you removed the topic.

Screenshot_2020-08-21 Node-RED 192 168 1 160

so the whole logic breaks after that because the join node expects a topic to merge the messages
before it is passed to the function node .. you need to study Colins flow again

Ah, I think you need to give more details of the sequence of signals. I'm guessing the if x is low, then that disables both opening and closing, but are x and y pulses or continuous signals? If they're pulses, that may change how they should be handled.

Yeah, Neowise was pretty spectacular, and I got some nice pictures too. I can see the need for an observatory if you're near Schiphol. I'm through there regularly and it's a busy area!

1 Like

In addition to the errors in the Change nodes you have added a line to the end of the Function node (though it doesn't matter as it will not get executed) but also you have not set the number of outputs in the function node to 2. The flow you have ended up with will obviously not work as you are sending the same message to both GPIO out nodes. When you get a suggestion from the forum it is important to make sure you understand what the flow is doing.
I presume you did at least import it and check it worked in the way you expect. Having done that you could have copied the nodes into your flow so there would not be any accidental typos.

Colin

You are right two outputs are needed, I also test your flow an it is working. i change the function to what i needed. So yep the test flow is oke and working as expected. I merged it in to my flow
But there is something strange i think its i kind of timing issue. Be aware i use Relay for switching the status of the GPIO in's

// Open IF
if (msg.payload.gpiox == 1 && msg.payload.gpioy == 1) {
node.send([{payload: 1},{payload: 0}])
}
// Close If
if (msg.payload.gpiox == 0 && msg.payload.gpioy == 1) {
node.send([{payload: 0},{payload: 1}])
}

[{"id":"b7e3a04d.6f76a8","type":"rpi-gpio in","z":"215a3733.57e8","name":"LesveDome Relay (22)","pin":"22","intype":"down","debounce":"1000","read":true,"x":120,"y":260,"wires":[["61f95196.2a3ea","9425dc48.21bba"]]},{"id":"a292dc8f.ae2c38","type":"rpi-gpio in","z":"215a3733.57e8","name":"LesveDome Relay (Close) (13)","pin":"13","intype":"down","debounce":"1000","read":true,"x":140,"y":340,"wires":[["4c04c2b2.4f655c","97526d86.ab7b5"]]},{"id":"4c04c2b2.4f655c","type":"debug","z":"215a3733.57e8","name":"gpioy-pin","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":380,"y":380,"wires":[]},{"id":"97526d86.ab7b5","type":"change","z":"215a3733.57e8","name":"gpioy","rules":[{"t":"set","p":"topic","pt":"msg","to":"gpioy","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":370,"y":340,"wires":[["30e22cb5.5ddc8c","e059ff9d.30ebf"]]},{"id":"e059ff9d.30ebf","type":"join","z":"215a3733.57e8","name":"","mode":"custom","build":"object","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":true,"timeout":"0","count":"2","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":690,"y":300,"wires":[["c9f478.8905f388","9b2bea9e.10941"]]},{"id":"9b2bea9e.10941","type":"debug","z":"215a3733.57e8","name":"Join","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":830,"y":260,"wires":[]},{"id":"c9f478.8905f388","type":"function","z":"215a3733.57e8","name":"If statement","func":"let gpioa = 0\nlet gpiob = 0\n// Open IF\nif (msg.payload.gpiox == 1  && msg.payload.gpioy == 1) {\n    node.send([{payload: 1},{payload: 0}])\n}\n// Close If\nif (msg.payload.gpiox == 0 && msg.payload.gpioy == 1) {\n    node.send([{payload: 0},{payload: 1}])\n}\nreturn      // don't return a message here as have already done it","outputs":2,"noerr":0,"x":850,"y":300,"wires":[["bebb5db5.dfef5"],["2a4005e9.98ceea"]]},{"id":"30e22cb5.5ddc8c","type":"debug","z":"215a3733.57e8","name":"gpioy","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":550,"y":380,"wires":[]},{"id":"9425dc48.21bba","type":"change","z":"215a3733.57e8","name":"gpiox","rules":[{"t":"set","p":"topic","pt":"msg","to":"gpiox","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":370,"y":260,"wires":[["63db55d1.2771c4","e059ff9d.30ebf"]]},{"id":"61f95196.2a3ea","type":"debug","z":"215a3733.57e8","name":"gpiox-pin","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":380,"y":200,"wires":[]},{"id":"63db55d1.2771c4","type":"debug","z":"215a3733.57e8","name":"gpiox","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":550,"y":200,"wires":[]},{"id":"bebb5db5.dfef5","type":"debug","z":"215a3733.57e8","name":"Open","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":1150,"y":260,"wires":[]},{"id":"2a4005e9.98ceea","type":"debug","z":"215a3733.57e8","name":"Close","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":1150,"y":320,"wires":[]}]

Looking to the join setting
Closing is doing his job.
But opening is strange it looks like it passes two time the join, my idea that that has to do with the timing of both GPIO's

Debug results:
8/21/2020, 3:01:38 PMnode: Join
gpiox : msg.payload : Object
{ gpioy: 0, gpiox: 1 }
8/21/2020, 3:01:38 PMnode: Joingpioy : msg.payload : Object
{ gpioy: 1, gpiox: 1 }
8/21/2020, 3:01:38 PMnode: Openmsg.payload : number
1
8/21/2020, 3:01:38 PMnode: Closemsg.payload : number
0
8/21/2020, 3:01:43 PMnode: Joingpiox : msg.payload : Object
{ gpioy: 1, gpiox: 0 }
8/21/2020, 3:01:43 PMnode: Openmsg.payload : number
0
8/21/2020, 3:01:43 PMnode: Closemsg.payload : number
1
8/21/2020, 3:01:43 PMnode: Joingpioy : msg.payload : Object
{ gpioy: 0, gpiox: 0 }

While disabling "and every subsequent message"
then opening works as expected but closing will not pas through the join

opening debug as we expect that i must work
8/21/2020, 3:06:00 PMnode: Joingpioy : msg.payload : Object
{ gpiox: 1, gpioy: 1 }
8/21/2020, 3:06:00 PMnode: Openmsg.payload : number
1
8/21/2020, 3:06:00 PMnode: Closemsg.payload : number
0
8/21/2020, 3:06:05 PMnode: Join
gpioy : msg.payload : Object
{ gpiox: 0, gpioy: 0 }

So the question what do i wrong or what kind of work arround can we make

Chris

Looking at the debug you can see that first gpioy goes to zero, which causes an output from the join. However because that is not one of the valid combinations in the function then there is no output from the function node, as expected. Then gpioy goes back to 1 and you get the ouputs open 1 and close 0 as expected.
Then I see gpiox goes to zero (at 3:01:43) which cases the function node to output open 0 close 1.
So what is the problem? It looks as if all is working to me.

Colin

the point is that when gpiox and y become high I see two times the results of the join

{ gpioy= 1 and gpiox = 0 } and { gpioy= 1 and gpiox = 1 } because of this this two out put will go through the IF the first will trigger de close relay and secon the open relay

when the relays are going down (for the eyes equal) you see again two times
{ gpioy= 1 and gpiox = 0 } and { gpioy= 0 and gpiox = 1 } and this the the close relay is triggered.

i expect only one join result for opening { gpioy= 1 and gpiox = 1 }

8/21/2020, 4:29:58 PM[node: Join] // Not expected because both are high for the eyes
gpiox : msg.payload : Object
{ gpioy: 0, gpiox: 1 }
8/21/2020, 4:29:58 PM[node: Join] // expected and correct
gpioy : msg.payload : Object
{ gpioy: 1, gpiox: 1 }
8/21/2020, 4:29:58 PM[node: Open] //Expected and correct
msg.payload : number
1
8/21/2020, 4:29:58 PM[node: Close] // Expected and correct
msg.payload : number
0
// now GPOI both are going to zero
8/21/2020, 4:30:03 PM[node: Join] // not expected
gpiox : msg.payload : Object
{ gpioy: 1, gpiox: 0 }
8/21/2020, 4:30:03 PM[node: Open] //Not expected
msg.payload : number
0
8/21/2020, 4:30:03 PM[node: Close] //Not expected becaus it trigger the clore relay
msg.payload : number
1
8/21/2020, 4:30:03 PM[node: Join]
gpioy : msg.payload : Object
{ gpioy: 0, gpiox: 0 }


For closing it works well zie below
8/21/2020, 4:26:15 PM[node: Join]
gpioy : msg.payload : Object
{ gpioy: 1, gpiox: 0 } // Closing value of both GPIO's
8/21/2020, 4:26:15 PM[node: Open]
msg.payload : number
0
8/21/2020, 4:26:15 PM[node: Close]
msg.payload : number
1
8/21/2020, 4:26:20 PM [node: Join]
gpioy : msg.payload : Object
{ gpioy: 0, gpiox: 0} // Back to normal

I think im running in to timing issue where one GPOI is quicker than the other one. possible due to using physical relays. So in general the flow is working but it strange that ther are to join string by opening

Chris

As you can see gpioy is 0 and gpiox is 1, presumably they were both zero before you did this. But also, as I said, it does not matter because the function node ignores that combination.

Because of the way node-red works, even if they both changed at the same time, node red will always see the message from one before the other. But again, as I said, since the Function node does not output a message for this combination there is no problem.
If you still think that is a problem then tell me what is wrong with what you see on the function node output.

Colin

This is the problem in the open flow debug results

/ now GPOI both are going to zero
8/21/2020, 4:30:03 PM[node: Join] // not expected
gpiox : msg.payload : Object
{ gpioy: 1, gpiox: 0 }

because this match the close situation and that triggers the relay

// Close If
if (msg.payload.gpiox == 0 && msg.payload.gpioy == 1) {
node.send([{payload: 0},{payload: 1}])

and that is not what I want if I request an open situation

Again your flow is working 100% as we both expected and tested. But I think the timing and that node-red is based on a sequence flow make this issue. to compare GPOI hard.

I also see a different behaviour when "and every subsequent message." is checked then the open sequence is acting as expected. But the closing will never flow through the join

Sorry can't explain it in other way
Anyway i aprciate that you still have look on this issue, let this be clear

Chris

You must have "every subsequent message" selected, it won't work otherwise.
Please explain the full sequence of what happens to gpio x and y through a full cycle.
Make a table showing something like

X     Y       A         B
-       -       -          -      Starting Values
-       -        -           -       Open

and so on. Make sure to include the full sequence of inputs even if they are not supposed to generate an output change on A and B

When you enter it use the </> button and put the table where it says to paste, that helps with the formatting, though it will still be a bit indeterminate.

What Colin has suggested is constructing a "Truth Table".
This is a pictorial way of showing the results for combinational logic or input signals (e.g. GPIO pins).
If you include every input state in the table you might be able to minimise it by removing redundant lines.

It's normally very easy to translate the Truth Table to a piece of code (Javascript in a function block).

If you have timing issues between signals (e.g. GPIO pins), then a finite state machine (FSM) approach might be more suitable (as a change in output is based on the current state and the state of the inputs).

Not quite, what I am looking for is a time sequence of what actually happens. We already have a truth table (effectively) but it seems that the transitions between values are causing problems, which is why I want to understand the sequence.

Hoi alle

i think i will make a small drawing this weekend. then you see my setup and it can be that there is an issue.

@Dynamicdave
True table is like this
Open Roof
Gpio x in = 1 => gpio a out = 1 = relays A (Open Roof)
gpio y in = 1 => gpio b out = 0 = Relays B (Close Roof)

Close Roof
Gpio x in = o => gpio a out = 0 = relays A (Open Roof)
gpio y in = 1 => gpio b out = 1 = relays B (Close Roof)

In boot situation the gpoi y in is one this is where complexity come's, there what i understood is that
node red is sequence driven.
As Coliin explain the test flow is work as expected on this truth table.

By the way i rebuild the flow to boolian expersion but i see the same situation.
About the FSM for each GPIO in want do you suggest for function to use?

ANyway guys i will make a drawing to show the situation, i must do it anyway

Chris