Skip to content

Bump zhong-hong-hvac to 1.0.15 and add gateway health availability to zhong_hong - #177945

Open
crhan wants to merge 4 commits into
home-assistant:devfrom
crhan:zhong-hong-hvac-1.0.14
Open

Bump zhong-hong-hvac to 1.0.15 and add gateway health availability to zhong_hong#177945
crhan wants to merge 4 commits into
home-assistant:devfrom
crhan:zhong-hong-hvac-1.0.14

Conversation

@crhan

@crhan crhan commented Aug 1, 2026

Copy link
Copy Markdown
Contributor

Breaking change

None.

Proposed change

The gateway connection in zhong-hong-hvac 1.0.13 can die silently: a status frame with an undefined fan speed value (0x00, observed after an indoor unit is switched off) crashes the library listener thread, and nothing restarts it. Entities then keep showing stale state forever with no health signal.

zhong-hong-hvac 1.0.15 fixes the library (tolerant parsing, listener self-healing, health probes, reconnect, and propagation of the send result through all control methods) and exposes ZhongHongGateway.connected / HVAC.connected. This PR:

  • pins zhong-hong-hvac to 1.0.15
  • polls every entity every 60 s so state self-heals even when the gateway stops pushing
  • marks entities unavailable when the gateway connection is unhealthy (via connected)
  • logs a warning when a control command cannot be sent
  • stops sending an invalid fan mode to the library when an unsupported value is requested

Type of change

  • Dependency upgrade
  • Bugfix (non-breaking change which fixes an issue)
  • New integration (thank you!)
  • New feature (which adds functionality to an existing integration)
  • Deprecation (breaking change to happen in the future)
  • Breaking change (fix/feature causing existing functionality to break)
  • Code quality improvements to existing code or addition of tests

Additional information

  • This PR fixes or closes issue: fixes #(none)
  • This PR is related to issue: none
  • Link to documentation pull request: none
  • Link to developer documentation pull request: none
  • Link to frontend pull request: none

Checklist

  • I understand the code I am submitting and can explain how it works.
  • The code change is tested and works locally.
  • Local tests pass. Your PR cannot be merged unless tests pass
  • There is no commented out code in this PR.
  • I have followed the development checklist
  • I have followed the perfect PR recommendations
  • The code has been formatted using Ruff (ruff format homeassistant tests)
  • Tests have been added to verify that the new code works.
  • Any generated code has been carefully reviewed for correctness and compliance with project standards.

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

  • Documentation added/updated for [www.home-assistant.io][docs-repository]

If the code communicates with devices, web services, or third-party tools:

If the code communicates with devices, web services, or third-party tools:

  • New or updated dependencies have been added to requirements_all.txt.
  • New or updated dependencies have been added to requirements_test_all.txt.

Copilot AI review requested due to automatic review settings August 1, 2026 11:27

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Updates ZhongHong climate entities to use gateway health reporting and periodic polling.

Changes:

  • Bumps zhong-hong-hvac to 1.0.14.
  • Adds 60-second polling and connection-based availability.
  • Adds command-failure logging and fan-mode validation.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
homeassistant/components/zhong_hong/manifest.json Updates the library dependency.
homeassistant/components/zhong_hong/climate.py Adds polling, availability, and command handling.
Suppressed comments (4)

homeassistant/components/zhong_hong/climate.py:251

  • Return the gateway send result from the library before checking turn_off(). The v1.0.14 HVAC.send() implementation returns None, making this warning unconditional after every turn-off command.
        if not self._device.turn_off():
            _LOGGER.warning("%s: failed to send turn-off command", self.entity_id)

homeassistant/components/zhong_hong/climate.py:260

  • Fix the library's command return propagation before checking set_temperature(). Version 1.0.14's HVAC.send() drops the boolean result, so this logs a failure for successful temperature commands too.
            if not self._device.set_temperature(temperature):
                _LOGGER.warning(
                    "%s: failed to send temperature command", self.entity_id
                )

