Skip to content

Fix TypeError in switch.py: async_schedule_update_ha_state must not be awaited - #42

Open
proscar87 wants to merge 1 commit into
Connectlife-LLC:mainfrom
proscar87:fix/switch-incorrect-await
Open

Fix TypeError in switch.py: async_schedule_update_ha_state must not be awaited#42
proscar87 wants to merge 1 commit into
Connectlife-LLC:mainfrom
proscar87:fix/switch-incorrect-await

Conversation

@proscar87

Copy link
Copy Markdown

Summary

Fixes #14, #16, and Bug 2 of #28 — the same one-line defect reported three times:

TypeError: object NoneType can't be used in 'await' expression
  custom_components/hisense_ac_plugin/switch.py:474

async_schedule_update_ha_state() is a callback that returns None; awaiting it raises on every scheduled update.

Credit

This is @bsantelicesm's fix, cherry-picked with authorship preserved from their fork (see their comment in #28 — the fixes were sitting there since June without a PR). I'm just upstreaming it so everyone gets it via HACS.

Runs live on my 7-AC ConnectLife household.

🤖 Upstreamed with Claude Code

The await command on line 474 in switch.py is incorrect, the called function is not a coroutine.

(cherry picked from commit 9979bea)
@bsantelicesm

Copy link
Copy Markdown

Hey! Thanks for the shout-out! I forked it because this repo seems dead, I thought I had pushed PRs #30 and #31 but to be perfectly honest I'm pretty new to open-source and I might have messed it up. My copy of the repo just makes the fixed code available for anyone if they need it. If it's active again, I'll make sure to clean everything up in case I messed it up.

@proscar87

Copy link
Copy Markdown
Author

Good news first: you didn't mess anything up. #30 and #31 are correctly filed and still open, exactly where they should be — you can see them in the PR list right alongside mine. Nothing to clean up.

The silence isn't yours. The repo's last push is July 2025, and there are eight open PRs from five different people, none answered. Your fork was a reasonable response to that.

And I owe you a correction on my own PRs: #30 and #31 are the same two fixes as my #42 and #43, and yours came four months earlier. I found the await bug and the blocking-websocket bug independently and opened mine on 4 August without spotting that you'd already filed both in April — I only found your fork afterwards, which is what prompted the shout-out. That's on me for not checking the open PRs first.

So for whoever eventually looks at this repo: #30 and #31 have priority. If a maintainer shows up, they should take yours and close mine as duplicates. I'll leave mine open only because more visible reports may help wake the repo up, not because they're the ones worth merging.

If they stay unanswered, your fork is genuinely useful to people hitting these bugs — that await one breaks switches outright.

@bsantelicesm

Copy link
Copy Markdown

That's excellent news, thank you!

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.

TypeError in switch.py during reload: object NoneType can't be used in 'await' expression

2 participants