# Start/ Stop thermostat

**URL:** <https://discourse.nodered.org/t/start-stop-thermostat/60905>\
**Category:** General\
**Created:** [6 April 2022 22:38 UTC](https://discourse.nodered.org/t/start-stop-thermostat/60905 "2022-04-06T22:38:27Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![darrenra10](https://avatars.discourse-cdn.com/v4/letter/d/f14d63/32.png) [@darrenra10](https://discourse.nodered.org/u/darrenra10)\
**Post date:** [6 April 2022 22:38 UTC](https://discourse.nodered.org/t/start-stop-thermostat/60905/1 "2022-04-06T22:38:27Z")

</div>

I'm using the node-red-contrib-basic-thermostat node to control a relay output on my raspberry pi. With this setup the node starts looking at the input temps and gives an output as soon as node-red is started on my pi. Is it possible to implement a start and stop button on the dashboard so the thermostat only starts when the start button is pressed and can be stopped anytime. I'm fairly new to node-red and would appreciate some assistance.

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [6 April 2022 22:58 UTC](https://discourse.nodered.org/t/start-stop-thermostat/60905/2 "2022-04-06T22:58:26Z")

</div>

Hi darrenra10 and welcome to the forum.

Yes, you could do what you want, but there are problems depending on which way you do it.

To _over-ride_ the node you will have to change the flow you have.

The first thing you should do is work out how you are going to over-ride the output of the node.  
Because depending on that there are a lot of ways to get what you want done.

But a question that is sticking out for me is:  
If you have the flow set up to turn things on/off depending on the temperature, and: every time you turn on the computer and run node-red _it_ is turned on, is the temperatures you have set _wrong_?

If it is turning on the heater because _it_ thinks it is too cold..... and you don't want the heater on, there seems to be an underlying problem there.

I have a flow on another machine that controls a fan that is used to cool the RasPi.  
There are a few _modes_. it can be in Automatic or Manual mode.  
But if it is in Manual mode and things get too hot, there are provisions that the fan is turned on anyway.  
And if it keeps getting too hot: the machine can be shut down.

But that may be beyond your needs.

I'd maybe suggest leaving that flow as is, and writing another one which can turn the thing on/off manually.

Get that working so you have two flows working.

This may help you see _problems_ with having them - not saying there is a magic answer with no _problems_.  
It is just dependant on how they interact with one another.

---

<div class="post-metadata">

**Author:** ![darrenra10](https://avatars.discourse-cdn.com/v4/letter/d/f14d63/32.png) [@darrenra10](https://discourse.nodered.org/u/darrenra10)\
**Post date:** [6 April 2022 23:05 UTC](https://discourse.nodered.org/t/start-stop-thermostat/60905/3 "2022-04-06T23:05:11Z")

</div>

Thanks for the reply. I'm trying to control an egg incubator and I don't want the heater turning on as soon as I boot the pi and node red, I'd like to have the start button there to start the heating when ready. Currently I don't have any modes for its operation.

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [6 April 2022 23:10 UTC](https://discourse.nodered.org/t/start-stop-thermostat/60905/4 "2022-04-06T23:10:50Z")

</div>

So how is the incubator controlled when the computer is turned off?

There must be something else running all the time to turn it on and off as needed.

---

<div class="post-metadata">

**Author:** ![darrenra10](https://avatars.discourse-cdn.com/v4/letter/d/f14d63/32.png) [@darrenra10](https://discourse.nodered.org/u/darrenra10)\
**Post date:** [6 April 2022 23:20 UTC](https://discourse.nodered.org/t/start-stop-thermostat/60905/5 "2022-04-06T23:20:38Z")

</div>

Well I'm using the pi along with node-red to control the incubator I have 2 temp sensors whose average goes to the thermostat node which turns the heater on/off. If the pi is off the incubator is off.

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [7 April 2022 00:07 UTC](https://discourse.nodered.org/t/start-stop-thermostat/60905/6 "2022-04-07T00:07:49Z")

</div>

Oh...

Ok.

So if the thermostat is set to turn on at a _low_ temperature and turn off when it is warm enough...  
I'm confused why you are worried that when you turn on the Pi and run node-red the relay turns on. I would have thought that is/was because it (the temperature) it too low.

Anyway...

So now you need to make a second flow to do just that but with two buttons. One to turn it on and one to turn it off.

Don't connect it to the actual GPIO node yet. Just stick a `debug` node there to make sure it is working.

The rest will come after you have done that.

But you still need to consider HOW the over-ride is going to happen.  
Will it be possible to turn the relay on if it really gets too cold, and likewise turn it off if things get too hot.

---

<div class="post-metadata">

**Author:** ![darrenra10](https://avatars.discourse-cdn.com/v4/letter/d/f14d63/32.png) [@darrenra10](https://discourse.nodered.org/u/darrenra10)\
**Post date:** [7 April 2022 00:23 UTC](https://discourse.nodered.org/t/start-stop-thermostat/60905/7 "2022-04-07T00:23:18Z")

</div>

The thing is I have no idea how to build this flow. I tried using the interrupt flow node but when I interrupt the flow the thermostat keeps its last recorded temp and remains in whatever state it was in.

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [7 April 2022 00:25 UTC](https://discourse.nodered.org/t/start-stop-thermostat/60905/8 "2022-04-07T00:25:43Z")

</div>

How did you get the first flow with the thermostat working?

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [7 April 2022 00:34 UTC](https://discourse.nodered.org/t/start-stop-thermostat/60905/9 "2022-04-07T00:34:46Z")

</div>

Leave the existing flow as is.

Don't touch it.

You need to make a new flow. It may be an idea to make it on a new tab to help with the demarcation between then. Though a bit extreme it may help.

You will need (to start with) two `inject` nodes - to get the idea across - and a `debug` node.

Oh, but before you can do all this it may be a good idea to put a `debug` node in parallel with the `GPIO` node to determine what _message_ is being sent to turn the relay on/off.

---

<div class="post-metadata">

**Author:** ![darrenra10](https://avatars.discourse-cdn.com/v4/letter/d/f14d63/32.png) [@darrenra10](https://discourse.nodered.org/u/darrenra10)\
**Post date:** [7 April 2022 01:46 UTC](https://discourse.nodered.org/t/start-stop-thermostat/60905/10 "2022-04-07T01:46:37Z")

</div>

![Screenshot 2022-04-06 214512](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/b/5/b5aa626bbd9ab8e7ea310f7edffc8d9586d5ae30.png)  
This is the basic setup

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [7 April 2022 01:48 UTC](https://discourse.nodered.org/t/start-stop-thermostat/60905/11 "2022-04-07T01:48:09Z")

</div>

Ok...

Stick a `debug` node out of the `invert` node and find out what is coming out of there to signal the heater to be `on` and `off`.

We'll work from there.

It may take some time to get both signals.

---

<div class="post-metadata">

**Author:** ![darrenra10](https://avatars.discourse-cdn.com/v4/letter/d/f14d63/32.png) [@darrenra10](https://discourse.nodered.org/u/darrenra10)\
**Post date:** [7 April 2022 01:54 UTC](https://discourse.nodered.org/t/start-stop-thermostat/60905/12 "2022-04-07T01:54:51Z")

</div>

![Screenshot 2022-04-06 215405](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/2/3/230d72b412b6ba1e9e6ace46ad3d94ef1e0141b5.png)

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [7 April 2022 01:56 UTC](https://discourse.nodered.org/t/start-stop-thermostat/60905/13 "2022-04-07T01:56:59Z")

</div>

Ok, so now all you need to do (FOR TESTING PURPOSES ONLY) is get TWO `inject` nodes.  
One of them set to send `true` (select from the drop down in the node's edit window)  
and one to send `false`.

Connect them to the `Heater` node - remove the wire from the `invert` node when doing this.  
Press one, see if the relay turns on.  
Press the other one and see it turn off.

When you have that working we can move to the next step.

(All of that given you `DEPLOY` once all it is done before pressing the `inject` nodes to test.`)

---

<div class="post-metadata">

**Author:** ![darrenra10](https://avatars.discourse-cdn.com/v4/letter/d/f14d63/32.png) [@darrenra10](https://discourse.nodered.org/u/darrenra10)\
**Post date:** [7 April 2022 02:04 UTC](https://discourse.nodered.org/t/start-stop-thermostat/60905/14 "2022-04-07T02:04:32Z")

</div>

![Screenshot 2022-04-06 220311](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/a/9/a96b00b5bb8a81decb55c468d552690e6356ded1.png)  
When I inject false the relay turns on when true the relay goes off

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [7 April 2022 02:05 UTC](https://discourse.nodered.org/t/start-stop-thermostat/60905/15 "2022-04-07T02:05:32Z")

</div>

Yup. That should work - but also given that the connection from the other `inverter` node is not there.

One should turn the relay `on` and the other should turn it `off`.

---

<div class="post-metadata">

**Author:** ![darrenra10](https://avatars.discourse-cdn.com/v4/letter/d/f14d63/32.png) [@darrenra10](https://discourse.nodered.org/u/darrenra10)\
**Post date:** [7 April 2022 02:11 UTC](https://discourse.nodered.org/t/start-stop-thermostat/60905/16 "2022-04-07T02:11:26Z")

</div>

Okay I don't think I understand your approach. What I need is to keep the flow but implement something that would only allow the thermostat and heater to function after I push a start button.

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [7 April 2022 02:12 UTC](https://discourse.nodered.org/t/start-stop-thermostat/60905/17 "2022-04-07T02:12:47Z")

</div>

So you want an over-riding "GO/NO GO" for things....

And this will determine if the existing flow turns the relay on or off as needed.

---

<div class="post-metadata">

**Author:** ![darrenra10](https://avatars.discourse-cdn.com/v4/letter/d/f14d63/32.png) [@darrenra10](https://discourse.nodered.org/u/darrenra10)\
**Post date:** [7 April 2022 02:16 UTC](https://discourse.nodered.org/t/start-stop-thermostat/60905/18 "2022-04-07T02:16:04Z")

</div>

Yes that's exactly it, sorry for my poor explanations.

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [7 April 2022 02:19 UTC](https://discourse.nodered.org/t/start-stop-thermostat/60905/19 "2022-04-07T02:19:35Z")

</div>

That's ok.

Here are two ways of doing it.

I hope you know how to import stuff.

There is a foreign node here.

`node-red-contrib-simple-gate`

See if you can understand what they are doing.

One is an easy way to see how things are working.  
The other (second) needs a bit more understanding of how Node-red works.  
Not rocket science, but also not intuitive if you are new.

```auto
[{"id":"b444a0fc38e450fe","type":"inject","z":"7e987ddf260bdf0d","name":"Stop","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"control","payload":"stop","payloadType":"str","x":260,"y":3450,"wires":[["46e0098845a5e7ec"]]},{"id":"4f64ae6f5335f34a","type":"inject","z":"7e987ddf260bdf0d","name":"Go","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"control","payload":"go","payloadType":"str","x":260,"y":3490,"wires":[["46e0098845a5e7ec"]]},{"id":"eda8ff856eaa0a27","type":"debug","z":"7e987ddf260bdf0d","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":580,"y":3550,"wires":[]},{"id":"2c1ace6b519af552","type":"inject","z":"7e987ddf260bdf0d","name":"existing stuff","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payloadType":"date","x":270,"y":3550,"wires":[["46e0098845a5e7ec"]]},{"id":"46e0098845a5e7ec","type":"gate","z":"7e987ddf260bdf0d","name":"","controlTopic":"control","defaultState":"open","openCmd":"go","closeCmd":"stop","toggleCmd":"toggle","defaultCmd":"default","persist":false,"x":420,"y":3550,"wires":[["eda8ff856eaa0a27"]]},{"id":"4cd39153ce4d99c7","type":"inject","z":"7e987ddf260bdf0d","name":"Stop","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"stop","payloadType":"str","x":250,"y":3600,"wires":[["7a30fcaa82d1f41e"]]},{"id":"757a190398377eaa","type":"inject","z":"7e987ddf260bdf0d","name":"Go","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"go","payloadType":"str","x":250,"y":3640,"wires":[["7a30fcaa82d1f41e"]]},{"id":"d24650868b66acef","type":"debug","z":"7e987ddf260bdf0d","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":570,"y":3700,"wires":[]},{"id":"d0c59526418f856f","type":"inject","z":"7e987ddf260bdf0d","name":"existing stuff","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payloadType":"date","x":260,"y":3700,"wires":[["e055f65538399ecb"]]},{"id":"7a30fcaa82d1f41e","type":"change","z":"7e987ddf260bdf0d","name":"Set context","rules":[{"t":"set","p":"state","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":430,"y":3620,"wires":[[]]},{"id":"e055f65538399ecb","type":"switch","z":"7e987ddf260bdf0d","name":"","property":"state","propertyType":"flow","rules":[{"t":"eq","v":"go","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":410,"y":3700,"wires":[["d24650868b66acef"]]}]

```

The `existing stuff` is the `invert` node and the `debug` is the `GPIO` node.  
And ok, this isn't at the GUI stage. We are nearly there.  
One more step.

---

<div class="post-metadata">

**Author:** ![darrenra10](https://avatars.discourse-cdn.com/v4/letter/d/f14d63/32.png) [@darrenra10](https://discourse.nodered.org/u/darrenra10)\
**Post date:** [7 April 2022 02:24 UTC](https://discourse.nodered.org/t/start-stop-thermostat/60905/20 "2022-04-07T02:24:47Z")

</div>

I'll work on these and get back to you.

[Next page](https://discourse.nodered.org/t/start-stop-thermostat/60905.md?page=2)
