Lights with 2 way or 3 way or even 4 way - Master/Slave Relationship

What’s the most efficient way to setup lights that have a master slave relationship eg I have 1 switch that controls the light (wired to the light) but I have multiple other “slave” switches that I want to control the same light via automation (not wired to the light). Each time I’ve set up a flow in node red it creates a loop. The loop eventually ends but I’d prefer to have something that doesn’t create a loop. Here’s what I currently have for 3 light switches.

[
    {
        "id": "a018dcfff48028ac",
        "type": "trigger-state",
        "z": "aa85dabc648140dc",
        "name": "Office Bathroom ON",
        "server": "d3151d26.c0d4f",
        "version": 5,
        "inputs": 0,
        "outputs": 2,
        "exposeAsEntityConfig": "",
        "entities": {
            "entity": [
                "light.office_bathroom"
            ],
            "substring": [],
            "regex": []
        },
        "debugEnabled": false,
        "constraints": [
            {
                "targetType": "this_entity",
                "targetValue": "",
                "propertyType": "current_state",
                "propertyValue": "new_state.state",
                "comparatorType": "is",
                "comparatorValueDatatype": "str",
                "comparatorValue": "on"
            },
            {
                "targetType": "entity_id",
                "targetValue": "light.sw_office_koi_in_office_2",
                "propertyType": "current_state",
                "propertyValue": "new_state.state",
                "comparatorType": "is",
                "comparatorValueDatatype": "str",
                "comparatorValue": "off"
            },
            {
                "targetType": "entity_id",
                "targetValue": "light.sonoff_10009954d0_1",
                "propertyType": "current_state",
                "propertyValue": "new_state.state",
                "comparatorType": "is",
                "comparatorValueDatatype": "str",
                "comparatorValue": "off"
            }
        ],
        "customOutputs": [],
        "outputInitially": false,
        "stateType": "str",
        "enableInput": false,
        "x": 170,
        "y": 80,
        "wires": [
            [
                "8435b896eb93246d"
            ],
            []
        ]
    },
    {
        "id": "8435b896eb93246d",
        "type": "api-call-service",
        "z": "aa85dabc648140dc",
        "name": "Turn ON ALL others",
        "server": "d3151d26.c0d4f",
        "version": 7,
        "debugenabled": false,
        "action": "light.turn_on",
        "floorId": [],
        "areaId": [],
        "deviceId": [],
        "entityId": [
            "light.sw_office_koi_in_office_2",
            "light.sonoff_10009954d0_1"
        ],
        "labelId": [],
        "data": "",
        "dataType": "jsonata",
        "mergeContext": "",
        "mustacheAltTags": false,
        "outputProperties": [],
        "queue": "none",
        "blockInputOverrides": false,
        "domain": "light",
        "service": "turn_on",
        "x": 430,
        "y": 80,
        "wires": [
            []
        ]
    },
    {
        "id": "b6fa67a9cc83dd77",
        "type": "trigger-state",
        "z": "aa85dabc648140dc",
        "name": "Koi in Office ON",
        "server": "d3151d26.c0d4f",
        "version": 5,
        "inputs": 0,
        "outputs": 2,
        "exposeAsEntityConfig": "",
        "entities": {
            "entity": [
                "light.sw_office_koi_in_office_2"
            ],
            "substring": [],
            "regex": []
        },
        "debugEnabled": false,
        "constraints": [
            {
                "targetType": "this_entity",
                "targetValue": "",
                "propertyType": "current_state",
                "propertyValue": "new_state.state",
                "comparatorType": "is",
                "comparatorValueDatatype": "str",
                "comparatorValue": "on"
            },
            {
                "targetType": "entity_id",
                "targetValue": "light.office_bathroom",
                "propertyType": "current_state",
                "propertyValue": "new_state.state",
                "comparatorType": "is",
                "comparatorValueDatatype": "str",
                "comparatorValue": "off"
            },
            {
                "targetType": "entity_id",
                "targetValue": "light.sonoff_10009954d0_1",
                "propertyType": "current_state",
                "propertyValue": "new_state.state",
                "comparatorType": "is",
                "comparatorValueDatatype": "str",
                "comparatorValue": "off"
            }
        ],
        "customOutputs": [],
        "outputInitially": false,
        "stateType": "str",
        "enableInput": false,
        "x": 160,
        "y": 240,
        "wires": [
            [
                "2255252f13a66138"
            ],
            []
        ]
    },
    {
        "id": "2255252f13a66138",
        "type": "api-call-service",
        "z": "aa85dabc648140dc",
        "name": "Turn ON all others",
        "server": "d3151d26.c0d4f",
        "version": 7,
        "debugenabled": false,
        "action": "light.turn_on",
        "floorId": [],
        "areaId": [],
        "deviceId": [],
        "entityId": [
            "light.office_bathroom",
            "light.sonoff_10009954d0_1"
        ],
        "labelId": [],
        "data": "",
        "dataType": "jsonata",
        "mergeContext": "",
        "mustacheAltTags": false,
        "outputProperties": [],
        "queue": "none",
        "blockInputOverrides": false,
        "domain": "light",
        "service": "turn_on",
        "x": 430,
        "y": 240,
        "wires": [
            []
        ]
    },
    {
        "id": "67b389c23cfb2ae0",
        "type": "trigger-state",
        "z": "aa85dabc648140dc",
        "name": "Office Bathroom OFF",
        "server": "d3151d26.c0d4f",
        "version": 5,
        "inputs": 0,
        "outputs": 2,
        "exposeAsEntityConfig": "",
        "entities": {
            "entity": [
                "light.office_bathroom"
            ],
            "substring": [],
            "regex": []
        },
        "debugEnabled": false,
        "constraints": [
            {
                "targetType": "this_entity",
                "targetValue": "",
                "propertyType": "current_state",
                "propertyValue": "new_state.state",
                "comparatorType": "is",
                "comparatorValueDatatype": "str",
                "comparatorValue": "off"
            },
            {
                "targetType": "entity_id",
                "targetValue": "light.sw_office_koi_in_office_2",
                "propertyType": "current_state",
                "propertyValue": "new_state.state",
                "comparatorType": "is",
                "comparatorValueDatatype": "str",
                "comparatorValue": "on"
            },
            {
                "targetType": "entity_id",
                "targetValue": "light.sonoff_10009954d0_1",
                "propertyType": "current_state",
                "propertyValue": "new_state.state",
                "comparatorType": "is",
                "comparatorValueDatatype": "str",
                "comparatorValue": "on"
            }
        ],
        "customOutputs": [],
        "outputInitially": false,
        "stateType": "str",
        "enableInput": false,
        "x": 180,
        "y": 160,
        "wires": [
            [
                "5ee3de2adaf51920"
            ],
            []
        ]
    },
    {
        "id": "5ee3de2adaf51920",
        "type": "api-call-service",
        "z": "aa85dabc648140dc",
        "name": "Turn OFF ALL others",
        "server": "d3151d26.c0d4f",
        "version": 7,
        "debugenabled": false,
        "action": "light.turn_off",
        "floorId": [],
        "areaId": [],
        "deviceId": [],
        "entityId": [
            "light.sw_office_koi_in_office_2",
            "light.sonoff_10009954d0_1"
        ],
        "labelId": [],
        "data": "",
        "dataType": "jsonata",
        "mergeContext": "",
        "mustacheAltTags": false,
        "outputProperties": [],
        "queue": "none",
        "blockInputOverrides": false,
        "domain": "light",
        "service": "turn_off",
        "x": 440,
        "y": 160,
        "wires": [
            []
        ]
    },
    {
        "id": "fb30b2e9690d734a",
        "type": "trigger-state",
        "z": "aa85dabc648140dc",
        "name": "Koi in Office OFF",
        "server": "d3151d26.c0d4f",
        "version": 5,
        "inputs": 0,
        "outputs": 2,
        "exposeAsEntityConfig": "",
        "entities": {
            "entity": [
                "light.sw_office_koi_in_office_2"
            ],
            "substring": [],
            "regex": []
        },
        "debugEnabled": false,
        "constraints": [
            {
                "targetType": "this_entity",
                "targetValue": "",
                "propertyType": "current_state",
                "propertyValue": "new_state.state",
                "comparatorType": "is",
                "comparatorValueDatatype": "str",
                "comparatorValue": "off"
            },
            {
                "targetType": "entity_id",
                "targetValue": "light.office_bathroom",
                "propertyType": "current_state",
                "propertyValue": "new_state.state",
                "comparatorType": "is",
                "comparatorValueDatatype": "str",
                "comparatorValue": "on"
            },
            {
                "targetType": "entity_id",
                "targetValue": "light.sonoff_10009954d0_1",
                "propertyType": "current_state",
                "propertyValue": "new_state.state",
                "comparatorType": "is",
                "comparatorValueDatatype": "str",
                "comparatorValue": "on"
            }
        ],
        "customOutputs": [],
        "outputInitially": false,
        "stateType": "str",
        "enableInput": false,
        "x": 160,
        "y": 320,
        "wires": [
            [
                "54bd2711b2a06cc4"
            ],
            []
        ]
    },
    {
        "id": "54bd2711b2a06cc4",
        "type": "api-call-service",
        "z": "aa85dabc648140dc",
        "name": "Turn OFF ALL others",
        "server": "d3151d26.c0d4f",
        "version": 7,
        "debugenabled": false,
        "action": "light.turn_off",
        "floorId": [],
        "areaId": [],
        "deviceId": [],
        "entityId": [
            "light.office_bathroom",
            "light.sonoff_10009954d0_1"
        ],
        "labelId": [],
        "data": "",
        "dataType": "jsonata",
        "mergeContext": "",
        "mustacheAltTags": false,
        "outputProperties": [],
        "queue": "none",
        "blockInputOverrides": false,
        "domain": "light",
        "service": "turn_off",
        "x": 440,
        "y": 320,
        "wires": [
            []
        ]
    },
    {
        "id": "18dc1b7ff68d23dc",
        "type": "trigger-state",
        "z": "aa85dabc648140dc",
        "name": "Office light ON",
        "server": "d3151d26.c0d4f",
        "version": 5,
        "inputs": 0,
        "outputs": 2,
        "exposeAsEntityConfig": "",
        "entities": {
            "entity": [
                "light.sonoff_10009954d0_1"
            ],
            "substring": [],
            "regex": []
        },
        "debugEnabled": false,
        "constraints": [
            {
                "targetType": "this_entity",
                "targetValue": "",
                "propertyType": "current_state",
                "propertyValue": "new_state.state",
                "comparatorType": "is",
                "comparatorValueDatatype": "str",
                "comparatorValue": "on"
            },
            {
                "targetType": "entity_id",
                "targetValue": "light.office_bathroom",
                "propertyType": "current_state",
                "propertyValue": "new_state.state",
                "comparatorType": "is",
                "comparatorValueDatatype": "str",
                "comparatorValue": "off"
            },
            {
                "targetType": "entity_id",
                "targetValue": "light.sw_office_koi_in_office_2",
                "propertyType": "current_state",
                "propertyValue": "new_state.state",
                "comparatorType": "is",
                "comparatorValueDatatype": "str",
                "comparatorValue": "off"
            }
        ],
        "customOutputs": [],
        "outputInitially": false,
        "stateType": "str",
        "enableInput": false,
        "x": 160,
        "y": 400,
        "wires": [
            [
                "76b12068f9ec7c4b"
            ],
            []
        ]
    },
    {
        "id": "76b12068f9ec7c4b",
        "type": "api-call-service",
        "z": "aa85dabc648140dc",
        "name": "Turn ON ALL others",
        "server": "d3151d26.c0d4f",
        "version": 7,
        "debugenabled": false,
        "action": "light.turn_on",
        "floorId": [],
        "areaId": [],
        "deviceId": [],
        "entityId": [
            "light.office_bathroom",
            "light.sw_office_koi_in_office_2"
        ],
        "labelId": [],
        "data": "",
        "dataType": "jsonata",
        "mergeContext": "",
        "mustacheAltTags": false,
        "outputProperties": [],
        "queue": "none",
        "blockInputOverrides": false,
        "domain": "light",
        "service": "turn_on",
        "x": 430,
        "y": 400,
        "wires": [
            []
        ]
    },
    {
        "id": "731afb276233a9fc",
        "type": "trigger-state",
        "z": "aa85dabc648140dc",
        "name": "Office light OFF",
        "server": "d3151d26.c0d4f",
        "version": 5,
        "inputs": 0,
        "outputs": 2,
        "exposeAsEntityConfig": "",
        "entities": {
            "entity": [
                "light.sonoff_10009954d0_1"
            ],
            "substring": [],
            "regex": []
        },
        "debugEnabled": false,
        "constraints": [
            {
                "targetType": "this_entity",
                "targetValue": "",
                "propertyType": "current_state",
                "propertyValue": "new_state.state",
                "comparatorType": "is",
                "comparatorValueDatatype": "str",
                "comparatorValue": "off"
            },
            {
                "targetType": "entity_id",
                "targetValue": "light.office_bathroom",
                "propertyType": "current_state",
                "propertyValue": "new_state.state",
                "comparatorType": "is",
                "comparatorValueDatatype": "str",
                "comparatorValue": "on"
            },
            {
                "targetType": "entity_id",
                "targetValue": "light.sw_office_koi_in_office_2",
                "propertyType": "current_state",
                "propertyValue": "new_state.state",
                "comparatorType": "is",
                "comparatorValueDatatype": "str",
                "comparatorValue": "on"
            }
        ],
        "customOutputs": [],
        "outputInitially": false,
        "stateType": "str",
        "enableInput": false,
        "x": 160,
        "y": 480,
        "wires": [
            [
                "bbeaca38bd4efe4f"
            ],
            []
        ]
    },
    {
        "id": "bbeaca38bd4efe4f",
        "type": "api-call-service",
        "z": "aa85dabc648140dc",
        "name": "Turn OFF ALL others",
        "server": "d3151d26.c0d4f",
        "version": 7,
        "debugenabled": false,
        "action": "light.turn_off",
        "floorId": [],
        "areaId": [],
        "deviceId": [],
        "entityId": [
            "light.office_bathroom",
            "light.sw_office_koi_in_office_2"
        ],
        "labelId": [],
        "data": "",
        "dataType": "jsonata",
        "mergeContext": "",
        "mustacheAltTags": false,
        "outputProperties": [],
        "queue": "none",
        "blockInputOverrides": false,
        "domain": "light",
        "service": "turn_off",
        "x": 440,
        "y": 480,
        "wires": [
            []
        ]
    },
    {
        "id": "d3151d26.c0d4f",
        "type": "server",
        "name": "Home Assistant Tyrrell",
        "addon": true,
        "rejectUnauthorizedCerts": true,
        "ha_boolean": "",
        "connectionDelay": false,
        "cacheJson": false,
        "heartbeat": false,
        "heartbeatInterval": "",
        "areaSelector": "friendlyName",
        "deviceSelector": "friendlyName",
        "entitySelector": "friendlyName",
        "statusSeparator": "/",
        "statusYear": "numeric",
        "statusMonth": "numeric",
        "statusDay": "numeric",
        "statusHourCycle": "h23",
        "statusTimeFormat": "h:m",
        "enableGlobalContextStore": true
    }
]

