Multiple motion sensors with multiple lamps

Node-RED v2.1.4

Hi all,

I tried finding the answer to my problem on this form aswel as on Google, no luck. I'm very sorry if I missed something....here I go:

I have 7 lamps and 3 motion sensors. Each sensor drives a different set of lamps (some overlap). Everything seems to work 'ok' but sometimes a set of lamps won't turn on when there is movement. It seems this happens when the lamps turned off only x minutes ago. So for example:

  1. Sensor A detects movement --> lamps on
  2. Sensor A detects NO movement --> Lamps off
  3. Only a minute after step 2 Sensor A (should) detect movement again --> Nothing happens

Motion sensors:

  • zigbee2mqtt/MotionKeukengang (tradfri motion sensor)
  • zigbee2mqtt/MotionNachthal1 (tradfri motion sensor)
  • zigbee2mqtt/MotionNachthal2 (tradfri motion sensor)
    Lamps:
  • tradfri_bulb_5
  • tradfri_bulb_6
  • Nachthal 1 (tuya)
  • Nachthal 2 (tuya)
  • Nachthal 3 (tuya)
  • Nachthal 4 (tuya)
  • Nachthal 5 (tuya)
  1. MotionKeukengang drives: tradfri_bulb_5, tradfri_bulb_6 and Nachthal 2
  2. MotionNachthal1 drives: Nachthal 1, Nachthal 2, Nachthal 3
  3. MotionNachthal2 drives: Nachthal 3, Nachthal 4, Nachthal 5

