Telegram + 9x gpio-multi-function-lights + P.I.R + dash all working ;) but need help with a function

[{"id":"de3f81b5.8f7a1","type":"smartswitch","z":"7355e642.932538","name":"","topic":"FAMILY ROOM","timeout":"0","x":1020,"y":40,"wires":[["256d0392.f2548c","6a95b7c5.5901f8"]]},{"id":"256d0392.f2548c","type":"function","z":"7355e642.932538","name":"message","func":"\nmsg.payload = {chatId : 1111111111, type : 'message', content : msg.topic + '  ' + msg.payload}\nreturn msg;","outputs":1,"noerr":0,"x":1220,"y":580,"wires":[["17e458c3.0a9dd7"]]},{"id":"e9e54225.8596","type":"ui_button","z":"7355e642.932538","name":"","group":"3ac4d831.cb06a8","order":0,"width":0,"height":0,"passthru":true,"label":"FAMILY ROOM","tooltip":"","color":"","bgcolor":"","icon":"","payload":"","payloadType":"str","topic":"toggle","x":580,"y":40,"wires":[["de3f81b5.8f7a1"]]},{"id":"9f1060a7.917e7","type":"telegram command","z":"7355e642.932538","name":"1","command":"/1","bot":"b7d63749.957328","strict":false,"x":430,"y":40,"wires":[["e9e54225.8596"],[]]},{"id":"17e458c3.0a9dd7","type":"telegram sender","z":"7355e642.932538","name":"","bot":"b7d63749.957328","x":1190,"y":620,"wires":[[]]},{"id":"6a95b7c5.5901f8","type":"rpi-gpio out","z":"7355e642.932538","name":"","pin":"31","set":"","level":"0","freq":"","out":"out","x":1220,"y":40,"wires":[]},{"id":"276f44b5.15badc","type":"smartswitch","z":"7355e642.932538","name":"","topic":"MASTER ROOM","timeout":"0","x":1010,"y":100,"wires":[["256d0392.f2548c","ae5f077f.3ff778"]]},{"id":"2a2882d0.7a860e","type":"ui_button","z":"7355e642.932538","name":"","group":"3ac4d831.cb06a8","order":0,"width":0,"height":0,"passthru":true,"label":"MASTER ROOM","tooltip":"","color":"","bgcolor":"","icon":"","payload":"","payloadType":"str","topic":"toggle","x":590,"y":100,"wires":[["276f44b5.15badc"]]},{"id":"3b00a66d.53ccca","type":"telegram command","z":"7355e642.932538","name":"2","command":"/2","bot":"b7d63749.957328","strict":false,"x":430,"y":100,"wires":[["2a2882d0.7a860e"],[]]},{"id":"ae5f077f.3ff778","type":"rpi-gpio out","z":"7355e642.932538","name":"","pin":"35","set":"","level":"0","freq":"","out":"out","x":1220,"y":100,"wires":[]},{"id":"1555e300.febb3d","type":"smartswitch","z":"7355e642.932538","name":"","topic":"SPARE ROOM","timeout":"0","x":1020,"y":160,"wires":[["cf195a42.e37138","256d0392.f2548c"]]},{"id":"428859f3.c337b8","type":"ui_button","z":"7355e642.932538","name":"","group":"3ac4d831.cb06a8","order":0,"width":0,"height":0,"passthru":true,"label":"SPARE ROOM","tooltip":"","color":"","bgcolor":"","icon":"","payload":"","payloadType":"str","topic":"toggle","x":580,"y":160,"wires":[["1555e300.febb3d"]]},{"id":"acc831f6.7e79c","type":"telegram command","z":"7355e642.932538","name":"3","command":"/3","bot":"b7d63749.957328","strict":false,"x":430,"y":160,"wires":[["428859f3.c337b8"],[]]},{"id":"cf195a42.e37138","type":"rpi-gpio out","z":"7355e642.932538","name":"","pin":"37","set":"","level":"0","freq":"","out":"out","x":1220,"y":160,"wires":[]},{"id":"d5ae8f6d.29fb7","type":"smartswitch","z":"7355e642.932538","name":"","topic":"BATH ROOM","timeout":"0","x":1020,"y":220,"wires":[["1c52ef1b.564ee1","256d0392.f2548c"]]},{"id":"f29f49d0.5e83d8","type":"ui_button","z":"7355e642.932538","name":"","group":"3ac4d831.cb06a8","order":0,"width":0,"height":0,"passthru":true,"label":"BATH ROOM","tooltip":"","color":"","bgcolor":"","icon":"","payload":"","payloadType":"str","topic":"toggle","x":580,"y":220,"wires":[["d5ae8f6d.29fb7"]]},{"id":"63f4be8a.26e26","type":"telegram command","z":"7355e642.932538","name":"4","command":"/4","bot":"b7d63749.957328","strict":false,"x":430,"y":220,"wires":[["f29f49d0.5e83d8"],[]]},{"id":"1c52ef1b.564ee1","type":"rpi-gpio out","z":"7355e642.932538","name":"","pin":"40","set":"","level":"0","freq":"","out":"out","x":1220,"y":220,"wires":[]},{"id":"e960192d.a38eb8","type":"smartswitch","z":"7355e642.932538","name":"","topic":"DINING ROOM","timeout":"0","x":1020,"y":280,"wires":[["6977e098.fc119","256d0392.f2548c"]]},{"id":"73f44d0e.198ee4","type":"ui_button","z":"7355e642.932538","name":"","group":"3ac4d831.cb06a8","order":0,"width":0,"height":0,"passthru":true,"label":"DINING ROOM","tooltip":"","color":"","bgcolor":"","icon":"","payload":"","payloadType":"str","topic":"toggle","x":580,"y":280,"wires":[["e960192d.a38eb8"]]},{"id":"56b17b98.f41454","type":"telegram command","z":"7355e642.932538","name":"5","command":"/5","bot":"b7d63749.957328","strict":false,"x":430,"y":280,"wires":[["73f44d0e.198ee4"],[]]},{"id":"6977e098.fc119","type":"rpi-gpio out","z":"7355e642.932538","name":"","pin":"38","set":"","level":"0","freq":"","out":"out","x":1220,"y":280,"wires":[]},{"id":"46d2e0f2.e1f53","type":"smartswitch","z":"7355e642.932538","name":"","topic":"KITCHEN","timeout":"0","x":1040,"y":340,"wires":[["b3179bd2.876b68","256d0392.f2548c"]]},{"id":"82b9415a.b5f4a","type":"ui_button","z":"7355e642.932538","name":"","group":"3ac4d831.cb06a8","order":0,"width":0,"height":0,"passthru":true,"label":"KITCHEN","tooltip":"","color":"","bgcolor":"","icon":"","payload":"","payloadType":"str","topic":"toggle","x":560,"y":340,"wires":[["46d2e0f2.e1f53"]]},{"id":"d8b3b639.d83748","type":"telegram command","z":"7355e642.932538","name":"6","command":"/6","bot":"b7d63749.957328","strict":false,"x":430,"y":340,"wires":[["82b9415a.b5f4a"],[]]},{"id":"b3179bd2.876b68","type":"rpi-gpio out","z":"7355e642.932538","name":"","pin":"36","set":"","level":"0","freq":"","out":"out","x":1220,"y":340,"wires":[]},{"id":"7758da3a.822b74","type":"smartswitch","z":"7355e642.932538","name":"","topic":"OFFICE","timeout":"0","x":1040,"y":400,"wires":[["cda27a8c.71f918","256d0392.f2548c"]]},{"id":"68ad4f5a.5c2bc","type":"ui_button","z":"7355e642.932538","name":"","group":"3ac4d831.cb06a8","order":0,"width":0,"height":0,"passthru":true,"label":"OFFICE","tooltip":"","color":"","bgcolor":"","icon":"","payload":"","payloadType":"str","topic":"toggle","x":560,"y":400,"wires":[["7758da3a.822b74"]]},{"id":"e310bdf9.e73e3","type":"telegram command","z":"7355e642.932538","name":"7","command":"/7","bot":"b7d63749.957328","strict":false,"x":430,"y":400,"wires":[["68ad4f5a.5c2bc"],[]]},{"id":"cda27a8c.71f918","type":"rpi-gpio out","z":"7355e642.932538","name":"","pin":"33","set":"","level":"0","freq":"","out":"out","x":1220,"y":400,"wires":[]},{"id":"2ebcf200.ed873e","type":"smartswitch","z":"7355e642.932538","name":"","topic":"PATIO","timeout":"0","x":1050,"y":460,"wires":[["7321f9ad.15e358","256d0392.f2548c"]]},{"id":"b3880aa1.7a5f48","type":"ui_button","z":"7355e642.932538","name":"","group":"3ac4d831.cb06a8","order":0,"width":0,"height":0,"passthru":true,"label":"PATIO","tooltip":"","color":"","bgcolor":"","icon":"","payload":"","payloadType":"str","topic":"toggle","x":550,"y":460,"wires":[["2ebcf200.ed873e"]]},{"id":"16ed2318.9c3cdd","type":"telegram command","z":"7355e642.932538","name":"8","command":"/8","bot":"b7d63749.957328","strict":false,"x":430,"y":460,"wires":[["b3880aa1.7a5f48"],[]]},{"id":"7321f9ad.15e358","type":"rpi-gpio out","z":"7355e642.932538","name":"","pin":"29","set":"","level":"0","freq":"","out":"out","x":1220,"y":460,"wires":[]},{"id":"399c10b9.6855e","type":"smartswitch","z":"7355e642.932538","name":"","topic":"DRIVEWAY","timeout":"0","x":1030,"y":520,"wires":[["8ab21e46.31aaa","256d0392.f2548c"]]},{"id":"dc42252e.2390a8","type":"ui_button","z":"7355e642.932538","name":"","group":"3ac4d831.cb06a8","order":0,"width":0,"height":0,"passthru":true,"label":"DRIVEWAY","tooltip":"","color":"","bgcolor":"","icon":"","payload":"","payloadType":"str","topic":"toggle","x":570,"y":520,"wires":[["399c10b9.6855e"]]},{"id":"742e4124.6bde9","type":"telegram command","z":"7355e642.932538","name":"9","command":"/9","bot":"b7d63749.957328","strict":false,"x":430,"y":520,"wires":[["dc42252e.2390a8"],[]]},{"id":"8ab21e46.31aaa","type":"rpi-gpio out","z":"7355e642.932538","name":"","pin":"32","set":"","level":"0","freq":"","out":"out","x":1220,"y":520,"wires":[]},{"id":"aa65196e.2d1228","type":"ui_button","z":"7355e642.932538","name":"","group":"3ac4d831.cb06a8","order":0,"width":0,"height":0,"passthru":true,"label":"SLEEP","tooltip":"","color":"","bgcolor":"","icon":"","payload":"10","payloadType":"str","topic":"timeout","x":800,"y":600,"wires":[["399c10b9.6855e","2ebcf200.ed873e","7758da3a.822b74","46d2e0f2.e1f53","e960192d.a38eb8","d5ae8f6d.29fb7","1555e300.febb3d","276f44b5.15badc","de3f81b5.8f7a1"]]},{"id":"e6efcfd0.acf33","type":"telegram command","z":"7355e642.932538","name":"10","command":"/10","bot":"b7d63749.957328","strict":false,"x":430,"y":580,"wires":[["aa65196e.2d1228"],[]]},{"id":"f19ff37a.38678","type":"ui_switch","z":"7355e642.932538","name":"F R","label":"FAMILY ROOM","tooltip":"","group":"85429dae.9a4b5","order":19,"width":0,"height":0,"passthru":true,"decouple":"false","topic":"set","style":"","onvalue":"1","onvalueType":"num","onicon":"","oncolor":"","offvalue":"0","offvalueType":"num","officon":"","offcolor":"","x":770,"y":60,"wires":[["de3f81b5.8f7a1"]]},{"id":"710570cd.798a5","type":"ui_switch","z":"7355e642.932538","name":"M R","label":"MASTER ROOM","tooltip":"","group":"85429dae.9a4b5","order":19,"width":0,"height":0,"passthru":true,"decouple":"false","topic":"set","style":"","onvalue":"1","onvalueType":"num","onicon":"","oncolor":"","offvalue":"0","offvalueType":"num","officon":"","offcolor":"","x":770,"y":120,"wires":[["276f44b5.15badc"]]},{"id":"af619060.4745e","type":"ui_switch","z":"7355e642.932538","name":"S R","label":"SPARE ROOM","tooltip":"","group":"85429dae.9a4b5","order":19,"width":0,"height":0,"passthru":true,"decouple":"false","topic":"set","style":"","onvalue":"1","onvalueType":"num","onicon":"","oncolor":"","offvalue":"0","offvalueType":"num","officon":"","offcolor":"","x":770,"y":180,"wires":[["1555e300.febb3d"]]},{"id":"63b7cb7c.42d214","type":"ui_switch","z":"7355e642.932538","name":"B R","label":"BATH ROOM","tooltip":"","group":"85429dae.9a4b5","order":19,"width":0,"height":0,"passthru":true,"decouple":"false","topic":"set","style":"","onvalue":"1","onvalueType":"num","onicon":"","oncolor":"","offvalue":"0","offvalueType":"num","officon":"","offcolor":"","x":770,"y":240,"wires":[["d5ae8f6d.29fb7"]]},{"id":"804ac699.b9acc8","type":"ui_switch","z":"7355e642.932538","name":"D R","label":"DINING ROOM","tooltip":"","group":"85429dae.9a4b5","order":19,"width":0,"height":0,"passthru":true,"decouple":"false","topic":"set","style":"","onvalue":"1","onvalueType":"num","onicon":"","oncolor":"","offvalue":"0","offvalueType":"num","officon":"","offcolor":"","x":770,"y":300,"wires":[["e960192d.a38eb8"]]},{"id":"8dd2d4dc.d17ee8","type":"ui_switch","z":"7355e642.932538","name":"K","label":"KITCHEN","tooltip":"","group":"85429dae.9a4b5","order":19,"width":0,"height":0,"passthru":true,"decouple":"false","topic":"set","style":"","onvalue":"1","onvalueType":"num","onicon":"","oncolor":"","offvalue":"0","offvalueType":"num","officon":"","offcolor":"","x":770,"y":360,"wires":[["46d2e0f2.e1f53"]]},{"id":"c1223799.b32428","type":"ui_switch","z":"7355e642.932538","name":"O","label":"OFFICE","tooltip":"","group":"85429dae.9a4b5","order":19,"width":0,"height":0,"passthru":true,"decouple":"false","topic":"set","style":"","onvalue":"1","onvalueType":"num","onicon":"","oncolor":"","offvalue":"0","offvalueType":"num","officon":"","offcolor":"","x":770,"y":420,"wires":[["7758da3a.822b74"]]},{"id":"fa44cb6d.6dd7f8","type":"ui_switch","z":"7355e642.932538","name":"P","label":"PATIO","tooltip":"","group":"85429dae.9a4b5","order":19,"width":0,"height":0,"passthru":true,"decouple":"false","topic":"set","style":"","onvalue":"1","onvalueType":"num","onicon":"","oncolor":"","offvalue":"0","offvalueType":"num","officon":"","offcolor":"","x":770,"y":480,"wires":[["2ebcf200.ed873e"]]},{"id":"a7768b38.795df8","type":"ui_switch","z":"7355e642.932538","name":"D","label":"DRIVEWAY","tooltip":"","group":"85429dae.9a4b5","order":19,"width":0,"height":0,"passthru":true,"decouple":"false","topic":"set","style":"","onvalue":"1","onvalueType":"num","onicon":"","oncolor":"","offvalue":"0","offvalueType":"num","officon":"","offcolor":"","x":770,"y":540,"wires":[["399c10b9.6855e"]]},{"id":"38f862cc.5b1fee","type":"ui_button","z":"7355e642.932538","name":"","group":"3a987860.bfdeb8","order":0,"width":0,"height":0,"passthru":true,"label":"sleep","tooltip":"","color":"","bgcolor":"","icon":"","payload":"5","payloadType":"str","topic":"timeout","x":250,"y":340,"wires":[["de3f81b5.8f7a1"]]},{"id":"c29782ba.6fb18","type":"rpi-gpio in","z":"7355e642.932538","name":"","pin":"11","intype":"tri","debounce":"25","read":true,"x":90,"y":260,"wires":[["38f862cc.5b1fee","d6a8dcad.2db35","a2e5e220.61b4b"]]},{"id":"e465983c.2fa4f8","type":"ui_switch","z":"7355e642.932538","name":"all","label":"ALL","tooltip":"","group":"85429dae.9a4b5","order":19,"width":0,"height":0,"passthru":true,"decouple":"false","topic":"set","style":"","onvalue":"1","onvalueType":"num","onicon":"","oncolor":"","offvalue":"0","offvalueType":"num","officon":"","offcolor":"","x":590,"y":580,"wires":[["a7768b38.795df8","fa44cb6d.6dd7f8","c1223799.b32428","8dd2d4dc.d17ee8","804ac699.b9acc8","63b7cb7c.42d214","af619060.4745e","710570cd.798a5","f19ff37a.38678"]]},{"id":"644f2a86.15f754","type":"inject","z":"7355e642.932538","name":"","topic":"","payload":"1","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":"","x":90,"y":340,"wires":[["38f862cc.5b1fee","d6a8dcad.2db35","a2e5e220.61b4b"]]},{"id":"d6a8dcad.2db35","type":"ui_button","z":"7355e642.932538","name":"","group":"3a987860.bfdeb8","order":0,"width":0,"height":0,"passthru":true,"label":"on","tooltip":"","color":"","bgcolor":"","icon":"","payload":"1","payloadType":"str","topic":"state","x":250,"y":300,"wires":[["de3f81b5.8f7a1"]]},{"id":"a2e5e220.61b4b","type":"ui_button","z":"7355e642.932538","name":"","group":"3a987860.bfdeb8","order":0,"width":0,"height":0,"passthru":true,"label":"pir","tooltip":"","color":"","bgcolor":"","icon":"","payload":"1","payloadType":"str","topic":"set","x":250,"y":260,"wires":[["de3f81b5.8f7a1"]]},{"id":"3ac4d831.cb06a8","type":"ui_group","z":"","name":"light","tab":"ab92a34b.f6f13","disp":true,"width":"6","collapse":false},{"id":"b7d63749.957328","type":"telegram bot","z":"","botname":"LostPi","usernames":"","chatids":"","baseapiurl":"","updatemode":"polling","pollinterval":"300","sockshost":"","socksport":"6667","socksusername":"anonymous","sockspassword":"","bothost":"","localbotport":"8443","publicbotport":"8443","privatekey":"","certificate":"","verboselogging":true},{"id":"85429dae.9a4b5","type":"ui_group","z":"","name":"timer","tab":"175d481c.72b628","disp":true,"width":"6","collapse":false},{"id":"3a987860.bfdeb8","type":"ui_group","z":"","name":"pir","tab":"ab92a34b.f6f13","disp":true,"width":"6","collapse":false},{"id":"ab92a34b.f6f13","type":"ui_tab","z":"","name":"Home","icon":"dashboard","disabled":false,"hidden":false},{"id":"175d481c.72b628","type":"ui_tab","z":"","name":"Home","icon":"home","order":"1"}]

