Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hard Thermostat #481

Closed
off14 opened this issue May 25, 2017 · 78 comments
Closed

Hard Thermostat #481

off14 opened this issue May 25, 2017 · 78 comments
Labels
enhancement Type - Enhancement that will be worked on fixed Result - The work on the issue has ended

Comments

@off14
Copy link

off14 commented May 25, 2017

Is it possible to include functionality of HARD thermostat - where no MQTT(or similar) server is available or there are no commands received.
Of course this mode will require temp sensor connected.
You need to include logic to support COOL or HEAT modes, Hystersis setup (0.1 - 5) together with TargetTemperature

This will make sonoff working as a thermostat with web interface, even without any server. Very useful when sonoff is installed on remote location and there are big chances that internet is not stable there

WDYT?

@citrusfizz
Copy link

i like this idea. i recently built a thermostat with a raspberry pi, some relays and Node-Red and mqtt all built in. Trusting the PI for 24/7 operation is a bit sketchy. and if it reboots it takes a while to boot up and get all its gears turning. Working well so far, if you have a PI i can share my node red flows with you.

@off14
Copy link
Author

off14 commented May 26, 2017

Thanks, i have mine also in node-red and in openhab rules
the main idea is to have independent thermostat, which not requires any server (mqtt or whatever)

@CommodoreWhite
Copy link

Why not for any sensor that returns an analogue value (that is, not binary). So, for instance, a set point for humidity to control the bathroom extractor fan, a light sensor could turn security lights on and off, a proximity detector could control stair well lights. Hmm, the last one is a bad example but you get the picture.

The underlying logic is generic, if a sensor value is exceeds some thresholds, switch a relay and or send a message.

The implementation might not be as responsive as you like because, if memory serves, sensors are polled rather than continuously monitored and why having a proximity sensor manage stair lights could have undesirable consequences.

So it's a +1 from me.

Peter

@CommodoreWhite
Copy link

Oh! I forgot. It would be nice if the feature could be enabled or disabled depending on the presence or absence of an Mqtt connection. So, if the Mqtt service dies, lights still turn off and on. If Mqtt is working the control reverts to a higher authority.

@AlexTransit
Copy link

AlexTransit commented May 26, 2017

I made a simple thermostat at my place. (On fast)
He has no settings

I wanted to make PID and settings.
Do not do it. :)

sonoff.ino

