Run interface poll on the event loop (fix async_dispatcher_send off-thread)

The interface-status poll was registered as a plain lambda, so
async_track_time_interval ran it in an executor thread, where its
_push_state()->async_dispatcher_send() call tripped HA's thread-safety guard.

Make refresh_interface_status a @callback (it only reads fast in-memory
interface attributes) and pass it to async_track_time_interval directly.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
claude
2026-07-22 19:19:21 +03:00
parent 66b5d4a64a
commit 3be19028b1
3 changed files with 10 additions and 5 deletions

View File

@@ -114,10 +114,12 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
await _safe_announce(manager)
_schedule_periodic(hass, entry, runtime)
# Poll interface status.
# Poll interface status. refresh_interface_status is a @callback, so pass it
# directly (a lambda would be a plain sync job and get run in an executor
# thread, where its async_dispatcher_send call is not thread-safe).
runtime.unsubs.append(
async_track_time_interval(
hass, lambda _now: manager.refresh_interface_status(), INTERFACE_POLL
hass, manager.refresh_interface_status, INTERFACE_POLL
)
)