hi guys, this is my first attempt at none-red/coding, and raspberry pi3
as you can see, everything above works pretty well (don't know why, lol) and i am quite happy with
the direction it is going.
the part that i need help with, is the bit (hack) on the left.
at the end of the day, there will be one p.i.r per light, and a switch on the dash and telegram
to enable/disable the function.
so the basics of its operation, is, when enabled, if the pir is activated, the light will go on and
will go off if there is no activity for a set time (simple right? lol)
you can test every scenarios as it is now, and you will see it works 'ok' except, i cant disable it, the pir must be triggered twice, if i switch on a light, it would switch off after pir is triggered and timed out, and then there is the fact of the unnecessary, extra buttons (the sleep one is useful and i will keep that function)
if you can help, i will appreciate it.
:thinking:

1 Like

Someone else asked exactly the same question in the last couple of days, is this coursework?

Search the forum and you should find it.

thanx, i went back on the posts, and found nothing related to my problem although interesting
if you think i have something to do with these posts, or doing a school project, then no.

https://discourse.nodered.org/t/home-security-alarm/7936?u=lost66
&&
https://discourse.nodered.org/t/security-alarm-turn-on-light-and-buzzer/8134?u=lost66

what i think i need, is a function node between the gpio node and smartswitch node, that will replace the three buttons, but must have a switch on the dash to disable

so if i am not mistaken,

when switched on and when p.i.r is triggered, the node must send:
the topics: set = 1, timeout = 30 and state = 1. if enabled but, not time out if light is already on

thanx again

Take a look at this thread. How do I only pass a motion sensor change between dusk and dawn?

thanx again for trying to help,
but let me try be a bit more spastic,

the main problem for me starts with the node 'smartswitch' itself:
the buttons needs to injects a 'topic' and 'payload' to the inputs:

  • topic "toggle" = toggle current state
  • topic "state" = payload is 1 ON or 0 OFF
  • topic "reset" = reset the timer if on
  • topic "set" = payload is 1 Enable, 0 Disable timeout function
  • topic "timeout" = set timeout to new number if turned on

the 'topic' is key to how 'smartswitch' reacts to the input it gets.
so the one way that i can do this at the moment, is to use the 'inject' node
and the dash 'button' node.

if i want to control it with telegram, i take it through a 'button' node (because i know no other way)
the same goes for, if i want to use the 'gpio in' node

but now i want to do it different,
i want to use the 'gpio' node, to a ...'function', that will send the 'topic' and 'payload' to the ...'smartswitch'
(it should be clear by now, that i do not know how to wright the 'function' node)

so for the p.i.r connected to the 'gpio' to work, the 'function' would have to send...,
topic "state" & payload 1, and
topic "set" & payload 1, and
topic "timeout" & payload 30
...to the 'smartswitch'

here is a downright nasty piece of flow, but it dose overcome some of the problems


and the code

[{"id":"ab055f49.a91ff","type":"rpi-gpio in","z":"c0964dcc.37f2f","name":"","pin":"11","intype":"tri","debounce":"25","read":true,"x":50,"y":180,"wires":[["27e4619f.b0563e","e8458a78.d2a958","e9c8d44c.e8e7a8","ad73d95a.4f9b48"]]},{"id":"a381b18f.d834c","type":"inject","z":"c0964dcc.37f2f","name":"","topic":"","payload":"","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":70,"y":140,"wires":[["e8458a78.d2a958","e9c8d44c.e8e7a8","27e4619f.b0563e","ad73d95a.4f9b48"]]},{"id":"1b74fe28.c4b412","type":"function","z":"c0964dcc.37f2f","name":"msg.topic=\"set\"; msg.payload=\"1\";","func":"msg.topic=\"set\";\nmsg.payload=\"1\";\n\nreturn msg;","outputs":1,"noerr":0,"x":300,"y":280,"wires":[["7dc8fdba.943334"]]},{"id":"f3fcf696.1fcd88","type":"function","z":"c0964dcc.37f2f","name":"msg.topic=\"timeout\"; msg.payload=\"5\";","func":"msg.topic=\"timeout\";\nmsg.payload=\"5\";\n\nreturn msg;","outputs":1,"noerr":0,"x":350,"y":200,"wires":[["7dc8fdba.943334","17e42063.99f22"]]},{"id":"27e4619f.b0563e","type":"function","z":"c0964dcc.37f2f","name":"msg.topic=\"state\"; msg.payload=\"1\";","func":"msg.topic=\"state\";\nmsg.payload=\"1\";\n\nreturn msg;","outputs":1,"noerr":0,"x":290,"y":340,"wires":[["7dc8fdba.943334"]]},{"id":"e8458a78.d2a958","type":"delay","z":"c0964dcc.37f2f","name":"","pauseType":"delay","timeout":"0.5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":270,"y":160,"wires":[["f3fcf696.1fcd88"]]},{"id":"e9c8d44c.e8e7a8","type":"delay","z":"c0964dcc.37f2f","name":"","pauseType":"delay","timeout":"0.3","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":230,"y":240,"wires":[["1b74fe28.c4b412"]]},{"id":"ad73d95a.4f9b48","type":"delay","z":"c0964dcc.37f2f","name":"","pauseType":"delay","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":300,"y":80,"wires":[["f4de1360.d599f"]]},{"id":"f4de1360.d599f","type":"trigger","z":"c0964dcc.37f2f","op1":"","op2":"","op1type":"str","op2type":"str","duration":"10","extend":false,"units":"ms","reset":"","bytopic":"all","name":"","x":310,"y":120,"wires":[["b72473a5.0ecf3"]]},{"id":"9198ab90.d901d8","type":"telegram command","z":"c0964dcc.37f2f","name":"1","command":"/1","bot":"","strict":false,"x":470,"y":20,"wires":[["b72473a5.0ecf3"],[]]},{"id":"b72473a5.0ecf3","type":"ui_button","z":"c0964dcc.37f2f","name":"","group":"3ac4d831.cb06a8","order":0,"width":0,"height":0,"passthru":true,"label":"FAMILY ROOM","tooltip":"","color":"","bgcolor":"","icon":"","payload":"","payloadType":"str","topic":"toggle","x":620,"y":20,"wires":[["7dc8fdba.943334"]]},{"id":"17e42063.99f22","type":"ui_switch","z":"c0964dcc.37f2f","name":"F R","label":"FAMILY ROOM","tooltip":"","group":"85429dae.9a4b5","order":19,"width":0,"height":0,"passthru":true,"decouple":"false","topic":"set","style":"","onvalue":"1","onvalueType":"num","onicon":"","oncolor":"","offvalue":"0","offvalueType":"num","officon":"","offcolor":"","x":730,"y":60,"wires":[["7dc8fdba.943334"]]},{"id":"7dc8fdba.943334","type":"smartswitch","z":"c0964dcc.37f2f","name":"","topic":"FAMILY ROOM","timeout":"0","x":1020,"y":20,"wires":[["be404b93.02f848","7386d633.e0f6e8"]]},{"id":"7386d633.e0f6e8","type":"rpi-gpio out","z":"c0964dcc.37f2f","name":"","pin":"31","set":"","level":"0","freq":"","out":"out","x":1220,"y":20,"wires":[]},{"id":"be404b93.02f848","type":"function","z":"c0964dcc.37f2f","name":"message","func":"\nmsg.payload = {chatId : 590161514, type : 'message', content : msg.topic + '  ' + msg.payload}\nreturn msg;","outputs":1,"noerr":0,"x":1220,"y":420,"wires":[["81afe49d.b932e8"]]},{"id":"81afe49d.b932e8","type":"telegram sender","z":"c0964dcc.37f2f","name":"","bot":"","x":1190,"y":460,"wires":[[]]},{"id":"836dd779.816168","type":"telegram command","z":"c0964dcc.37f2f","name":"10","command":"/10","bot":"","strict":false,"x":470,"y":440,"wires":[["8ab55deb.5f5"],[]]},{"id":"fcadb7fc.e25cf8","type":"ui_switch","z":"c0964dcc.37f2f","name":"all","label":"ALL","tooltip":"","group":"3ac4d831.cb06a8","order":19,"width":0,"height":0,"passthru":true,"decouple":"false","topic":"set","style":"","onvalue":"1","onvalueType":"num","onicon":"","oncolor":"","offvalue":"0","offvalueType":"num","officon":"","offcolor":"","x":610,"y":400,"wires":[["17e42063.99f22"]]},{"id":"8ab55deb.5f5","type":"ui_button","z":"c0964dcc.37f2f","name":"","group":"3ac4d831.cb06a8","order":0,"width":0,"height":0,"passthru":true,"label":"SLEEP","tooltip":"","color":"","bgcolor":"","icon":"","payload":"10","payloadType":"str","topic":"timeout","x":800,"y":440,"wires":[["7dc8fdba.943334"]]},{"id":"3ac4d831.cb06a8","type":"ui_group","z":"","name":"light","tab":"ab92a34b.f6f13","disp":true,"width":"6","collapse":false},{"id":"85429dae.9a4b5","type":"ui_group","z":"","name":"timer","tab":"175d481c.72b628","disp":true,"width":"6","collapse":false},{"id":"ab92a34b.f6f13","type":"ui_tab","z":"","name":"Home","icon":"dashboard","disabled":false,"hidden":false},{"id":"175d481c.72b628","type":"ui_tab","z":"","name":"Home","icon":"home","order":"1"}]

it is not practical to use as is, but it shows what is needed.
when triggered, (from the bottom, up)

-it sends:
msg.topic="state";
msg.payload="1";
return msg;
to the 'smartswitch'

-after 0.3sec (these delays ensures that it dose not have to be triggered twice for the desired outcome)

-it sends:
msg.topic="set";
msg.payload="1";
return msg;
to the 'smartswitch'

-after 0.5sec

-it sends:
msg.topic="timeout";
msg.payload="5";
return msg;
to the 'smartswitch',
and to the 'FR switch' (somehow this ensures that the original 'set' of the 'smartswitch' is retained)

-after 5sec (the same time of the 'timeout')

-it sends:
a quick to toggle to 'family room' (this sets the original 'state' of the 'smartswitch' back to what it was)

like i say, this is in no way a practical solution, but it is all that i can come.
i have spent many hour and late nights/mornings on trying to find answers
i feel like node-red is not as easy as i hoped, and it is time to give up