# Thermostat and save config after reboot system

**URL:** <https://discourse.nodered.org/t/thermostat-and-save-config-after-reboot-system/14805>\
**Category:** General\
**Created:** [26 August 2019 22:06 UTC](https://discourse.nodered.org/t/thermostat-and-save-config-after-reboot-system/14805 "2019-08-26T22:06:39Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![Notturno](https://avatars.discourse-cdn.com/v4/letter/n/49beb7/32.png) [@Notturno](https://discourse.nodered.org/u/Notturno)\
**Post date:** [26 August 2019 22:06 UTC](https://discourse.nodered.org/t/thermostat-and-save-config-after-reboot-system/14805/1 "2019-08-26T22:06:39Z")

</div>

Hello. Installed Node-Red to work with esp8266 in iot.

I want to adjust the heating control according to the set temperature obtained from 18B20, as well as according to the set days and times.  
Tell me, how can I solve this without writing code?

I also want to know if it is possible to make sure that the chain settings do not go astray after rebooting the computer or node-red? That those sliders, the buttons that I pressed, would return after the reboot, but everything would not go astray!

Thank you in advance, and I apologize for my English.

---

<div class="post-metadata">

**Author:** ![ukmoose](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ukmoose/32/13_2.png) [@ukmoose](https://discourse.nodered.org/u/ukmoose)\
**Post date:** [27 August 2019 07:20 UTC](https://discourse.nodered.org/t/thermostat-and-save-config-after-reboot-system/14805/2 "2019-08-27T07:20:46Z")

</div>

The best way of learning Node-RED is to have a "play".  
There are nodes that can send a message at set times (such as [https://flows.nodered.org/node/node-red-contrib-bigtimer](https://flows.nodered.org/node/node-red-contrib-bigtimer))  
there are nodes that are designed to mimic a thermostat (such as [https://flows.nodered.org/node/node-red-contrib-ramp-thermostat](https://flows.nodered.org/node/node-red-contrib-ramp-thermostat))

I would start by looking at those, the cookbook [http://cookbook.nodered.org](http://cookbook.nodered.org) and flows that you can download from [https://flows.nodered.org/?type=flow&num\_pages=1](https://flows.nodered.org/?type=flow&num_pages=1)

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [27 August 2019 08:51 UTC](https://discourse.nodered.org/t/thermostat-and-save-config-after-reboot-system/14805/3 "2019-08-27T08:51:10Z")

</div>

> [@Notturno](#):
>
> I also want to know if it is possible to make sure that the chain settings do not go astray after rebooting the computer or node-red? That those sliders, the buttons that I pressed, would return after the reboot,

I solve these problems by using retained topics in MQTT to keep the current system state. So when the system is restarted the previous values automatically set switches etc to the required states.

---

<div class="post-metadata">

**Author:** ![Notturno](https://avatars.discourse-cdn.com/v4/letter/n/49beb7/32.png) [@Notturno](https://discourse.nodered.org/u/Notturno)\
**Post date:** [27 August 2019 21:13 UTC](https://discourse.nodered.org/t/thermostat-and-save-config-after-reboot-system/14805/4 "2019-08-27T21:13:30Z")

</div>

Guys, thank you for the answers, I read the Cookbook, thanks for the link.  
I would like to know how to implement such a scheme.  
Turning on the load according to the temperature sensor, the schedule certain days and times, and also that it would be possible to control the switch to turn the load on or off, regardless of the schedule.

---

<div class="post-metadata">

**Author:** ![Notturno](https://avatars.discourse-cdn.com/v4/letter/n/49beb7/32.png) [@Notturno](https://discourse.nodered.org/u/Notturno)\
**Post date:** [27 August 2019 22:14 UTC](https://discourse.nodered.org/t/thermostat-and-save-config-after-reboot-system/14805/5 "2019-08-27T22:14:25Z")

</div>

> [@Colin](#):
>
> I solve these problems by using retained topics in MQTT to keep the current system state. So when the system is restarted the previous values automatically set switches etc to the required states.

I do not quite understand how this can be implemented, do not tell me?

---

<div class="post-metadata">

**Author:** ![ukmoose](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ukmoose/32/13_2.png) [@ukmoose](https://discourse.nodered.org/u/ukmoose)\
**Post date:** [28 August 2019 06:39 UTC](https://discourse.nodered.org/t/thermostat-and-save-config-after-reboot-system/14805/6 "2019-08-28T06:39:35Z")

</div>

What scheme? There are several different suggestions. What have you tried? Where are you stuck?

Yes you could have an over ride switch. But how to do it will depend on what you have done.

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [28 August 2019 09:41 UTC](https://discourse.nodered.org/t/thermostat-and-save-config-after-reboot-system/14805/7 "2019-08-28T09:41:11Z")

</div>

> [@Notturno](#):
>
> I do not quite understand how this can be implemented, do not tell me?

What parts do you not understand and what steps have to taken to research what it means?  
You can find about MQTT at [MQTT Essentials - All Core Concepts Explained](https://www.hivemq.com/mqtt-essentials/)

---

<div class="post-metadata">

**Author:** ![Notturno](https://avatars.discourse-cdn.com/v4/letter/n/49beb7/32.png) [@Notturno](https://discourse.nodered.org/u/Notturno)\
**Post date:** [29 August 2019 21:48 UTC](https://discourse.nodered.org/t/thermostat-and-save-config-after-reboot-system/14805/8 "2019-08-29T21:48:49Z")

</div>

![Screenshot_2](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/4/4ae87ecb11dc1b7758d0f7ebb228d8b62517fc87.png)

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [30 August 2019 07:26 UTC](https://discourse.nodered.org/t/thermostat-and-save-config-after-reboot-system/14805/9 "2019-08-30T07:26:35Z")

</div>

What do you want the switch to do?

---

<div class="post-metadata">

**Author:** ![ukmoose](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ukmoose/32/13_2.png) [@ukmoose](https://discourse.nodered.org/u/ukmoose)\
**Post date:** [30 August 2019 07:34 UTC](https://discourse.nodered.org/t/thermostat-and-save-config-after-reboot-system/14805/10 "2019-08-30T07:34:55Z")

</div>

You could include an switch by having a separate flow. That sets a context value to “on” or “off”

In you existing flow you then include a switch  
that checks on the context value.  
If the context value is “on” the message gets passed. If it’s “off” the message stops.

There’s a page in the docs about working with context values and flows in the cookbook.

For the temperature setting it’s the same way just storing the temp rather than on and off

---

<div class="post-metadata">

**Author:** ![Notturno](https://avatars.discourse-cdn.com/v4/letter/n/49beb7/32.png) [@Notturno](https://discourse.nodered.org/u/Notturno)\
**Post date:** [31 August 2019 09:52 UTC](https://discourse.nodered.org/t/thermostat-and-save-config-after-reboot-system/14805/11 "2019-08-31T09:52:37Z")

</div>

I want to be able to control the thermostat with a switch, that is, I turned on the thermostat with a button in the web interface and it works, it automatically maintains the set temperature, it turns on and off itself when the threshold is reached.  
And also I want to be able to start the thermostat on a schedule.  
If I make a second chain, yes, I can send commands true or false with a button and these commands will come to the pin, but the first chain is not disabled and it will send commands in parallel, and enable or disable accordingly.  
So I’m thinking how to implement the scheme ....

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [31 August 2019 10:30 UTC](https://discourse.nodered.org/t/thermostat-and-save-config-after-reboot-system/14805/12 "2019-08-31T10:30:08Z")

</div>

This one of the ideal uses of MQTT. Feed all of your control mechanisms (switches, schedulers etc) into an MQTT topic. Then drive the pin from MQTT. By funnelling everything through MQTT any of the schemes can control it. Also pick up the topic from MQTT and feed it back into the input of the switch so that if, for example, the schedule changes it then the switch on the dashboard will update to the correct state. By making the topic Retained then it will even remember the state over a system reset or deploy. Finally you can even control it from a different device on the network by sending it to the central MQTT server.

---

<div class="post-metadata">

**Author:** ![ukmoose](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ukmoose/32/13_2.png) [@ukmoose](https://discourse.nodered.org/u/ukmoose)\
**Post date:** [31 August 2019 12:53 UTC](https://discourse.nodered.org/t/thermostat-and-save-config-after-reboot-system/14805/13 "2019-08-31T12:53:07Z")

</div>

No by integrating a switch that checks the value of the second flow you can stop messages flowing within the first flow.

As this flow in the cookbook demonstrates  
[https://cookbook.nodered.org/basic/route-on-context](https://cookbook.nodered.org/basic/route-on-context)

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [31 August 2019 13:24 UTC](https://discourse.nodered.org/t/thermostat-and-save-config-after-reboot-system/14805/14 "2019-08-31T13:24:56Z")

</div>

I think I misunderstood the requirement
