Beginner Question - DHT11 triggering Relay

Hello,
Here is a most basic example of a flow that based on the input sends 0 if the input is below 20 and 1 when above. It uses a change node with a simple jsonata conditional for this and an rbe node after that to only send something if it changed from 1 to 0 or otherwise:

[{"id":"d7891e82.9dbe9","type":"inject","z":"6fb808b7.b81b6","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"21","payloadType":"str","x":210,"y":100,"wires":[["930aa71c.bc49b8"]]},{"id":"8e2a9b6f.e3c77","type":"inject","z":"6fb808b7.b81b6","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"18","payloadType":"str","x":210,"y":180,"wires":[["930aa71c.bc49b8"]]},{"id":"75500510.a0269c","type":"debug","z":"6fb808b7.b81b6","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":730,"y":140,"wires":[]},{"id":"930aa71c.bc49b8","type":"change","z":"6fb808b7.b81b6","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"($number(msg.payload) < 20) ? 0 : 1","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":400,"y":140,"wires":[["add1e361.5f294"]]},{"id":"add1e361.5f294","type":"rbe","z":"6fb808b7.b81b6","name":"","func":"rbe","gap":"","start":"","inout":"out","property":"payload","x":570,"y":140,"wires":[["75500510.a0269c"]]}]

The videos don’t handle such concrete examples as they are more about teaching the methods that are used to solve problems with nodered.
@Colin recommended the ramp thermostat node as you can run into problems when switching based on temperature as when the temperature is around the switch point it can bounce below and above it in short succession and lead to unwanted oscillation in the switching. The ramp thermostat prevents this by implementing a hysteresis feature.
Hope this helps,
Johannes

1 Like