If the switch can be detached from the lamp, then it can be used to run a script.

Other than that you will have to look into a trigger id.

I think this is the best I can do with no loops.
Hopefully this helps someone given the amount of help I’ve received from this community reading old threads :slight_smile:

In short the solution is

  1. State change - list all entities where there can be a change as this is an “or” node
  2. Get entities - I used a group helper as this is an “and” node and you’d need either 3 nodes or a group and given I’ll have 4 and 5 way switches then this is probably the easiest. The entities need to be the same as in 1 above. You can’t use groups in 1 above as if 1 item is on in the group then the group is on so turning off doesn’t work.
  3. Function - Part a: Put all the entities through a function to compare their state to the state change and if the state is the same then exclude them from the output
  4. Function - Part b: Pass the turn_on/turn_off. This makes everything a variable in the action node. This means you only need to maintain 1 and 2 above.
  5. Action - empty as it gets everything from the function node
[
    {
        "id": "aa85dabc648140dc",
        "type": "tab",
        "label": "Flow 4",
        "disabled": false,
        "info": "",
        "env": []
    },
    {
        "id": "a018dcfff48028ac",
        "type": "trigger-state",
        "z": "aa85dabc648140dc",
        "d": true,
        "name": "Office Bathroom ON",
        "server": "d3151d26.c0d4f",
        "version": 5,
        "inputs": 0,
        "outputs": 2,
        "exposeAsEntityConfig": "",
        "entities": {
            "entity": [
                "light.office_bathroom"
            ],
            "substring": [],
            "regex": []
        },
        "debugEnabled": false,
        "constraints": [
            {
                "targetType": "this_entity",
                "targetValue": "",
                "propertyType": "current_state",
                "propertyValue": "new_state.state",
                "comparatorType": "is",
                "comparatorValueDatatype": "str",
                "comparatorValue": "on"
            },
            {
                "targetType": "entity_id",
                "targetValue": "light.sw_office_koi_in_office_2",
                "propertyType": "current_state",
                "propertyValue": "new_state.state",
                "comparatorType": "is",
                "comparatorValueDatatype": "str",
                "comparatorValue": "off"
            },
            {
                "targetType": "entity_id",
                "targetValue": "light.sonoff_10009954d0_1",
                "propertyType": "current_state",
                "propertyValue": "new_state.state",
                "comparatorType": "is",
                "comparatorValueDatatype": "str",
                "comparatorValue": "off"
            }
        ],
        "customOutputs": [],
        "outputInitially": false,
        "stateType": "str",
        "enableInput": false,
        "x": 170,
        "y": 80,
        "wires": [
            [
                "8435b896eb93246d"
            ],
            []
        ]
    },
    {
        "id": "8435b896eb93246d",
        "type": "api-call-service",
        "z": "aa85dabc648140dc",
        "d": true,
        "name": "Turn ON ALL others",
        "server": "d3151d26.c0d4f",
        "version": 7,
        "debugenabled": false,
        "action": "light.turn_on",
        "floorId": [],
        "areaId": [],
        "deviceId": [],
        "entityId": [
            "light.sw_office_koi_in_office_2",
            "light.sonoff_10009954d0_1"
        ],
        "labelId": [],
        "data": "",
        "dataType": "jsonata",
        "mergeContext": "",
        "mustacheAltTags": false,
        "outputProperties": [],
        "queue": "none",
        "blockInputOverrides": false,
        "domain": "light",
        "service": "turn_on",
        "x": 430,
        "y": 80,
        "wires": [
            []
        ]
    },
    {
        "id": "b6fa67a9cc83dd77",
        "type": "trigger-state",
        "z": "aa85dabc648140dc",
        "d": true,
        "name": "Koi in Office ON",
        "server": "d3151d26.c0d4f",
        "version": 5,
        "inputs": 0,
        "outputs": 2,
        "exposeAsEntityConfig": "",
        "entities": {
            "entity": [
                "light.sw_office_koi_in_office_2"
            ],
            "substring": [],
            "regex": []
        },
        "debugEnabled": false,
        "constraints": [
            {
                "targetType": "this_entity",
                "targetValue": "",
                "propertyType": "current_state",
                "propertyValue": "new_state.state",
                "comparatorType": "is",
                "comparatorValueDatatype": "str",
                "comparatorValue": "on"
            },
            {
                "targetType": "entity_id",
                "targetValue": "light.office_bathroom",
                "propertyType": "current_state",
                "propertyValue": "new_state.state",
                "comparatorType": "is",
                "comparatorValueDatatype": "str",
                "comparatorValue": "off"
            },
            {
                "targetType": "entity_id",
                "targetValue": "light.sonoff_10009954d0_1",
                "propertyType": "current_state",
                "propertyValue": "new_state.state",
                "comparatorType": "is",
                "comparatorValueDatatype": "str",
                "comparatorValue": "off"
            }
        ],
        "customOutputs": [],
        "outputInitially": false,
        "stateType": "str",
        "enableInput": false,
        "x": 160,
        "y": 240,
        "wires": [
            [
                "2255252f13a66138"
            ],
            []
        ]
    },
    {
        "id": "2255252f13a66138",
        "type": "api-call-service",
        "z": "aa85dabc648140dc",
        "d": true,
        "name": "Turn ON all others",
        "server": "d3151d26.c0d4f",
        "version": 7,
        "debugenabled": false,
        "action": "light.turn_on",
        "floorId": [],
        "areaId": [],
        "deviceId": [],
        "entityId": [
            "light.office_bathroom",
            "light.sonoff_10009954d0_1"
        ],
        "labelId": [],
        "data": "",
        "dataType": "jsonata",
        "mergeContext": "",
        "mustacheAltTags": false,
        "outputProperties": [],
        "queue": "none",
        "blockInputOverrides": false,
        "domain": "light",
        "service": "turn_on",
        "x": 430,
        "y": 240,
        "wires": [
            []
        ]
    },
    {
        "id": "67b389c23cfb2ae0",
        "type": "trigger-state",
        "z": "aa85dabc648140dc",
        "d": true,
        "name": "Office Bathroom OFF",
        "server": "d3151d26.c0d4f",
        "version": 5,
        "inputs": 0,
        "outputs": 2,
        "exposeAsEntityConfig": "",
        "entities": {
            "entity": [
                "light.office_bathroom"
            ],
            "substring": [],
            "regex": []
        },
        "debugEnabled": false,
        "constraints": [
            {
                "targetType": "this_entity",
                "targetValue": "",
                "propertyType": "current_state",
                "propertyValue": "new_state.state",
                "comparatorType": "is",
                "comparatorValueDatatype": "str",
                "comparatorValue": "off"
            },
            {
                "targetType": "entity_id",
                "targetValue": "light.sw_office_koi_in_office_2",
                "propertyType": "current_state",
                "propertyValue": "new_state.state",
                "comparatorType": "is",
                "comparatorValueDatatype": "str",
                "comparatorValue": "on"
            },
            {
                "targetType": "entity_id",
                "targetValue": "light.sonoff_10009954d0_1",
                "propertyType": "current_state",
                "propertyValue": "new_state.state",
                "comparatorType": "is",
                "comparatorValueDatatype": "str",
                "comparatorValue": "on"
            }
        ],
        "customOutputs": [],
        "outputInitially": false,
        "stateType": "str",
        "enableInput": false,
        "x": 180,
        "y": 160,
        "wires": [
            [
                "5ee3de2adaf51920"
            ],
            []
        ]
    },
    {
        "id": "5ee3de2adaf51920",
        "type": "api-call-service",
        "z": "aa85dabc648140dc",
        "d": true,
        "name": "Turn OFF ALL others",
        "server": "d3151d26.c0d4f",
        "version": 7,
        "debugenabled": false,
        "action": "light.turn_off",
        "floorId": [],
        "areaId": [],
        "deviceId": [],
        "entityId": [
            "light.sw_office_koi_in_office_2",
            "light.sonoff_10009954d0_1"
        ],
        "labelId": [],
        "data": "",
        "dataType": "jsonata",
        "mergeContext": "",
        "mustacheAltTags": false,
        "outputProperties": [],
        "queue": "none",
        "blockInputOverrides": false,
        "domain": "light",
        "service": "turn_off",
        "x": 440,
        "y": 160,
        "wires": [
            []
        ]
    },
    {
        "id": "fb30b2e9690d734a",
        "type": "trigger-state",
        "z": "aa85dabc648140dc",
        "d": true,
        "name": "Koi in Office OFF",
        "server": "d3151d26.c0d4f",
        "version": 5,
        "inputs": 0,
        "outputs": 2,
        "exposeAsEntityConfig": "",
        "entities": {
            "entity": [
                "light.sw_office_koi_in_office_2"
            ],
            "substring": [],
            "regex": []
        },
        "debugEnabled": false,
        "constraints": [
            {
                "targetType": "this_entity",
                "targetValue": "",
                "propertyType": "current_state",
                "propertyValue": "new_state.state",
                "comparatorType": "is",
                "comparatorValueDatatype": "str",
                "comparatorValue": "off"
            },
            {
                "targetType": "entity_id",
                "targetValue": "light.office_bathroom",
                "propertyType": "current_state",
                "propertyValue": "new_state.state",
                "comparatorType": "is",
                "comparatorValueDatatype": "str",
                "comparatorValue": "on"
            },
            {
                "targetType": "entity_id",
                "targetValue": "light.sonoff_10009954d0_1",
                "propertyType": "current_state",
                "propertyValue": "new_state.state",
                "comparatorType": "is",
                "comparatorValueDatatype": "str",
                "comparatorValue": "on"
            }
        ],
        "customOutputs": [],
        "outputInitially": false,
        "stateType": "str",
        "enableInput": false,
        "x": 160,
        "y": 320,
        "wires": [
            [
                "54bd2711b2a06cc4"
            ],
            []
        ]
    },
    {
        "id": "54bd2711b2a06cc4",
        "type": "api-call-service",
        "z": "aa85dabc648140dc",
        "d": true,
        "name": "Turn OFF ALL others",
        "server": "d3151d26.c0d4f",
        "version": 7,
        "debugenabled": false,
        "action": "light.turn_off",
        "floorId": [],
        "areaId": [],
        "deviceId": [],
        "entityId": [
            "light.office_bathroom",
            "light.sonoff_10009954d0_1"
        ],
        "labelId": [],
        "data": "",
        "dataType": "jsonata",
        "mergeContext": "",
        "mustacheAltTags": false,
        "outputProperties": [],
        "queue": "none",
        "blockInputOverrides": false,
        "domain": "light",
        "service": "turn_off",
        "x": 440,
        "y": 320,
        "wires": [
            []
        ]
    },
    {
        "id": "18dc1b7ff68d23dc",
        "type": "trigger-state",
        "z": "aa85dabc648140dc",
        "d": true,
        "name": "Office light ON",
        "server": "d3151d26.c0d4f",
        "version": 5,
        "inputs": 0,
        "outputs": 2,
        "exposeAsEntityConfig": "",
        "entities": {
            "entity": [
                "light.sonoff_10009954d0_1"
            ],
            "substring": [],
            "regex": []
        },
        "debugEnabled": false,
        "constraints": [
            {
                "targetType": "this_entity",
                "targetValue": "",
                "propertyType": "current_state",
                "propertyValue": "new_state.state",
                "comparatorType": "is",
                "comparatorValueDatatype": "str",
                "comparatorValue": "on"
            },
            {
                "targetType": "entity_id",
                "targetValue": "light.office_bathroom",
                "propertyType": "current_state",
                "propertyValue": "new_state.state",
                "comparatorType": "is",
                "comparatorValueDatatype": "str",
                "comparatorValue": "off"
            },
            {
                "targetType": "entity_id",
                "targetValue": "light.sw_office_koi_in_office_2",
                "propertyType": "current_state",
                "propertyValue": "new_state.state",
                "comparatorType": "is",
                "comparatorValueDatatype": "str",
                "comparatorValue": "off"
            }
        ],
        "customOutputs": [],
        "outputInitially": false,
        "stateType": "str",
        "enableInput": false,
        "x": 160,
        "y": 400,
        "wires": [
            [
                "76b12068f9ec7c4b"
            ],
            []
        ]
    },
    {
        "id": "76b12068f9ec7c4b",
        "type": "api-call-service",
        "z": "aa85dabc648140dc",
        "d": true,
        "name": "Turn ON ALL others",
        "server": "d3151d26.c0d4f",
        "version": 7,
        "debugenabled": false,
        "action": "light.turn_on",
        "floorId": [],
        "areaId": [],
        "deviceId": [],
        "entityId": [
            "light.office_bathroom",
            "light.sw_office_koi_in_office_2"
        ],
        "labelId": [],
        "data": "",
        "dataType": "jsonata",
        "mergeContext": "",
        "mustacheAltTags": false,
        "outputProperties": [],
        "queue": "none",
        "blockInputOverrides": false,
        "domain": "light",
        "service": "turn_on",
        "x": 430,
        "y": 400,
        "wires": [
            []
        ]
    },
    {
        "id": "731afb276233a9fc",
        "type": "trigger-state",
        "z": "aa85dabc648140dc",
        "d": true,
        "name": "Office light OFF",
        "server": "d3151d26.c0d4f",
        "version": 5,
        "inputs": 0,
        "outputs": 2,
        "exposeAsEntityConfig": "",
        "entities": {
            "entity": [
                "light.sonoff_10009954d0_1"
            ],
            "substring": [],
            "regex": []
        },
        "debugEnabled": false,
        "constraints": [
            {
                "targetType": "this_entity",
                "targetValue": "",
                "propertyType": "current_state",
                "propertyValue": "new_state.state",
                "comparatorType": "is",
                "comparatorValueDatatype": "str",
                "comparatorValue": "off"
            },
            {
                "targetType": "entity_id",
                "targetValue": "light.office_bathroom",
                "propertyType": "current_state",
                "propertyValue": "new_state.state",
                "comparatorType": "is",
                "comparatorValueDatatype": "str",
                "comparatorValue": "on"
            },
            {
                "targetType": "entity_id",
                "targetValue": "light.sw_office_koi_in_office_2",
                "propertyType": "current_state",
                "propertyValue": "new_state.state",
                "comparatorType": "is",
                "comparatorValueDatatype": "str",
                "comparatorValue": "on"
            }
        ],
        "customOutputs": [],
        "outputInitially": false,
        "stateType": "str",
        "enableInput": false,
        "x": 160,
        "y": 480,
        "wires": [
            [
                "bbeaca38bd4efe4f"
            ],
            []
        ]
    },
    {
        "id": "bbeaca38bd4efe4f",
        "type": "api-call-service",
        "z": "aa85dabc648140dc",
        "d": true,
        "name": "Turn OFF ALL others",
        "server": "d3151d26.c0d4f",
        "version": 7,
        "debugenabled": false,
        "action": "light.turn_off",
        "floorId": [],
        "areaId": [],
        "deviceId": [],
        "entityId": [
            "light.office_bathroom",
            "light.sw_office_koi_in_office_2"
        ],
        "labelId": [],
        "data": "",
        "dataType": "jsonata",
        "mergeContext": "",
        "mustacheAltTags": false,
        "outputProperties": [],
        "queue": "none",
        "blockInputOverrides": false,
        "domain": "light",
        "service": "turn_off",
        "x": 440,
        "y": 480,
        "wires": [
            []
        ]
    },
    {
        "id": "2147d906049aee41",
        "type": "server-state-changed",
        "z": "aa85dabc648140dc",
        "name": "",
        "server": "d3151d26.c0d4f",
        "version": 6,
        "outputs": 2,
        "exposeAsEntityConfig": "",
        "entities": {
            "entity": [
                "light.sw_office_koi_in_office_2",
                "light.office_bathroom",
                "light.sonoff_10009954d0_1"
            ],
            "substring": [],
            "regex": []
        },
        "outputInitially": false,
        "stateType": "str",
        "ifState": "on",
        "ifStateType": "str",
        "ifStateOperator": "is",
        "outputOnlyOnStateChange": true,
        "for": "0",
        "forType": "num",
        "forUnits": "minutes",
        "ignorePrevStateNull": false,
        "ignorePrevStateUnknown": false,
        "ignorePrevStateUnavailable": false,
        "ignoreCurrentStateUnknown": false,
        "ignoreCurrentStateUnavailable": false,
        "outputProperties": [
            {
                "property": "payload",
                "propertyType": "msg",
                "value": "",
                "valueType": "entityState"
            },
            {
                "property": "data",
                "propertyType": "msg",
                "value": "",
                "valueType": "eventData"
            },
            {
                "property": "topic",
                "propertyType": "msg",
                "value": "",
                "valueType": "triggerId"
            }
        ],
        "x": 360,
        "y": 580,
        "wires": [
            [
                "db9ebe6261a9d2fc"
            ],
            [
                "db9ebe6261a9d2fc"
            ]
        ]
    },
    {
        "id": "9e1cb94fbb4981e0",
        "type": "function",
        "z": "aa85dabc648140dc",
        "name": "function 4",
        "func": "// Get the entity ID that triggered the event\nconst triggerEntity = msg.entity_id;\n\n// Determine the trigger state (\"on\" or \"off\")\nlet triggerState = null;\n\nif (typeof msg.payload === 'string') {\n    triggerState = msg.payload;\n} else if (msg.payload?.new_state?.state) {\n    triggerState = msg.payload.new_state.state;\n//} else {\n//    node.warn(\"⚠️ Could not determine trigger state\");\n//   return null;\n}\n\n// Get all entities (from Get Entities node)\nconst allEntities = msg.entities || [];\n\n// Filter out the triggering entity and those already in the same state\nconst entitiesToControl = allEntities\n    .filter(e => e.entity_id !== triggerEntity)\n    .filter(e => e.state !== triggerState)\n    .map(e => e.entity_id);\n\n// If there are no entities to control, do nothing\nif (entitiesToControl.length === 0) {\n    return null;\n}\n\n// Build the correct payload for the action node\nmsg.payload = {\n    action: `light.turn_${triggerState}`,  // e.g., \"light.turn_on\"\n    data: {\n        entity_id: entitiesToControl\n    }\n};\n\nreturn msg;\n",
        "outputs": 1,
        "timeout": 0,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 460,
        "y": 660,
        "wires": [
            [
                "d067369bbbe9a238"
            ]
        ]
    },
    {
        "id": "db9ebe6261a9d2fc",
        "type": "ha-get-entities",
        "z": "aa85dabc648140dc",
        "name": "",
        "server": "d3151d26.c0d4f",
        "version": 1,
        "rules": [
            {
                "condition": "state_object",
                "property": "entity_id",
                "logic": "in_group",
                "value": "light.aa_test_light_group_for_2_way",
                "valueType": "str"
            }
        ],
        "outputType": "array",
        "outputEmptyResults": false,
        "outputLocationType": "msg",
        "outputLocation": "entities",
        "outputResultsCount": 1,
        "x": 260,
        "y": 640,
        "wires": [
            [
                "9e1cb94fbb4981e0"
            ]
        ]
    },
    {
        "id": "b74a3a9bbb53299f",
        "type": "debug",
        "z": "aa85dabc648140dc",
        "name": "debug 19",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "true",
        "targetType": "full",
        "statusVal": "",
        "statusType": "auto",
        "x": 880,
        "y": 660,
        "wires": []
    },
    {
        "id": "d067369bbbe9a238",
        "type": "api-call-service",
        "z": "aa85dabc648140dc",
        "name": "Office light",
        "server": "d3151d26.c0d4f",
        "version": 7,
        "debugenabled": false,
        "action": "",
        "floorId": [],
        "areaId": [],
        "deviceId": [],
        "entityId": [],
        "labelId": [],
        "data": "",
        "dataType": "jsonata",
        "mergeContext": "",
        "mustacheAltTags": false,
        "outputProperties": [],
        "queue": "none",
        "blockInputOverrides": false,
        "domain": "light",
        "service": "",
        "x": 690,
        "y": 660,
        "wires": [
            [
                "b74a3a9bbb53299f"
            ]
        ]
    },
    {
        "id": "1b6b71ee24ed0fb7",
        "type": "function",
        "z": "aa85dabc648140dc",
        "name": "function 5 backup",
        "func": "// Get the entity ID that triggered the event\nconst triggerEntity = msg.entity_id;\n\n// Determine the trigger state (\"on\" or \"off\")\nlet triggerState = null;\n\nif (typeof msg.payload === 'string') {\n    triggerState = msg.payload;\n} else if (msg.payload?.new_state?.state) {\n    triggerState = msg.payload.new_state.state;\n} else {\n    node.warn(\"⚠️ Could not determine trigger state\");\n    return null;\n}\n\n// Get all entities (from Get Entities node)\nconst allEntities = msg.entities || [];\n\n// Filter out the triggering entity and those already in the same state\nconst entitiesToControl = allEntities\n    .filter(e => e.entity_id !== triggerEntity)\n    .filter(e => e.state !== triggerState)\n    .map(e => e.entity_id);\n\n// If there are no entities to control, do nothing\nif (entitiesToControl.length === 0) {\n    return null;\n}\n\n// Build the correct payload for the action node\nmsg.payload = {\n    action: `light.turn_${triggerState}`,  // e.g., \"light.turn_on\"\n    data: {\n        entity_id: entitiesToControl\n    }\n};\n\nreturn msg;\n",
        "outputs": 1,
        "timeout": 0,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 470,
        "y": 880,
        "wires": [
            []
        ]
    },
    {
        "id": "d3151d26.c0d4f",
        "type": "server",
        "name": "Home Assistant Tyrrell",
        "addon": true,
        "rejectUnauthorizedCerts": true,
        "ha_boolean": "",
        "connectionDelay": false,
        "cacheJson": false,
        "heartbeat": false,
        "heartbeatInterval": "",
        "areaSelector": "friendlyName",
        "deviceSelector": "friendlyName",
        "entitySelector": "friendlyName",
        "statusSeparator": "/",
        "statusYear": "numeric",
        "statusMonth": "numeric",
        "statusDay": "numeric",
        "statusHourCycle": "h23",
        "statusTimeFormat": "h:m",
        "enableGlobalContextStore": true
    }
]

Note: the action node must have Block Input overrides deselected - it’s selected by default.
image