homeassistant/components/zhong_hong/climate.py:277

  • Fix the library's command return propagation before checking set_operation_mode(). Because v1.0.14's HVAC.send() returns None, every mode command reaches this warning regardless of whether it was sent successfully.
        if not self._device.set_operation_mode(hvac_mode.upper()):
            _LOGGER.warning("%s: failed to send mode command", self.entity_id)

homeassistant/components/zhong_hong/climate.py:287

  • Fix the library's command return propagation before checking set_fan_mode(). The v1.0.14 HVAC.send() method discards gateway.send()'s bool, so this warns after successful fan commands as well.
        if not self._device.set_fan_mode(mapped_mode):
            _LOGGER.warning("%s: failed to send fan command", self.entity_id)

Comment on lines +244 to +245
if not self._device.turn_on():
_LOGGER.warning("%s: failed to send turn-on command", self.entity_id)
"loggers": ["zhong_hong_hvac"],
"quality_scale": "legacy",
"requirements": ["zhong-hong-hvac==1.0.13"]
"requirements": ["zhong-hong-hvac==1.0.14"]
"loggers": ["zhong_hong_hvac"],
"quality_scale": "legacy",
"requirements": ["zhong-hong-hvac==1.0.13"]
"requirements": ["zhong-hong-hvac==1.0.14"]
@crhan
crhan force-pushed the zhong-hong-hvac-1.0.14 branch from c2bcc01 to 46889e6 Compare August 1, 2026 11:46
Copilot AI review requested due to automatic review settings August 1, 2026 11:46
@crhan crhan changed the title Bump zhong-hong-hvac to 1.0.14 and add gateway health availability to zhong_hong Bump zhong-hong-hvac to 1.0.15 and add gateway health availability to zhong_hong Aug 1, 2026
@crhan

crhan commented Aug 1, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for the review. The Copilot comments are correct: in zhong-hong-hvac 1.0.14 HVAC.send() called gw.send() without returning its boolean, so the new failure warnings would have fired after every command. Fixed in the library (1.0.15 now propagates the send result through all control methods) and this PR now pins 1.0.15.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated no new comments.

Suppressed comments (2)

homeassistant/components/zhong_hong/climate.py:244

  • Restore the repository's complete PR template and correct its dependency details before merge. The current description omits the required Type of change, Additional information, and Checklist sections, and repeatedly says 1.0.14 even though the code pins 1.0.15; the control-method return propagation used here was also added only in 1.0.15.
        if not self._device.turn_on():
            _LOGGER.warning("%s: failed to send turn-on command", self.entity_id)

homeassistant/components/zhong_hong/climate.py:44

  • Split these functional integration changes into a separate PR and keep this dependency-upgrade PR limited to the manifest and generated requirement updates. The polling, availability, validation, and command-logging behavior is not required merely to bump the package version and must be reviewed independently.
SCAN_INTERVAL = timedelta(seconds=60)

Copilot AI review requested due to automatic review settings August 1, 2026 11:50

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated no new comments.

Suppressed comments (6)

homeassistant/components/zhong_hong/climate.py:250

  • Raise HomeAssistantError when the turn-off send fails. Logging and returning makes the climate service report success even though the library exhausted its send retries, so callers cannot detect the failed action.
        if not self._device.turn_off():
            _LOGGER.warning("%s: failed to send turn-off command", self.entity_id)

homeassistant/components/zhong_hong/climate.py:244

  • Raise HomeAssistantError when the turn-on send fails. Logging and returning makes the climate service report success even though the library exhausted its send retries, so callers cannot detect the failed action.
        if not self._device.turn_on():
            _LOGGER.warning("%s: failed to send turn-on command", self.entity_id)

homeassistant/components/zhong_hong/climate.py:259

  • Raise HomeAssistantError when the temperature send fails. Logging and continuing makes the service report success—and may proceed to change the HVAC mode—even though the requested temperature was not sent.
            if not self._device.set_temperature(temperature):
                _LOGGER.warning(
                    "%s: failed to send temperature command", self.entity_id
                )

