Hello,
Would appreciate some help with the attached flow.
The flow works but is a bit of a hack and I would appreciate a hint or two of how you would do this to optimize it.
It is simply three switches wired in parallell. One for Home kit, one for the Node red dashboard and one for a physical Shelly relay.
All serve to switch the Shelly the same way.
A physical moment switch at the shelly and the two soft switches should switch it the same, and also reflect a change anywhere between the three of them, yet not create a loop. I am unable to come up with a clean and robust solution. But again, this appears to work, so is perhaps a half-decent way to at least show why I am trying to do..
Can you suggest a cleaner and more robust way of doing this by any chance? Many thanks!
[ { "id": "bd02da3896c29e8e", "type": "group", "z": "eef618ccc6e2ee8c", "name": "", "style": { "fill": "#c8e7a7", "label": true }, "nodes": [ "6cf1745b3ff6c936", "4af867cdef1fe329", "471bab8f3e6f3ee5", "2d525d44e40f0620", "7474a3430fe26c3b", "fc59cc75739f647e", "275e3477b122dccb", "d51fad32e4e06e01", "9d8303659e2b8c88", "1ba86a8a37c44aad", "4a56db0a0217c071", "bee423ae8e3b77bd", "ee6fb4a6d08475c3", "06ddbd6bdb128515", "1d06c797a0da1a3a", "9f7eb3b869ac7d8a", "24ffd3e970e86e62", "8347e45955618064", "56b25b4442efe183", "7724b8fa22901271" ], "x": 74, "y": 119, "w": 1192, "h": 522 }, { "id": "6cf1745b3ff6c936", "type": "homekit-service", "z": "eef618ccc6e2ee8c", "g": "bd02da3896c29e8e", "isParent": true, "hostType": "0", "bridge": "1d2439381726168b", "accessoryId": "", "parentService": "", "name": "Switch 3 - Homekit", "serviceName": "Switch", "topic": "", "filter": false, "manufacturer": "NRCHKB", "model": "1.3.6", "serialNo": "Default Serial Number", "firmwareRev": "1.3.6", "hardwareRev": "1.3.6", "softwareRev": "1.3.6", "cameraConfigVideoProcessor": "ffmpeg", "cameraConfigSource": "", "cameraConfigStillImageSource": "", "cameraConfigMaxStreams": 2, "cameraConfigMaxWidth": 1280, "cameraConfigMaxHeight": 720, "cameraConfigMaxFPS": 10, "cameraConfigMaxBitrate": 300, "cameraConfigVideoCodec": "libx264", "cameraConfigAudioCodec": "libfdk_aac", "cameraConfigAudio": false, "cameraConfigPacketSize": 1316, "cameraConfigVerticalFlip": false, "cameraConfigHorizontalFlip": false, "cameraConfigMapVideo": "0:0", "cameraConfigMapAudio": "0:1", "cameraConfigVideoFilter": "scale=1280:720", "cameraConfigAdditionalCommandLine": "-tune zerolatency", "cameraConfigDebug": false, "cameraConfigSnapshotOutput": "disabled", "cameraConfigInterfaceName": "", "characteristicProperties": "{}", "waitForSetupMsg": false, "outputs": 2, "x": 810, "y": 440, "wires": [ [ "4af867cdef1fe329", "7474a3430fe26c3b", "8347e45955618064" ], [] ] }, { "id": "4af867cdef1fe329", "type": "ui_switch", "z": "eef618ccc6e2ee8c", "g": "bd02da3896c29e8e", "name": "Switch 2 - NR Dash", "label": "Switch 2 - NR Dash", "tooltip": "", "group": "e48e8a33f9fc6cf2", "order": 1, "width": 7, "height": 1, "passthru": true, "decouple": "false", "topic": "payload", "topicType": "msg", "style": "", "onvalue": "{\"On\":true}", "onvalueType": "json", "onicon": "", "oncolor": "", "offvalue": "{\"On\":false}", "offvalueType": "json", "officon": "", "offcolor": "", "animate": true, "className": "", "x": 820, "y": 380, "wires": [ [ "6cf1745b3ff6c936", "56b25b4442efe183" ] ] }, { "id": "471bab8f3e6f3ee5", "type": "shelly-gen2", "z": "eef618ccc6e2ee8c", "g": "bd02da3896c29e8e", "hostname": "192.168.11.199", "description": "Switch 1 Shelly", "pollinginterval": 5000, "pollstatus": true, "getstatusoncommand": true, "devicetype": "Relay", "outputs": 1, "credentials": { "username": "", "password": "" }, "x": 500, "y": 500, "wires": [ [ "275e3477b122dccb", "7724b8fa22901271" ] ] }, { "id": "2d525d44e40f0620", "type": "switch", "z": "eef618ccc6e2ee8c", "g": "bd02da3896c29e8e", "name": "split", "property": "payload", "propertyType": "msg", "rules": [ { "t": "eq", "v": "{\"On\":true}", "vt": "str" }, { "t": "eq", "v": "{\"On\":false}", "vt": "str" } ], "checkall": "true", "repair": false, "outputs": 2, "x": 250, "y": 320, "wires": [ [ "9d8303659e2b8c88" ], [ "4a56db0a0217c071" ] ] }, { "id": "7474a3430fe26c3b", "type": "delay", "z": "eef618ccc6e2ee8c", "g": "bd02da3896c29e8e", "name": "", "pauseType": "rate", "timeout": "5", "timeoutUnits": "seconds", "rate": "1", "nbRateUnits": "5", "rateUnits": "second", "randomFirst": "1", "randomLast": "5", "randomUnits": "seconds", "drop": true, "allowrate": false, "outputs": 1, "x": 180, "y": 500, "wires": [ [ "fc59cc75739f647e" ] ] }, { "id": "fc59cc75739f647e", "type": "json", "z": "eef618ccc6e2ee8c", "g": "bd02da3896c29e8e", "name": "", "property": "payload", "action": "", "pretty": false, "x": 250, "y": 360, "wires": [ [ "2d525d44e40f0620" ] ] }, { "id": "275e3477b122dccb", "type": "json", "z": "eef618ccc6e2ee8c", "g": "bd02da3896c29e8e", "name": "", "property": "payload", "action": "", "pretty": false, "x": 770, "y": 220, "wires": [ [ "bee423ae8e3b77bd" ] ] }, { "id": "d51fad32e4e06e01", "type": "inject", "z": "eef618ccc6e2ee8c", "g": "bd02da3896c29e8e", "name": "Turn On", "props": [ { "p": "payload", "v": "", "vt": "date" }, { "p": "topic", "v": "", "vt": "str" } ], "repeat": "", "crontab": "", "once": false, "onceDelay": 0.1, "topic": "", "payload": "", "payloadType": "date", "x": 490, "y": 220, "wires": [ [ "9d8303659e2b8c88" ] ] }, { "id": "9d8303659e2b8c88", "type": "function", "z": "eef618ccc6e2ee8c", "g": "bd02da3896c29e8e", "name": "0 on", "func": "msg.payload = {\n method: \"Switch.Set\",\n parameters : {\n id : 0,\n on : true,\n // toggle_after : 2 // optional flip back time in seconds\n }\n};\nreturn msg;", "outputs": 1, "noerr": 0, "initialize": "", "finalize": "", "libs": [], "x": 490, "y": 260, "wires": [ [ "471bab8f3e6f3ee5" ] ] }, { "id": "1ba86a8a37c44aad", "type": "inject", "z": "eef618ccc6e2ee8c", "g": "bd02da3896c29e8e", "name": "Turn Off", "repeat": "", "crontab": "", "once": false, "onceDelay": 0.1, "topic": "", "payload": "", "payloadType": "date", "x": 490, "y": 300, "wires": [ [ "4a56db0a0217c071" ] ] }, { "id": "4a56db0a0217c071", "type": "function", "z": "eef618ccc6e2ee8c", "g": "bd02da3896c29e8e", "name": "0 off", "func": "msg.payload = {\n method: \"Switch.Set\",\n parameters : {\n id : 0,\n on : false,\n // toggle_after : 2 // optional flip back time in seconds\n }\n};\nreturn msg;", "outputs": 1, "noerr": 0, "initialize": "", "finalize": "", "libs": [], "x": 490, "y": 340, "wires": [ [ "471bab8f3e6f3ee5" ] ] }, { "id": "bee423ae8e3b77bd", "type": "switch", "z": "eef618ccc6e2ee8c", "g": "bd02da3896c29e8e", "name": "", "property": "payload", "propertyType": "msg", "rules": [ { "t": "cont", "v": "output\":true", "vt": "str" }, { "t": "cont", "v": "output\":false", "vt": "str" } ], "checkall": "true", "repair": false, "outputs": 2, "x": 770, "y": 260, "wires": [ [ "ee6fb4a6d08475c3" ], [ "06ddbd6bdb128515" ] ] }, { "id": "ee6fb4a6d08475c3", "type": "ui_button", "z": "eef618ccc6e2ee8c", "g": "bd02da3896c29e8e", "name": "{\"On\":true}", "group": "e48e8a33f9fc6cf2", "order": 14, "width": 0, "height": 0, "passthru": true, "label": "{\"On\":true}", "tooltip": "", "color": "", "bgcolor": "", "className": "", "icon": "", "payload": "{\"On\":true}", "payloadType": "json", "topic": "topic", "topicType": "msg", "x": 790, "y": 300, "wires": [ [ "4af867cdef1fe329" ] ] }, { "id": "06ddbd6bdb128515", "type": "ui_button", "z": "eef618ccc6e2ee8c", "g": "bd02da3896c29e8e", "name": "{\"On\":false}", "group": "e48e8a33f9fc6cf2", "order": 14, "width": 0, "height": 0, "passthru": true, "label": "{\"On\":false}", "tooltip": "", "color": "", "bgcolor": "", "className": "", "icon": "", "payload": "{\"On\":false}", "payloadType": "json", "topic": "topic", "topicType": "msg", "x": 790, "y": 340, "wires": [ [ "4af867cdef1fe329" ] ] }, { "id": "1d06c797a0da1a3a", "type": "comment", "z": "eef618ccc6e2ee8c", "g": "bd02da3896c29e8e", "name": "3 switches in parallell. Each switch needs to be able to switch on and off and the other two switches need to reflect changes. All without creating a loop.", "info": "", "x": 630, "y": 160, "wires": [] }, { "id": "9f7eb3b869ac7d8a", "type": "comment", "z": "eef618ccc6e2ee8c", "g": "bd02da3896c29e8e", "name": "This Shelly is a physical relay that can also be switched with a physical button", "info": "", "x": 420, "y": 560, "wires": [] }, { "id": "24ffd3e970e86e62", "type": "comment", "z": "eef618ccc6e2ee8c", "g": "bd02da3896c29e8e", "name": "So the Shelly needs to be the master state", "info": "", "x": 440, "y": 600, "wires": [] }, { "id": "8347e45955618064", "type": "debug", "z": "eef618ccc6e2ee8c", "g": "bd02da3896c29e8e", "name": "Switch 3 - Homekit", "active": true, "tosidebar": true, "console": false, "tostatus": true, "complete": "true", "targetType": "full", "statusVal": "payload", "statusType": "auto", "x": 1090, "y": 460, "wires": [] }, { "id": "56b25b4442efe183", "type": "debug", "z": "eef618ccc6e2ee8c", "g": "bd02da3896c29e8e", "name": "Switch 2 - NR Dash", "active": true, "tosidebar": true, "console": false, "tostatus": true, "complete": "true", "targetType": "full", "statusVal": "payload", "statusType": "auto", "x": 1100, "y": 380, "wires": [] }, { "id": "7724b8fa22901271", "type": "debug", "z": "eef618ccc6e2ee8c", "g": "bd02da3896c29e8e", "name": "Switch 1 - Shelly Gen 2", "active": true, "tosidebar": true, "console": false, "tostatus": true, "complete": "true", "targetType": "full", "statusVal": "payload", "statusType": "auto", "x": 1110, "y": 520, "wires": [] }, { "id": "1d2439381726168b", "type": "homekit-bridge", "bridgeName": "Dev share 1b", "pinCode": "033-96-068", "port": "", "advertiser": "bonjour-hap", "allowInsecureRequest": false, "manufacturer": "NRCHKB", "model": "1.4.3", "serialNo": "Default Serial Number", "firmwareRev": "1.4.3", "hardwareRev": "1.4.3", "softwareRev": "1.4.3", "customMdnsConfig": false, "mdnsMulticast": true, "mdnsInterface": "", "mdnsPort": "", "mdnsIp": "", "mdnsTtl": "", "mdnsLoopback": true, "mdnsReuseAddr": true, "allowMessagePassthrough": true }, { "id": "e48e8a33f9fc6cf2", "type": "ui_group", "name": "Default", "tab": "3ecaa427cf920875", "order": 1, "disp": true, "width": "7", "collapse": true, "className": "" }, { "id": "3ecaa427cf920875", "type": "ui_tab", "name": "Dev share", "icon": "dashboard", "disabled": false, "hidden": false } ]