homeassistant-truenas
homeassistant-truenas copied to clipboard
[Bug] HA 2024.5.0b0 - Integration fails to update entities
Describe the issue
Integration fails to update entities.
How to reproduce the issue
Setup integration and wait for an update coordinator call.
Expected behavior
No errors when updating entities.
Screenshots
Software versions
- Home Assistant version: 2024.5.0b0
- TrueNAS integration version: 1.3beta
- TrueNAS version: 23.10.x (Bluefin)
Diagnostics data
Traceback/Error logs
2024-04-25 07:04:26.367 ERROR (MainThread) [custom_components.truenas.coordinator] Unexpected error fetching TrueNAS data
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 315, in _async_refresh
self.data = await self._async_update_data()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/config/custom_components/truenas/coordinator.py", line 102, in _async_update_data
await self.hass.async_add_executor_job(self.get_dataset)
File "/usr/local/lib/python3.12/concurrent/futures/thread.py", line 58, in run
result = self.fn(*self.args, **self.kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/config/custom_components/truenas/coordinator.py", line 899, in get_dataset
entity_registry.async_remove(entity_id)
File "/usr/src/homeassistant/homeassistant/helpers/entity_registry.py", line 908, in async_remove
self.hass.bus.async_fire(
File "/usr/src/homeassistant/homeassistant/core.py", line 1475, in async_fire
self._hass.verify_event_loop_thread("async_fire")
File "/usr/src/homeassistant/homeassistant/core.py", line 440, in verify_event_loop_thread
frame.report(
File "/usr/src/homeassistant/homeassistant/helpers/frame.py", line 162, in report
_report_integration(what, integration_frame, level, error_if_integration)
File "/usr/src/homeassistant/homeassistant/helpers/frame.py", line 203, in _report_integration
raise RuntimeError(
RuntimeError: Detected that custom integration 'truenas' calls async_fire from a thread at custom_components/truenas/coordinator.py, line 899: entity_registry.async_remove(entity_id). Please report it to the author of the 'truenas' custom integration.
Additional context
https://github.com/tomaae/homeassistant-truenas/blob/4234ed7cfeefc793a054318e882f7fd1e141e529/custom_components/truenas/coordinator.py#L899
Should use the following call:
self.hass.async_create_task(entity_registry.async_remove(entity_id))