DIY OpenTherm Thermostat?

@wzbart im not sure tasmotas thermostat can talk via MQTT. You can integrate tasmota board into HA and find out how can you change setpoint from it. Or you can add bluetooth support to thermostat sketch, if you have programming skills.
Another option is to leave HA thermostat sketch and integrate bluetooth thermometer directly into HA via tasmota or openmqttgateway and then point thermostat temp topic to openmqttgateway’s one. That approach would require another esp32 board for bluetooth scanning purposes.

Actually if you’re using this system at a place where you live full shutdown is not critical problem, since youre always at place and can quickly figure out that something going wrong. We just not included that feature because its not safe for ‘unattended setup’ use cases.
At my house Im doing ‘full shutdown’ if none of my three heating zones requires heat. There was a glitch maybe once or twice, i just fixed the problem and forgot about it for the rest of the time.

Could you give me a bit more details on that third option please? So what you’re suggesting is to make that ble sensor taking via mqtt. I dont really understand however which temp topic i should be pioning to that mqttgateway one.

Official tasmota documentation is actually referring to this AH integration https://www.home-assistant.io/integrations/opentherm_gw/. It might be worth to check this out.

That integration implies OpenTherm gateway plugged to a PC via USB-Serial adapter if i understood correctly

You can use this guide: Home Assistant OpenTherm Thermostat - DIYLESS Electronics

Then in homeassistant you just need to set up an automation which sends whatever your temperature source is to an mqtt publish e.g.

- alias: sendtemp trigger: - platform: time_pattern seconds: "/20" action: service: mqtt.publish data: {"payload": "{{ states('sensor.0x00158d000465809a_temperature') }}", "topic": "opentherm-thermostat/current-temperature/set", "qos": 0, "retain": 0}

Source: Publish current temperature to mqtt topic - #4 by nonyhaha

Edit: As suggested by @Dujith you should use the github link for up to date sketch but the steps in the blog post cover the rest of the setup: https://github.com/diyless/home-assistant-opentherm-thermostat

I personally use esphome to read LYWSD03MMClink but as mentioned above to read these ble sensors you need an esp32. Instructions are in that link.

1 Like

@wzbart @sour_brambles
The blog is outdated, best is to use their github: https://github.com/diyless/home-assistant-opentherm-thermostat

1 Like

Aye, that’s a good point.

@shcherban might be worth amending your blog post to point to up to date source code so there isn’t any confusion for newer users.

Thanks a lot @sour_brambles. I know that blog and this is exactly what I was planning to do. Another esp32 is not a problem, as I’m already using one (with esphome) to read other xiaomi ble sensors I have. The only part, which I’m still not sure about, is that OpenTherm Thermostat sketch for home assistant. I’m lacking this king of programming sills, therefore I don’t really know how does it really works and how to send external temp sensor readings to the thermostat. Now you’re telling me it’s just enough to publish external temp value to opentherm-thermostat/current-temperature/set topic, and if this all that it takes I think I can manage it easily. I will probably go for node red automation, rather than standard HA one.
Once again. Many thanks for your advice !

If I’m understanding what you are trying to do then yes that’s all you need to do.

In terms of the arudino sketch the only thing you need is to add the libraries mentioned in the blog and change the pins if you are using an esp32. You also need to add your WiFi details and mqtt server but that’s it with the sketch.

Once you have that up and running you can use node red to send the ble temperature to opentherm-thermostat/current-temperature/set

There are a few people trying to implement opentherm via esphome and there is a working example using the diyless board if you are more comfortable with esphome but at the same time it is early days.

@shcherban would you be happy to share the sketch you are using? I’m also lacking in the code department and I’d like to implement the full shutdown into the code. Or maybe it could be add to the github source but commented out to allow people to implement if they choose to do so. Sorry for being a pest.

I did add the modulation part as i wanted to see that.
In config.h add:

// Modulation Status
const char* CV_MODULATION_GET_TOPIC = "opentherm-thermostat/cv-modulation/get";

And in opentherm-ha below:

  snprintf (msg, MSG_BUFFER_SIZE, "%s", String(dhwTarget).c_str());
  client.publish(TEMP_DHW_GET_TOPIC, msg);

Add:

  // Extra code for getting modulation
  int modulation = ot.getModulation();
  snprintf (msg, MSG_BUFFER_SIZE, "%s", String(modulation).c_str());
  client.publish(CV_MODULATION_GET_TOPIC, msg);

Just add a simple sensor in your configuration.yaml (or sensor file if you splitted)