homeassistant/components/zhong_hong/climate.py:276

  • Raise HomeAssistantError when the operation-mode send fails. Logging and returning makes the climate service report success after the library has reported that the command could not be sent.
        if not self._device.set_operation_mode(hvac_mode.upper()):
            _LOGGER.warning("%s: failed to send mode command", self.entity_id)

homeassistant/components/zhong_hong/climate.py:286

  • Raise HomeAssistantError when the fan-mode send fails. Logging and returning makes the climate service report success after the library has reported that the command could not be sent.
        if not self._device.set_fan_mode(mapped_mode):
            _LOGGER.warning("%s: failed to send fan command", self.entity_id)

homeassistant/components/zhong_hong/manifest.json:9

  • Update and complete the PR description before merge. The code pins 1.0.15, but the Summary and Testing sections still claim 1.0.14—even though 1.0.15 contains the send-result fix these new checks depend on—and the required Home Assistant PR-template sections and checklists are missing.
  "requirements": ["zhong-hong-hvac==1.0.15"]

@crhan
crhan force-pushed the zhong-hong-hvac-1.0.14 branch from f994aac to f04356f Compare August 1, 2026 14:46
Copilot AI review requested due to automatic review settings August 1, 2026 15:05
@crhan
crhan force-pushed the zhong-hong-hvac-1.0.14 branch from f04356f to 7a4d1a8 Compare August 1, 2026 15:05

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated no new comments.

Suppressed comments (2)

homeassistant/components/zhong_hong/manifest.json:9

  • Restore the full PR template and make its version references consistent with 1.0.15. The current description omits the required Proposed change, Type of change, Additional information, and Checklist sections, and still states that this pins/publishes 1.0.14 while the changed requirement is 1.0.15.
  "requirements": ["zhong-hong-hvac==1.0.15"]

homeassistant/components/zhong_hong/climate.py:188

  • Move the runtime behavior changes into a follow-up PR. This dependency upgrade also changes polling, availability, and command handling, so separating those changes keeps the package update independently reviewable and revertible.
    def update(self) -> None:

@crhan

crhan commented Aug 1, 2026

Copy link
Copy Markdown
Contributor Author

The only failing CI check (Run tests Python 3.14.5 (8)) is unrelated to this PR: tests/components/compit/test_binary_sensor.py::test_binary_sensor_entities_snapshot fails with KeyError: 224 in the compit test fixture (tests/components/compit/conftest.py:93), introduced by #174239. It reproduces on the dev base itself (our branch contains no compit changes). Upstream fix: #177894. I will rebase once that lands.

… zhong_hong

The gateway connection in zhong-hong-hvac 1.0.13 can die silently: a
status frame with an undefined fan speed value (0x00) crashes the
listener thread and nothing restarts it, so entities keep showing stale
state forever with no health signal.

zhong-hong-hvac 1.0.15 fixes the library (tolerant parsing, listener
self-healing, health probes, reconnect), propagates send results through
the HVAC control methods, and exposes ZhongHongGateway.connected /
HVAC.connected. This PR:

- pins zhong-hong-hvac to 1.0.15
- polls every entity every 60 s so state self-heals even when the
  gateway stops pushing
- marks entities unavailable when the gateway connection is unhealthy
- logs a warning when a control command cannot be sent
- stops sending an invalid fan mode to the library when an unsupported
  value is requested

Signed-off-by: ruohan.chen <crhan123@gmail.com>
Copilot AI review requested due to automatic review settings August 2, 2026 00:58
@crhan
crhan force-pushed the zhong-hong-hvac-1.0.14 branch from 7a4d1a8 to 35a922e Compare August 2, 2026 00:58

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated no new comments.

Suppressed comments (8)

