Problem with node-red-contrib-heater-controller

Hello. In my project I use a temperature controller https://flows.nodered.org/node/node-red-contrib-heater-controller controller works but ...! I noticed that when you remove the sensor physicaly. controller still works. that is, in the absence of a sensor, it displays the last measured temperature and continues to chase the set temperature. This is not very correct about security, I must emphasize it! I tried to deal with the problem myself, but my knowledge is not that great. I have some achievements but it is not the expected result. I want to send a message inside the function before the controller to stop it. This is a half solution because I send the controller the required temperature of 0 degrees. Please review what I am sending you. Thanks. Greetings. Sorry for bad english.

[{"id":"a5956592.9081b8","type":"tab","label":"Flow 3","disabled":false,"info":""},{"id":"9a784ad1.0f5d28","type":"sensor-ds18b20","z":"a5956592.9081b8","name":"currentTemp","topic":"","sensorid":"10-0008037d9f05","timer":"10","repeat":false,"x":250,"y":40,"wires":[["9d4223c9.0dbf7"]]},{"id":"1e2a54c0.d7197b","type":"ui_heater_controller","z":"a5956592.9081b8","name":"heater","group":"f0b2787.55ae588","unit":"C","order":1,"width":"6","height":"4","topic":"","title":"","sliderMinValue":10,"sliderMaxValue":35,"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":550,"y":140,"wires":[["1f322d40.ee2bf3"]]},{"id":"9d4223c9.0dbf7","type":"change","z":"a5956592.9081b8","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload.temperature","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":440,"y":40,"wires":[["1e2a54c0.d7197b","3d51c838.cd3138"]]},{"id":"1f322d40.ee2bf3","type":"debug","z":"a5956592.9081b8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":710,"y":140,"wires":[]},{"id":"eba7d818.df8288","type":"inject","z":"a5956592.9081b8","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":140,"y":120,"wires":[["9a784ad1.0f5d28"]]},{"id":"3d51c838.cd3138","type":"debug","z":"a5956592.9081b8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":630,"y":40,"wires":[]},{"id":"505c3c82.30d184","type":"inject","z":"a5956592.9081b8","name":"","topic":"currentTemp","payload":"false","payloadType":"bool","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":210,"y":360,"wires":[["7e01ff6.b9fe4"]]},{"id":"1b0ff112.61f38f","type":"inject","z":"a5956592.9081b8","name":"","topic":"userTargetValue","payload":"0","payloadType":"num","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":210,"y":300,"wires":[["2d985f8e.4da7a"]]},{"id":"2d985f8e.4da7a","type":"debug","z":"a5956592.9081b8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":430,"y":260,"wires":[]},{"id":"44ad131d.a7f17c","type":"debug","z":"a5956592.9081b8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":590,"y":360,"wires":[]},{"id":"d412a09c.acf4","type":"inject","z":"a5956592.9081b8","name":"","topic":"userTargetValue","payload":"0","payloadType":"num","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":330,"y":180,"wires":[["1e2a54c0.d7197b"]]},{"id":"7e01ff6.b9fe4","type":"function","z":"a5956592.9081b8","name":"","func":"if (msg.payload === false){\nmsg.payload = (\"userTargetValue\"=0);\nreturn msg;\n} else {\nmsg.payload = \"off\";\nreturn msg;\n}\n\n ","outputs":1,"noerr":7,"x":430,"y":360,"wires":[["44ad131d.a7f17c"]]},{"id":"47d620c8.95907","type":"inject","z":"a5956592.9081b8","name":"","topic":"currentTemp","payload":"23","payloadType":"num","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":200,"y":400,"wires":[["7e01ff6.b9fe4"]]},{"id":"b0eeec20.32012","type":"inject","z":"a5956592.9081b8","name":"","topic":"currentTemp","payload":"23","payloadType":"num","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":200,"y":260,"wires":[["2d985f8e.4da7a"]]},{"id":"f0b2787.55ae588","type":"ui_group","z":"","name":"Pool","tab":"940b8076.c9a17","order":1,"disp":true,"width":"6","collapse":false},{"id":"940b8076.c9a17","type":"ui_tab","z":"","name":"Nest Thermostat sample","icon":"dashboard","order":1}]