void every_second()
{
  char log[LOGSZ], stopic[TOPSZ], svalue[MESSZ], stime[21];
  float ctemp;

#ifdef TEMPERATURE_CONTROL_DS18x20
if (ds18x20_read(0, TEMP_CONVERSION, ctemp, true)) 
{
  if ((ctemp == 85.0) || (ctemp >= sysCfg.temp_target)){
      if (power != 0) {
      do_cmnd_power(1, 0);}
      //setRelay(0);
  } else {
      if (power != 1) {do_cmnd_power(1, 1);}
      //setRelay(1);
  }
} else { //sensor error. disable power
  if (power != 0) {do_cmnd_power(1, 0);}
}
#endif // TEMPERATURE_CONTROL_DS18x20

@davidelang
Copy link
Collaborator

davidelang commented May 26, 2017 via email

@AlexTransit
Copy link

All right.
I did not have a source on my boiler.
I specifically use the library 18x20
And the temperature adjustment is done taking into account the sensor address.
Also incorrect data can come from the sensor. Then the temperature will be 85.0 degrees.

If you make a thermostat, then there may be several controls.
Just a relay or SSR
Or two relays, add a cold, and add hot.
Still the sensor 18 is quite slow. (Sample 700ms)

@off14
Copy link
Author

off14 commented May 27, 2017

i think it should be independent from type of sensor you are using. if you have any sensor supplying temperature then the "thermostat" option should be available, with dropdown list for sensors found.

of course, could be many variations, like 2 relays, pow-models etc - but i guess it will make the development complicated and even not compatible with sonoff chip (memory size)

my suggestion is to go with simplest possible setup
MODE: HEAT/COOL
HYSTERSIS: 0.1-5.0
MQTT_MSG: thermo { "mode": , "hyst": , "currentstate" : , "enabled" : };

@pprotschka
Copy link

has anybody been able to implement this? Tasmota is great but Wifi routers and Networks fail...and i dont want my walk in freezer to be left ON forever.

i know that easyesp has "rules" that make this possible but unfortunately easyesp is a lot more tricky to configure.

@davidelang
Copy link
Collaborator

davidelang commented Jul 26, 2017 via email

@mo8Zomo0
Copy link

+1

I was wondering about the same functionality and before opening a new request I searched and found this one.

It would really be a handy feature to control heating, cooling, de-/humidifiers, or use input from other sensors like light, moisture, ...

@nambuco
Copy link

nambuco commented Oct 9, 2017

+1 that would love this functionality.

To make implementation simple, should focus on Sonoff TH10/TH16 hardware (one sensor / one relay).

@apathyuk
Copy link

apathyuk commented Oct 9, 2017

Sounds interesting. Has anyone have a solution for controlling radiator TVRs?

@PeggyFree
Copy link

PeggyFree commented Oct 9, 2017 via email

@vstonkus
Copy link

I building electric floors heating in bathroom. There is a simple 220v wire (https://www.infrafloor.com/images/HomeBoxes/big/InfraFloorMat-FloorHeating.jpg). I think that Sonoff TH10/16 with water proof temp sensor inside floor concrete below tiles would be a solution here.
I would like to get it connected to home assistant, and Homekit. Would be great configure it to raise tiles temperature in the morning and in the evening for a little.
In bathroom there is other unit to control - coil heater, but it should be on after shower, so it can be connected on Sonoff TH with temperature and humidity sensor. Home assistant for example could notice increased humidity and turn on coil heater or mirror heating for example. Mirror does not need hard thermostat, but coil heater and mostly floors heating does.

I agree with @nambuco. Would be great to have this feature.

@nambuco
Copy link

nambuco commented Oct 11, 2017

I will try to implement a temp control for Sonoff TH, in case it works I will share it here. I may need help from someone who knows the sw structure. I will use AlexTransit code as a starting point, add PID and setpoint adjustment using MQTT (that's the complex part...). Let's see...

@AlexTransit
Copy link

I connected Sonof BASIC to the thermopot. as a relay I use SSR.
there is a small problem.
if you turn on the web. and disable the WIFI point then
the procedure "every_second" does not work until you go to the web page.
the firmware version is very old. (3.2.13)
I do not have enough programming knowledge and experience to implement a normal PID controller
but I'll find out. :) I do not know when.
still there is a problem with the OTA update when the size is more than 50%
this set back my further elaboration of PID.
the size of the firmware is great. and update the cable is not possible.

@spacefolder
Copy link

spacefolder commented Nov 1, 2017

Hi guys! Any news on this request? I have my sonoffs running my own (buggy, sloppy and slow) firmware, but having a TASMOTA Thermostat would be great, realy great!

+1

@nambuco
Copy link

nambuco commented Nov 7, 2017

Hello Guys, I finally got my USB/TTL converter and flashed my first Sonoff TH for testing. I forked this repository and will start coding a "hard thermostat".

Every tip / information will be welcome.

I will implement an on-off controller because my application (refrigerator) does not require a PID control.

I noticed that temp measures are done on every telemetry cycle defined by TelePeriod parameter. My idea is to run the thermostat function at same frequency.

I want to use some of the free setting bytes for a SetPointTemp, Histeresys and ThermostatMode - On (or Auto) and Off .

I will post here the evolution of this change.

Nambuco

@davidelang
Copy link
Collaborator

davidelang commented Nov 7, 2017 via email

@mo8Zomo0
Copy link

It would be good if the TH1x temperature sensors would be supported and even cooler of also a remote temperature sensor could be supported.

@nambuco Btw, regards flashing, check out: https://github.com/mirko/SonOTA

@nambuco
Copy link

nambuco commented Nov 15, 2017

@davidelang, thanks for the tip, it helped me to implement the first beta version available on https://github.com/nambuco/Sonoff-Tasmota for testing.

@mo8Zomo0, I am using the OTA in the WebServer interface, works fine here. I implemented for DS18B20, I do not have the TH1x sensor to test, but should be easy to adapt (replace Ds18b20ReadTemperature() by ShtReadTempHum() in the thermostat.ino file).

@Yevgenium
Copy link

@nambuco Can you make in the firmware a simple logic for switching the relay?
Example:
if Temperature<30 - Relay OFF
if Temperature>30 - Relay ON

@nambuco
Copy link

nambuco commented Nov 19, 2017

Hi @sgttrs ,

If you change the constant on thermostat.ino file

#define OFF_DELAY 90 // minimal off time in seconds
#define HYSTERESIS 2 // Hysteresys in 0.1 Degrees

both to zero, you have the effect you want. I just warn you that turning off and on before 60 seconds can damage a compressor (if this is your application).

Important point, set tele_period to 10 to allow a fast response

@Yevgenium
Copy link

@nambuco Thanks for the answer. I want to use Sonoff in the heating system to start the circulation pump. Is it suitable for this application?

@nambuco
Copy link

nambuco commented Nov 20, 2017

Hi @sgttrs , if the logic is like you describe (temp above setpoint turns on the relay) it will work as it is. Please be aware that I did not test in all possible conditions, You have to download and help me test in your setup.

I am planning to add a second mode where the relay will turn on if temp is below setpoint.

@Yevgenium
Copy link

Hi @nambuco, I'm testing the firmware with the settings you suggested. When I activate the thermostat and enter SETPOINT 30, the thermostat turns on the relay at any temperature, even if it is less than 30 ° C. I also noticed that when I connect Sonof to AC, it turns on and off the relay several times. Is there any way to avoid this?

@nambuco
Copy link

nambuco commented Nov 21, 2017

Hi @sgttrs, the SetPoint is defined in 0,1 steps, this means, to get 30C you have to input 300 in SetPoint.
Concerning the on / off during boot, that odd, I never faced it, but I will test in different conditions.

@pixidixi88
Copy link

Hi
I would like to use SONOFF TH16 to floor heating control. I have a AM2301 sensors. I need such rules:
If temperature is > wished temp - relay ON
If temperature is < wished temp - relay OFF
It seems like "cooling" because it will close valves when temperature is higher then wished.

Is it possible to put wished temperature via MQTT? I would like to add this as "thermostat device" to my Homebridge.

I am beginner so please explain me as clear as possible. :)

@Yevgenium
Copy link

Hi @nambuco. I just tried to change the temperature with the setpoint command via mqtt and via console. The result of processing the command:

15:41:25 CMD: setpoint 500
15:41:25 MQT: stat/sonoff/RESULT = {"SetPoint":300}

Rebooting the module does not help.

Hi @pixidixi88. The firmware is still under development. Various errors in work are possible. If you are ready for this, here is the instruction on how to install the firmware on the module. Also read the posts of nambuco in this thread.
I use Home Assistant to control my devices. To set the temperature value through mqtt, send the topic: cmnd/sonoff/setpoint. In the content of the topic, set the desired temperature value, multiplied by 10.

@spacefolder
Copy link

Hi!

I have a Sonoff TH16. Was working flawlessly with tasmota 5.10.0.
Decided to try the ThermoWeb. Flashed it ok OTA.

Now I can't see the sonoff in my network.
Serial Monitor shows that the device boots up just fine,
but it's manually self assigning the IP to 192.168.1.1 (which is my routers IP).

If I unplug my router, I can access the web interface (I have a dedicated AP for home automation), but it's asking to login in, with user & pass, which I don't know.

image

image

Any ideas?
Cheers!

@dweston
Copy link

dweston commented May 21, 2018

@IceStuff I have been running with v5.12.2 now for 20 days and it has worked flawlessly.

@ascillato
Copy link
Contributor

Hi,

In the wiki, now is available an example of a Simple Thermostat using RULE feature (https://github.com/arendst/Sonoff-Tasmota/wiki/Rules#7-simple-thermostat-example)

Please, check it to see if that helps you.

@spacefolder
Copy link

@dweston , did you go from "regular" tasmota to ThermoWeb, uploading sonoff-GB-thermostat-5.12.2_beta.bin OTA through the web interface, or did you flash the .bin using the serial port?

@dweston
Copy link

dweston commented May 21, 2018

@spacefolder I downloaded the .bin file off Github and flashed it OTA within my local network.

@dweston
Copy link

dweston commented May 21, 2018

@ascillato I would not say that is simple, but I can certainly see the powerful flexibility built into the 'rule' system. When I can set aside the time I will give it a go using this example. In the meantime for my present purposes v5.12.2 is working perfectly well for me and is considerably easier to work with.

@spacefolder
Copy link

spacefolder commented May 22, 2018

@dweston @IceStuff

I gave it another shot. Reinstalled Tasmota. Everything working fine. My DHCP assigns the IP correctly, and the Sonoff reads temp and humidity values correctly (itead Si7021 sensor).

Tried upgrading via web interface (downloaded a "fresh" thermoweb .bin)
(Upgrade by file upload)

image

Still the same issues. It self asigns 192.168.1.1 (clashing with my routers' IP)
If I unplug my router, I can ping and connect to the Sonoff, but it keeps asking me user & pass.
(admin and "blank" dont work)

Any clues?
Thanks. Cheers!

@dweston
Copy link

dweston commented May 22, 2018

@spacefolder I'd suggest you do a complete memory erase via serial https://github.com/arendst/Sonoff-Tasmota/wiki/Esptool#optional-erase-firmware and then reinstall https://github.com/arendst/Sonoff-Tasmota/wiki/Esptool#upload-firmware using Esptool. Remember the OTA does not overwrite some persistent areas of Flash so if a bug is in the persistent part it will keep on being an issue.

@pbutterworth
Copy link

Hi folks,
There's also another open source project (hasn't been touched in a while) that implements a thermostat on a ESP8266 board (not sonoff). It's a bit cobbled together, but does have some really nice functionality.
https://guide.openenergymonitor.org/integrations/mqtt-relay/
https://github.com/openenergymonitor/ESP8266_Relay_Board/tree/master/1ch_relay

What is particularly interesting is the local scheduler and web interface feature, making it possible to manage and use the thermostat completely independently.

image

The scheduler comes from here:
https://github.com/emoncms/development/tree/master/experimental/control/open_thermostat_scheduler

Would be super-nice to get this in to this project for TH modules.

@dweston
Copy link

dweston commented Jun 1, 2018

@IceStuff I have just encountered my first hic-up with the v5.12.2 firmware.

I had reason to update my MqttHost address in all my Sonoffs, only one of which at the moment is running v5.12.2. All the rest are running v5.13.0.The pre-existing MqttHost name was an IP address.

After issuing a group topic command updating the MqttHost name, which in my case is now 'vistacontrol.local', all the devices changed over flawlessly except for the TH16 running v5.12.2. This refused to connect giving the following error:
00:00:00 Project wineFan Wine Fan (Topic wineFan, Fallback DVES_A010DE, GroupTopic sonoffs) Version 5.12.2-2_4_1
00:00:00 WIF: Connecting to AP1 xxxxxx in mode 11N as winefan...
00:00:06 WIF: Connected
00:00:06 DNS: Initialized
00:00:06 HTP: Web server active on winefan.local with IP address xx.xx.xx.xx
00:00:07 MQT: Attempting connection...
16:28:29 MQT: Connect failed to vistacontrol.local:1883, rc -2. Retry in 10 sec
16:28:33 RSL: stat/wineFan/RESULT = {"POWER":"OFF"}
16:28:33 RSL: stat/wineFan/POWER = OFF

Changing the MqttHost in this device back into an IP address format for the new broker and the device connects no problem:
00:00:00 Project wineFan Wine Fan (Topic wineFan, Fallback DVES_A010DE, GroupTopic sonoffs) Version 5.12.2-2_4_1
00:00:00 WIF: Connecting to AP1 xxxxxxx in mode 11N as winefan...
00:00:05 WIF: Connected
00:00:05 DNS: Initialized
00:00:05 HTP: Web server active on winefan.local with IP address xx.xx.xx.xx
00:00:06 MQT: Attempting connection...
00:00:06 MQT: Connected
00:00:06 MQT: tele/wineFan/LWT = Online (retained)
00:00:06 MQT: cmnd/wineFan/POWER =
00:00:06 MQT: tele/wineFan/INFO1 = {"Module":"Sonoff TH","Version":"5.12.2","FallbackTopic":"DVES_A010DE","GroupTopic":"sonoffs"}
00:00:06 MQT: tele/wineFan/INFO2 = {"WebServerMode":"Admin","Hostname":"winefan","IPAddress":"xx.xx.xx.xx"}
00:00:06 MQT: tele/wineFan/INFO3 = {"RestartReason":"Software/System restart"}
00:00:07 MQT: stat/wineFan/RESULT = {"POWER":"OFF"}
00:00:07 MQT: stat/wineFan/POWER = OFF
16:33:50 MQT: stat/wineFan/RESULT = {"POWER":"OFF"}
16:33:50 MQT: stat/wineFan/POWER = OFF

I presume this is a quirk resulting from v5.12.2 being a branch off the main repository.

@BladeRunner68
Copy link

is @IceStuff still around? I have just tried this excellent addition to control my freezer. However the web UI does not accept float numbers such as if I want to set the setpoint to -2.5C - same in the hysteresis input too. Is there a workaround?

Also this firmware works with sonoff basic with ds18b20 added to gpio14 and TH model set.

@ascillato
Copy link
Contributor

Referencing other similiar issues to keep the Thermostat thread here.
#2486 #2425 #818

@stale
Copy link

stale bot commented Aug 30, 2018

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale Action - Issue left behind - Used by the BOT to call for attention label Aug 30, 2018
@IceStuff
Copy link

IceStuff commented Sep 2, 2018

Hi @BladeRunner68, yes I am still here. I haven't received notification for any of these updates and just checked in to see how think are going.

Thanks,
Paul

@stale stale bot removed the stale Action - Issue left behind - Used by the BOT to call for attention label Sep 2, 2018
@dweston
Copy link

dweston commented Sep 3, 2018

@IceStuff are you intending to develop this branch further? I'm still using v5.12.2 which is quite stable, though the issue with MqttHost name referred to above, is still unresolved. I note the request above for float numbers, and the humidity ToDo mentioned at the bottom of your Wiki https://github.com/IceStuff/Sonoff-Tasmota/wiki would be very useful to me.

@ascillato2 ascillato2 added the enhancement Type - Enhancement that will be worked on label Sep 4, 2018
@dhzl84
Copy link

dhzl84 commented Nov 15, 2018

I built my own thermostats from scratch (with Home Assistant in mind) but I do like the idea to put it on top of tasmota.
Still need to get my head around all this tasmota stuff and how different things work together, so any help appreciated.
My productive SW is here: https://github.com/dhzl84/ESP8266-Smart-Home
My "trying to port" fork is: https://github.com/dhzl84/Sonoff-Tasmota
Already had a look into IceStuffs fork.

@gschmahl
Copy link

gschmahl commented Nov 25, 2018

Hello,
is it possible to see the setpoint on the main page as well as the actual temperature value?
I can't figure it out.
Can someone help on this or is it implemented?
Thanks in advance
gschmahl

@ascillato2
Copy link
Collaborator

Hi,

Closing this issue as it has been without activity for a while and it is not going to be developed soon for Tasmota. Anyway, it has been added the label Feature Request (hold over) for future reference because here were exposed very interesting ideas. May be this feature can be added as a new extra driver in the near future. Thanks everyone for sharing their ideas.

As a workaround for this feature there is in the wiki, an example of a Thermostat using RULES feature (https://github.com/arendst/Sonoff-Tasmota/wiki/Rules#7-simple-thermostat-example)

Please, check it to see if that helps you.

@ascillato2 ascillato2 added the requested feature (hold over) Result - Feature that will not be added soon (out of scope) label Dec 22, 2018
@ascillato ascillato mentioned this issue Apr 20, 2020
6 tasks
@ascillato
Copy link
Contributor

Added #8212

@ascillato2 ascillato2 added fixed Result - The work on the issue has ended and removed requested feature (hold over) Result - Feature that will not be added soon (out of scope) labels May 10, 2020
@dexterbot80
Copy link

Hi,

In the wiki, now is available an example of a Simple Thermostat using RULE feature (https://github.com/arendst/Sonoff-Tasmota/wiki/Rules#7-simple-thermostat-example)

Please, check it to see if that helps you.

Hello, Can you send the correct link here? Thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Type - Enhancement that will be worked on fixed Result - The work on the issue has ended
Projects
None yet
Development

No branches or pull requests