esphome / feature-requests

ESPHome Feature Request Tracker
https://esphome.io/
419 stars 26 forks source link

Opentherm support #520

Open rdehuyss opened 4 years ago

rdehuyss commented 4 years ago

Describe the problem you have/What new integration you would like

It would be great if ESPHome would support opentherm and directly integrate into Home Assistant

Please describe your use case for this integration and alternatives you've tried:

Currently I use the generic thermostat is HomeAssistant. My gas usage would probably diminish of I could use Opentherm modulation.

Additional context

brandond commented 4 years ago

Do you have any reference documentation or a chipset that supports it? It looks like the signalling is done using voltage in one direction, and current in the other. Current sensing and control would require additional external circuitry.

rdehuyss commented 4 years ago

My ideal situation would be that ESPHome could drive my central heating (including modulation) using opentherm.

There are some hardware options already available (http://ihormelnyk.com/opentherm_thermostat) including code for Arduino.

If we combine this with a smart thermostat in HomeAssistant (presence detection, weather forecast, input from various other sensors), I think we have a state of the art system.

There is also the opentherm gateway which can work using a serial connection over an ESP8266, could be another implemention of the same feature.

lwqcz commented 4 years ago

Support for eBus by Valliant would be fine also :-) https://ebus.github.io/adapter/

jperquin commented 4 years ago

Currently using Tado as homekit accessory / integration, but fed up with their cat & mouse approach API-wise, forcing our development community to play constant catch-up.

Have good wifi coverage throughout the house and a good deal of ESPHome devices that work well. Would want to switch to simple wifi controlled radiator thermostats and have HA manage all the smart logic, controlling the boiler / water heater thru opentherm.

Maybe someone can look at ihormelnik's Arduino code and port to ESPHome?

roma1141r1 commented 4 years ago

I subscribe to the question. Igor Melnik got a good, easily repeatable device and has open source codes, ideally this device should work in ESP HOME

Morphy99 commented 4 years ago

I had a look at ihormelnik's mqtt opentherm bridge but it looks like it only supports thermostat temperature. I'm looking for something that works with water temp and any other info the boiler might pump out

rsciriano commented 3 years ago

Hi, I have integrated my OpenTherm boiler using the ihormelnyk's OpenTherm Adapter and custom components (you can see the code here, it needs a good review/refactoring)

Now I would like to contribute to esphome, adding the appropriate components:

I'll be commenting here on the progress

jperquin commented 3 years ago

Very cool! Also from a perspective on how to adapt existing arduino projects to ESPHOME.

I copied your project files into /config/esphome and ESPHOME 1.15.3 validates the setup as OK, but get following error on compilation:

LibraryManager: Installing OpenTherm Library  @  1.1.0
git version 2.17.1
Cloning into '/data/opentherm/.piolibdeps/opentherm/_tmp_installing-apddemq_-package'...
fatal: unable to access 'https://github.com/ihormelnyk/OpenTherm Library /': The requested URL returned error: 400
PlatformioException: VCS: Could not process command ['git', 'clone', '--recursive', '--depth', '1', 'https://github.com/ihormelnyk/OpenTherm Library ', '/data/opentherm/.piolibdeps/opentherm/_tmp_installing-apddemq_-package']:

Compilation using the ESPHOME (dev) version available in HA add-on store (https://github.com/esphome/hassio) starts out well, but finally errors out as follows:

In file included from src/main.cpp:26:0:
src/opentherm_component.h:3:23: fatal error: opentherm.h: No such file or directory

*******************************************************************
* Looking for opentherm.h dependency? Check our library registry!
*
* CLI  > platformio lib search "header:opentherm.h"
* Web  > https://platformio.org/lib/search?query=header:opentherm.h
*
*******************************************************************

 #include "opentherm.h"
                       ^
compilation terminated.
*** [/data/opentherm/.pioenvs/opentherm/src/main.cpp.o] Error 1
rsciriano commented 3 years ago

Hi @jperquin,

I had a few mistakes in my code (It worked in my machine ;-)

I have updated the gist, fixing these errors (opentherm_component.h and opentherm.yaml files)

You also need to use the dev version of esphome

good luck!

trueskalon commented 3 years ago

Hi,

I have issues (as I can see from usb logs) with connecting to HA of my esp when trying rsciriano HA integration via esphome dev.

I tried esp8226 - d1 mini pro v1 and nodemcu v0.9 - no luck, same behivoure.

I was flashing, earsing, new HA, few psu for powering, used caps on 3,3v and 5v rail and always got same result.

The esp is connected to my router I can do OTA updateds...

Any suggestions?

Thank you :)

