ZHA communication to Aqara E1 Thermostat does not work from Script, and some other strange things

I need you help getting ZHA integration with Aqara E1 Thermostat working.
HW:

  • Sonoff USB dongle P version
  • Aqara E1 Thermostat

integration is done via ZHA

the Thermostat card on the dashboard works (almost) fine, I can change temperature ther, but… I cannot put thermostat into “Off” state. Pressing “Off” sign on the card - entire entity goes into “off” state, but if I look on the thermostat itself - it still shows latest temperature and heating state.
Log shows nothing about it - it looks like system sees this “works as expected”.
Now I am trying to write the script, which changes the temperature by +0.5 or +1 degree.
After studying all logs and chatting with some friends, who have this script working on their side, I have come to the conclusion that something is not right.
The script is not really executed and finishes on timeout. I’ve tried to execute is calling by Entity ID, or by Device ID -the result is identical - timeout with no impact in the Thermostat settings. Likely in this case there is something in the log.
Script:

alias: Room - temperature up
icon: mdi:thermometer-plus
sequence:
  - service: climate.set_temperature
    data:
      hvac_mode: heat
      temperature: >-
        {{ state_attr('climate.lumi_lumi_airrtc_agl001_thermostat', 
        'temperature') | float | round(1) + 0.5 }}
    target:
      entity_id: climate.lumi_lumi_airrtc_agl001_thermostat
mode: single

