Problems with heater relay control

Hey guys! New to node-red and im trying a new project using heater-control plugin.

I am trying to trigger my relay using the output topic currentHeaterStatus to a RPI GPIO pin with relay attached. My flow is attached below.

I am using a change node attached to the heater controller then outputting to the GPIO out.

I am trying to change "currentHeaterStatus=on" and "currentHeaterStatus=off" to control my relay. So I am trying to convert the "on" and "off" stings to boolean as true and false.

Running the change node.

Change >> msg.payload
search for >> String >> on
Replace with >> boolean >> true

Change >> msg.payload
search for >> String >> off
Replace with >> boolean >> false

It just throws the error

"Invalid input: NaN"

Please help ive been stuck on this for ages now.

Sorry if the formatting of this post is terrible.

[
    {
        "id": "af1d07e7.0b2b08",
        "type": "inject",
        "z": "835f825e.a9494",
        "name": "setCalendar",
        "topic": "setCalendar",
        "payload": "{\"Monday\":{\"00:00\":29,\"06:20\":22,\"08:00\":19,\"16:40\":22,\"23:59\":19},\"Tuesday\":{\"00:00\":19,\"06:20\":22,\"08:00\":19,\"16:40\":22,\"23:59\":19},\"Wednesday\":{\"00:00\":19,\"06:20\":22,\"08:00\":19,\"16:40\":10,\"23:59\":10},\"Thursday\":{\"00:00\":10,\"06:20\":10,\"08:00\":10,\"16:40\":10,\"23:59\":10},\"Friday\":{\"00:00\":19,\"06:20\":23,\"08:00\":19,\"16:40\":22,\"23:59\":19},\"Saturday\":{\"00:00\":19,\"08:00\":20,\"20:00\":22,\"23:59\":19},\"Sunday\":{\"00:00\":19,\"08:00\":20,\"20:00\":22,\"23:59\":19}}",
        "payloadType": "json",
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "x": 170,
        "y": 120,
        "wires": [
            [
                "204ec1e1.14220e"
            ]
        ]
    },
    {
        "id": "35589963.62dd86",
        "type": "debug",
        "z": "835f825e.a9494",
        "name": "",
        "active": false,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "targetType": "msg",
        "x": 590,
        "y": 160,
        "wires": []
    },
    {
        "id": "37bf3654.a50fca",
        "type": "inject",
        "z": "835f825e.a9494",
        "name": "",
        "topic": "userTargetValue",
        "payload": "29",
        "payloadType": "num",
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "x": 190,
        "y": 160,
        "wires": [
            [
                "204ec1e1.14220e"
            ]
        ]
    },
    {
        "id": "e7eba7ca.302758",
        "type": "inject",
        "z": "835f825e.a9494",
        "name": "isUserCustomLocked",
        "topic": "isUserCustomLocked",
        "payload": "true",
        "payloadType": "bool",
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "x": 200,
        "y": 200,
        "wires": [
            [
                "204ec1e1.14220e"
            ]
        ]
    },
    {
        "id": "204ec1e1.14220e",
        "type": "ui_heater_controller",
        "z": "835f825e.a9494",
        "name": "heater",
        "group": "117f6665.c06b9a",
        "unit": "C",
        "order": 0,
        "width": "6",
        "height": "4",
        "topic": "",
        "title": "",
        "logLengthType": "days",
        "logLength": "1",
        "sliderMinValue": 20,
        "sliderMaxValue": 50,
        "sliderStep": 0.5,
        "thresholdRising": 0.5,
        "thresholdFalling": 0.5,
        "calendar": "{\n    \"Monday\": {\n        \"00:00\": 15,\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": 420,
        "y": 160,
        "wires": [
            [
                "35589963.62dd86",
                "76e0703f.a1a9d"
            ]
        ]
    },
    {
        "id": "c1d4d00d.21d72",
        "type": "inject",
        "z": "835f825e.a9494",
        "name": "userConfig",
        "topic": "userConfig",
        "payload": "{\"isUserCustomLocked\":true,\"userTargetValue\":25.5}",
        "payloadType": "json",
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "x": 160,
        "y": 240,
        "wires": [
            [
                "204ec1e1.14220e"
            ]
        ]
    },
    {
        "id": "90c592e3.2f225",
        "type": "inject",
        "z": "835f825e.a9494",
        "name": "isUserCustom",
        "topic": "userConfig",
        "payload": "{\"isUserCustomLocked\":true,\"isUserCustom\": false, \"userTargetValue\": 23.5}",
        "payloadType": "json",
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "x": 170,
        "y": 280,
        "wires": [
            [
                "204ec1e1.14220e"
            ]
        ]
    },
    {
        "id": "c6f7e4d4.29f868",
        "type": "sensor-ds18b20",
        "z": "835f825e.a9494",
        "name": "currentTemp",
        "topic": "",
        "sensorid": "28-00000a69b724",
        "timer": "1",
        "repeat": true,
        "x": 150,
        "y": 80,
        "wires": [
            [
                "204ec1e1.14220e"
            ]
        ]
    },
    {
        "id": "6f5b9ef1.47e9",
        "type": "ui_switch",
        "z": "835f825e.a9494",
        "name": "Relay 2",
        "label": "Pump",
        "tooltip": "",
        "group": "1bda0b71.65e485",
        "order": 2,
        "width": 0,
        "height": 0,
        "passthru": true,
        "decouple": "false",
        "topic": "",
        "style": "",
        "onvalue": "false",
        "onvalueType": "bool",
        "onicon": "",
        "oncolor": "",
        "offvalue": "true",
        "offvalueType": "bool",
        "officon": "",
        "offcolor": "",
        "x": 140,
        "y": 420,
        "wires": [
            [
                "bde9d6e2.596918"
            ]
        ]
    },
    {
        "id": "90482267.06b3c",
        "type": "ui_switch",
        "z": "835f825e.a9494",
        "name": "Relay 3",
        "label": "Relay 3",
        "tooltip": "",
        "group": "1bda0b71.65e485",
        "order": 3,
        "width": 0,
        "height": 0,
        "passthru": true,
        "decouple": "false",
        "topic": "",
        "style": "",
        "onvalue": "false",
        "onvalueType": "bool",
        "onicon": "",
        "oncolor": "",
        "offvalue": "true",
        "offvalueType": "bool",
        "officon": "",
        "offcolor": "",
        "x": 140,
        "y": 460,
        "wires": [
            [
                "9b536e5f.0bb6a"
            ]
        ]
    },
    {
        "id": "4c261a3d.539df4",
        "type": "ui_switch",
        "z": "835f825e.a9494",
        "name": "Relay 4",
        "label": "Relay 4",
        "tooltip": "",
        "group": "1bda0b71.65e485",
        "order": 4,
        "width": 0,
        "height": 0,
        "passthru": true,
        "decouple": "false",
        "topic": "",
        "style": "",
        "onvalue": "false",
        "onvalueType": "bool",
        "onicon": "",
        "oncolor": "",
        "offvalue": "true",
        "offvalueType": "bool",
        "officon": "",
        "offcolor": "",
        "x": 140,
        "y": 500,
        "wires": [
            [
                "fc9b5bb4.474588"
            ]
        ]
    },
    {
        "id": "79edd54b.8d188c",
        "type": "ui_switch",
        "z": "835f825e.a9494",
        "name": "Relay 5",
        "label": "Relay 5",
        "tooltip": "",
        "group": "1bda0b71.65e485",
        "order": 5,
        "width": 0,
        "height": 0,
        "passthru": true,
        "decouple": "false",
        "topic": "",
        "style": "",
        "onvalue": "false",
        "onvalueType": "bool",
        "onicon": "",
        "oncolor": "",
        "offvalue": "true",
        "offvalueType": "bool",
        "officon": "",
        "offcolor": "",
        "x": 140,
        "y": 540,
        "wires": [
            [
                "4045d44f.db5f1c"
            ]
        ]
    },
    {
        "id": "bbbc2d1d.3434f",
        "type": "ui_switch",
        "z": "835f825e.a9494",
        "name": "Relay 6",
        "label": "Relay 6",
        "tooltip": "",
        "group": "1bda0b71.65e485",
        "order": 6,
        "width": 0,
        "height": 0,
        "passthru": true,
        "decouple": "false",
        "topic": "",
        "style": "",
        "onvalue": "false",
        "onvalueType": "bool",
        "onicon": "",
        "oncolor": "",
        "offvalue": "true",
        "offvalueType": "bool",
        "officon": "",
        "offcolor": "",
        "x": 140,
        "y": 580,
        "wires": [
            [
                "b8d5e808.5d9d28"
            ]
        ]
    },
    {
        "id": "bde9d6e2.596918",
        "type": "rpi-gpio out",
        "z": "835f825e.a9494",
        "name": "Relay 2",
        "pin": "5",
        "set": "",
        "level": "0",
        "freq": "",
        "out": "out",
        "x": 420,
        "y": 420,
        "wires": []
    },
    {
        "id": "9b536e5f.0bb6a",
        "type": "rpi-gpio out",
        "z": "835f825e.a9494",
        "name": "Relay 3",
        "pin": "19",
        "set": "",
        "level": "0",
        "freq": "",
        "out": "out",
        "x": 420,
        "y": 460,
        "wires": []
    },
    {
        "id": "fc9b5bb4.474588",
        "type": "rpi-gpio out",
        "z": "835f825e.a9494",
        "name": "Relay 4",
        "pin": "29",
        "set": "",
        "level": "0",
        "freq": "",
        "out": "out",
        "x": 420,
        "y": 500,
        "wires": []
    },
    {
        "id": "4045d44f.db5f1c",
        "type": "rpi-gpio out",
        "z": "835f825e.a9494",
        "name": "Relay 5",
        "pin": "31",
        "set": "",
        "level": "0",
        "freq": "",
        "out": "out",
        "x": 420,
        "y": 540,
        "wires": []
    },
    {
        "id": "b8d5e808.5d9d28",
        "type": "rpi-gpio out",
        "z": "835f825e.a9494",
        "name": "Relay 6",
        "pin": "26",
        "set": "",
        "level": "0",
        "freq": "",
        "out": "out",
        "x": 420,
        "y": 580,
        "wires": []
    },
    {
        "id": "9f85dc8f.ba634",
        "type": "ui_switch",
        "z": "835f825e.a9494",
        "name": "Relay 7",
        "label": "Relay 7",
        "tooltip": "",
        "group": "1bda0b71.65e485",
        "order": 7,
        "width": 0,
        "height": 0,
        "passthru": true,
        "decouple": "false",
        "topic": "",
        "style": "",
        "onvalue": "false",
        "onvalueType": "bool",
        "onicon": "",
        "oncolor": "",
        "offvalue": "true",
        "offvalueType": "bool",
        "officon": "",
        "offcolor": "",
        "x": 140,
        "y": 620,
        "wires": [
            [
                "c69e3e57.bf419"
            ]
        ]
    },
    {
        "id": "736323ff.b9159c",
        "type": "ui_switch",
        "z": "835f825e.a9494",
        "name": "Relay 8",
        "label": "Relay 8",
        "tooltip": "",
        "group": "1bda0b71.65e485",
        "order": 8,
        "width": 0,
        "height": 0,
        "passthru": true,
        "decouple": "false",
        "topic": "",
        "style": "",
        "onvalue": "false",
        "onvalueType": "bool",
        "onicon": "",
        "oncolor": "",
        "offvalue": "true",
        "offvalueType": "bool",
        "officon": "",
        "offcolor": "",
        "x": 140,
        "y": 660,
        "wires": [
            [
                "bc3f6929.fd2628"
            ]
        ]
    },
    {
        "id": "c69e3e57.bf419",
        "type": "rpi-gpio out",
        "z": "835f825e.a9494",
        "name": "Relay 7",
        "pin": "24",
        "set": "",
        "level": "0",
        "freq": "",
        "out": "out",
        "x": 420,
        "y": 620,
        "wires": []
    },
    {
        "id": "bc3f6929.fd2628",
        "type": "rpi-gpio out",
        "z": "835f825e.a9494",
        "name": "Relay 8",
        "pin": "21",
        "set": "",
        "level": "0",
        "freq": "",
        "out": "out",
        "x": 420,
        "y": 660,
        "wires": []
    },
    {
        "id": "ff21b329.cb89f",
        "type": "debug",
        "z": "835f825e.a9494",
        "name": "",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "targetType": "msg",
        "x": 870,
        "y": 300,
        "wires": []
    },
    {
        "id": "76e0703f.a1a9d",
        "type": "change",
        "z": "835f825e.a9494",
        "name": "currentHeaterStatus",
        "rules": [
            {
                "t": "change",
                "p": "payload.currentHeaterStatus",
                "pt": "msg",
                "from": "off",
                "fromt": "str",
                "to": "false",
                "tot": "bool"
            },
            {
                "t": "change",
                "p": "payload.currentHeaterStatus",
                "pt": "msg",
                "from": "on",
                "fromt": "str",
                "to": "true",
                "tot": "bool"
            },
            {
                "t": "delete",
                "p": "payload.currentTemp",
                "pt": "msg"
            },
            {
                "t": "delete",
                "p": "payload.targetValue",
                "pt": "msg"
            },
            {
                "t": "delete",
                "p": "payload.isUserCustom",
                "pt": "msg"
            },
            {
                "t": "delete",
                "p": "payload.userTargetValue",
                "pt": "msg"
            },
            {
                "t": "delete",
                "p": "payload.currentSchedule",
                "pt": "msg"
            },
            {
                "t": "delete",
                "p": "payload.nextSchedule",
                "pt": "msg"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 580,
        "y": 260,
        "wires": [
            [
                "2078d092.5e112"
            ]
        ]
    },
    {
        "id": "2078d092.5e112",
        "type": "rpi-gpio out",
        "z": "835f825e.a9494",
        "name": "heaterControl",
        "pin": "3",
        "set": "",
        "level": "0",
        "freq": "",
        "out": "out",
        "x": 880,
        "y": 260,
        "wires": []
    },
    {
        "id": "117f6665.c06b9a",
        "type": "ui_group",
        "z": "",
        "name": "Heater Control",
        "tab": "4d3f6bbe.f24db4",
        "order": 1,
        "disp": true,
        "width": "8",
        "collapse": false
    },
    {
        "id": "1bda0b71.65e485",
        "type": "ui_group",
        "z": "",
        "name": "Function",
        "tab": "4d3f6bbe.f24db4",
        "disp": true,
        "width": "6",
        "collapse": false
    },
    {
        "id": "4d3f6bbe.f24db4",
        "type": "ui_tab",
        "z": "",
        "name": "Control",
        "icon": "dashboard",
        "order": 3,
        "disabled": false,
        "hidden": false
    }
]

Sometimes you can't get away with just a change node - you need a switch and a couple of change nodes like this

[{"id":"c05b93db.2c516","type":"switch","z":"b84a122c.f0c8e","name":"","property":"payload.currentHeaterStatus","propertyType":"msg","rules":[{"t":"cont","v":"on","vt":"str"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":460,"y":160,"wires":[["1b6f73ff.f945cc"],["34fb9ed7.e29f22"]]},{"id":"1b6f73ff.f945cc","type":"change","z":"b84a122c.f0c8e","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"true","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":640,"y":140,"wires":[[]]},{"id":"34fb9ed7.e29f22","type":"change","z":"b84a122c.f0c8e","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"false","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":640,"y":180,"wires":[[]]}]

Thanks you are a legend. I will go through the setup of this now this is all working!

Cheers

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