Skip to content

ESPHome DHW active fix#139

Merged
Alexwijn merged 3 commits into
Alexwijn:developfrom
adipierro:develop
Jan 9, 2026
Merged

ESPHome DHW active fix#139
Alexwijn merged 3 commits into
Alexwijn:developfrom
adipierro:develop

Conversation

@adipierro
Copy link
Copy Markdown
Contributor

@adipierro adipierro commented Jan 7, 2026

Currently, ESPHome-based OpenTherm gateways' data on DHW usage is not working correctly; dhw_on is a toggle switch for DHW, but not the binary_sensor.

I've added dhw_active sensor for example ESPHome configuration and changed data retrieval logic in ESPHome part of the component so that it could understand that the boiler is "stuck on" due to making domestic hot water.

I've also added initial values for ESPHome configuration for t_set (both CH and DHW), as some boilers (like Baxi with Bertelli main board) exhibit undefined behavior if they receive zeroes during writing of these parameters, like heating water until bimetallic failsafe thermostat triggers at 115°C and stops gas flow in almost-a-disaster-scenario.

Summary by CodeRabbit

  • New Features
    • Added default initial values for OpenTherm DHW and heating temperature setpoints in ESPHome configuration.
    • Introduced a new DHW activity sensor to indicate when the domestic hot water system is active.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jan 7, 2026

Walkthrough

Updates add two initial_value settings and a new binary_sensor.dhw_active example to ESPHome OpenTherm docs, and introduce a new DATA_DHW_ACTIVE constant in the Python integration while switching DHW and flame entity lookups to the binary_sensor domain.

Changes

Cohort / File(s) Summary
Documentation: OpenTherm configuration
README.md
Added initial_value: 45 for number.t_dhw_set and initial_value: 10 for number.t_set; added example binary_sensor.dhw_active under the OpenTherm platform.
Code: DHW / flame entity tracking
custom_components/sat/esphome/__init__.py
Added constant DATA_DHW_ACTIVE = "dhw_active"; hot_water_active now reads from DATA_DHW_ACTIVE in binary_sensor domain instead of prior DATA_DHW_ENABLE; entity retrieval in async_added_to_hass updated to use binary_sensor for DHW and flame active entities.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'ESPHome DHW active fix' directly addresses the main objective of the PR, which is fixing DHW active sensor detection and exposure in the ESPHome component.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

📜 Recent review details

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a590150 and 6ae78b4.

📒 Files selected for processing (1)
  • custom_components/sat/esphome/__init__.py
🧰 Additional context used
🧬 Code graph analysis (1)
custom_components/sat/esphome/__init__.py (2)
custom_components/sat/serial/__init__.py (1)
  • get (156-158)
custom_components/sat/coordinator.py (3)
  • get (546-561)
  • DeviceState (30-32)
  • _get_entity_id (564-565)
🔇 Additional comments (3)
custom_components/sat/esphome/__init__.py (3)

18-18: LGTM! New constant follows naming conventions.

The new DATA_DHW_ACTIVE constant is well-named and consistent with other data constants in the file.


87-88: Excellent fix! Correctly distinguishes DHW state from DHW command.

The change from DATA_DHW_ENABLE (user control switch) to DATA_DHW_ACTIVE (actual boiler state binary sensor) properly detects when the boiler is actively producing domestic hot water, which aligns with the PR objective to detect when the boiler is "stuck on" for DHW production.


143-144: LGTM! Entity tracking correctly aligned with property domains.

Both changes are correct:

  • Line 143 fixes a pre-existing bug: flame_active property (line 84) reads from binary_sensor.DOMAIN, so tracking must use the same domain to receive state change events.
  • Line 144 correctly tracks DATA_DHW_ACTIVE from binary_sensor.DOMAIN, matching the hot_water_active property (line 88).

This resolves the critical issue flagged in the previous review.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
custom_components/sat/esphome/__init__.py (1)

1-1: Remove duplicate annotations import.

The annotations feature is imported twice in the same statement, which is redundant.

