I am trying to find a way to turn off a heater when the temperature sensor being used by the heaters generic thermostat fails to update
I can do this with an automation to look at the last state change and if it exceeds a set time then I can turn off the switch and it will resume when the generic thermostat gets a temperature reading again - this all works
My temperature sensor is a DHT22 connected to the GPIO of a sonoff running Tasmota firmware
The problem is that if there is a fault with the DHT22, I have simulated this by removing the signal wire, instead of a number, the tasmota firmware sends the string “nan” for the temperature value and home assistant registers this as a sensor update even though the sensor and thermostat both show the last received numeric value.
I have my generic ‘thermostat’ which is just a collection of automations to turn on/off my not-smart heatpumps. The off automation is triggered by my ecobee temperature sensor reading and a timer that is the failover. The timer is set to run for a fix period (2 hours) and is started/restarted every time heatpumps are turn on. So I don’t have to depend on just the temperature sensor.
I have now managed to get a solution working, this sensor value template detects the temperature of nan that is sent by tasmota when the temp sensor fails as not defined and replaces it with unknown. This sensor also has a expiry time that will cause home assistant to change the value to unknown after 120 seconds if no value is received. A single automation can detect both failures and turn off the heating. As soon as the temp values are available again, the thermostat will turn the switch back on if required.
Something has changed here, the dht22 when disconnected from the sonoff now shows as “None” in the states page. On sensors where I have applied an offset, eg. Float -1, it now shows the temperature as -1 C in a fault condition of a disconnected sensor. I will need to rewrite my rules for this.
Not sure if this topic is the right place given it is quite old.
I am trying to setup a Thermostat using Tasmota, SOnOff SV and a couple of sensors.
What I want is to try and create a failsafe if Home Assistant crashes or becomes unavailable.
If HA crashes, and I am not home at the time, it could potentially crash with the thermostat relay stuck in the on position, meaning the Sonoff really is on and nothing to send a signal to turn it off.
Any advice from a HA or Tasmota guru would be appreciated.
Look up rules for Tasmota, I have the following set on some of my sonoff basics so they turn off the relay if the mqtt server is disconnected. I once had ha crash but the mqtt was still connected so it’s not completely safe but the best I have found so far.
{“Rule1”:“ON”,“Once”:“OFF”,“StopOnError”:“OFF”,“Free”:471,“Rules”:“on Mqtt#Disconnected do power1 off endon”}
I was trying to make sense of the Tasmota rules a bit, I had trouble with the syntax.
I’ll try the rule you listed as that looks like what I need. I am using the onboard relay for the heat/furnace component and a secondary relay for fan only, so that should work well.
I have a couple of spare DHT11’s I might use as an absolute cut-off and see if I can work out the syntax enough to have a rule that cuts off inside Tasmota firmware if the temperature exceeds an absolute value.
Great thing about the Sonoff SV, it has GPIO4, GPIO5, and GPIO14 exposed as pins as well as Tx and Rx headers. A little sidetracked there
@Crhass
I used the rule and it works well. I also added a ON WiFi#Disconnected DO Power1 off EndOn as well.
Now I have the format right, I am also adding a On DHT11-14#Temperature>35 DO Power1 off EndOn as well as a second one that measures the temperature of the air in the ductwork as On DHT11-5#Temperature>60 DO Power1 off EndOn . I have two DHT11’s , one on GPIO14 and the other on GPIO5.
Thanks so much for helping with the rule syntax.
Edit: My temperatures are in Celsius. I just thought I should add that
I like your over temp rules, they won’t work for me as most of my dht22 sensors that control my heating are not on the same sonoffs.
Have you noticed restart reason ‘hardware watchdog’ on your sonoff Tasmota information page when using dht22 sensors? All mine suffer from this but the ones with no dht22 don’t restart for months.
I had a couple of spare DHT11 sensors so I added them specifically for over temp.
I have not noticed any restart events to be honest, but I am using DHT11’s not 22’s. Might be a bug with the DHT22 implementation… I might have to get a DHT22 and run some tests.