Put a debug nod on the output of the ds18b20 sensor node and see what it reads when you remove the sensor.

Yes, I did it. When there is a sensor displayed in the message indicates the temperature when the sensor removed at the temperature point is displayed boolean false. i want to use this boolean to set target temperature to zero.


The picture shows messages with and without sensor, I send edited flow for clarity. I add function node before heater. See contents of function.

[{"id":"a5956592.9081b8","type":"tab","label":"Flow 3","disabled":false,"info":""},{"id":"9a784ad1.0f5d28","type":"sensor-ds18b20","z":"a5956592.9081b8","name":"currentTemp","topic":"","sensorid":"10-0008037d9f05","timer":"10","repeat":false,"x":330,"y":60,"wires":[["9d4223c9.0dbf7"]]},{"id":"1e2a54c0.d7197b","type":"ui_heater_controller","z":"a5956592.9081b8","name":"heater","group":"f0b2787.55ae588","unit":"C","order":1,"width":"6","height":"4","topic":"","title":"","sliderMinValue":10,"sliderMaxValue":35,"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":550,"y":180,"wires":[["1f322d40.ee2bf3"]]},{"id":"9d4223c9.0dbf7","type":"change","z":"a5956592.9081b8","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload.temperature","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":520,"y":60,"wires":[["3d51c838.cd3138","b209bbdd.f82518"]]},{"id":"1f322d40.ee2bf3","type":"debug","z":"a5956592.9081b8","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":710,"y":180,"wires":[]},{"id":"eba7d818.df8288","type":"inject","z":"a5956592.9081b8","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":180,"y":60,"wires":[["9a784ad1.0f5d28"]]},{"id":"3d51c838.cd3138","type":"debug","z":"a5956592.9081b8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":730,"y":60,"wires":[]},{"id":"505c3c82.30d184","type":"inject","z":"a5956592.9081b8","name":"","topic":"currentTemp","payload":"false","payloadType":"bool","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":250,"y":500,"wires":[["7e01ff6.b9fe4"]]},{"id":"1b0ff112.61f38f","type":"inject","z":"a5956592.9081b8","name":"","topic":"userTargetValue","payload":"0","payloadType":"num","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":250,"y":360,"wires":[["2d985f8e.4da7a"]]},{"id":"2d985f8e.4da7a","type":"debug","z":"a5956592.9081b8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":470,"y":320,"wires":[]},{"id":"44ad131d.a7f17c","type":"debug","z":"a5956592.9081b8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":630,"y":460,"wires":[]},{"id":"7e01ff6.b9fe4","type":"function","z":"a5956592.9081b8","name":"","func":"if (msg.payload === false){\nmsg.payload = (\"userTargetValue\"=0);\nreturn msg;\n} else {\n\nreturn msg;\n}\n\n ","outputs":1,"noerr":7,"x":470,"y":460,"wires":[["44ad131d.a7f17c"]]},{"id":"47d620c8.95907","type":"inject","z":"a5956592.9081b8","name":"","topic":"currentTemp","payload":"23","payloadType":"num","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":240,"y":460,"wires":[["7e01ff6.b9fe4"]]},{"id":"b0eeec20.32012","type":"inject","z":"a5956592.9081b8","name":"","topic":"currentTemp","payload":"23","payloadType":"num","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":240,"y":320,"wires":[["2d985f8e.4da7a"]]},{"id":"f86094b6.e55988","type":"comment","z":"a5956592.9081b8","name":"Example","info":"","x":240,"y":280,"wires":[]},{"id":"79a6704e.91b81","type":"comment","z":"a5956592.9081b8","name":"Example","info":"","x":240,"y":420,"wires":[]},{"id":"b209bbdd.f82518","type":"function","z":"a5956592.9081b8","name":"","func":"if (msg.payload === false){\nmsg.payload = (\"userTargetValue\"=0);\nreturn msg;\n} else {\nreturn msg;\n}\n\n ","outputs":1,"noerr":7,"x":530,"y":120,"wires":[["1e2a54c0.d7197b"]]},{"id":"d412a09c.acf4","type":"inject","z":"a5956592.9081b8","name":"","topic":"userTargetValue","payload":"0","payloadType":"num","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":350,"y":180,"wires":[["1e2a54c0.d7197b"]]},{"id":"f0b2787.55ae588","type":"ui_group","z":"","name":"Pool","tab":"940b8076.c9a17","order":1,"disp":true,"width":"6","collapse":false},{"id":"940b8076.c9a17","type":"ui_tab","z":"","name":"Nest Thermostat sample","icon":"dashboard","order":1}]

