Thanks to ghayne's input I fine tuned my flow and added MQTT and websocket connection demo.
Have fun with it
[{"id":"57da71a5.519be","type":"tab","label":"I2C","disabled":false,"info":""},{"id":"a0db703.98f6b9","type":"i2c scan","z":"57da71a5.519be","name":"I2C scan","x":280,"y":120,"wires":[["73b294be.cc89ec"],["22b9fd8c.88e152"]]},{"id":"73b294be.cc89ec","type":"debug","z":"57da71a5.519be","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":450,"y":100,"wires":[]},{"id":"22b9fd8c.88e152","type":"debug","z":"57da71a5.519be","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":450,"y":140,"wires":[]},{"id":"c80b3a64.ef9f68","type":"inject","z":"57da71a5.519be","name":"I2C","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":130,"y":120,"wires":[["a0db703.98f6b9"]]},{"id":"c8d32b33.1066a8","type":"i2c in","z":"57da71a5.519be","name":"","address":"32","command":"6","count":"1","x":450,"y":300,"wires":[["d9405581.7230e8"]]},{"id":"c7c67536.cc0d98","type":"i2c out","z":"57da71a5.519be","name":"","address":"32","command":"6","payload":"0","payloadType":"num","count":"1","x":320,"y":260,"wires":[]},{"id":"aa1d6209.04a5c","type":"inject","z":"57da71a5.519be","name":"all r on","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":130,"y":260,"wires":[["c7c67536.cc0d98","130d917e.ff055f"]]},{"id":"130d917e.ff055f","type":"delay","z":"57da71a5.519be","name":"100 ms","pauseType":"delay","timeout":"100","timeoutUnits":"milliseconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":320,"y":300,"wires":[["c8d32b33.1066a8"]]},{"id":"7f2eb4d3.4a86dc","type":"inject","z":"57da71a5.519be","name":"device status check","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":690,"y":120,"wires":[["4b7766b7.4dfe88"]]},{"id":"4b7766b7.4dfe88","type":"i2c in","z":"57da71a5.519be","name":"","address":"32","command":"6","count":"1","x":870,"y":120,"wires":[["28b96e3c.e9bd02"]]},{"id":"c9b53692.3a60d8","type":"debug","z":"57da71a5.519be","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":1170,"y":100,"wires":[]},{"id":"28b96e3c.e9bd02","type":"function","z":"57da71a5.519be","name":"","func":"return [{payload : msg.payload},\n {payload : msg.payload.toString(2).padStart(4,'0')}\n ];","outputs":2,"noerr":0,"x":1010,"y":120,"wires":[["c9b53692.3a60d8"],["932d9fe8.031dd"]]},{"id":"932d9fe8.031dd","type":"debug","z":"57da71a5.519be","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":1170,"y":140,"wires":[]},{"id":"641c1ba9.c785d4","type":"i2c in","z":"57da71a5.519be","name":"","address":"32","command":"6","count":"1","x":710,"y":900,"wires":[["ccdad9d2.3d9a98"]]},{"id":"44be667e.060e68","type":"inject","z":"57da71a5.519be","name":"toggle r1","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":140,"y":500,"wires":[["2459c14d.a2c3ce"]]},{"id":"70c2b9e2.824c28","type":"i2c in","z":"57da71a5.519be","name":"","address":"32","command":"6","count":"1","x":630,"y":560,"wires":[["245a9c21.285894"]]},{"id":"245a9c21.285894","type":"function","z":"57da71a5.519be","name":"","func":"return{payload:msg.payload^msg.relay};","outputs":1,"noerr":0,"x":750,"y":560,"wires":[["b72763c7.c7b12"]]},{"id":"b72763c7.c7b12","type":"i2c out","z":"57da71a5.519be","name":"","address":"32","command":"6","payload":"payload","payloadType":"msg","count":"1","x":880,"y":560,"wires":[]},{"id":"2459c14d.a2c3ce","type":"change","z":"57da71a5.519be","name":"","rules":[{"t":"set","p":"relay","pt":"msg","to":"1","tot":"num"},{"t":"delete","p":"payload","pt":"msg"},{"t":"delete","p":"topic","pt":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":320,"y":500,"wires":[["81b483b4.e9eaa"]]},{"id":"86fe7eae.59976","type":"inject","z":"57da71a5.519be","name":"toggle r2","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":140,"y":540,"wires":[["68140e94.fd806"]]},{"id":"68140e94.fd806","type":"change","z":"57da71a5.519be","name":"","rules":[{"t":"set","p":"relay","pt":"msg","to":"2","tot":"num"},{"t":"delete","p":"payload","pt":"msg"},{"t":"delete","p":"topic","pt":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":320,"y":540,"wires":[["81b483b4.e9eaa"]]},{"id":"187a93ee.08aedc","type":"inject","z":"57da71a5.519be","name":"toggle r3","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":140,"y":580,"wires":[["aa757bb4.8d4878"]]},{"id":"aa757bb4.8d4878","type":"change","z":"57da71a5.519be","name":"","rules":[{"t":"set","p":"relay","pt":"msg","to":"3","tot":"num"},{"t":"delete","p":"payload","pt":"msg"},{"t":"delete","p":"topic","pt":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":320,"y":580,"wires":[["81b483b4.e9eaa"]]},{"id":"1ac58952.79aab7","type":"inject","z":"57da71a5.519be","name":"toggle r4","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":140,"y":620,"wires":[["7c085399.f5e9ec"]]},{"id":"7c085399.f5e9ec","type":"change","z":"57da71a5.519be","name":"","rules":[{"t":"set","p":"relay","pt":"msg","to":"4","tot":"num"},{"t":"delete","p":"payload","pt":"msg"},{"t":"delete","p":"topic","pt":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":320,"y":620,"wires":[["81b483b4.e9eaa"]]},{"id":"47583018.67892","type":"change","z":"57da71a5.519be","name":"","rules":[{"t":"delete","p":"topic","pt":"msg"},{"t":"delete","p":"payload","pt":"msg"},{"t":"set","p":"relay","pt":"msg","to":"1","tot":"num"},{"t":"set","p":"value","pt":"msg","to":"1","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":320,"y":760,"wires":[["8e1b10c7.d7ee1"]]},{"id":"4b25d308.b98fac","type":"change","z":"57da71a5.519be","name":"","rules":[{"t":"delete","p":"topic","pt":"msg"},{"t":"delete","p":"payload","pt":"msg"},{"t":"set","p":"relay","pt":"msg","to":"4","tot":"num"},{"t":"set","p":"value","pt":"msg","to":"1","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":320,"y":1000,"wires":[["8e1b10c7.d7ee1"]]},{"id":"77d5b4d5.25d71c","type":"change","z":"57da71a5.519be","name":"","rules":[{"t":"delete","p":"topic","pt":"msg"},{"t":"delete","p":"payload","pt":"msg"},{"t":"set","p":"relay","pt":"msg","to":"3","tot":"num"},{"t":"set","p":"value","pt":"msg","to":"1","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":320,"y":920,"wires":[["8e1b10c7.d7ee1"]]},{"id":"d21e2dde.0a8a9","type":"change","z":"57da71a5.519be","name":"","rules":[{"t":"delete","p":"topic","pt":"msg"},{"t":"delete","p":"payload","pt":"msg"},{"t":"set","p":"relay","pt":"msg","to":"2","tot":"num"},{"t":"set","p":"value","pt":"msg","to":"1","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":320,"y":840,"wires":[["8e1b10c7.d7ee1"]]},{"id":"960e3a67.f5d538","type":"inject","z":"57da71a5.519be","name":"switch r1 on","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":150,"y":760,"wires":[["47583018.67892"]]},{"id":"cb732c72.1c852","type":"inject","z":"57da71a5.519be","name":"switch r2 on","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":150,"y":840,"wires":[["d21e2dde.0a8a9"]]},{"id":"3f9755c1.39bfaa","type":"inject","z":"57da71a5.519be","name":"switch r3 on","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":150,"y":920,"wires":[["77d5b4d5.25d71c"]]},{"id":"17c78dc7.2f5482","type":"inject","z":"57da71a5.519be","name":"switch r4 on","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":150,"y":1000,"wires":[["4b25d308.b98fac"]]},{"id":"c6fbc1d5.0c648","type":"change","z":"57da71a5.519be","name":"","rules":[{"t":"delete","p":"topic","pt":"msg"},{"t":"delete","p":"payload","pt":"msg"},{"t":"set","p":"relay","pt":"msg","to":"1","tot":"num"},{"t":"set","p":"value","pt":"msg","to":"0","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":320,"y":800,"wires":[["8e1b10c7.d7ee1"]]},{"id":"4f85deba.616a7","type":"inject","z":"57da71a5.519be","name":"switch r1 off","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":150,"y":800,"wires":[["c6fbc1d5.0c648"]]},{"id":"57251349.0c76ec","type":"change","z":"57da71a5.519be","name":"","rules":[{"t":"delete","p":"topic","pt":"msg"},{"t":"delete","p":"payload","pt":"msg"},{"t":"set","p":"relay","pt":"msg","to":"2","tot":"num"},{"t":"set","p":"value","pt":"msg","to":"0","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":320,"y":880,"wires":[["8e1b10c7.d7ee1"]]},{"id":"2aaca5ac.8a173a","type":"inject","z":"57da71a5.519be","name":"switch r2 off","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":150,"y":880,"wires":[["57251349.0c76ec"]]},{"id":"5e6ac02c.b5372","type":"change","z":"57da71a5.519be","name":"","rules":[{"t":"delete","p":"topic","pt":"msg"},{"t":"delete","p":"payload","pt":"msg"},{"t":"set","p":"relay","pt":"msg","to":"3","tot":"num"},{"t":"set","p":"value","pt":"msg","to":"0","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":320,"y":960,"wires":[["8e1b10c7.d7ee1"]]},{"id":"c69dd00d.1097","type":"inject","z":"57da71a5.519be","name":"switch r3 off","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":150,"y":960,"wires":[["5e6ac02c.b5372"]]},{"id":"fc5eed6b.9baea","type":"change","z":"57da71a5.519be","name":"","rules":[{"t":"delete","p":"topic","pt":"msg"},{"t":"delete","p":"payload","pt":"msg"},{"t":"set","p":"relay","pt":"msg","to":"4","tot":"num"},{"t":"set","p":"value","pt":"msg","to":"0","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":320,"y":1040,"wires":[["8e1b10c7.d7ee1"]]},{"id":"9a34a124.52787","type":"inject","z":"57da71a5.519be","name":"switch r4 off","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":150,"y":1040,"wires":[["fc5eed6b.9baea"]]},{"id":"89de8eca.023bb","type":"i2c out","z":"57da71a5.519be","name":"","address":"32","command":"6","payload":"payload","payloadType":"msg","count":"1","x":960,"y":900,"wires":[]},{"id":"83b87ebc.429","type":"comment","z":"57da71a5.519be","name":"switch on or off; with bit masking, no impact on other relays, if relay already on or off do nothing","info":"","x":360,"y":700,"wires":[]},{"id":"78b139e2.f909a8","type":"comment","z":"57da71a5.519be","name":"switch all 4 relays on or off","info":"","x":150,"y":200,"wires":[]},{"id":"1f5e76b2.fb5cb9","type":"comment","z":"57da71a5.519be","name":"Toggles relay on and of","info":"","x":140,"y":440,"wires":[]},{"id":"22a8b580.1c9aba","type":"mqtt out","z":"57da71a5.519be","name":"","topic":"relay_shield","qos":"0","retain":"","broker":"ae5e8621.14af98","x":650,"y":1140,"wires":[]},{"id":"ca05163f.ccc348","type":"inject","z":"57da71a5.519be","name":"switch r1 on","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":150,"y":1120,"wires":[["7c1cd4e1.70617c"]]},{"id":"9596ed95.4de5c","type":"mqtt in","z":"57da71a5.519be","name":"","topic":"relay_shield/#","qos":"0","datatype":"auto","broker":"ae5e8621.14af98","x":890,"y":1140,"wires":[["c59eed13.6ef25"]]},{"id":"81b483b4.e9eaa","type":"function","z":"57da71a5.519be","name":"","func":"return{relay:(1 << (msg.relay-1))};","outputs":1,"noerr":0,"x":510,"y":560,"wires":[["70c2b9e2.824c28"]]},{"id":"8ce96375.8d598","type":"inject","z":"57da71a5.519be","name":"switch r1 off","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":150,"y":1160,"wires":[["78c44824.98eb28"]]},{"id":"c5bdf61e.64d9a8","type":"websocket in","z":"57da71a5.519be","name":"","server":"67c95b04.5d27a4","client":"","x":910,"y":1240,"wires":[["c59eed13.6ef25"]]},{"id":"163abc81.8cf893","type":"websocket out","z":"57da71a5.519be","name":"","server":"","client":"aa148930.c68918","x":700,"y":1240,"wires":[]},{"id":"81f7da08.b5c0d8","type":"inject","z":"57da71a5.519be","name":"switch r1 on","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":150,"y":1220,"wires":[["2fefe0a1.ae176"]]},{"id":"702388a8.da5e48","type":"inject","z":"57da71a5.519be","name":"switch r1 off","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":150,"y":1260,"wires":[["670caf0c.7466c"]]},{"id":"3bb32304.45b28c","type":"i2c out","z":"57da71a5.519be","name":"","address":"32","command":"6","payload":"1","payloadType":"num","count":"1","x":320,"y":1480,"wires":[]},{"id":"34766a3f.a957b6","type":"inject","z":"57da71a5.519be","name":"r1 off","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":130,"y":1480,"wires":[["3bb32304.45b28c","53dc4d1.cdfdfb4"]]},{"id":"7d8e22e5.194a3c","type":"i2c out","z":"57da71a5.519be","name":"","address":"32","command":"6","payload":"2","payloadType":"num","count":"1","x":320,"y":1640,"wires":[]},{"id":"c8f3ad02.4e8ec","type":"inject","z":"57da71a5.519be","name":"r2 off","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":130,"y":1640,"wires":[["7d8e22e5.194a3c","4576da2e.7b9494"]]},{"id":"1c2b5753.90d919","type":"i2c out","z":"57da71a5.519be","name":"","address":"32","command":"6","payload":"4","payloadType":"num","count":"1","x":320,"y":1800,"wires":[]},{"id":"42fe372d.0a4fe8","type":"inject","z":"57da71a5.519be","name":"r3 off","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":130,"y":1800,"wires":[["1c2b5753.90d919","3392a3d0.233dbc"]]},{"id":"a6c2adf0.89033","type":"i2c out","z":"57da71a5.519be","name":"","address":"32","command":"6","payload":"8","payloadType":"num","count":"1","x":320,"y":1880,"wires":[]},{"id":"cb96c25f.88bea","type":"inject","z":"57da71a5.519be","name":"r4 off","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":130,"y":1880,"wires":[["a6c2adf0.89033","f0c57ee7.87366"]]},{"id":"53dc4d1.cdfdfb4","type":"delay","z":"57da71a5.519be","name":"100 ms","pauseType":"delay","timeout":"100","timeoutUnits":"milliseconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":320,"y":1520,"wires":[["a8cd98cd.252488"]]},{"id":"a8cd98cd.252488","type":"i2c in","z":"57da71a5.519be","name":"","address":"32","command":"6","count":"1","x":450,"y":1520,"wires":[["c40b4bbe.5a34e8"]]},{"id":"4576da2e.7b9494","type":"delay","z":"57da71a5.519be","name":"100 ms","pauseType":"delay","timeout":"100","timeoutUnits":"milliseconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":320,"y":1680,"wires":[["ddf670c7.d8401"]]},{"id":"ddf670c7.d8401","type":"i2c in","z":"57da71a5.519be","name":"","address":"32","command":"6","count":"1","x":450,"y":1680,"wires":[["c40b4bbe.5a34e8"]]},{"id":"3392a3d0.233dbc","type":"delay","z":"57da71a5.519be","name":"100 ms","pauseType":"delay","timeout":"100","timeoutUnits":"milliseconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":320,"y":1840,"wires":[["d79c57db.aad3c8"]]},{"id":"d79c57db.aad3c8","type":"i2c in","z":"57da71a5.519be","name":"","address":"32","command":"6","count":"1","x":450,"y":1840,"wires":[["c40b4bbe.5a34e8"]]},{"id":"f0c57ee7.87366","type":"delay","z":"57da71a5.519be","name":"100 ms","pauseType":"delay","timeout":"100","timeoutUnits":"milliseconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":320,"y":1920,"wires":[["eec51295.d6916"]]},{"id":"eec51295.d6916","type":"i2c in","z":"57da71a5.519be","name":"","address":"32","command":"6","count":"1","x":450,"y":1920,"wires":[["c40b4bbe.5a34e8"]]},{"id":"305f67c.4876298","type":"i2c out","z":"57da71a5.519be","name":"","address":"32","command":"6","payload":"14","payloadType":"num","count":"1","x":320,"y":1400,"wires":[]},{"id":"1b2ea991.81b8d6","type":"inject","z":"57da71a5.519be","name":"r1 on","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":130,"y":1400,"wires":[["305f67c.4876298","f3415c83.c831e"]]},{"id":"8325b536.9aa7d8","type":"i2c out","z":"57da71a5.519be","name":"","address":"32","command":"6","payload":"13","payloadType":"num","count":"1","x":320,"y":1560,"wires":[]},{"id":"721693d4.c9700c","type":"inject","z":"57da71a5.519be","name":"r2 on","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":130,"y":1560,"wires":[["8325b536.9aa7d8","6640c9f2.f6b598"]]},{"id":"d2d4f047.fc875","type":"i2c out","z":"57da71a5.519be","name":"","address":"32","command":"6","payload":"11","payloadType":"num","count":"1","x":320,"y":1720,"wires":[]},{"id":"371e7130.81675e","type":"inject","z":"57da71a5.519be","name":"r3 on","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":130,"y":1720,"wires":[["d2d4f047.fc875","cb5483d.1cf378"]]},{"id":"4af4b15f.3191","type":"i2c out","z":"57da71a5.519be","name":"","address":"32","command":"6","payload":"7","payloadType":"num","count":"1","x":320,"y":1960,"wires":[]},{"id":"f8680d0b.0d7f2","type":"inject","z":"57da71a5.519be","name":"r4 on","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":130,"y":1960,"wires":[["4af4b15f.3191","d4210a42.8cf998"]]},{"id":"f3415c83.c831e","type":"delay","z":"57da71a5.519be","name":"100 ms","pauseType":"delay","timeout":"100","timeoutUnits":"milliseconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":320,"y":1440,"wires":[["d63e7dba.5814b"]]},{"id":"d63e7dba.5814b","type":"i2c in","z":"57da71a5.519be","name":"","address":"32","command":"6","count":"1","x":450,"y":1440,"wires":[["c40b4bbe.5a34e8"]]},{"id":"6640c9f2.f6b598","type":"delay","z":"57da71a5.519be","name":"100 ms","pauseType":"delay","timeout":"100","timeoutUnits":"milliseconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":320,"y":1600,"wires":[["b50a6134.7f74b"]]},{"id":"b50a6134.7f74b","type":"i2c in","z":"57da71a5.519be","name":"","address":"32","command":"6","count":"1","x":450,"y":1600,"wires":[["c40b4bbe.5a34e8"]]},{"id":"cb5483d.1cf378","type":"delay","z":"57da71a5.519be","name":"100 ms","pauseType":"delay","timeout":"100","timeoutUnits":"milliseconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":320,"y":1760,"wires":[["a774f87f.661e28"]]},{"id":"a774f87f.661e28","type":"i2c in","z":"57da71a5.519be","name":"","address":"32","command":"6","count":"1","x":450,"y":1760,"wires":[["c40b4bbe.5a34e8"]]},{"id":"d4210a42.8cf998","type":"delay","z":"57da71a5.519be","name":"100 ms","pauseType":"delay","timeout":"100","timeoutUnits":"milliseconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":320,"y":2000,"wires":[["2426a945.a1a516"]]},{"id":"2426a945.a1a516","type":"i2c in","z":"57da71a5.519be","name":"","address":"32","command":"6","count":"1","x":450,"y":2000,"wires":[["c40b4bbe.5a34e8"]]},{"id":"54e5ea86.7df4a4","type":"comment","z":"57da71a5.519be","name":"simple switch, no bit masking, impacts other relays","info":"","x":230,"y":1340,"wires":[]},{"id":"d099268e.ffdfc8","type":"debug","z":"57da71a5.519be","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":810,"y":1700,"wires":[]},{"id":"c40b4bbe.5a34e8","type":"function","z":"57da71a5.519be","name":"","func":"return [{payload : msg.payload},\n {payload : msg.payload.toString(2).padStart(4,'0')}\n ];","outputs":2,"noerr":0,"x":650,"y":1720,"wires":[["d099268e.ffdfc8"],["24cd8061.9b00d"]]},{"id":"24cd8061.9b00d","type":"debug","z":"57da71a5.519be","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":810,"y":1740,"wires":[]},{"id":"3d2861bc.a08bae","type":"debug","z":"57da71a5.519be","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":750,"y":320,"wires":[]},{"id":"d9405581.7230e8","type":"function","z":"57da71a5.519be","name":"","func":"return [{payload : msg.payload},\n {payload : msg.payload.toString(2).padStart(4,'0')}\n ];","outputs":2,"noerr":0,"x":590,"y":340,"wires":[["3d2861bc.a08bae"],["e8f42019.4fd82"]]},{"id":"e8f42019.4fd82","type":"debug","z":"57da71a5.519be","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":750,"y":360,"wires":[]},{"id":"c03ea9e3.554a88","type":"i2c in","z":"57da71a5.519be","name":"","address":"32","command":"6","count":"1","x":450,"y":380,"wires":[["d9405581.7230e8"]]},{"id":"d19281f2.dea63","type":"i2c out","z":"57da71a5.519be","name":"","address":"32","command":"6","payload":"15","payloadType":"num","count":"1","x":320,"y":340,"wires":[]},{"id":"6e1a54ff.fecdbc","type":"inject","z":"57da71a5.519be","name":"all r off","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":130,"y":340,"wires":[["d19281f2.dea63","f2249c9b.6607f"]]},{"id":"f2249c9b.6607f","type":"delay","z":"57da71a5.519be","name":"100 ms","pauseType":"delay","timeout":"100","timeoutUnits":"milliseconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":320,"y":380,"wires":[["c03ea9e3.554a88"]]},{"id":"cfabdeb6.8f0d","type":"comment","z":"57da71a5.519be","name":"Utilities","info":"","x":90,"y":40,"wires":[]},{"id":"381aabc1.252884","type":"comment","z":"57da71a5.519be","name":"MQTT","info":"","x":1070,"y":1140,"wires":[]},{"id":"9f6ce1af.3947e","type":"comment","z":"57da71a5.519be","name":"Websocket","info":"","x":1080,"y":1240,"wires":[]},{"id":"8e1b10c7.d7ee1","type":"function","z":"57da71a5.519be","name":"","func":"return{relay:(1 << (msg.relay-1)),value:msg.value};","outputs":1,"noerr":0,"x":590,"y":900,"wires":[["641c1ba9.c785d4"]]},{"id":"ccdad9d2.3d9a98","type":"function","z":"57da71a5.519be","name":"","func":"switch(msg.value){\n case 1:\n return{payload:(msg.payload &= ~msg.relay)};\n case 0:\n return{payload:(msg.payload |= msg.relay)};\n} \n\n","outputs":1,"noerr":0,"x":830,"y":900,"wires":[["89de8eca.023bb"]]},{"id":"2e4d2c10.b31fc4","type":"function","z":"57da71a5.519be","name":"obj to string","func":"var obj = JSON.parse(JSON.stringify(msg));\nreturn {payload : JSON.stringify(obj)};\n\n","outputs":1,"noerr":0,"x":490,"y":1140,"wires":[["22a8b580.1c9aba"]]},{"id":"c59eed13.6ef25","type":"function","z":"57da71a5.519be","name":"string to obj","func":"return JSON.parse(msg.payload);","outputs":1,"noerr":0,"x":1110,"y":1180,"wires":[["8e1b10c7.d7ee1"]]},{"id":"7c1cd4e1.70617c","type":"change","z":"57da71a5.519be","name":"","rules":[{"t":"delete","p":"topic","pt":"msg"},{"t":"delete","p":"payload","pt":"msg"},{"t":"set","p":"relay","pt":"msg","to":"1","tot":"num"},{"t":"set","p":"value","pt":"msg","to":"1","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":320,"y":1120,"wires":[["2e4d2c10.b31fc4"]]},{"id":"78c44824.98eb28","type":"change","z":"57da71a5.519be","name":"","rules":[{"t":"delete","p":"topic","pt":"msg"},{"t":"delete","p":"payload","pt":"msg"},{"t":"set","p":"relay","pt":"msg","to":"1","tot":"num"},{"t":"set","p":"value","pt":"msg","to":"0","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":320,"y":1160,"wires":[["2e4d2c10.b31fc4"]]},{"id":"cd0e876c.64c948","type":"function","z":"57da71a5.519be","name":"obj to string","func":"var obj = JSON.parse(JSON.stringify(msg));\nreturn {payload : JSON.stringify(obj)};\n\n","outputs":1,"noerr":0,"x":490,"y":1240,"wires":[["163abc81.8cf893"]]},{"id":"2fefe0a1.ae176","type":"change","z":"57da71a5.519be","name":"","rules":[{"t":"delete","p":"topic","pt":"msg"},{"t":"delete","p":"payload","pt":"msg"},{"t":"set","p":"relay","pt":"msg","to":"1","tot":"num"},{"t":"set","p":"value","pt":"msg","to":"1","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":320,"y":1220,"wires":[["cd0e876c.64c948"]]},{"id":"670caf0c.7466c","type":"change","z":"57da71a5.519be","name":"","rules":[{"t":"delete","p":"topic","pt":"msg"},{"t":"delete","p":"payload","pt":"msg"},{"t":"set","p":"relay","pt":"msg","to":"1","tot":"num"},{"t":"set","p":"value","pt":"msg","to":"0","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":320,"y":1260,"wires":[["cd0e876c.64c948"]]},{"id":"ae5e8621.14af98","type":"mqtt-broker","z":"","name":"10.0.0.43","broker":"10.0.0.43","port":"1883","clientid":"","usetls":false,"compatmode":true,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""},{"id":"67c95b04.5d27a4","type":"websocket-listener","z":"","path":"/ws","wholemsg":"false"},{"id":"aa148930.c68918","type":"websocket-client","z":"","path":"ws://localhost:1880/ws","tls":"","wholemsg":"false"}]