Shelly + ESPHome to act as a thermostat in case HA crashes

Hey everyone, I’ve been researching how to integrate my gas boiler with Home Assistant and wanted to share what I’ve managed to figure out so far with my limited knowledge and get some feedback from people who’ve done something similar.

My setup / constraints:

Boiler: Immergas EOLO STAR 24 4E, it’s in a closet on the apartment balcony (standard installation in my country)

Apartment: It’s an 85sqm/915sqft apartment, so there shouldn’t be too much temperature deviation from one room to another.

The boiler uses a proprietary IMG_BUS / CAR V2 protocol, no OpenTherm.

Over here thermostats are fairly rare, so my house has zero thermostat wiring. I usually just adjust up the water temperature on the boiler manually, meaning that It also never a steady temperature inside.

I’ve purchased a ready-made ES32 usb dongle and a few BLE temp sensors to monitor temperature and humidity in my rooms.

I don’t need a physical thermostat display, happy to control everything from my phone, through automation, or directly on the boiler

The boiler has a thermostat terminal (clamps 40 & 41) with a jumper bridge installed from the factory. Removing the jumper and replacing it with a dry-contact switch should allow remote control of the boiler

For the HA and ESPHome side, the plan would be:

Shelly 1 relay module (because it has isolated dry-contact output) wired to S20 inside the boiler, Temp sensors feeding temperature data to ESPHome/HA and All control via phone / HA automations. As I haven’t ever really had a thermostat, I wont be missing out on much.

One concern I’ve read about this is that if HA crashes the boiler continues to heat the house, or alternatively stays off even when the temperature falls. So that’s why I want to add ESPHome. My understanding is that the ESP32 device will have information coming in from the BLE temperature sensors, which it can then use control the Shelly relay, and pass all of this information to Home Assistant for a dashboard. In case of an HA outage, the ESPHome would take over and keep the boiler at a set temperature independently.

Has anyone done something similar with an Immergas boiler? Any gotchas? I’ve read some people on here trying to integrate Immergas’ own thermostats into HA, without much luck.

Any better recommendations to implement remote heating?

You have many options here.
But Shelly has nice local webserver UI with full control, so you could set “hardcoded” off-timer there to make sure it will never stay on for more than this set time even if wifi or ha is down.

Also, you can flash Shelly with esphome if needed.

Do you have any way of adding a wired temperature sensor (like Dallas) in the apartment?
Meaning you solder on the sensor wires to the Shelly and route the cable indoors.

That will give you a proper thermostat if you flash it with ESP-Home.
Not sure if wireless works but I suppose they would since ESPs can read the Bluetooth data.

With ESP-Home you can create a thermostat entity that is then shared to Home Assistant.
If HA stops working then the ESP will continue as it’s set to.

That’s an option for sure. There seem to be at least a few options to prevent overheating. On Reddit someone suggested the following

when you make your home assistant thermostat, use an Input Boolean as a “call for heat” instead of turning the Shelly on directly from the thermostat template. You will make an automation that runs every minute that checks if the call for heat is on, and any safety checks you desire (no room too hot, temperature sensors still available), and then turn on the Shelly. This ensures that if home assistant crashes, goes offline, or something unplanned occurs, your boiler will shut off and stay off without your intervention.

I’m just wondering if I can make the ESP work as a “backup” thermostat, in case of an HA outage, and not just to send a simple shut-off signal.

The only way to route the cable indoors would be through the balcony doors, which is kind of laborious (they’re aluminium so a bit more involved), drilling the walls would be too much (40 cm cement all around the outside walls).

I think the wireless temp sensors should work, that’s what I’ve read that people have been doing, ESP as a bluetooth proxy and sensors sending info intermittently.

The one real question I have is will the ESP be able to address the Shelly directly? Shelly has Bluetooth but I think it’s pretty restricted in usage to their own network with sensors and etc. It also has wifi, which is what I was thinking of using.

Any thoughts on that?

I guess I could also use a Shelly Blu H&T sensor which I think should directly integrate with the Shelly on its local web UI or Shelly app.

Not familiar with it’s web UI, does anyone know if that kind of automation is possible?

That isn’t the same thing as the ESP getting the value directly.
Proxy means the value is sent to HA and then you can send it back to the ESP again.
But that means if HA goes down you wont get the temperature.
I suggest you figure out a way to get the temperature directly to the ESP then optionally share it to HA.

Using ESP-Home thermostat means it is not a backup. It is the real thermostat.
Using Web Server Component means you can not only control it from HA but also directly using wifi and the ESP access point.

The ESP IS the Shelly. The chip inside the plastic is an ESP.
I suggest flashing it with ESP-Home to get complete control of it.

It is quite comprehensive, including scripting.

Oh! Understood, okay yeah, I’ll try to figure something out in that case.

Yeah, wrong wording. The ESP-home is the real thermostat, the HA is the my preffered way of controlling it, but if HA goes down it continues to function with either the last temperature setting I “requested” or by its own automation function.

Yeah I get that, I’m just also going to have another ESP device (the one which will supply the temperature information to HA, and act as the thermostat transmitter) so that’s why I’m referring to them separately.

The Web Server Component seems to be what I’m looking for. So I either flash the Shelly with ESP-Home and use that, connect it to the HA for control on my phone or other devices, if the HA goes down the Shelly continues working according to the automation in ESP-Home.

Or, I do that with a separate ESP, leave the Shelly with its stock firmware and control the Shelly through the other ESP.

Or finally, get a Shelly temp sensor, leave out connecting the Shelly to the ESP, and in the Shelly web UI set an automation to use the Shelly sensor in case HA goes down. I’d have to figure out the logic so that the automation is used only when HA is down, but I think that also should be doable somehow.

Thank you both for the answers and ideas.

I’ll sort out how I want it to function and what is doable overall in my house and go with that.

Step 1 is to figure out a way to get the temperature data from the BLE sensors directly to the ESP and then share that with HA.

Step 2, see how doable it is to control the Shelly through that ESP. If not, flash ESP-Home to the Shelly relay directly.

Step 3, if the above doesn’t work for some reason, get a Shelly BLU temp sensor, connect it up to the Shelly relay and have that act as the fallback.

You have almost too many options to try.
First of all, request to shelly to turn ON can always include &toggle_after=(duration), so once it receives ON command, the OFF is already set.

For direct BLU based backup, you could for example set HA to make “heartbeat” request every 30min, write a shelly script to use BLU if that heartbeat is not received.

Yeah this is exactly what I was thinking.

So if that’s doable, I think it’s the simplest option given everything. Thank you so much. This thread cleared up a lot of things.

If you already have another ESP32 then use this for testing before flashing the Shelly.

Maybe one of these will give you the temperature directly in the ESP.

LYWSD03MMC

This is the one I specifically purchased based on that list, that’s why I had the thought of using the ESP-Home.

As far as I can understand, I will be needing to flash the firmware on these devices, so that’s going to be a first and a fun thing to tinker with.

Flashing it with esphome gives you the highest flexibility. Everything I wrote above was for stock Shelly though, I rarely flash them. If you are tinkering with any mains powered shelly, be aware that logic gnd is directly bonded to mains live.

I meant the temp sensors that I bought. I would prefer to keep the Shelly device on stock firmware, don’t want to be messing up something connected to my boiler for no reason.