As I understand your issue, you want to set the temperature to 0 when the reading changes to false.

If this is the correct understanding, you can (very simply and easily) use a Change node and just set it to change the sensor output msg from boolean false to numeric 0, and you should be good to go.

Is this the right understanding?

I tried, but it doesn't work. A whole message must be injected at the inlet of the heater
{
"topic": "userTargetValue",
payload: 0
}
this must be done by function. My condition is clear spelling is not good for me. I don't know where to put brackets or dots and commas, but I will gradually learn. the examples in flow show that it works, look at the function.

maybe with change node will happen but I was unable to send the message correctly.
I add change rule to change node and I succeeded replace boolean false with text or number but no whole message, otherwise, it looks like the most elegant solution.

[{"id":"918cc061.1517c","type":"tab","label":"Flow 2","disabled":false,"info":""},{"id":"e300da27.daefc8","type":"sensor-ds18b20","z":"918cc061.1517c","name":"currentTemp","topic":"","sensorid":"10-0008037d9f05","timer":"10","repeat":false,"x":290,"y":120,"wires":[["8b6512b.b67d9f"]]},{"id":"7ee95c19.4c14e4","type":"ui_heater_controller","z":"918cc061.1517c","name":"heater","group":"5d123304.f3ec4c","unit":"C","order":1,"width":"6","height":"4","topic":"","title":"","sliderMinValue":10,"sliderMaxValue":35,"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":510,"y":240,"wires":[["fcb49d15.daa17"]]},{"id":"8b6512b.b67d9f","type":"change","z":"918cc061.1517c","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload.temperature","tot":"msg"},{"t":"change","p":"payload","pt":"msg","from":"false","fromt":"bool","to":"{\"topic\":\"userTargetValue\",\"payload\":0}","tot":"json"}],"action":"","property":"","from":"","to":"","reg":false,"x":480,"y":120,"wires":[["5019e9a2.992da8","7ee95c19.4c14e4"]]},{"id":"fcb49d15.daa17","type":"debug","z":"918cc061.1517c","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":670,"y":240,"wires":[]},{"id":"7c599711.39e888","type":"inject","z":"918cc061.1517c","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":140,"y":120,"wires":[["e300da27.daefc8"]]},{"id":"5019e9a2.992da8","type":"debug","z":"918cc061.1517c","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":690,"y":120,"wires":[]},{"id":"5d123304.f3ec4c","type":"ui_group","z":"","name":"Default","tab":"940b8076.c9a17","disp":true,"width":"6","collapse":false},{"id":"940b8076.c9a17","type":"ui_tab","z":"","name":"Nest Thermostat sample","icon":"dashboard","order":1}]

You should go read https://nodered.org/docs/user-guide/messages before you go any further.

once you have read that you might want to add a switch after the DS18B20 node to test if the payload is false or not and continue processing from there.

To create a new message you need to go through function node. I have some progress. I built a message that stops the controller. Now I have to merge change node with function Here it is.

