Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: Concurrent call to receive() is not allowed #60

Closed
mdkeil opened this issue Feb 8, 2023 · 11 comments · Fixed by #61
Closed

Error: Concurrent call to receive() is not allowed #60

mdkeil opened this issue Feb 8, 2023 · 11 comments · Fixed by #61

Comments

@mdkeil
Copy link

mdkeil commented Feb 8, 2023

I have some automations that often failes due to following same error messages for space heating and hot water tank Integration device.

Homeassistent 2023.2.2

  1. Space Heater
Logger: homeassistant.components.automation.wp_nachtabsenkung_off
Source: custom_components/daikin_altherma/number.py:177
Integration: Automatisierung (documentation, issues)
First occurred: 06:00:00 (2 occurrences)
Last logged: 06:00:00

WP_Nachtabsenkung_OFF: Error executing script. Unexpected error for device at pos 1: Concurrent call to receive() is not allowed
While executing automation automation.wp_nachtabsenkung_off
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 451, in _async_step
    await getattr(self, handler)()
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 692, in _async_device_step
    await device_action.async_call_action_from_config(
  File "/usr/src/homeassistant/homeassistant/components/device_automation/action.py", line 71, in async_call_action_from_config
    await platform.async_call_action_from_config(hass, config, variables, context)
  File "/usr/src/homeassistant/homeassistant/components/number/device_action.py", line 62, in async_call_action_from_config
    await hass.services.async_call(
  File "/usr/src/homeassistant/homeassistant/core.py", line 1787, in async_call
    task.result()
  File "/usr/src/homeassistant/homeassistant/core.py", line 1824, in _execute_service
    await cast(Callable[[ServiceCall], Awaitable[None]], handler.job.target)(
  File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 213, in handle_service
    await service.entity_service_call(
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 680, in entity_service_call
    future.result()  # pop exception if have
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 968, in async_request_call
    await coro
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 720, in _handle_entity_call
    await result
  File "/usr/src/homeassistant/homeassistant/components/number/__init__.py", line 96, in async_set_value
    await entity.async_set_native_value(native_value)
  File "/config/custom_components/daikin_altherma/number.py", line 177, in async_set_native_value
    await self._api.device.climate_control.call_operation(key, float(value))
  File "/usr/local/lib/python3.10/site-packages/pyaltherma/controllers.py", line 126, in call_operation
    return await self._connection.request(destination, payload=payload)
  File "/usr/local/lib/python3.10/site-packages/pyaltherma/comm.py", line 46, in request
    response_str = await self._client.receive_str(timeout=self._timeout)
  File "/usr/local/lib/python3.10/site-packages/aiohttp/client_ws.py", line 273, in receive_str
    msg = await self.receive(timeout)
  File "/usr/local/lib/python3.10/site-packages/aiohttp/client_ws.py", line 217, in receive
    raise RuntimeError("Concurrent call to receive() is not allowed")
RuntimeError: Concurrent call to receive() is not allowed
Dieser Fehler wurde von einer benutzerdefinierten Integration verursacht

Logger: custom_components.daikin_altherma
Source: custom_components/daikin_altherma/__init__.py:57
Integration: Daikin Altherma HVAC (documentation, issues)
First occurred: 05:30:00 (4 occurrences)
Last logged: 06:23:43

Bad logger message: Failed to update the device status with error Received message 8:1007 is not str ((TypeError('Received message 8:1007 is not str'),))
  1. Hot water tank
Logger: homeassistant.components.automation.wp_dhw_eco
Source: custom_components/daikin_altherma/water_heater.py:62
Integration: Automatisierung (documentation, issues)
First occurred: 05:30:00 (6 occurrences)
Last logged: 06:23:43

WP_DHW_ECO_werktags: Error executing script. Unexpected error for call_service at pos 1: Concurrent call to receive() is not allowed
While executing automation automation.wp_dhw_eco
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 451, in _async_step
    await getattr(self, handler)()
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 684, in _async_call_service_step
    await service_task
  File "/usr/src/homeassistant/homeassistant/core.py", line 1787, in async_call
    task.result()
  File "/usr/src/homeassistant/homeassistant/core.py", line 1824, in _execute_service
    await cast(Callable[[ServiceCall], Awaitable[None]], handler.job.target)(
  File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 213, in handle_service
    await service.entity_service_call(
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 680, in entity_service_call
    future.result()  # pop exception if have
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 968, in async_request_call
    await coro
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 720, in _handle_entity_call
    await result
  File "/usr/src/homeassistant/homeassistant/components/water_heater/__init__.py", line 370, in async_service_temperature_set
    await entity.async_set_temperature(**kwargs)
  File "/config/custom_components/daikin_altherma/water_heater.py", line 62, in async_set_temperature
    await device.set_domestic_hot_water_temperature_heating(target_temperature)
  File "/usr/local/lib/python3.10/site-packages/pyaltherma/controllers.py", line 231, in set_domestic_hot_water_temperature_heating
    await self.call_operation('DomesticHotWaterTemperatureHeating', value)
  File "/usr/local/lib/python3.10/site-packages/pyaltherma/controllers.py", line 126, in call_operation
    return await self._connection.request(destination, payload=payload)
  File "/usr/local/lib/python3.10/site-packages/pyaltherma/comm.py", line 46, in request
    response_str = await self._client.receive_str(timeout=self._timeout)
  File "/usr/local/lib/python3.10/site-packages/aiohttp/client_ws.py", line 273, in receive_str
    msg = await self.receive(timeout)
  File "/usr/local/lib/python3.10/site-packages/aiohttp/client_ws.py", line 217, in receive
    raise RuntimeError("Concurrent call to receive() is not allowed")
RuntimeError: Concurrent call to receive() is not allowed
@mdkeil
Copy link
Author

mdkeil commented Feb 8, 2023

automation example:

alias: WP_DHW_ECO_werktags
description: ""
trigger:
  - platform: time
    at: "05:30:00"
condition:
  - condition: time
    weekday:
      - mon
      - tue
      - wed
      - thu
      - fri
    after: "05:30:00"
action:
  - service: water_heater.set_temperature
    data:
      temperature: 32
    target:
      entity_id: water_heater.domestic_hot_water_tank
  - delay:
      hours: 0
      minutes: 0
      seconds: 15
      milliseconds: 0
    enabled: true
  - service: water_heater.set_operation_mode
    data:
      operation_mode: "on"
    target:
      entity_id: water_heater.domestic_hot_water_tank
    enabled: true
mode: single

@tadasdanielius
Copy link
Owner

Yes, this is known issue. The problem is that daikin gateway accepts only one connection and sometimes it happens when getting the data from the device and setting the data at the same time it throws that error. I just need to find a time to fix that as it requires some refactoring to be done. In the meantime as a workaround you can change how often the integration query the device for new changes. In order to do that you can go to /config/custom_components/daikin_altherma/const.py and change

UPDATE_INTERVAL_SECONDS = 2

To something like 10 seconds (and of course restart HA)

UPDATE_INTERVAL_SECONDS = 10

The drawback is that changes made on the device might take longer to appear on the HA.

You can look into this issue.

Keep in mind if you make a change and later reinstall/upgrade the integration the changes will be lost so you will need to update that again.

@mdkeil
Copy link
Author

mdkeil commented Feb 9, 2023

ok, I will try this workaround.

I have some new warning for further investigation:

Detected integration that called async_setup_platforms instead of awaiting async_forward_entry_setups; this will fail in version 2023.3. Please report issue to the custom integration author for daikin_altherma using this method at custom_components/daikin_altherma/__init__.py, line 81: hass.config_entries.async_setup_platforms(entry, PLATFORMS)

@tadasdanielius
Copy link
Owner

ok it looks like async_setup_platforms is going to be deprecated very soon. At the moment it shouldn't be a problem but thanks for pointing that out.

@mdkeil
Copy link
Author

mdkeil commented Feb 10, 2023

the workaround didn't work for me.. I parallel use espaltherma, that readout some registers every 10s.

Get some more error message with the same cause:

Dieser Fehler wurde von einer benutzerdefinierten Integration verursacht

Logger: custom_components.daikin_altherma
Source: custom_components/daikin_altherma/__init__.py:190
Integration: Daikin Altherma HVAC (documentation, issues)
First occurred: 06:00:00 (1 occurrences)
Last logged: 06:00:00

Something went wrong while updating data from the device
Traceback (most recent call last):
  File "/config/custom_components/daikin_altherma/__init__.py", line 190, in async_update
    self._status = await self.device.get_current_state()
  File "/usr/local/lib/python3.10/site-packages/pyaltherma/controllers.py", line 398, in get_current_state
    unit_status = await unit.get_current_state()
  File "/usr/local/lib/python3.10/site-packages/pyaltherma/controllers.py", line 129, in get_current_state
    sensors = await self.read_sensors()
  File "/usr/local/lib/python3.10/site-packages/pyaltherma/controllers.py", line 63, in read_sensors
    results[sensor] = await self.read_sensor(sensor)
  File "/usr/local/lib/python3.10/site-packages/pyaltherma/controllers.py", line 57, in read_sensor
    return await self.read(query_type='Sensor', prop=sensor)
  File "/usr/local/lib/python3.10/site-packages/pyaltherma/controllers.py", line 49, in read
    result = await self._connection.request(destination)
  File "/usr/local/lib/python3.10/site-packages/pyaltherma/comm.py", line 46, in request
    response_str = await self._client.receive_str(timeout=self._timeout)
  File "/usr/local/lib/python3.10/site-packages/aiohttp/client_ws.py", line 273, in receive_str
    msg = await self.receive(timeout)
  File "/usr/local/lib/python3.10/site-packages/aiohttp/client_ws.py", line 217, in receive
    raise RuntimeError("Concurrent call to receive() is not allowed")
RuntimeError: Concurrent call to receive() is not allowed

@mdkeil mdkeil changed the title Error messages space heater & hot water tank (automations) Error: Concurrent call to receive() is not allowed Feb 10, 2023
@Meatballs1
Copy link

Following, hit the same issue

@tadasdanielius
Copy link
Owner

tadasdanielius commented Feb 10, 2023

I looked at your automation maybe you should increase the delay between actions as well. Try 30 seconds or 1 minute. After change has been made the integration might try to refresh the current status which can take a while to query all parameters. ESPAltherma should not cause any problems

@mdkeil
Copy link
Author

mdkeil commented Feb 10, 2023

Will give this a try.. but the last error I get with following simple automation: (no further queries)

device_id = "Space Heating"

alias: WP_Nachtabsenkung_OFF
description: ""
trigger:
  - platform: time
    at: "06:00:00"
condition: []
action:
  - device_id: be7a5189fd8cdd68e59cad3ccd8f6b3e
    domain: number
    entity_id: number.temperature_control
    type: set_value
    value: 0
mode: single

@tadasdanielius
Copy link
Owner

I have created alpha release 1.3.9 which should address this problem. Haven't fully tested that but If you want you can try to install and test yourself. If you are using HACS you might want to switch "show beta releases" and redownload the repo.

@mdkeil
Copy link
Author

mdkeil commented Feb 10, 2023

I will try the alpha release and give feedback.

@mdkeil
Copy link
Author

mdkeil commented Feb 11, 2023

No more errors and my automations working as expected without changing the update interval. 💪🏻

This issue was closed.
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 a pull request may close this issue.

3 participants