MartinPham / ring-integration-modified

35 stars 0 forks source link

Unexpected exception - calls async_write_ha_state from a thread - self.async_write_ha_state() #8

Open serlinGi opened 4 months ago

serlinGi commented 4 months ago

Hi, I've been using the Ring Intercom device, without problems until April; I can also open the gate without receiving a knock, wich is not possible from the Ring App!!!

now, after update HA 2024.5.0, I receive in Logs this warning:

Detected that custom integration 'ring_martinpham' calls async_write_ha_state from a thread at custom_components/ring_martinpham/number.py, line 119: self.async_write_ha_state(), please report it to the author of the 'ring_martinpham' custom integration

and this ERROR:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 239, in handle_call_service
    response = await hass.services.async_call(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/core.py", line 2738, in async_call
    response_data = await coro
                    ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/core.py", line 2779, 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/number/__init__.py", line 116, in async_set_value
    await entity.async_set_native_value(native_value)
  File "/usr/src/homeassistant/homeassistant/components/number/__init__.py", line 405, in async_set_native_value
    await self.hass.async_add_executor_job(self.set_native_value, value)
  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/ring_martinpham/number.py", line 119, in set_native_value
    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 'ring_martinpham' calls async_write_ha_state from a thread at custom_components/ring_martinpham/number.py, line 119: self.async_write_ha_state(). Please report it to the author of the 'ring_martinpham' custom integration.

Do, I've to fix something or we waiting for your update?

Thanks for all your work

serlinGi commented 4 months ago

opsss... I forgot: this appends when I adjust the ringer or microphone volumes :)

MartinPham commented 4 months ago

thanks, i will look into it