i tried different options but currently it is set to set a "Trigger Node" on motion (turn lamps on) and set the option "and then send" in this trigger node to turn the lamps off after x seconds. (I'm not using the "occupacy false" of the tradri motion sensor.)

[
    {
        "id": "d029c89fdf7ef984",
        "type": "mqtt in",
        "z": "765afc503538b02b",
        "name": "",
        "topic": "zigbee2mqtt/MotionNachthal2",
        "qos": "2",
        "datatype": "auto",
        "broker": "xxxxx",
        "nl": false,
        "rap": true,
        "rh": 0,
        "inputs": 0,
        "x": 400,
        "y": 660,
        "wires": [
            [
                "a65ae55fd4ad5e4a"
            ]
        ]
    },
    {
        "id": "a65ae55fd4ad5e4a",
        "type": "json",
        "z": "765afc503538b02b",
        "name": "beweging?",
        "property": "payload",
        "action": "",
        "pretty": false,
        "x": 650,
        "y": 660,
        "wires": [
            [
                "71b089087199d56e"
            ]
        ]
    },
    {
        "id": "71b089087199d56e",
        "type": "switch",
        "z": "765afc503538b02b",
        "name": "",
        "property": "payload.occupancy",
        "propertyType": "msg",
        "rules": [
            {
                "t": "true"
            },
            {
                "t": "false"
            }
        ],
        "checkall": "true",
        "repair": false,
        "outputs": 2,
        "x": 790,
        "y": 660,
        "wires": [
            [
                "9e7b3d093b828f61",
                "75120da75002711f"
            ],
            []
        ]
    },
    {
        "id": "4c1a92f14f09e617",
        "type": "tuya-local",
        "z": "765afc503538b02b",
        "devName": "Nachthal 4",
        "devIp": "192.168.1.252",
        "devId": "xxx",
        "devKey": "xxx",
        "protocolVer": "3.3",
        "renameSchema": "",
        "filterCB": "",
        "x": 1290,
        "y": 680,
        "wires": [
            []
        ]
    },
    {
        "id": "75120da75002711f",
        "type": "trigger",
        "z": "765afc503538b02b",
        "name": "",
        "op1": "{\"multiple\": true, \"data\": { \"20\": true, \"22\": 50 }}",
        "op2": "{\"multiple\": false, \"data\": { \"20\": true, \"22\": 50 }}",
        "op1type": "json",
        "op2type": "json",
        "duration": "260",
        "extend": true,
        "overrideDelay": false,
        "units": "s",
        "reset": "",
        "bytopic": "all",
        "topic": "topic",
        "outputs": 1,
        "x": 1090,
        "y": 680,
        "wires": [
            [
                "4c1a92f14f09e617",
                "a05fcf847935f846"
            ]
        ]
    },
    {
        "id": "a05fcf847935f846",
        "type": "tuya-local",
        "z": "765afc503538b02b",
        "devName": "Nachthal 5",
        "devIp": "192.168.1.147",
        "devId": "ccc",
        "devKey": "ccc",
        "protocolVer": "3.3",
        "renameSchema": "",
        "filterCB": "",
        "x": 1290,
        "y": 720,
        "wires": [
            []
        ]
    },
    {
        "id": "122c1e4b8b05108b",
        "type": "mqtt in",
        "z": "765afc503538b02b",
        "name": "",
        "topic": "zigbee2mqtt/MotionNachthal1",
        "qos": "2",
        "datatype": "auto",
        "broker": "16ef4cb1ac065d33",
        "nl": false,
        "rap": true,
        "rh": 0,
        "inputs": 0,
        "x": 400,
        "y": 600,
        "wires": [
            [
                "b1197172f18f29fc"
            ]
        ]
    },
    {
        "id": "8f27442da26f3aca",
        "type": "mqtt in",
        "z": "765afc503538b02b",
        "name": "",
        "topic": "zigbee2mqtt/MotionKeukengang",
        "qos": "2",
        "datatype": "auto",
        "broker": "16ef4cb1ac065d33",
        "nl": false,
        "rap": true,
        "rh": 0,
        "inputs": 0,
        "x": 410,
        "y": 540,
        "wires": [
            [
                "b027701d36fb54d5"
            ]
        ]
    },
    {
        "id": "b1197172f18f29fc",
        "type": "json",
        "z": "765afc503538b02b",
        "name": "beweging?",
        "property": "payload",
        "action": "",
        "pretty": false,
        "x": 650,
        "y": 600,
        "wires": [
            [
                "4ba0f9a83bd01d0f"
            ]
        ]
    },
    {
        "id": "b027701d36fb54d5",
        "type": "json",
        "z": "765afc503538b02b",
        "name": "beweging?",
        "property": "payload",
        "action": "",
        "pretty": false,
        "x": 650,
        "y": 540,
        "wires": [
            [
                "95ee6b217962121f"
            ]
        ]
    },
    {
        "id": "4ba0f9a83bd01d0f",
        "type": "switch",
        "z": "765afc503538b02b",
        "name": "",
        "property": "payload.occupancy",
        "propertyType": "msg",
        "rules": [
            {
                "t": "true"
            },
            {
                "t": "false"
            }
        ],
        "checkall": "true",
        "repair": false,
        "outputs": 2,
        "x": 810,
        "y": 600,
        "wires": [
            [
                "6384320ad12a9b84",
                "87dd27f76ac1e337",
                "dd0b853ad1965fd7",
                "9e7b3d093b828f61"
            ],
            []
        ]
    },
    {
        "id": "95ee6b217962121f",
        "type": "switch",
        "z": "765afc503538b02b",
        "name": "",
        "property": "payload.occupancy",
        "propertyType": "msg",
        "rules": [
            {
                "t": "true"
            },
            {
                "t": "false"
            }
        ],
        "checkall": "true",
        "repair": false,
        "outputs": 2,
        "x": 810,
        "y": 540,
        "wires": [
            [
                "6384320ad12a9b84",
                "dd0b853ad1965fd7"
            ],
            []
        ]
    },
    {
        "id": "6384320ad12a9b84",
        "type": "trigger",
        "z": "765afc503538b02b",
        "name": "",
        "op1": "",
        "op2": "",
        "op1type": "pay",
        "op2type": "payl",
        "duration": "260",
        "extend": true,
        "overrideDelay": false,
        "units": "s",
        "reset": "",
        "bytopic": "all",
        "topic": "topic",
        "outputs": 2,
        "x": 1090,
        "y": 520,
        "wires": [
            [
                "708a9af4bb024323"
            ],
            [
                "3e6fe70a4e684660"
            ]
        ]
    },
    {
        "id": "708a9af4bb024323",
        "type": "api-call-service",
        "z": "765afc503538b02b",
        "name": "Keukengang AAN",
        "server": "0dd06a145163b1fe",
        "version": 3,
        "debugenabled": false,
        "service_domain": "light",
        "service": "turn_on",
        "entityId": "light.tradfri_bulb_5, light.tradfri_bulb_6",
        "data": "",
        "dataType": "jsonata",
        "mergecontext": "",
        "mustacheAltTags": false,
        "outputProperties": [],
        "queue": "none",
        "x": 1310,
        "y": 480,
        "wires": [
            []
        ]
    },
    {
        "id": "3e6fe70a4e684660",
        "type": "api-call-service",
        "z": "765afc503538b02b",
        "name": "Keukengang UIT",
        "server": "0dd06a145163b1fe",
        "version": 3,
        "debugenabled": false,
        "service_domain": "light",
        "service": "turn_off",
        "entityId": "light.tradfri_bulb_5, light.tradfri_bulb_6",
        "data": "",
        "dataType": "jsonata",
        "mergecontext": "",
        "mustacheAltTags": false,
        "outputProperties": [],
        "queue": "none",
        "x": 1310,
        "y": 520,
        "wires": [
            []
        ]
    },
    {
        "id": "e22c7426356bd27b",
        "type": "tuya-local",
        "z": "765afc503538b02b",
        "devName": "Nachthal 2",
        "devIp": "192.168.1.106",
        "devId": "bbb",
        "devKey": "bbb",
        "protocolVer": "3.3",
        "renameSchema": "",
        "filterCB": "",
        "x": 1290,
        "y": 600,
        "wires": [
            []
        ]
    },
    {
        "id": "dd0b853ad1965fd7",
        "type": "trigger",
        "z": "765afc503538b02b",
        "name": "",
        "op1": "{\"multiple\": true, \"data\": { \"20\": true, \"22\": 50 }}",
        "op2": "{\"multiple\": false, \"data\": { \"20\": true, \"22\": 50 }}",
        "op1type": "json",
        "op2type": "json",
        "duration": "260",
        "extend": true,
        "overrideDelay": false,
        "units": "s",
        "reset": "",
        "bytopic": "all",
        "topic": "topic",
        "outputs": 1,
        "x": 1090,
        "y": 600,
        "wires": [
            [
                "e22c7426356bd27b"
            ]
        ]
    },
    {
        "id": "b1cfcd6a9ae26f80",
        "type": "tuya-local",
        "z": "765afc503538b02b",
        "devName": "Nachthal 1",
        "devIp": "192.168.1.168",
        "devId": "nnn",
        "devKey": "nnn",
        "protocolVer": "3.3",
        "renameSchema": "",
        "filterCB": "",
        "x": 1290,
        "y": 560,
        "wires": [
            []
        ]
    },
    {
        "id": "972339871bd2eba5",
        "type": "tuya-local",
        "z": "765afc503538b02b",
        "devName": "Nachthal 3",
        "devIp": "192.168.1.127",
        "devId": "qqq",
        "devKey": "qqq",
        "protocolVer": "3.3",
        "renameSchema": "",
        "filterCB": "",
        "x": 1290,
        "y": 640,
        "wires": [
            []
        ]
    },
    {
        "id": "87dd27f76ac1e337",
        "type": "trigger",
        "z": "765afc503538b02b",
        "name": "",
        "op1": "{\"multiple\": true, \"data\": { \"20\": true, \"22\": 50 }}",
        "op2": "{\"multiple\": false, \"data\": { \"20\": true, \"22\": 50 }}",
        "op1type": "json",
        "op2type": "json",
        "duration": "260",
        "extend": true,
        "overrideDelay": false,
        "units": "s",
        "reset": "",
        "bytopic": "all",
        "topic": "topic",
        "outputs": 1,
        "x": 1090,
        "y": 560,
        "wires": [
            [
                "b1cfcd6a9ae26f80"
            ]
        ]
    },
    {
        "id": "9e7b3d093b828f61",
        "type": "trigger",
        "z": "765afc503538b02b",
        "name": "",
        "op1": "{\"multiple\": true, \"data\": { \"20\": true, \"22\": 50 }}",
        "op2": "{\"multiple\": false, \"data\": { \"20\": true, \"22\": 50 }}",
        "op1type": "json",
        "op2type": "json",
        "duration": "260",
        "extend": true,
        "overrideDelay": false,
        "units": "s",
        "reset": "",
        "bytopic": "all",
        "topic": "topic",
        "outputs": 1,
        "x": 1090,
        "y": 640,
        "wires": [
            [
                "972339871bd2eba5"
            ]
        ]
    },
    {
        "id": "6c1bc2d1ee411537",
        "type": "comment",
        "z": "765afc503538b02b",
        "name": "Nachthal/Keukengang verlichting",
        "info": "Bewegingsensor_nachthal1\ndeze sensor zet de lampen in de keukengang aan, inclusief nachthal 1, 2 en 3\n\nBewegingsensor_nachthal2\ndeze sensor zet nachthal 3, 4 en 5 aan\n\nBewegingsensor_keukengang\nDeze sensor zet de 2 lampen in de keukengang aan inclusief nachthal lamp 2",
        "x": 410,
        "y": 500,
        "wires": []
    },
    {
        "id": "16ef4cb1ac065d33",
        "type": "mqtt-broker",
        "name": "",
        "broker": "192.168.1.55",
        "port": "1883",
        "clientid": "",
        "autoConnect": true,
        "usetls": false,
        "protocolVersion": "5",
        "keepalive": "60",
        "cleansession": true,
        "birthTopic": "",
        "birthQos": "0",
        "birthPayload": "",
        "birthMsg": {},
        "closeTopic": "",
        "closeQos": "0",
        "closePayload": "",
        "closeMsg": {},
        "willTopic": "",
        "willQos": "0",
        "willPayload": "",
        "willMsg": {},
        "sessionExpiry": ""
    },
    {
        "id": "0dd06a145163b1fe",
        "type": "server",
        "name": "Home Assistant",
        "version": 2,
        "addon": false,
        "rejectUnauthorizedCerts": false,
        "ha_boolean": "y|yes|true|on|home|open",
        "connectionDelay": false,
        "cacheJson": true,
        "heartbeat": false,
        "heartbeatInterval": "30"
    }
]

Welcome to the forum @strip3z

The technique to use to find the problem is to work out which node(s) are not doing what you expect. So start by adding debug nodes to the MQTT outputs to see what they show in the failure condition. Then if that looks correct move on to the next nodes, and so on. Once you know where it is failing then note the sequence of inputs going that node and what comes out. If you can't work out what is going on then tell us what you are seeing at the failing node.

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