Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add OpenTherm component #6645

Open
wants to merge 11 commits into
base: dev
Choose a base branch
from

Conversation

olegtarasov
Copy link
Contributor

@olegtarasov olegtarasov commented Apr 26, 2024

What does this implement/fix?

This PR adds a new component that allows ESPHome to communicate with OpenTherm devices via a hardware bridge.

OpenTherm (OT) is a standard communications protocol used in central heating systems for the communication between a central heating appliances and a thermostatic controller.

EDIT: Right after finishing all the work of fixing linter errors, I saw a small “integration: opentherm“ label and discovered another open pull request: #3921 😂

I would still argue for my implementation (which is based on Arthur Rump's work here: https://github.com/arthurrump/esphome-opentherm) for the following reasons:

  1. I replaced Ihor Melnik's underlying OpenTherm communication library with code based on Jiří Praus' implementation (https://github.com/jpraus/arduino-opentherm). I would argue that it's conceptually more robust, since it uses hardware timers to sample OpenTherm signal levels, and thus doesn't rely on measuring the amount of milliseconds passed from a previous event. It's also more stable because some timer samples can be safely lost and message would still be correctly decoded, as opposed to Ihor Melnik's implementation, where loss of a single interrupt signal leads to OpenTherm message getting decoded incorrectly. This proved to be an issue when sharing a single ESP device between OpenTherm component and Dallas temperature sensors. And as a final argument, my implementation allows fine-grained protocol debugging, where faulty frames can be logged with precision of a single incorrect bit.
  2. Arthur Rump's implementation generates C++ code dynamically, so if some OpenTherm sensors are not used (and most of them are not used, since most boilers don't support the full set of sensors), the code for their handling is simply not generated.

Types of changes

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Other

Pull request in esphome-docs with documentation (if applicable): esphome/esphome-docs#3800

Test Environment

  • ESP32
  • ESP32 IDF
  • ESP8266
  • RP2040
  • BK72xx
  • RTL87xx

Example entry for config.yaml:

# An extremely minimal configuration which only enables you to set the boiler's
# water temperature setpoint as a number.

esphome:
  name: thermostat-number-minimal

esp8266:
  board: d1_mini

opentherm:
  in_pin: 21
  out_pin: 26

number:
  - platform: opentherm
    t_set:
      name: "Boiler Control setpoint"

Checklist:

  • The code change is tested and works locally.
  • Tests have been added to verify that the new code works (under tests/ folder).

If user exposed functionality or configuration variables are added/changed:

@probot-esphome
Copy link

Hey there @olegtarasov,
Thanks for submitting this pull request! Can you add yourself as a codeowner for this integration? This way we can notify you if a bug report for this integration is reported.
In __init__.py of the integration, please add:

CODEOWNERS = ["@olegtarasov"]

And run script/build_codeowners.py

(message by NeedsCodeownersLabel)

@codecov-commenter
Copy link

codecov-commenter commented Apr 26, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 54.13%. Comparing base (4d8b5ed) to head (3c77d11).
Report is 626 commits behind head on dev.

Additional details and impacted files
@@            Coverage Diff             @@
##              dev    #6645      +/-   ##
==========================================
+ Coverage   53.70%   54.13%   +0.42%     
==========================================
  Files          50       50              
  Lines        9408     9619     +211     
  Branches     1654     1698      +44     
==========================================
+ Hits         5053     5207     +154     
- Misses       4056     4086      +30     
- Partials      299      326      +27     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

olegtarasov added a commit to olegtarasov/esphome-opentherm that referenced this pull request Apr 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants