Feedback loop from motion detection

Hi all,

I’m new to Node-RED and have created an unfortunate feedback loop.

When my lights turn back off, they then trigger the cameras’ motion detection, which triggers the flow and we start all over.

What would you recommend to prevent this? I don’t want to put an initial delay on the trigger because the goal is to have lights turn on as quickly as possible.

Thanks in advance.

So, the problem is, that your camera detects motion even though its just the light turning off, correct?
In that case, maybe you just block the trigger with a traffic node whenever the light turns off, and then turn the traffic light green again after some time.

Thanks, Marcus. So, I know your time is valuable, but if you have a moment to show me how to do this, I’d appreciate it. The traffic node expects a regex not a payload and I can’t seem to get it working. Is there a different node?

Yes correct. Please find below an example of a traffic node triggered by a state to on, and then to off by another state:

[
    {
        "id": "2db5a6a5.ddffda",
        "type": "switch",
        "z": "d4113bbe.91f4a8",
        "name": "",
        "property": "payload",
        "propertyType": "msg",
        "rules": [
            {
                "t": "eq",
                "v": "brightness_up_hold",
                "vt": "str"
            },
            {
                "t": "eq",
                "v": "brightness_up_release",
                "vt": "str"
            }
        ],
        "checkall": "true",
        "repair": false,
        "outputs": 2,
        "x": 330,
        "y": 1000,
        "wires": [
            [
                "235ac263.baf1de",
                "79a7a052.73"
            ],
            [
                "79a7a052.73"
            ]
        ]
    },
    {
        "id": "235ac263.baf1de",
        "type": "api-current-state",
        "z": "d4113bbe.91f4a8",
        "name": "",
        "server": "2fba4297.e4145e",
        "version": 1,
        "outputs": 2,
        "halt_if": "off",
        "halt_if_type": "str",
        "halt_if_compare": "is",
        "override_topic": false,
        "entity_id": "light.wohnzimmer",
        "state_type": "str",
        "state_location": "payload",
        "override_payload": "msg",
        "entity_location": "data",
        "override_data": "msg",
        "blockInputOverrides": false,
        "x": 870,
        "y": 1000,
        "wires": [
            [],
            [
                "3d5903d0.c8a5cc"
            ]
        ]
    },
    {
        "id": "3d5903d0.c8a5cc",
        "type": "function",
        "z": "d4113bbe.91f4a8",
        "name": "Lower or Higher",
        "func": "newmsg = {}\n\nvar currentbrightness = msg.data.attributes.brightness\nvar up = currentbrightness + 45\n\nnewmsg.payload = { data: { \"brightness\":(up)},\"transition\":\"1\" };\n\n\n\nreturn newmsg;",
        "outputs": 1,
        "noerr": 0,
        "x": 1100,
        "y": 1000,
        "wires": [
            [
                "6c08d8e4.aa23d8"
            ]
        ]
    },
    {
        "id": "6c08d8e4.aa23d8",
        "type": "api-call-service",
        "z": "d4113bbe.91f4a8",
        "name": "Wohnzimmer 100%",
        "server": "2fba4297.e4145e",
        "version": "1",
        "service_domain": "light",
        "service": "turn_on",
        "entityId": "light.wohnzimmer",
        "data": "",
        "dataType": "json",
        "mergecontext": "",
        "output_location": "",
        "output_location_type": "none",
        "mustacheAltTags": false,
        "x": 1290,
        "y": 1000,
        "wires": [
            [
                "6cd31cf3.8c09f4"
            ]
        ]
    },
    {
        "id": "79a7a052.73",
        "type": "traffic",
        "z": "d4113bbe.91f4a8",
        "name": "",
        "property_allow": "payload",
        "filter_allow": "brightness_up_hold",
        "ignore_case_allow": false,
        "negate_allow": false,
        "send_allow": false,
        "property_stop": "payload",
        "filter_stop": "brightness_up_release",
        "ignore_case_stop": false,
        "negate_stop": false,
        "send_stop": false,
        "default_start": false,
        "differ": false,
        "x": 650,
        "y": 1000,
        "wires": [
            [
                "235ac263.baf1de"
            ]
        ]
    },
    {
        "id": "6cd31cf3.8c09f4",
        "type": "delay",
        "z": "d4113bbe.91f4a8",
        "name": "",
        "pauseType": "delay",
        "timeout": "1",
        "timeoutUnits": "seconds",
        "rate": "1",
        "nbRateUnits": "1",
        "rateUnits": "second",
        "randomFirst": "1",
        "randomLast": "5",
        "randomUnits": "seconds",
        "drop": false,
        "x": 480,
        "y": 1000,
        "wires": [
            [
                "79a7a052.73"
            ]
        ]
    },
    {
        "id": "89e8dfba.f919b",
        "type": "server-state-changed",
        "z": "d4113bbe.91f4a8",
        "name": "Button?",
        "server": "2fba4297.e4145e",
        "version": 1,
        "entityidfilter": "sensor.ikea_remote_action",
        "entityidfiltertype": "exact",
        "outputinitially": false,
        "state_type": "str",
        "haltifstate": "",
        "halt_if_type": "str",
        "halt_if_compare": "is",
        "outputs": 1,
        "output_only_on_state_change": true,
        "x": 70,
        "y": 1000,
        "wires": [
            [
                "513118c2.ffcf08",
                "387a685a.e54248",
                "2db5a6a5.ddffda",
                "9001417d.475cf",
                "f79774f7.10fe88"
            ]
        ]
    },
    {
        "id": "9bd2c2f0.f1535",
        "type": "comment",
        "z": "d4113bbe.91f4a8",
        "name": "Up",
        "info": "",
        "x": 330,
        "y": 960,
        "wires": []
    },
    {
        "id": "2fba4297.e4145e",
        "type": "server",
        "z": "",
        "name": "Home Assistant",
        "legacy": false,
        "addon": true,
        "rejectUnauthorizedCerts": true,
        "ha_boolean": "y|yes|true|on|home|open",
        "connectionDelay": true
    }
]

So basically you can do 2 things:

  1. adapt the regex to your specific payload you expect
  2. Just add any regex and send that as a specific payload (i.e. via a change node)

Got it! I’ll try that. Thank you.