Home Assistant 2024.5 async_write_ha_state errors
Closed this issue · 2 comments
AlexMKX commented
When calling xiaomi miot services getting following errors:
RuntimeError: Detected that custom integration 'xiaomi_miot' calls async_write_ha_state from a thread at custom_components/xiaomi_miot/__init__.py, line 1924: self.async_write_ha_state(). Please report it to the author of the 'xiaomi_miot' custom integration.
2024-04-28 08:47:00.650 ERROR (MainThread) [homeassistant.components.automation.kabinet_auto_fan] While executing automation automation.kabinet_auto_fan
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/components/automation/__init__.py", line 723, in async_trigger
return await self.action_script.async_run(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 1727, in async_run
return await asyncio.shield(create_eager_task(run.async_run()))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 451, in async_run
await self._async_step(log_exceptions=False)
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 503, in _async_step
self._handle_exception(
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 533, in _handle_exception
raise exception
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 501, in _async_step
await getattr(self, handler)()
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 736, in _async_call_service_step
response_data = await self._async_run_long_action(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 699, in _async_run_long_action
return await long_task
^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/core.py", line 2705, in async_call
response_data = await coro
^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/core.py", line 2746, in _execute_service
return await target(service_call)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 975, in entity_service_call
single_response = await _handle_entity_call(
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 1047, in _handle_entity_call
result = await task
^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/fan/__init__.py", line 242, in async_set_percentage
await self.hass.async_add_executor_job(self.set_percentage, percentage)
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/xiaomi_miot/fan.py", line 230, in set_percentage
return self.turn_on(percentage=percentage)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/config/custom_components/xiaomi_miot/fan.py", line 150, in turn_on
ret = self.set_property(self._prop_percentage, percentage)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/config/custom_components/xiaomi_miot/__init__.py", line 1860, in set_property
result = self.set_miot_property(siid, piid, value)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/config/custom_components/xiaomi_miot/__init__.py", line 1924, in set_miot_property
self.async_write_ha_state()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1008, in async_write_ha_state
self.hass.verify_event_loop_thread("async_write_ha_state")
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 'xiaomi_miot' calls async_write_ha_state from a thread at custom_components/xiaomi_miot/__init__.py, line 1924: self.async_write_ha_state(). Please report it to the author of the 'xiaomi_miot' custom integration.
al-one commented
Fixed in master branch.
AlexMKX commented
Thank you guys. Your'e blazingly fast!