esphome log: WARNING Initial connection failed. The ESP might not be connected to WiFi yet (Timeout while waiting for message response!). Re-Trying in 1 seconds

usb log:

ets Jan  8 2013,rst cause:2, boot mode:(3,6)

load 0x4010f000, len 3456, room 16 
tail 0
chksum 0x84
csum 0x84
va5432625
@cp:0
ld
rsciriano commented 3 years ago

Hi @trueskalon,

I'm currently busy with other things so I can't get time to try to reproduce the error. I would also like to work on integrating this code into ESPHome :(

I don't know what could be happening, the same code is working in my boiler, in a Wemos D1 mini

Things that might help diagnose the problem:

I hope it will be helpful

wichers commented 3 years ago

I'm obsessed in getting all my equipment to run esphome. I'm currently working on an OpenTherm gateway: https://github.com/wichers/esphome-opentherm

Current version is working, but work in progress. My plan is to incorporate the same features as this pic16f project: http://otgw.tclcode.com/firmware.html#dataids

As this is a native (ESPxxx RX/TX legs connected to Boiler and Thermostat) OpenTherm implementation you need hardware directly connected to your esp, for example: https://github.com/jpraus/arduino-opentherm (I'm using this on a WeMos R32) https://diyless.com/product/arduino-opentherm-gateway http://ihormelnyk.com/opentherm_adapter

Weissnix4711 commented 3 years ago

Interesting stuff.

I have been trying to do something similar to @rsciriano for quite some time. Sadly, cpp isn't my strong point.

I've also seen this library which may be an alternative to Ihor Melnyk's library. The master interface of @jpraus' shield is virtually identical to Melnyk's adaptor, so this should be compatible.

Edit: Ooops, I didn't realise wichers had already linked this.

diyless commented 3 years ago

@wichers, Ihor has updated his OpenTherm library, now it supports DHW, just FYI

Weissnix4711 commented 3 years ago

@wichers, Ihor has updated his OpenTherm library, now it supports DHW, just FYI

This is only some clean wrapper function, there is no need to add support for dhw, it's practically identical to CH, only a different msg id.

Weissnix4711 commented 3 years ago

As I understand, the main issue is not blocking the main loop for too long. Each frame is 32 bits, with 1ms for each bit. That may or may not be problematic, I am unsure quite how long we could block for.

ihormelnyk commented 3 years ago

There is a sample at the bottom of the article how to use asynchronous requests http://ihormelnyk.com/opentherm_library Also, there is a tutorial on how to build/send any of OT commands using my OpenTherm Library

serhat-ozkara commented 3 years ago

Any progress on this? I would REALLY love to have my boiler working with PID on Opentherm. I don't know how commercial OT thermostats regulate but PID would be fine on boiler temp i guess. Currently on my setup, PID duty is handled on Node-RED and Tasmota with OT support. Unfortunately, tasmota thermostat implementation only works for on/off operation.

trueskalon commented 3 years ago

@serhat, you can use rsciriano OT integration for controlling heating water temp via call service node, so you can create some kind of "heating curve" (you will need outside temp reading).

Just curious - what do you what to regulate (and read) with PID valves controls and OT boiler ? you want to include reading of return temp? regulate temp of heating water / outside temp and room temp and include it in PID function?

serhat-ozkara commented 3 years ago

@trueskalon I use a bt sensor to read room temp & feed it to PID to change boiler's opentherm ot_boiler target temp. I then limit & map output of PID 0-100 to boiler temp to 30 - 55 range (which is economical, efficient). On/off control is inefficient as my boiler supports modulation of flame and on/off defeats that capability. I have to do this because boiler central heating water temp 30 does not mean room temperature will be 30 degrees...

Screen Shot 2021-03-14 at 17 29 25
rsciriano commented 3 years ago

Very interesting @serhat-ozkara!!!

I will have to incorporate PID to my code and convert the heating watter climate on an ambient temperature climate.

I have been doing some research and in this post by @ihormelnyk there is an implementation of a PID in C code. I have also located this library that looks good.

I am currently cannot spend time on this, I will keep you informed if I have any progress :-)

serhat-ozkara commented 3 years ago

@rsciriano You'll be surprised of the temp stability and comfort of my current setup. I'm providing a graph screenshot. But nodered adds another failure point. There's already a PID thermostat entity along with autotune function on ESPHome: https://esphome.io/components/climate/pid.html May be that can be utilized?

Screen Shot 2021-03-14 at 22 08 32
rsciriano commented 3 years ago

@serhat-ozkara Yes, PID Climate Component could be used :-)

In my code, the heatting watter climate should be replaced by a float out with the value of the PID

Let's see when I can dedicate some time to it. Also, I'm going to be away from home for a while so I can't test it :(