[{"id":"a5956592.9081b8","type":"tab","label":"Flow 3","disabled":false,"info":""},{"id":"9a784ad1.0f5d28","type":"sensor-ds18b20","z":"a5956592.9081b8","name":"currentTemp","topic":"","sensorid":"10-0008037d9f05","timer":"10","repeat":false,"x":330,"y":60,"wires":[["9d4223c9.0dbf7"]]},{"id":"1e2a54c0.d7197b","type":"ui_heater_controller","z":"a5956592.9081b8","name":"heater","group":"f0b2787.55ae588","unit":"C","order":1,"width":"6","height":"4","topic":"","title":"","sliderMinValue":10,"sliderMaxValue":35,"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":550,"y":180,"wires":[["1f322d40.ee2bf3"]]},{"id":"9d4223c9.0dbf7","type":"change","z":"a5956592.9081b8","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload.temperature","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":520,"y":60,"wires":[["3d51c838.cd3138","1e2a54c0.d7197b"]]},{"id":"1f322d40.ee2bf3","type":"debug","z":"a5956592.9081b8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":710,"y":180,"wires":[]},{"id":"eba7d818.df8288","type":"inject","z":"a5956592.9081b8","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":180,"y":60,"wires":[["9a784ad1.0f5d28"]]},{"id":"3d51c838.cd3138","type":"debug","z":"a5956592.9081b8","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":730,"y":60,"wires":[]},{"id":"d08b68bb.f08658","type":"function","z":"a5956592.9081b8","name":"","func":"var msg1 = {topic:\"userTargetValue\", payload:0};\nreturn msg1;\n","outputs":1,"noerr":0,"x":350,"y":180,"wires":[["1e2a54c0.d7197b","e34c9a5.ec8d668"]]},{"id":"73371000.25c22","type":"inject","z":"a5956592.9081b8","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":180,"y":180,"wires":[["d08b68bb.f08658"]]},{"id":"6640e5cd.85bb6c","type":"inject","z":"a5956592.9081b8","name":"","topic":"currentTemp","payload":"false","payloadType":"bool","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":230,"y":240,"wires":[["d08b68bb.f08658"]]},{"id":"c73e59cc.464408","type":"function","z":"a5956592.9081b8","name":"","func":"var msg1 = {topic:\"userTargetValue\", payload:0};\nreturn msg1;\n","outputs":1,"noerr":0,"x":430,"y":380,"wires":[["a2cddab4.18fa68"]]},{"id":"667c7128.4e629","type":"inject","z":"a5956592.9081b8","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":260,"y":380,"wires":[["c73e59cc.464408"]]},{"id":"a1b80c02.53309","type":"inject","z":"a5956592.9081b8","name":"","topic":"","payload":"false","payloadType":"bool","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":270,"y":440,"wires":[["c73e59cc.464408"]]},{"id":"e34c9a5.ec8d668","type":"debug","z":"a5956592.9081b8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":540,"y":260,"wires":[]},{"id":"a2cddab4.18fa68","type":"debug","z":"a5956592.9081b8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":590,"y":380,"wires":[]},{"id":"f0b2787.55ae588","type":"ui_group","z":"","name":"Pool","tab":"940b8076.c9a17","order":1,"disp":true,"width":"6","collapse":false},{"id":"940b8076.c9a17","type":"ui_tab","z":"","name":"Nest Thermostat sample","icon":"dashboard","order":1}]

The msg object is made up of different parts and payload is one part and topic is another. node-red-contrib-heater-controler says to send a msg with

{
    "topic" : "currentTemp",
    "payload" : "22.5"
}

You are setting msg.payload to

{
    "topic":"userTargetValue",
    "payload":0
}

which means your msg object will be

{
    "topic" : "currentTemp",
    "payload" : {
        "topic":"userTargetValue",
        "payload":0
    }
}

Which is not what the node is looking for.

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