homeassistant/components/zhong_hong/climate.py:244

  • Raise HomeAssistantError when the turn-on send fails. Logging and returning normally makes the climate service call report success even though the library returned False, so callers and automations cannot detect the failure.
        if not self._device.turn_on():
            _LOGGER.warning("%s: failed to send turn-on command", self.entity_id)

homeassistant/components/zhong_hong/climate.py:250

  • Raise HomeAssistantError when the turn-off send fails. A warning followed by a normal return reports this failed command as a successful climate service call.
        if not self._device.turn_off():
            _LOGGER.warning("%s: failed to send turn-off command", self.entity_id)

homeassistant/components/zhong_hong/climate.py:259

  • Raise HomeAssistantError when sending the temperature fails. Returning normally after the library reports False prevents the service caller from detecting that the target temperature was not sent.
            if not self._device.set_temperature(temperature):
                _LOGGER.warning(
                    "%s: failed to send temperature command", self.entity_id
                )

homeassistant/components/zhong_hong/climate.py:276

  • Raise HomeAssistantError when sending the HVAC mode fails. Logging alone causes the service call to complete successfully despite the mode command not being sent.
        if not self._device.set_operation_mode(hvac_mode.upper()):
            _LOGGER.warning("%s: failed to send mode command", self.entity_id)

homeassistant/components/zhong_hong/climate.py:286

  • Raise HomeAssistantError when sending the fan mode fails. This warning-only path reports success to the service caller even though the library explicitly returned False.
        if not self._device.set_fan_mode(mapped_mode):
            _LOGGER.warning("%s: failed to send fan command", self.entity_id)

homeassistant/components/zhong_hong/manifest.json:9

  • Restore the complete PR template in the description. The current Summary/Testing-only description omits the required Proposed change, Type of change, Additional information, Checklist, conditional dependency checklist, and review checklist sections and checkboxes.
  "requirements": ["zhong-hong-hvac==1.0.15"]

homeassistant/components/zhong_hong/manifest.json:9

  • Update the PR description to consistently identify version 1.0.15. It says both the pin and published/tested SDK are 1.0.14, but this manifest and requirements_all.txt install 1.0.15; the latter is material because only 1.0.15 propagates command send results.
  "requirements": ["zhong-hong-hvac==1.0.15"]

homeassistant/components/zhong_hong/manifest.json:9

  • Split the integration behavior changes into a separate PR. Dependency bump PRs must contain only files required for the version bump; keep the manifest and generated requirement update here and move the climate.py changes.
  "requirements": ["zhong-hong-hvac==1.0.15"]

@crhan

crhan commented Aug 2, 2026

Copy link
Copy Markdown
Contributor Author

Rebased onto current dev, which now contains #177894 (the compit test fixture fix). All 39 checks are green — the previously failing Run tests Python 3.14.5 (8) passes now.

The only remaining red mark is the required-labels status: it asks for one of breaking-change / bugfix / code-quality / dependency / deprecation / new-feature / new-integration. I've added the "Type of change" section to the description (Dependency upgrade + New feature), but the label itself hasn't been applied and I don't have permission to set labels here — a maintainer would need to add dependency.

Copilot AI review requested due to automatic review settings August 3, 2026 01:05

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated no new comments.

Suppressed comments (8)

homeassistant/components/zhong_hong/climate.py:244

  • Raise HomeAssistantError when the turn-on send fails instead of returning normally. Logging alone makes the climate action report success to the caller even though the library returned False; use a translatable action exception.
        if not self._device.turn_on():
            _LOGGER.warning("%s: failed to send turn-on command", self.entity_id)

homeassistant/components/zhong_hong/climate.py:197

  • Fix the upstream no-first-response health state before relying on connected here. In zhong-hong-hvac 1.0.15, connected returns True while _last_seen is None, and _maybe_probe() also returns without probing in that state, so a gateway that goes silent after discovery but before the listener receives its first frame remains available indefinitely with stale or empty state; update the library to time out/probe this state and bump to that release.
        return self._hub.connected