- platform: mqtt
  name: "CV_Modulation"
  state_topic: "opentherm-thermostat/cv-modulation/get"
  value_template: "{{ value }}"
  unit_of_measurement: "%"
  icon: mdi:percent
2 Likes

Thanks again @sour_brambles . OpenTherm Thermostat will be actually sitting on D1 mini, so I’m guessing I don’t need to touching pins configuration in the arduino sketch. Esp32 I was mentioning previously will be only reading temp value from external ble sensor (in the room I want to control the temperature) and sending it back to HA via esphome. Then, HA will be publishing temp value to OpenTherm Thermostat topic.
In my heating setup OpenTherm Thermostat will be mounted next to boiler (as it needs to be connected via wires), and the room I’m trying to control temp in is couple of walls away from the boiler. I don’t want to be throwing cables all around my house, therefore I decided I need to look around for any wireless solution. And obviously I’m big HA fan, so I want to have it all in HA :slight_smile: Thanks to OpenTherm Thermostat and your help guys I think I found exactly what I need. Will try to get it all implemented over the weekend.

Correct, no pin changes required. Sounds like a near identical install to myself. Best of luck :+1:

1 Like

Does anyone know if it’s possible to use the diyless gateway with HA? The howtos don’t seem to cover that option.

I would like to keep the normal thermostat functionality in case of HA crashing or being unresponsive.

Hi guys. So I got my open therm termostat working. It’s taking temp from external bluetooth sensor (ESPHome is reading temp from sensor and then HA is publishing it to OpenTherm thermostat ). Everything is working well, except one little problem. From time to time Open therm is showing 0 degree for current temp (the one measured remotely in controlled room). I have checked and there is no zeros coming from the ext temp sensor. Also HA is not publishing any zeros to OpenTherm Thermostat. I believe something is happening inside the thermostat itself. I’m using the sketch from this github link https://github.com/diyless/home-assistant-opentherm-thermostat. Any idea of what can be wrong? How can I trouble shoot this problem?

Hi
can you tell how often is temperature published to the MQTT?
you can try to increase timeout in sketch:
image
set 300 (5 min) or so and see if issue still happens.
P.S.that might be causing it
image
you can remove if statement and always return t to completely bypass timeout function. That was introduced as a fallback to the internal sensor (DS18B20) to avoid house freeze if broker fails or external temp is not published for a long time for some other reason.

Actually for a full shutdown/eco mode (low temp for floor only) im using slightly tuned basic sketch from home assistant example and all additional logicis done in node-red. That was faster for me than constantly uploading firmware to ESP and then bringing it to boiler, test, repeat etc…
If actual room temp is more than 0.1 °C above setpoint - im sending some predefined value (29 in my case) to the opentherm-thermostat/setpoint-override/set topic.
Heres attached code:
tricky
thats an archive inside png since forum does not allow archives uploading. Download it and open with archiver.
Heres how does it look at the node red side:


Every 10 seconds im checking if difference is more than 0.1°C, if so - second exit is active and sends setpoint override to the mqtt. If less 0.1 - no action performed, sketch works alone.
And eco-switch box is:
image
also there’s some additional logic for hysteresis, configuring floor mode temp via home assistant input and so on

1 Like

Thanks a lot for light speed reply. I’m publishing temp value every 20 sec. It seems that zero values is showing up in some almost regular intervals (see below). I will check that Timeout option and will let you know whether it worked or not.
One more thing. One day my MQTT broker stoped working and at the same time I realised an error message “A9” showed up on my Vitodens 111-W boiler. A9 is OpenTherm communication problem. Is it possible that MQTT broker failure could cause any communication issues to OpenTherm protocol.

Yep, it might be that ESP stuck trying to connect to the broker and ‘forgot’ about OT communication. It depends on what exactly failed on the broker side. I.e. if socket was in open state but was not sending any reposnse - arduino library will freeze because it sees than connection is accepted and so waiting for a response. Maybe we need some watchdog in arduino code to reset if program hangs.
P.S. sorry, found actual reason: that is mistake by design :frowning:
image
thermostat will try to reconnect indefinitely. Seems that at the moment of writing that sample i was not assuming that something might happen with broker (im using emqx failover setup, 2 brokers in parallel).
To fix that we would need some rewriting and disabling mqtt publish if broker not available

set 300 (5 min) or so and see if issue still happens.

I have set it to 300 and zeros are still showing up. Actually I can even see some -127 values in my HA history. I will leave it over the night and check again tomorrow morning. One thing I dont really understand. If that IF statement was meant to failback to internal sensor (which is very nice idea btw), why it’s not getting correct values from it?