fix(switch): drop await on sync async_schedule_update_ha_state#36
Open
daboynb wants to merge 1 commit into
Open
fix(switch): drop await on sync async_schedule_update_ha_state#36daboynb wants to merge 1 commit into
daboynb wants to merge 1 commit into
Conversation
async_schedule_update_ha_state is a @callback def in HA core (homeassistant/helpers/entity.py:1313-1314 on master) — sync, returns None. Awaiting it raises: TypeError: 'NoneType' object can't be awaited Two call sites in switch.py used `await`: - HisenseSwitch._async_schedule_update (line 272) - debounce-else branch (line 474) Removing the `await` matches callback semantics implied by the `async_schedule_*` name (fire-and-forget schedule, not coroutine). The state still propagates correctly because the callback schedules an HA write internally. Reproduces on HA 2024.11+: every AC switch state change outside the debounce window logs a TypeError traceback. After the patch the entity updates without error.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
awaitonself.async_schedule_update_ha_state(True)at two call sites inswitch.py(lines 272 and 474).async_schedule_update_ha_stateis a@callback defin HA core (homeassistant/helpers/entity.py:1313-1314) — sync, returnsNone. Awaiting it raisesTypeError: 'NoneType' object can't be awaited.awaitmatches the fire-and-forget semantics implied by theasync_schedule_*name. State still propagates correctly because the callback schedules an HA state write internally.Reproduction
On HA Container 2024.11+, every AC switch state change outside the debounce window logs:
The same pattern fires from line 272 when device state-change events arrive outside the debounce window.
Test plan
TypeError/NoneType awaitedtraceback in HA logs across multiple debounce-window-crossing actionsawaitDiff
(applied at both lines 272 and 474)