homeassistant/components/zhong_hong/climate.py:250

  • Raise HomeAssistantError when the turn-off send fails instead of returning normally. Logging alone makes the climate action report success to the caller even though the command was not sent; use a translatable action exception.
        if not self._device.turn_off():
            _LOGGER.warning("%s: failed to send turn-off command", self.entity_id)

homeassistant/components/zhong_hong/climate.py:259

  • Raise HomeAssistantError when the temperature send fails instead of returning normally. Otherwise the action reports success and may continue to change the HVAC mode after the requested temperature was not sent; use a translatable action exception.
            if not self._device.set_temperature(temperature):
                _LOGGER.warning(
                    "%s: failed to send temperature command", self.entity_id
                )

homeassistant/components/zhong_hong/climate.py:276

  • Raise HomeAssistantError when the operation-mode send fails instead of returning normally. Logging alone makes the climate action report success despite the failed command; use a translatable action exception.
        if not self._device.set_operation_mode(hvac_mode.upper()):
            _LOGGER.warning("%s: failed to send mode command", self.entity_id)

homeassistant/components/zhong_hong/climate.py:286

  • Raise HomeAssistantError when the fan-mode send fails instead of returning normally. Logging alone makes the climate action report success despite the failed command; use a translatable action exception.
        if not self._device.set_fan_mode(mapped_mode):
            _LOGGER.warning("%s: failed to send fan command", self.entity_id)

homeassistant/components/zhong_hong/climate.py:145

  • Split the behavioral changes into a separate PR and keep this dependency-upgrade PR limited to the version/generated requirement updates. Repository review policy requires dependency bumps not to include unrelated feature changes such as enabling polling and availability handling.
    _attr_should_poll = True

homeassistant/components/zhong_hong/manifest.json:9

  • Restore the complete repository PR template before review. The description replaces Proposed change with Summary, omits Additional information and the full checklist, and checks two change types even though the template requires exactly one.
  "requirements": ["zhong-hong-hvac==1.0.15"]

Copilot AI review requested due to automatic review settings August 3, 2026 02:07
@crhan

crhan commented Aug 3, 2026

Copy link
Copy Markdown
Contributor Author

Status update — all checks green except the two below:

  1. codecov/patch — fixed: I added a test suite for this integration (tests/components/zhong_hong/, 13 tests) covering the new polling, availability and command-failure paths. It was previously at 0% because zhong_hong had no tests at all. The PR description has also been restored to the full template.

  2. required-labels — this one needs a maintainer: the PR has no type label and I don't have permission to set labels. If a maintainer could add dependency (or bugfix), that check will pass. Everything else (CI, CLA, code-owner, docs) is green.

Thanks for the review!

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated no new comments.

Suppressed comments (2)

homeassistant/components/zhong_hong/climate.py:145

  • Split the behavioral changes into a separate bug-fix PR. Dependency-upgrade PRs may contain only changes required for the version bump, while enabling polling and adding availability/command handling are independent consumer behavior changes that should be reviewed separately.
    _attr_should_poll = True

homeassistant/components/zhong_hong/manifest.json:9

  • Restore the complete current PR template and select exactly one change type. The description uses an obsolete checklist, omits required items (including the dependency compare/changelog link and review-two-PRs checkbox), and checks both Dependency upgrade and Bugfix despite the template requiring one.
  "requirements": ["zhong-hong-hvac==1.0.15"]

@crhan

crhan commented Aug 3, 2026

Copy link
Copy Markdown
Contributor Author

All green now. The test suite I added brought codecov/patch to 100.00% of diff hit (was 0.00%). The previous run's Run tests Python 3.14.5 (5) failure was the known-flaky tests/test_bootstrap.py::test_tasks_logged_that_block_stage_2 (intermittent timing race, unrelated to this PR — reproduces on dev too; see #169424); a fresh run passed the full suite.

Remaining: only required-labels — the PR needs a maintainer to add a type label (dependency or bugfix). I don't have permission to set labels on this repo.

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.

2 participants