Multiple switches trigger

I need help creating flow for multiple switches.

I have 6 fan switches, zone_1 - zone_6, their states are off and fan_only.

I wish they could work like this

they are all off then go to the next one

either one of them is fan_only go to the other one

Can anyone give me a sample so I can look into it?

thanks!

So I recommend to put all in one object - and translate off to false and fan_only to true.

[
    {
        "id": "434f43cc4f36f51d",
        "type": "switch",
        "z": "54b226bc.0793e8",
        "name": "OR?",
        "property": "$reduce(payload.*,function($i, $j){$i or $j})",
        "propertyType": "jsonata",
        "rules": [
            {
                "t": "true"
            },
            {
                "t": "false"
            }
        ],
        "checkall": "true",
        "repair": false,
        "outputs": 2,
        "x": 510,
        "y": 3100,
        "wires": [
            [
                "f46360d91a25f936"
            ],
            [
                "05d404c088048d4e"
            ]
        ],
        "info": "# Only one or more properties of an object need to be true.\n\n Only one or more properties of an object need to be true.\n\n`{\n    \"Office\": false,\n    \"Bedroom\": false,\n    \"Living Room Balcony\": false,\n    \"Liviueng Room Right Window\": false,\n    \"Living Room Left Window\": false\n}`\n\nis false,\n\n`{\n    \"Office\": false,\n    \"Bedroom\": true,\n    \"Living Room Balcony\": false,\n    \"Living Room Right Window\": false,\n    \"Living Room Left Window\": false\n}`\n\nis true.\n\n# Mindestens eine Eigenschaft des Objektes muss wahr sein.\n\nMindestens eine Eigenschaft des Objektes muss wahr sein.\n\n`{\n    \"Büro Balkon\": false,\n    \"Schlafzimmer Balkon\": false,\n    \"Wohnzimmer Balkon\": false,\n    \"Wohnzimmer rechtes Fenster\": false,\n    \"Wohnzimmer linkes Fenster\": false\n}`\n\nergibt false,\n\n`{\n    \"Büro Balkon\": false,\n    \"Schlafzimmer Balkon\": true,\n    \"Wohnzimmer Balkon\": false,\n    \"Wohnzimmer rechtes Fenster\": false,\n    \"Wohnzimmer linkes Fenster\": false\n}`\n\nergibt true (wahr)."
    },
    {
        "id": "33ed66f9f5bfad95",
        "type": "inject",
        "z": "54b226bc.0793e8",
        "name": "all off",
        "props": [
            {
                "p": "payload"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "{\"zone-1\":false,\"zone-2\":false,\"zone-3\":false,\"zone-4\":false,\"zone-5\":false,\"zone-6\":false}",
        "payloadType": "json",
        "x": 330,
        "y": 3080,
        "wires": [
            [
                "434f43cc4f36f51d"
            ]
        ]
    },
    {
        "id": "cbd8f3464cd6739a",
        "type": "inject",
        "z": "54b226bc.0793e8",
        "name": "one on",
        "props": [
            {
                "p": "payload"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "{\"zone-1\":false,\"zone-2\":false,\"zone-3\":true,\"zone-4\":false,\"zone-5\":false,\"zone-6\":false}",
        "payloadType": "json",
        "x": 330,
        "y": 3120,
        "wires": [
            [
                "434f43cc4f36f51d"
            ]
        ]
    },
    {
        "id": "05d404c088048d4e",
        "type": "debug",
        "z": "54b226bc.0793e8",
        "name": "all off",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "",
        "statusType": "auto",
        "x": 670,
        "y": 3120,
        "wires": []
    },
    {
        "id": "f46360d91a25f936",
        "type": "debug",
        "z": "54b226bc.0793e8",
        "name": "one on",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "",
        "statusType": "auto",
        "x": 670,
        "y": 3080,
        "wires": []
    }
]

If you dont know how to create the object here a complete flow with translations:


[
    {
        "id": "e88d7f6c78b20c7c",
        "type": "inject",
        "z": "54b226bc.0793e8",
        "name": "",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "zone-1",
        "payload": "off",
        "payloadType": "str",
        "x": 320,
        "y": 3240,
        "wires": [
            [
                "1bbbe1f8b058ea07"
            ]
        ]
    },
    {
        "id": "8c862811545026c1",
        "type": "inject",
        "z": "54b226bc.0793e8",
        "name": "",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "zone-2",
        "payload": "off",
        "payloadType": "str",
        "x": 320,
        "y": 3280,
        "wires": [
            [
                "1bbbe1f8b058ea07"
            ]
        ]
    },
    {
        "id": "208509976d8f72f2",
        "type": "inject",
        "z": "54b226bc.0793e8",
        "name": "",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "zone-3",
        "payload": "off",
        "payloadType": "str",
        "x": 320,
        "y": 3320,
        "wires": [
            [
                "1bbbe1f8b058ea07"
            ]
        ]
    },
    {
        "id": "c6fe73fc70b13cc8",
        "type": "inject",
        "z": "54b226bc.0793e8",
        "name": "",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "zone-4",
        "payload": "off",
        "payloadType": "str",
        "x": 320,
        "y": 3360,
        "wires": [
            [
                "1bbbe1f8b058ea07"
            ]
        ]
    },
    {
        "id": "746ee55b398e14bc",
        "type": "inject",
        "z": "54b226bc.0793e8",
        "name": "",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "zone-5",
        "payload": "off",
        "payloadType": "str",
        "x": 320,
        "y": 3400,
        "wires": [
            [
                "1bbbe1f8b058ea07"
            ]
        ]
    },
    {
        "id": "366d285e820bcce1",
        "type": "inject",
        "z": "54b226bc.0793e8",
        "name": "",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "zone-6",
        "payload": "off",
        "payloadType": "str",
        "x": 320,
        "y": 3440,
        "wires": [
            [
                "1bbbe1f8b058ea07"
            ]
        ]
    },
    {
        "id": "1bbbe1f8b058ea07",
        "type": "change",
        "z": "54b226bc.0793e8",
        "name": "translate",
        "rules": [
            {
                "t": "change",
                "p": "payload",
                "pt": "msg",
                "from": "off",
                "fromt": "str",
                "to": "false",
                "tot": "bool"
            },
            {
                "t": "change",
                "p": "payload",
                "pt": "msg",
                "from": "fan_only",
                "fromt": "str",
                "to": "true",
                "tot": "bool"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 520,
        "y": 3320,
        "wires": [
            [
                "1712a10693436277"
            ]
        ]
    },
    {
        "id": "1712a10693436277",
        "type": "join",
        "z": "54b226bc.0793e8",
        "name": "",
        "mode": "custom",
        "build": "object",
        "property": "payload",
        "propertyType": "msg",
        "key": "topic",
        "joiner": "\\n",
        "joinerType": "str",
        "accumulate": true,
        "timeout": "",
        "count": "1",
        "reduceRight": false,
        "reduceExp": "",
        "reduceInit": "",
        "reduceInitType": "",
        "reduceFixup": "",
        "x": 670,
        "y": 3320,
        "wires": [
            [
                "b865c08eb848d36f"
            ]
        ]
    },
    {
        "id": "b865c08eb848d36f",
        "type": "switch",
        "z": "54b226bc.0793e8",
        "name": "OR?",
        "property": "$reduce(payload.*,function($i, $j){$i or $j})",
        "propertyType": "jsonata",
        "rules": [
            {
                "t": "true"
            },
            {
                "t": "false"
            }
        ],
        "checkall": "true",
        "repair": false,
        "outputs": 2,
        "x": 810,
        "y": 3320,
        "wires": [
            [
                "eff51d8e146cd433"
            ],
            [
                "c94c112143c7a353"
            ]
        ],
        "info": "# Only one or more properties of an object need to be true.\n\n Only one or more properties of an object need to be true.\n\n`{\n    \"Office\": false,\n    \"Bedroom\": false,\n    \"Living Room Balcony\": false,\n    \"Liviueng Room Right Window\": false,\n    \"Living Room Left Window\": false\n}`\n\nis false,\n\n`{\n    \"Office\": false,\n    \"Bedroom\": true,\n    \"Living Room Balcony\": false,\n    \"Living Room Right Window\": false,\n    \"Living Room Left Window\": false\n}`\n\nis true.\n\n# Mindestens eine Eigenschaft des Objektes muss wahr sein.\n\nMindestens eine Eigenschaft des Objektes muss wahr sein.\n\n`{\n    \"Büro Balkon\": false,\n    \"Schlafzimmer Balkon\": false,\n    \"Wohnzimmer Balkon\": false,\n    \"Wohnzimmer rechtes Fenster\": false,\n    \"Wohnzimmer linkes Fenster\": false\n}`\n\nergibt false,\n\n`{\n    \"Büro Balkon\": false,\n    \"Schlafzimmer Balkon\": true,\n    \"Wohnzimmer Balkon\": false,\n    \"Wohnzimmer rechtes Fenster\": false,\n    \"Wohnzimmer linkes Fenster\": false\n}`\n\nergibt true (wahr)."
    },
    {
        "id": "c94c112143c7a353",
        "type": "debug",
        "z": "54b226bc.0793e8",
        "name": "all off",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "",
        "statusType": "auto",
        "x": 970,
        "y": 3340,
        "wires": []
    },
    {
        "id": "eff51d8e146cd433",
        "type": "debug",
        "z": "54b226bc.0793e8",
        "name": "one on",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "",
        "statusType": "auto",
        "x": 970,
        "y": 3300,
        "wires": []
    },
    {
        "id": "d27a59977cd320c6",
        "type": "inject",
        "z": "54b226bc.0793e8",
        "name": "",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "zone-3",
        "payload": "fan_only",
        "payloadType": "str",
        "x": 300,
        "y": 3480,
        "wires": [
            [
                "1bbbe1f8b058ea07"
            ]
        ]
    }
]

This is a more compact JSONata expression which outputs true or false

true in $$.payload.*

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.