serhat-ozkara commented 3 years ago

@rsciriano I'd gladly test it out. :)

MSMikl commented 3 years ago

Hi,

I have issues (as I can see from usb logs) with connecting to HA of my esp when trying rsciriano HA integration via esphome dev.

I tried esp8226 - d1 mini pro v1 and nodemcu v0.9 - no luck, same behivoure.

I was flashing, earsing, new HA, few psu for powering, used caps on 3,3v and 5v rail and always got same result.

The esp is connected to my router I can do OTA updateds...

Any suggestions?

Thank you :)

esphome log: WARNING Initial connection failed. The ESP might not be connected to WiFi yet (Timeout while waiting for message response!). Re-Trying in 1 seconds

usb log:

ets Jan  8 2013,rst cause:2, boot mode:(3,6)

load 0x4010f000, len 3456, room 16 
tail 0
chksum 0x84
csum 0x84
va5432625
@cp:0
ld

Hi. I've got the same issue and I solved it. You should change pin numbers in component.h, because D1 mini lite and D1 mini have different pins. I use D1 mini and set input pin to 4 and output - to 5. And it only works if it can read OT data, so you will see complete log inly when plug ESP into the shield.

It works nice, but my boiler doesn't send return temereature and pressure, so I've removed them

rsciriano commented 3 years ago

Hi @serhat-ozkara, I've been working on integrating my code with PID Climate, and I've made progress :-)

You can see the code in my repo https://github.com/rsciriano/ESPHome-OpenTherm

I have tested by connecting it to Home Assistant (simulating a temperature sensor and without connection to the boiler) and it seems to work (though it needs more work)

Home Assistant Screenshot

serhat-ozkara commented 3 years ago

That's great news @rsciriano ! I can give it a try as i have another d1 mini lying around. Can you provide an example yml for esphome? I'm totally new to esphome.

rsciriano commented 3 years ago

@serhat-ozkara, in my repo you have an example yaml, for try it

If you have more questions, you can open an issue in my repo (to avoid making noise here).

Weissnix4711 commented 3 years ago

@serhat-ozkara I might suggest using weather compensation. Or even a combination of weather compensation + PID?

Your flow temperature should be calculated from the outside temperature using a weather compensation curve. On a warmer day you will not need to use a flow temperature as on a cooler day, therefore weather compensation should yield better results than PID alone.

For example, here (and the equation here) is a somewhat complex example of such a weather compensation curve (from Viessmann). vtsoll = boiler temperature, rtsoll = room temperature setpoint, at = outside temperature. Niv and nei are values used to modify the curve, though for the purpose of illustration they can be ignored. The first offsets the boiler temperature, and the second is used to modify the slope of the curve, such as for underfloor heating you'd want to use a "flatter" slope than for radiators.

Weissnix4711 commented 3 years ago

I should also mention me and rspaargaren had a conversation on discord a while ago. He managed to come up with this, sending messages via interrupts.

This is a step further towards an actual component as part of esphome. Following the contributing standards, any libraries should be re implemented if possible, and large(-ish) delays, such as that of sending an opentherm message synchronously, should be avoided. Sure, the custom component by @rsciriano does work, but what I am trying to say is it wouldn't get implemented as-is.

bartmarchand1 commented 3 years ago

any progress on this issue? would love to see this implemented in esphome. Right now, I'm using a diyless example with mqtt.

MSMikl commented 3 years ago

It works good. I don't use PID and calculate requiring temperature on my HA, not on ESP. Now I think, that MQTT is not so bad, because MQTT stores all parameters and sends them to ESP even after reboot. And in my current implementation parameters aren't saving on ESP, it uses default parameters after reboot

Chupaka commented 3 years ago

Now I think, that MQTT is not so bad, because MQTT stores all parameters and sends them to ESP even after reboot

Something like https://esphome.io/components/sensor/homeassistant.html ?

SergiiBuglak commented 2 years ago

@rsciriano Do you have plans on moving to async calls?

Weissnix4711 commented 2 years ago

Now I think, that MQTT is not so bad, because MQTT stores all parameters and sends them to ESP even after reboot. And in my current implementation parameters aren't saving on ESP, it uses default parameters after reboot

MQTT also has its issues.

Also, it is possible to store values in flash, so they can be restored after reboot. Even if there are network issues, the ESP should never lose track of these params/states. Btw a nice trick if any components don't explicitly support recovering flash, you can always use a combination of global variables and scripts which run at startup.

Something like https://esphome.io/components/sensor/homeassistant.html ?

@MSMikl was referring to MQTT's 'retain' functionality, where the MQTT broker (such as the MQTT addon for HASS) will remember the last state, and resend that state whenever any clients subscribe).

