HomeAssistantPlugin
HomeAssistantPlugin copied to clipboard
fix(switch): drop await on sync async_schedule_update_ha_state
Summary
- Remove erroneous
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.- Removing
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:
ERROR (SyncWorker_N) [homeassistant] Error doing job: Task exception was never retrieved (task: None)
Traceback (most recent call last):
File "/config/custom_components/hisense_ac_plugin/switch.py", line 474, in _async_schedule_update
await self.async_schedule_update_ha_state(True)
TypeError: 'NoneType' object can't be awaited
The same pattern fires from line 272 when device state-change events arrive outside the debounce window.
Test plan
- [x] Applied to a live HA Container (2025.x, Python 3.14), restarted HA
- [x] AC switch entities still update state correctly on action and on incoming device events
- [x] No
TypeError/NoneType awaitedtraceback in HA logs across multiple debounce-window-crossing actions - [x] Diff is 2 lines, behavior change limited to removing the erroneous
await
Diff
- await self.async_schedule_update_ha_state(True)
+ self.async_schedule_update_ha_state(True)
(applied at both lines 272 and 474)