Trace shows that Script works (it has increased temperature by 0.5 degree as it is deined in the script.
I’ve tried to increase by 1 degree - the same results.

Executed: December 18, 2022 at 8:34:10 PM
Result:
params:
  domain: climate
  service: set_temperature
  service_data:
    hvac_mode: heat
    temperature: 19.5
    entity_id:
      - climate.lumi_lumi_airrtc_agl001_thermostat
  target:
    entity_id:
      - climate.lumi_lumi_airrtc_agl001_thermostat
running_script: false
limit: 10

log:

Logger: homeassistant.core
Source: components/zha/core/channels/hvac.py:301
First occurred: 12:05:29 AM (17 occurrences)
Last logged: 8:34:41 PM

Error executing service: <ServiceCall climate.set_temperature (c:01GMJN8YTT98RBC7JFKBD75X43): hvac_mode=heat, temperature=15.0, area_id=['living_room'], device_id=['*<here the device number>*']>
Error executing service: <ServiceCall climate.set_temperature (c:01GMJNGVZ9B8WEXQNTVQAR8PB8): hvac_mode=heat, temperature=15.0, area_id=['living_room'], device_id=['*<here the device number>*']>
Error executing service: <ServiceCall climate.set_temperature (c:01GMKA9DYBSM2Q0ET8TGE7T4SA): hvac_mode=heat, temperature=20.0, entity_id=['climate.lumi_lumi_airrtc_agl001_thermostat']>
Error executing service: <ServiceCall climate.set_temperature (c:01GMKAQAQPKWQF8MSJV1MPTHAY): hvac_mode=heat, temperature=20.0, entity_id=['climate.lumi_lumi_airrtc_agl001_thermostat']>
Error executing service: <ServiceCall climate.set_temperature (c:01GMKBNF2WKVBBHNECFEP26PYX): hvac_mode=heat, temperature=19.5, entity_id=['climate.lumi_lumi_airrtc_agl001_thermostat']>
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/asyncio/tasks.py", line 456, in wait_for
    return fut.result()
asyncio.exceptions.CancelledError

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/core.py", line 1763, in catch_exceptions
    await coro_or_task
  File "/usr/src/homeassistant/homeassistant/core.py", line 1782, 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 678, in entity_service_call
    future.result()  # pop exception if have
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 943, in async_request_call
    await coro
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 715, in _handle_entity_call
    await result
  File "/usr/src/homeassistant/homeassistant/components/climate/__init__.py", line 613, in async_service_temperature_set
    await entity.async_set_temperature(**kwargs)
  File "/usr/src/homeassistant/homeassistant/components/zha/climate.py", line 463, in async_set_temperature
    success = await thrm.async_set_heating_setpoint(
  File "/usr/src/homeassistant/homeassistant/components/zha/core/channels/hvac.py", line 266, in async_set_heating_setpoint
    if not await self.write_attributes(data):
  File "/usr/src/homeassistant/homeassistant/components/zha/core/channels/hvac.py", line 301, in write_attributes
    res = await self.cluster.write_attributes(data, **kwargs)
  File "/usr/local/lib/python3.10/site-packages/zigpy/zcl/__init__.py", line 567, in write_attributes
    return await self.write_attributes_raw(attrs, manufacturer)
  File "/usr/local/lib/python3.10/site-packages/zigpy/zcl/__init__.py", line 573, in write_attributes_raw
    result = await self._write_attributes(attrs, manufacturer=manufacturer)
  File "/usr/local/lib/python3.10/site-packages/zigpy/zcl/__init__.py", line 324, in request
    return await self._endpoint.request(
  File "/usr/local/lib/python3.10/site-packages/zigpy/endpoint.py", line 237, in request
    return await self.device.request(
  File "/usr/local/lib/python3.10/site-packages/zigpy/device.py", line 312, in request
    return await asyncio.wait_for(req.result, timeout)
  File "/usr/local/lib/python3.10/asyncio/tasks.py", line 458, in wait_for
    raise exceptions.TimeoutError() from exc
asyncio.exceptions.TimeoutError

Digging into the log further, following error has been identified:

Logger: zigpy.application
Source: /usr/local/lib/python3.10/site-packages/zigpy/application.py:134
First occurred: 9:42:33 PM (1 occurrences)
Last logged: 9:42:33 PM

Couldn't start application
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/asyncio/tasks.py", line 456, in wait_for
    return fut.result()
asyncio.exceptions.CancelledError

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/local/lib/python3.10/site-packages/zigpy/application.py", line 132, in startup
    await self.initialize(auto_form=auto_form)
  File "/usr/local/lib/python3.10/site-packages/zigpy/application.py", line 77, in initialize
    await self.load_network_info(load_devices=False)
  File "/usr/local/lib/python3.10/site-packages/bellows/zigbee/application.py", line 209, in load_network_info
    status, node_type, nwk_params = await ezsp.getNetworkParameters()
  File "/usr/local/lib/python3.10/asyncio/tasks.py", line 458, in wait_for
    raise exceptions.TimeoutError() from exc
asyncio.exceptions.TimeoutError

I feel it might be connected, and not starting “zigpy.application” might be a reason? - guessing.
Where and what needs to be checked?

Can you please help?

I am experiencing the same issue with the Aqara e1. I can’t change the temperature from Home Assistant, if I change the temperature on the TVR, it’s updated in Home Assistant. After I re-sync the device, the issue is resolved and returns after a couple of days.

Traceback (most recent call last):
  File "/usr/local/lib/python3.10/asyncio/tasks.py", line 456, in wait_for
    return fut.result()
asyncio.exceptions.CancelledError

I use zha.

Hi @Jeroen.wou ,
I’ve experienced the same issue.
The Aqara thermostat was not working consistently.
My configuration was: Sonoff dongle version E (newer one).
Reading forums and asking the same question I’be come to the conclusion that those, who do not experience this problem, are not on ZHA, but use Zigbee2MQTT, and also none of those who have reported no issues use the Sonoff dongle version E, but use the Sonoff dongle version P (older version, with different chipset).
Now I am in migration process to the Zigbee2MQTT and I’ve replaced the dongle to the older one, Sonoff dongle version E.
First: Zigbee2MQTT recognized the Aqara thermostat E1 as native and supported.
Second: Zigbee2MQTT shows much more entities than ZHA, much more.
the integration works, all commands work, I am able to change presets, even switch off thermostat (What was absolutely not possible in ZHA with Sonoff dongle version E).
All works out of the box.
I do not know what was exactly the reason: ZHA, dongle or their combination.
What I can report: issue has been resolved after the migration to the Sonoff dongle version P and Zigbee2MQTT.
Updated: and yes, scripts did not work in the ZHA, they were continuously being timeouted. Now all works, including scripts.
I hope this helps.