🔧 Proposed fix
-from __future__ import annotations, annotations
+from __future__ import annotations
🤖 Fix all issues with AI agents
In @custom_components/sat/esphome/__init__.py:
- Line 144: The code is tracking DATA_DHW_ACTIVE using switch.DOMAIN but
hot_water_active reads it from binary_sensor.DOMAIN; update the entity tracking
call that references DATA_DHW_ACTIVE (the call to self._get_entity_id) to use
binary_sensor.DOMAIN instead of switch.DOMAIN so the coordinator listens for
binary_sensor state changes for dhw_active and matches the hot_water_active
property.
📜 Review details

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e76591b and a590150.

📒 Files selected for processing (2)
  • README.md
  • custom_components/sat/esphome/__init__.py
🧰 Additional context used
🧬 Code graph analysis (1)
custom_components/sat/esphome/__init__.py (2)
custom_components/sat/coordinator.py (3)
  • get (546-561)
  • DeviceState (30-32)
  • _get_entity_id (564-565)
custom_components/sat/serial/__init__.py (1)
  • get (156-158)
🔇 Additional comments (4)
custom_components/sat/esphome/__init__.py (2)

18-18: LGTM!

The new constant DATA_DHW_ACTIVE follows the established naming convention and aligns with the PR's objective to add DHW active sensor tracking.


87-88: LGTM!

The property now correctly reads DHW active status from a binary sensor instead of the DHW enable switch. This properly distinguishes between the user-controlled enable/disable switch and the actual DHW activity state reported by the boiler.

README.md (2)

118-122: LGTM!

The addition of initial_value parameters for both DHW and central heating setpoints addresses the PR's objective to prevent undefined behavior on certain boiler models. The default values (45°C for DHW, 10°C for CH) are safe and reasonable starting points.


158-159: LGTM!

The documentation correctly adds the dhw_active binary sensor to the ESPHome configuration example, enabling users to expose the DHW active status to the SAT component.

Comment thread custom_components/sat/esphome/__init__.py Outdated
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
custom_components/sat/esphome/__init__.py (1)

1-1: Critical syntax error: duplicate import.

The annotations module is imported twice in the same statement. This will cause a syntax error.

🐛 Proposed fix
-from __future__ import annotations, annotations
+from __future__ import annotations
📜 Review details

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a590150 and 6ae78b4.

📒 Files selected for processing (1)
  • custom_components/sat/esphome/__init__.py
🧰 Additional context used
🧬 Code graph analysis (1)
custom_components/sat/esphome/__init__.py (2)
custom_components/sat/serial/__init__.py (1)
  • get (156-158)
custom_components/sat/coordinator.py (3)
  • get (546-561)
  • DeviceState (30-32)
  • _get_entity_id (564-565)
🔇 Additional comments (3)
custom_components/sat/esphome/__init__.py (3)

18-18: LGTM! New constant follows naming conventions.

The new DATA_DHW_ACTIVE constant is well-named and consistent with other data constants in the file.


87-88: Excellent fix! Correctly distinguishes DHW state from DHW command.

The change from DATA_DHW_ENABLE (user control switch) to DATA_DHW_ACTIVE (actual boiler state binary sensor) properly detects when the boiler is actively producing domestic hot water, which aligns with the PR objective to detect when the boiler is "stuck on" for DHW production.


143-144: LGTM! Entity tracking correctly aligned with property domains.

Both changes are correct:

  • Line 143 fixes a pre-existing bug: flame_active property (line 84) reads from binary_sensor.DOMAIN, so tracking must use the same domain to receive state change events.
  • Line 144 correctly tracks DATA_DHW_ACTIVE from binary_sensor.DOMAIN, matching the hot_water_active property (line 88).

This resolves the critical issue flagged in the previous review.

@Alexwijn Alexwijn self-requested a review January 9, 2026 11:55
@Alexwijn
Copy link
Copy Markdown
Owner

Alexwijn commented Jan 9, 2026

Thanks!

@Alexwijn Alexwijn merged commit e4db6ce into Alexwijn:develop Jan 9, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants