100% cpu when touching ui or a specific flow reloads

I've created a flow to control my thermostat and also to reset it after some time.
While testing I set an inject to push timestamp every 5 seconds and if the last change on the thermostat +10 seconds is reached to reset. (this is not fully finished but yet)

The issue is, after some point of running it began eating memory and CPU! and I cannot understand why.
The Flow is:

[
    {
        "id": "4398d66c.162748",
        "type": "mqtt in",
        "z": "ebd56e5.ec86b9",
        "name": "TRV CurrentTemp",
        "topic": "zwave2mqtt/HallwayFirst/TRV/49/1/1",
        "qos": "2",
        "datatype": "json",
        "broker": "90876955.0f6418",
        "x": 130,
        "y": 80,
        "wires": [
            [
                "1156e4a.3707d1b"
            ]
        ]
    },
    {
        "id": "6611a45c.a42f9c",
        "type": "ui_heater_controller",
        "z": "ebd56e5.ec86b9",
        "name": "heater",
        "group": "fbed6f0b.6a621",
        "unit": "C",
        "order": 1,
        "width": 0,
        "height": 0,
        "topic": "",
        "title": "",
        "logLengthType": "days",
        "logLength": "0",
        "sliderMinValue": 12,
        "sliderMaxValue": 28,
        "sliderStep": 0.5,
        "thresholdRising": 0.5,
        "thresholdFalling": 0.5,
        "calendar": "{\n    \"Monday\": {\n        \"00:00\": 19,\n        \"06:20\": 22,\n        \"08:00\": 19,\n        \"16:40\": 22,\n        \"23:59\": 19\n    },\n    \"Tuesday\": {\n        \"00:00\": 19,\n        \"06:20\": 22,\n        \"08:00\": 19,\n        \"16:40\": 22,\n        \"23:59\": 19\n    },\n    \"Wednesday\": {\n        \"00:00\": 19,\n        \"06:20\": 22,\n        \"08:00\": 19,\n        \"16:40\": 22,\n        \"23:59\": 19\n    },\n    \"Thursday\": {\n        \"00:00\": 19,\n        \"06:20\": 22,\n        \"08:00\": 19,\n        \"16:40\": 22,\n        \"23:59\": 19\n    },\n    \"Friday\": {\n        \"00:00\": 19,\n        \"06:20\": 23,\n        \"08:00\": 19,\n        \"16:40\": 22,\n        \"23:59\": 19\n    },\n    \"Saturday\": {\n        \"00:00\": 19,\n        \"08:00\": 20,\n        \"20:00\": 22,\n        \"23:59\": 19\n    },\n    \"Sunday\": {\n        \"00:00\": 19,\n        \"08:00\": 20,\n        \"20:00\": 22,\n        \"23:59\": 19\n    }\n}",
        "x": 490,
        "y": 80,
        "wires": [
            [
                "a8e2dfa0.23693",
                "cfed7818.3ce6a8"
            ]
        ]
    },
    {
        "id": "1156e4a.3707d1b",
        "type": "change",
        "z": "ebd56e5.ec86b9",
        "name": "",
        "rules": [
            {
                "t": "set",
                "p": "topic",
                "pt": "msg",
                "to": "currentTemp",
                "tot": "str"
            },
            {
                "t": "set",
                "p": "payload",
                "pt": "msg",
                "to": "payload.value",
                "tot": "msg"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 320,
        "y": 80,
        "wires": [
            [
                "6611a45c.a42f9c"
            ]
        ]
    },
    {
        "id": "a8e2dfa0.23693",
        "type": "switch",
        "z": "ebd56e5.ec86b9",
        "name": "",
        "property": "payload.targetValue",
        "propertyType": "msg",
        "rules": [
            {
                "t": "neq",
                "v": "currentSetTemp",
                "vt": "flow"
            }
        ],
        "checkall": "true",
        "repair": false,
        "outputs": 1,
        "x": 690,
        "y": 160,
        "wires": [
            [
                "4043672b.9b5ef8"
            ]
        ]
    },
    {
        "id": "61949791.655088",
        "type": "change",
        "z": "ebd56e5.ec86b9",
        "name": "",
        "rules": [
            {
                "t": "set",
                "p": "currentSetTemp",
                "pt": "flow",
                "to": "payload.value",
                "tot": "msg"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 490,
        "y": 440,
        "wires": [
            []
        ]
    },
    {
        "id": "26e241e0.01f89e",
        "type": "mqtt in",
        "z": "ebd56e5.ec86b9",
        "name": "TRV SetTemp",
        "topic": "zwave2mqtt/HallwayFirst/TRV/67/1/1",
        "qos": "1",
        "datatype": "json",
        "broker": "90876955.0f6418",
        "x": 230,
        "y": 440,
        "wires": [
            [
                "61949791.655088"
            ]
        ]
    },
    {
        "id": "4043672b.9b5ef8",
        "type": "change",
        "z": "ebd56e5.ec86b9",
        "name": "",
        "rules": [
            {
                "t": "set",
                "p": "payload",
                "pt": "msg",
                "to": "payload.targetValue",
                "tot": "msg"
            },
            {
                "t": "set",
                "p": "#:(disk)::changeTimestamp",
                "pt": "flow",
                "to": "",
                "tot": "date"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 860,
        "y": 160,
        "wires": [
            []
        ]
    },
    {
        "id": "78177e54.cd333",
        "type": "inject",
        "z": "ebd56e5.ec86b9",
        "name": "",
        "topic": "",
        "payload": "",
        "payloadType": "date",
        "repeat": "5",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "x": 110,
        "y": 280,
        "wires": [
            [
                "687a69.d60d8598",
                "42b35a0.9de0ea8"
            ]
        ]
    },
    {
        "id": "cda34824.2d2678",
        "type": "switch",
        "z": "ebd56e5.ec86b9",
        "name": "",
        "property": "($flowContext(\"changeTimestamp\", \"disk\") + 10000) < payload",
        "propertyType": "jsonata",
        "rules": [
            {
                "t": "true"
            }
        ],
        "checkall": "true",
        "repair": false,
        "outputs": 1,
        "x": 410,
        "y": 280,
        "wires": [
            []
        ]
    },
    {
        "id": "42b35a0.9de0ea8",
        "type": "debug",
        "z": "ebd56e5.ec86b9",
        "name": "Custom state",
        "active": true,
        "tosidebar": false,
        "console": false,
        "tostatus": true,
        "complete": "$flowContext(\"isUserCustom\", \"disk\")",
        "targetType": "jsonata",
        "x": 360,
        "y": 360,
        "wires": []
    },
    {
        "id": "cfed7818.3ce6a8",
        "type": "change",
        "z": "ebd56e5.ec86b9",
        "name": "",
        "rules": [
            {
                "t": "set",
                "p": "#:(disk)::isUserCustom",
                "pt": "flow",
                "to": "payload.isUserCustom",
                "tot": "msg"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 760,
        "y": 80,
        "wires": [
            []
        ]
    },
    {
        "id": "687a69.d60d8598",
        "type": "switch",
        "z": "ebd56e5.ec86b9",
        "name": "",
        "property": "#:(disk)::isUserCustom",
        "propertyType": "flow",
        "rules": [
            {
                "t": "true"
            }
        ],
        "checkall": "true",
        "repair": false,
        "outputs": 1,
        "x": 270,
        "y": 280,
        "wires": [
            [
                "cda34824.2d2678"
            ]
        ]
    },
    {
        "id": "90876955.0f6418",
        "type": "mqtt-broker",
        "z": "",
        "name": "Main MQTT",
        "broker": "mqtt",
        "port": "1883",
        "clientid": "",
        "usetls": false,
        "compatmode": false,
        "keepalive": "60",
        "cleansession": true,
        "birthTopic": "",
        "birthQos": "0",
        "birthPayload": "",
        "closeTopic": "",
        "closeQos": "0",
        "closePayload": "",
        "willTopic": "",
        "willQos": "0",
        "willPayload": ""
    },
    {
        "id": "fbed6f0b.6a621",
        "type": "ui_group",
        "z": "",
        "name": "Heating",
        "tab": "dee0def.c82102",
        "order": 1,
        "disp": true,
        "width": "6",
        "collapse": false
    },
    {
        "id": "dee0def.c82102",
        "type": "ui_tab",
        "z": "",
        "name": "Main",
        "icon": "dashboard",
        "order": 1,
        "disabled": false,
        "hidden": false
    }
]

One possibility is an mqtt loop. Connect to the mqtt broker using a different client, such as mosqitto_sub, and subscribe to "#" so you will see all traffic, and leave that running. See if anything obvious happens when it starts going wrong.

It is not mqtt the
mqtt in topic is different. And It was the first link to remove before testing the ui again.
also using my MQTT explorer i've seen no traffic in mqtt side

Does it fail with just that section of the flow that you exported enabled? If so then if there are not thousands of messages passing through then the only thing I can see that could be using the resources is the ui_heater_controller which I don't know anything about.

It fails even manually injected objects (for testing and to avoid loops)
I suspect memory heap or something similar..
Can it be my flows.json is "contaminated" and causes this?

Did you export the complete flow or is there lots more?
Which process(s) are consuming the resources?
How quickly does it fail?
What do you mean by the flows file being contaminated?
It might be worth posting the node-red startup log here, sometimes that is useful. Start node red in a terminal and post the log.

It was full.
once i set/change temp from ui it goes 100%. I rebuilt it and it doesn't do it.

also finalised it.. to control my thermostat for a room.

I take care of:

  1. Avoid repeating the same message to MQTT if setTemp on thermostat and currentSetTemp is the same!
  2. Added timeout in case it is Overridden by manual/user change (Adjustable with global variable)

Can I use on MQTT In/OUT variable as topic?
If so maybe I can then use something like Subflow, to replicate mechanism on each room.

here is the final:

[
    {
        "id": "ebd56e5.ec86b9",
        "type": "tab",
        "label": "Hall First Flow",
        "disabled": false,
        "info": ""
    },
    {
        "id": "4398d66c.162748",
        "type": "mqtt in",
        "z": "ebd56e5.ec86b9",
        "name": "TRV CurrentTemp",
        "topic": "zwave2mqtt/HallwayFirst/TRV/49/1/1",
        "qos": "2",
        "datatype": "json",
        "broker": "90876955.0f6418",
        "x": 110,
        "y": 40,
        "wires": [
            [
                "1156e4a.3707d1b"
            ]
        ]
    },
    {
        "id": "6611a45c.a42f9c",
        "type": "ui_heater_controller",
        "z": "ebd56e5.ec86b9",
        "name": "Heater Hallway",
        "group": "fbed6f0b.6a621",
        "unit": "C",
        "order": 1,
        "width": 0,
        "height": 0,
        "topic": "",
        "title": "Hallway First",
        "logLengthType": "days",
        "logLength": "0",
        "sliderMinValue": 12,
        "sliderMaxValue": 28,
        "sliderStep": 0.5,
        "thresholdRising": 0.5,
        "thresholdFalling": 0.5,
        "calendar": "{\n    \"Monday\": {\n        \"00:00\": 19,\n        \"06:20\": 22,\n        \"08:00\": 19,\n        \"16:40\": 22,\n        \"23:59\": 19\n    },\n    \"Tuesday\": {\n        \"00:00\": 19,\n        \"06:20\": 22,\n        \"08:00\": 19,\n        \"16:40\": 22,\n        \"23:59\": 19\n    },\n    \"Wednesday\": {\n        \"00:00\": 19,\n        \"06:20\": 22,\n        \"08:00\": 19,\n        \"16:40\": 22,\n        \"23:59\": 19\n    },\n    \"Thursday\": {\n        \"00:00\": 19,\n        \"06:20\": 22,\n        \"08:00\": 19,\n        \"16:40\": 22,\n        \"23:59\": 19\n    },\n    \"Friday\": {\n        \"00:00\": 19,\n        \"06:20\": 23,\n        \"08:00\": 19,\n        \"16:40\": 22,\n        \"23:59\": 19\n    },\n    \"Saturday\": {\n        \"00:00\": 19,\n        \"08:00\": 20,\n        \"20:00\": 22,\n        \"23:59\": 19\n    },\n    \"Sunday\": {\n        \"00:00\": 19,\n        \"08:00\": 20,\n        \"20:00\": 22,\n        \"23:59\": 19\n    }\n}",
        "x": 500,
        "y": 80,
        "wires": [
            [
                "4043672b.9b5ef8",
                "a8e2dfa0.23693"
            ]
        ]
    },
    {
        "id": "1156e4a.3707d1b",
        "type": "change",
        "z": "ebd56e5.ec86b9",
        "name": "",
        "rules": [
            {
                "t": "set",
                "p": "topic",
                "pt": "msg",
                "to": "currentTemp",
                "tot": "str"
            },
            {
                "t": "set",
                "p": "payload",
                "pt": "msg",
                "to": "payload.value",
                "tot": "msg"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 300,
        "y": 40,
        "wires": [
            [
                "6611a45c.a42f9c"
            ]
        ]
    },
    {
        "id": "a8e2dfa0.23693",
        "type": "switch",
        "z": "ebd56e5.ec86b9",
        "name": "",
        "property": "payload.targetValue",
        "propertyType": "msg",
        "rules": [
            {
                "t": "neq",
                "v": "currentSetTemp",
                "vt": "flow"
            }
        ],
        "checkall": "true",
        "repair": false,
        "outputs": 1,
        "x": 670,
        "y": 40,
        "wires": [
            [
                "152685af.aa1f6a"
            ]
        ]
    },
    {
        "id": "61949791.655088",
        "type": "change",
        "z": "ebd56e5.ec86b9",
        "name": "",
        "rules": [
            {
                "t": "set",
                "p": "currentSetTemp",
                "pt": "flow",
                "to": "payload.value",
                "tot": "msg"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 430,
        "y": 320,
        "wires": [
            []
        ]
    },
    {
        "id": "26e241e0.01f89e",
        "type": "mqtt in",
        "z": "ebd56e5.ec86b9",
        "name": "TRV SetTemp",
        "topic": "zwave2mqtt/HallwayFirst/TRV/67/1/1",
        "qos": "1",
        "datatype": "json",
        "broker": "90876955.0f6418",
        "x": 130,
        "y": 300,
        "wires": [
            [
                "61949791.655088",
                "e789c9c0.fab848"
            ]
        ]
    },
    {
        "id": "4043672b.9b5ef8",
        "type": "change",
        "z": "ebd56e5.ec86b9",
        "name": "",
        "rules": [
            {
                "t": "set",
                "p": "payload",
                "pt": "msg",
                "to": "payload.targetValue",
                "tot": "msg"
            },
            {
                "t": "set",
                "p": "#:(disk)::changeTimestamp",
                "pt": "flow",
                "to": "",
                "tot": "date"
            },
            {
                "t": "set",
                "p": "#:(disk)::isUserCustom",
                "pt": "global",
                "to": "payload.isUserCustom",
                "tot": "str"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 700,
        "y": 120,
        "wires": [
            []
        ]
    },
    {
        "id": "78177e54.cd333",
        "type": "inject",
        "z": "ebd56e5.ec86b9",
        "name": "",
        "topic": "",
        "payload": "",
        "payloadType": "date",
        "repeat": "300",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "x": 130,
        "y": 380,
        "wires": [
            [
                "687a69.d60d8598",
                "7ec87129.2d552",
                "e2bbf171.f1154"
            ]
        ]
    },
    {
        "id": "cda34824.2d2678",
        "type": "switch",
        "z": "ebd56e5.ec86b9",
        "name": "",
        "property": "($flowContext(\"changeTimestamp\", \"disk\") + ($globalContext(\"heatingDelay\", \"disk\")*(60*60*1000) )) < payload",
        "propertyType": "jsonata",
        "rules": [
            {
                "t": "true"
            }
        ],
        "checkall": "true",
        "repair": false,
        "outputs": 1,
        "x": 430,
        "y": 380,
        "wires": [
            [
                "3c718ee3.0e7a22",
                "5d18d402.6fc84c"
            ]
        ]
    },
    {
        "id": "687a69.d60d8598",
        "type": "switch",
        "z": "ebd56e5.ec86b9",
        "name": "",
        "property": "#:(disk)::isUserCustom",
        "propertyType": "flow",
        "rules": [
            {
                "t": "true"
            }
        ],
        "checkall": "true",
        "repair": false,
        "outputs": 1,
        "x": 290,
        "y": 380,
        "wires": [
            [
                "cda34824.2d2678",
                "d5c01eb2.0da33"
            ]
        ]
    },
    {
        "id": "3c718ee3.0e7a22",
        "type": "change",
        "z": "ebd56e5.ec86b9",
        "name": "",
        "rules": [
            {
                "t": "set",
                "p": "topic",
                "pt": "msg",
                "to": "userConfig",
                "tot": "str"
            },
            {
                "t": "set",
                "p": "payload",
                "pt": "msg",
                "to": "{ \"isUserCustom\": false }",
                "tot": "json"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 660,
        "y": 380,
        "wires": [
            [
                "fac3d47d.2ed618"
            ]
        ]
    },
    {
        "id": "fac3d47d.2ed618",
        "type": "link out",
        "z": "ebd56e5.ec86b9",
        "name": "",
        "links": [
            "94a3a152.08248"
        ],
        "x": 775,
        "y": 300,
        "wires": []
    },
    {
        "id": "94a3a152.08248",
        "type": "link in",
        "z": "ebd56e5.ec86b9",
        "name": "",
        "links": [
            "fac3d47d.2ed618"
        ],
        "x": 355,
        "y": 80,
        "wires": [
            [
                "6611a45c.a42f9c"
            ]
        ]
    },
    {
        "id": "d5c01eb2.0da33",
        "type": "debug",
        "z": "ebd56e5.ec86b9",
        "name": "",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": true,
        "complete": "$flowContext(\"changeTimestamp\", \"disk\") + ($globalContext(\"heatingDelay\", \"disk\")*(60*60*1000) )",
        "targetType": "jsonata",
        "x": 480,
        "y": 460,
        "wires": []
    },
    {
        "id": "5d18d402.6fc84c",
        "type": "debug",
        "z": "ebd56e5.ec86b9",
        "name": "",
        "active": true,
        "tosidebar": false,
        "console": false,
        "tostatus": true,
        "complete": "$flowContext(\"changeTimestamp\", \"disk\") + ($globalContext(\"heatingDelay\", \"disk\")*(60*60*1000) )",
        "targetType": "jsonata",
        "x": 760,
        "y": 440,
        "wires": []
    },
    {
        "id": "7ec87129.2d552",
        "type": "debug",
        "z": "ebd56e5.ec86b9",
        "name": "Override",
        "active": true,
        "tosidebar": false,
        "console": false,
        "tostatus": true,
        "complete": "$flowContext(\"isUserCustom\", \"disk\")",
        "targetType": "jsonata",
        "x": 460,
        "y": 520,
        "wires": []
    },
    {
        "id": "e2bbf171.f1154",
        "type": "debug",
        "z": "ebd56e5.ec86b9",
        "name": "Last Exec",
        "active": true,
        "tosidebar": false,
        "console": false,
        "tostatus": true,
        "complete": "$now()",
        "targetType": "jsonata",
        "x": 300,
        "y": 540,
        "wires": []
    },
    {
        "id": "509b298d.970c98",
        "type": "mqtt out",
        "z": "ebd56e5.ec86b9",
        "name": "updateTemp",
        "topic": "zwave2mqtt/HallwayFirst/TRV/67/1/1/set",
        "qos": "1",
        "retain": "",
        "broker": "90876955.0f6418",
        "x": 990,
        "y": 40,
        "wires": []
    },
    {
        "id": "e789c9c0.fab848",
        "type": "delay",
        "z": "ebd56e5.ec86b9",
        "name": "",
        "pauseType": "delay",
        "timeout": "1",
        "timeoutUnits": "seconds",
        "rate": "1",
        "nbRateUnits": "1",
        "rateUnits": "second",
        "randomFirst": "1",
        "randomLast": "5",
        "randomUnits": "seconds",
        "drop": false,
        "x": 320,
        "y": 240,
        "wires": [
            [
                "8971020f.e4497"
            ]
        ]
    },
    {
        "id": "b122b16e.166aa",
        "type": "debug",
        "z": "ebd56e5.ec86b9",
        "name": "",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "x": 740,
        "y": 220,
        "wires": []
    },
    {
        "id": "8971020f.e4497",
        "type": "function",
        "z": "ebd56e5.ec86b9",
        "name": "",
        "func": "msg.topic = \"userConfig\"\nmsg.payload = {\"Temp\": msg.payload};\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "x": 540,
        "y": 240,
        "wires": [
            [
                "b122b16e.166aa"
            ]
        ]
    },
    {
        "id": "152685af.aa1f6a",
        "type": "change",
        "z": "ebd56e5.ec86b9",
        "name": "",
        "rules": [
            {
                "t": "set",
                "p": "payload",
                "pt": "msg",
                "to": "payload.targetValue",
                "tot": "msg"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 820,
        "y": 40,
        "wires": [
            [
                "509b298d.970c98"
            ]
        ]
    },
    {
        "id": "90876955.0f6418",
        "type": "mqtt-broker",
        "z": "",
        "name": "Main MQTT",
        "broker": "mqtt",
        "port": "1883",
        "clientid": "",
        "usetls": false,
        "compatmode": false,
        "keepalive": "60",
        "cleansession": true,
        "birthTopic": "",
        "birthQos": "0",
        "birthPayload": "",
        "closeTopic": "",
        "closeQos": "0",
        "closePayload": "",
        "willTopic": "",
        "willQos": "0",
        "willPayload": ""
    },
    {
        "id": "fbed6f0b.6a621",
        "type": "ui_group",
        "z": "",
        "name": "Heating",
        "tab": "dee0def.c82102",
        "order": 1,
        "disp": true,
        "width": "8",
        "collapse": false
    },
    {
        "id": "dee0def.c82102",
        "type": "ui_tab",
        "z": "",
        "name": "Main",
        "icon": "dashboard",
        "order": 1,
        "disabled": false,
        "hidden": false
    }
]

Please explain what you mean

My MQTT topic (the device payload) is
zwave2mqtt///

can this become a variable? and used in the topic field of mqtt ndoe?

Do you mean the value received when you subscribe to some mqtt topic is the string "zwave2mqtt///" and you want that to be used as an mqtt topic? I am not sure that would be a valid topic, but apart from that then I suppose so. Why would you want to do that though? Do you want to subscribe to it or publish. Publish is easy as you can pass the topic to the MQTT out node. Subscribe is not so easy, you would need to subscribe with wildcards to get all such topics then filter it in the flow.

for some reason the < and > been removed
topic can be zwave2mqtt/DeviceLoc/DeviceName/Payload
the DeviceLoc or DeviceName can be variable

You need to put special chars in backticks in the forum, otherwise it interprets them as markup codes.
You can subscribe to topics like
wave2mqtt/+/+/Payload
and that will subscribe to all topics where + is anything. Or you can subscribe to
wave2mqtt/#
and that will subscribe to anything starting with wave2mqtt/

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