DIY OpenTherm Thermostat?

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?

Do you have ds18b20 attached to board?

Yes. Iā€™m using esp8266 thermostat shield which have one on board.

Strangeā€¦ Either its faulty or some error in sketch. Flashed that sketch to my board, working without an issue so far. Let move a discussion to the private messages so not to flood forum. When we find error in a sketch - will post it here.

@wzbart figured out what was causing zeros in temperature readings. HomeAssistant can send ā€˜unavailableā€™ payload if sensor was out of range for some time and arduino sketch treats any invalid string as zero, so response from thermostat was 0.
Iā€™ll update the sketch to just skip non-numerical strings to avoid this issue.

I added this code to configuration.yaml, but no value is displayed. Other changes to other files are probably needed ā€¦? Thanks.

Sorry for that, iā€™ve forgot to update the sketch. Now should work, added flame status and level reporting on topics:
opentherm-thermostat/flame-status/get for status (on/off)
opentherm-thermostat/flame-level/get for current level (0ā€¦100)
P.S. the sketch has been updated to support domestic hot water functions and also thereā€™s now a check for temperature validity, if any string other than a valid number is sent to a setpoint or temperature topic - it is ignored.
Also added manual setpoint override, if for some reason you need set specific heating water temp (water going to your radiators/floors etc) - use setpoint-override/set topic. You should send temperature to this topic every 30 sec or less. To leave setpoint_override_mode - just stop sending, and it will return back to PID after 30 s or send any message to the setpoint-override/reset to return back immediately.

4 Likes

Thanks a lot @shcherban. New sketch is goin to be much of help if it comes to more advancet boiler control. Right now Iā€™m using this thermostat to control one area with floor heating. Now I might use that new override topic to send out temp from a different room (with radiators) in case corrent temp is lower than target one.

Override topic is for heating water temperature, and not room temperature . If you just send 18-22Ā°C, radiators would not get enought thermal energy and wont heat your room.
To switch to coldest room just send room temp to the regular current_temp topic .

Actually in my setup I can use it to do exactly what I described. Right now OpenTherm Thermostat is only controlling my floor hearing in lining room (letā€™s say set to 21 degree). In case I need to send more temperature to my kids room radiators (target temp 22 degree) I just close floor heating loop with electric valves and set override topic to letā€™s say 60 degree until current temp in kids room actually hits the target one. On radiators I have zigbee thermostats and they will make sure current temp is not going to go above the target one. Then just I stop sending override topic and OprnTherm control is going back to my living room.
So this is my idea for using override topic at least. Let me know in case I missed anything :slight_smile:

Now i see. All correct, youā€™ve done all the setup as it was intended (i mean override topic). Write here a word about results when you test your system.