I have an esp32 with a Dallas temperature probe and a relay for controlling an aquarium heater. I’ve setup the bang bang component to manage this like a thermostat. It works well when connected to home assistant but if the Wi-Fi drops out bang bang doesn’t seem to change the relay when the probe reaches the set temperature until it connects to Wi-Fi again. Should this work offline? I’m surprised it doesn’t given how simple it should be but I’m not sure if it’s something wrong with my configuration or my expectations.
I’ve set reboot_timeout: 0s to let it keep running when the Wi-Fi drops
Yes, being connected to home assistant 100% of the time would be lovely but I’d like this to be resilient to outages.
For anyone to figure out what is going on, they will need logs and the configuration that you are using.
If I was debugging this, I would set up local serial logging (probably verbose) to see what happens when Wi-Fi goes away. That would confirm (or deny) what you think is happening and also likely give you a clue as to why.
I typically use a laptop (see to never sleep with a power cord) with a terminal emulator (Terra term or putty are common choices) set to log to a file. I can then review the (timestamped) file at my leisure.
Is there a reason you are using bang-bang instead of the standard Thermostat? I don’t think that would change the results, but the definition of bang-bang seems a little weird. I chose thermostat for my heating only tasks and it has been working fine (but my Wi-Fi never goes out, at least before the power does completely).
Getting logs while it is disconnected from Wi-Fi is awkward so I haven’t done that yet. My first question was just should it work offline? I assumed it should but maybe someone can say that it wasn’t actually designed to do that.
In my experience, yes it does. The original gas-bulb thermostatic switch on my fridge died nearly 4 years ago and a replacement wasn’t available. So, I replaced it with a sonoff basic with a temp sensor using the bang-bang thermostat component.
I would also echo Neel’s comment that you may get a more helpful answer to your overall situation if you share your config. Unless it’s really bare-bones (like my fridge switch was) there may be some other component that will require a stable or continuous connection.
You’ve done so for the API, but not the WiFi. Although this shouldn’t keep the thermostat from functioning, especially since bang-bang doesn’t seem to have minimum cycle times. But it still means the whole thing is rebooting every 15 minutes.
Your config is not a minimal configuration. You do have components that need connectivity. It is possible/likely that they are part of the problem you are seeing.
You can remove them and see if that solves your problem.
When I first read the bang-bang controller page it didn’t make much sense to me. It still doesn’t. It does have some warnings about using it both heating and cooling (which you aren’t). The regular thermostat says it is just two bang-bang controllers. But, I find it much easier to understand. I set the set point and I can set the upper and lower dead bands and/or set minimum run and/or idle times. All of those things make sense to me.
You get the same behavior in bang-bang (for heating) but you have to change both set points when you want to change the target. If you always want the same temperature it doesn’t matter. I change the set point based on activity and time so only having to change one thing is an advantage to me. This really isn’t the cause of the issue you are seeing.
If you don’t want to get logs, just remove everything else and see if the problem goes away. I find the time it takes to set up logging more than pays in the time it takes to solve problems once you have the logs.
Thanks for the help everyone. It seems like I misdiagnosed the issue and it wasn’t the Wi-Fi dropping, just the Dallas temperature sensor being flaky due to loose connections. Glad to hear esphome would be able to keep running offline as this gives me confidence to build more on it in the future.