Weissnix4711 commented 2 years ago

any progress on this issue? would love to see this implemented in esphome. Right now, I'm using a diyless example with mqtt.

For an implementation to be accepted, it must followed some quite strict guidelines. The hardest to figure out is probably going to be timings. Something could probably be thrown together using timer interrupts, but I don't know shit about how those work, and I don't have the time to figure it out. Sadly, due to the nature of the protocol, using existing serial implementations and abstractions probably won't work.

I'd suggest you join the conversation on the discord if you aren't already.

omdathetkan commented 2 years ago

After some tinkering I am currently using ESPHome-OpenTherm, and it appears to be working great so far! I agree having this supported natively would reduce the barrier to entry. I have not bothered getting the MQTT solution to work, but I can't imagine it being less complicated than rsciriano's implementation.

Also: For those who where trying to replicate the DIYLESS setup with the D1 Mini ESP32 board, I needed to make this fix to esphome-flasher to get it to flash.

Mio3000 commented 1 year ago

Hi all, I would also add to this request also the OpenTherm Gateway, im using the one from DIYLESS using Wichers repo https://github.com/wichers/esphome-opentherm, i added some stuff to it, but i have no clue how to change values for the setpoints like max ch water setpoint, and also i would like to have also climate option for the DHW temperature.

tricker1234 commented 1 year ago

Hi group! Had someone an error during instalation?

"In file included from src/main.cpp:51:src/opentherm_component.h:3:10: fatal error: OpenTherm.h: No such file or directory"

I copied 0.5 version to config->esphome-> (there is opentherm.yaml and esphome-opentherm)

SebuZet commented 1 year ago

@serhat-ozkara I might suggest using weather compensation. Or even a combination of weather compensation + PID?

Your flow temperature should be calculated from the outside temperature using a weather compensation curve. On a warmer day you will not need to use a flow temperature as on a cooler day, therefore weather compensation should yield better results than PID alone.

For example, here (and the equation here) is a somewhat complex example of such a weather compensation curve (from Viessmann). vtsoll = boiler temperature, rtsoll = room temperature setpoint, at = outside temperature. Niv and nei are values used to modify the curve, though for the purpose of illustration they can be ignored. The first offsets the boiler temperature, and the second is used to modify the slope of the curve, such as for underfloor heating you'd want to use a "flatter" slope than for radiators.

@Weissnix4711 thanks for the formula. I used it to create a controller for my boiler and underfloor heating system. I didn't use it wih PID controller. Do you think those to approaches can be combined?

Weissnix4711 commented 1 year ago

@Weissnix4711 thanks for the formula. I used it to create a controller for my boiler and underfloor heating system. I didn't use it wih PID controller. Do you think those to approaches can be combined?

@SebuZet Yes, absolutely.

Using the example of Viessmann again (because that's what I know), they can run in 'witterungsgeführtem Betrieb mit Raumeinfluss'. Ie. Weather compensated mode with room influence.

All that does is take the difference between setpoint and actual room temp, and multiplies it by a factor. This is then added (or subtracted) to the flow temp.

If you want to get really technical, this is the exact logic they use:

vtsoll = vtsoll + ((rtsoll - rtist) * (1 + nei) * (refaktor / 4))

rtist - room temp actual value (ist means 'is' in German) refaktor - room influence (einfluss) factor. Default is 8.

The nei (slope) variable is just in there to make the setting feel more intuitive for any given curve. It doesn't really matter too much.

You'll notice this is literally just a P-only controller. I'm only posting the exact formula in case someone here has used Viessmann systems before, and might already have an intuition for what factor they need for their home. I'm not necessarily suggesting anyone implement this logic exactly.

However, what I've done is use a PI controller, where the input is the room temp error, and the output is summed with the output of the previous weather compensation logic. Similar to Viessmann's room influence logic. The derivative is a bit overkill and just another setting to mess with so I'd leave it. Importantly though, because this PID (or rather PI) controller is working in tandem with weather comp, its gonna be a lot more forgiving in configuration than if the entire system worked solely on PID.

Because of the very slow response time of the system, calibrating it and trying to prevent windup was/continues to be a pain. But hey. It does help driving away any constant error due to inaccuracies in outside temp measurement (I'm just using the hourly weather forecast, which ain't perfect) and makes the system heat up much quicker.

kmarek1 commented 11 months ago

@SebuZet

thanks for the formula. I used it to create a controller for my boiler and underfloor heating system. I didn't use it wih PID controller.

Could you please share your solution?

ananyevgv commented 6 months ago

https://github.com/FreeBear-nc/esphome-opentherm

ananyevgv commented 6 months ago

https://github.com/khenderick/esphome-opentherm