HomeAssistantPlugin icon indicating copy to clipboard operation
HomeAssistantPlugin copied to clipboard

Slow startup (5min websocket timeout) + TypeError in switch.py:474 with HA 2026.04

Open pifma opened this issue 7 months ago • 3 comments

Environment

  • Home Assistant version: 2026.04
  • Integration version: v1.0.0 (via HACS)
  • Python version: 3.14
  • Hardware: Raspberry Pi (Home Assistant OS)
  • Devices: 5x Hisense split AC (model 009-199), managed via ConnectLife

Bug 1: Websocket blocks HA startup for 5 minutes

During Home Assistant startup, HisenseWebSocket._connect_ws() hangs and causes a 5-minute timeout before HA can proceed. This blocks ALL other integrations from completing setup.

Log: 2026-04-06 18:50:39.442 WARNING (MainThread) [homeassistant.bootstrap] Setup timed out for bootstrap waiting on {<Task pending name='Task-604' coro=<HisenseWebSocket._connect_ws() running at /config/custom_components/hisense_ac_plugin/websocket.py:119> wait_for= cb=[set.remove()]>} - moving forward

Expected behavior: The websocket connection should either complete quickly or fail gracefully without blocking HA startup. Consider using hass.async_create_background_task() instead of blocking the setup phase.

Bug 2: TypeError in switch.py line 474 (15 occurrences per boot)

After startup, multiple TypeError: 'NoneType' object can't be awaited errors are logged from switch.py:474. With 5 AC units × 3 switches each, this generates 15 errors per boot.

Log: 2026-04-06 18:45:21.509 ERROR (SyncWorker_5) [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

Expected behavior: _async_schedule_update should check if async_schedule_update_ha_state returns a valid awaitable before awaiting it, or handle the None case gracefully.

Additional warnings (non-blocking)

The integration also logs these warnings for each device, which is expected behavior but worth noting: WARNING [custom_components.hisense_ac_plugin.number] No supported numbers found WARNING [custom_components.hisense_ac_plugin.water_heater] Skipping unsupported device: 009-199 (...) WARNING [custom_components.hisense_ac_plugin.humidifier] Skipping unsupported device: 009-199 (...)

These are just informational (009-199 are AC units, not water heaters/humidifiers), but could be silenced to keep logs clean.

pifma avatar Apr 06 '26 17:04 pifma

I have the same behavior on my system. HA startup went from seconds to five minutes, at which point the sockets timeout. If I disable the integration before restarting it goes back and reenabling it creates a similar error trace:

Image

bsantelicesm avatar Apr 10 '26 03:04 bsantelicesm

Bug 2 is fixed just by removing the await keyword on line 474. I have generated pull request #30 with this fix.

bsantelicesm avatar Apr 21 '26 03:04 bsantelicesm

Generated PR #31 to rebuild connection functions to prevent blocking of startup routines.

bsantelicesm avatar Apr 21 '26 04:04 bsantelicesm

Any update on this problem? I got hit with this and had to remove it due to the painfully slow and long restart times.

antisane avatar Jun 21 '26 07:06 antisane

There appears to be very little activity on this repo. I have merged the main branch of my own repository so that both bugs are fixed.

bsantelicesm avatar Jun 22 '26 02:06 bsantelicesm