syssi / xiaomi_airconditioningcompanion

Xiaomi Mi and Aqara Air Conditioning Companion integration for Home Assistant
Apache License 2.0
394 stars 93 forks source link

Platform error climate.xiaomi_miio_airconditioningcompanion - Exception importing custom_components.xiaomi_miio_airconditioningcompanion.climate #160

Closed hoanglongutc closed 1 year ago

hoanglongutc commented 1 year ago

When I updated Home Assistant version 2023.6.0 got the following error while checking the configuration: Unexpected exception importing platform custom_components.xiaomi_miio_airconditioningcompanion.climate Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/loader.py", line 833, in get_platform cache[full_name] = self._import_platform(platform_name) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/loader.py", line 850, in _import_platform return importlib.import_module(f"{self.pkg_path}.{platform_name}") ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/importlib/init.py", line 126, in import_module return _bootstrap._gcd_import(name[level:], package, level) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "", line 1206, in _gcd_import File "", line 1178, in _find_and_load File "", line 1149, in _find_and_load_unlocked File "", line 690, in _load_unlocked File "", line 940, in exec_module File "", line 241, in _call_with_frames_removed File "/config/custom_components/xiaomi_miio_airconditioningcompanion/climate.py", line 129, in @asyncio.coroutine ^^^^^^^^^^^^^^^^^ AttributeError: module 'asyncio' has no attribute 'coroutine'

syssi commented 1 year ago

I've prepared a new release (2023.6.0.0). Please give it a try!

kwxiaozhu commented 1 year ago

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/websocket_api/decorators.py", line 26, in _handle_async_response
    await func(hass, connection, msg)
  File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 678, in handle_execute_script
    await script_obj.async_run(msg.get("variables"), context=context)
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 1533, in async_run
    await asyncio.shield(run.async_run())
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 410, in async_run
    await self._async_step(log_exceptions=False)
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 454, in _async_step
    self._handle_exception(
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 477, in _handle_exception
    raise exception
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 452, in _async_step
    await getattr(self, handler)()
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 685, in _async_call_service_step
    await service_task
  File "/usr/src/homeassistant/homeassistant/core.py", line 1910, in async_call
    task.result()
  File "/usr/src/homeassistant/homeassistant/core.py", line 1950, in _execute_service
    await cast(Callable[[ServiceCall], Awaitable[None]], handler.job.target)(
  File "/config/custom_components/xiaomi_miio_airconditioningcompanion/climate.py", line 194, in async_service_handler
    await getattr(device, method["method"])(**params)
TypeError: object generator can't be used in 'await' expression

when call the service: xiaomi_miio_airconditioningcompanion.climate_learn_command
new version 2023.6.0.0
syssi commented 1 year ago

I will have a look. Thanks for your feedback!

Leo4242 commented 1 year ago

I have the same issue

syssi commented 1 year ago

It looks like I wasn't awake this morning. I've pushed another release. Please give it a try! May be there are more issues which needs to be fixed.

kwxiaozhu commented 1 year ago

not work 2023.6.0.1


Unexpected exception importing platform custom_components.xiaomi_miio_airconditioningcompanion.climate
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/loader.py", line 833, in get_platform
    cache[full_name] = self._import_platform(platform_name)
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/loader.py", line 850, in _import_platform
    return importlib.import_module(f"{self.pkg_path}.{platform_name}")
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen importlib._bootstrap>", line 1206, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1178, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1149, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 690, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 936, in exec_module
  File "<frozen importlib._bootstrap_external>", line 1074, in get_code
  File "<frozen importlib._bootstrap_external>", line 1004, in source_to_code
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/config/custom_components/xiaomi_miio_airconditioningcompanion/climate.py", line 310
    yield from self._async_update_power_state(new_state)
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
SyntaxError: 'yield from' inside async function
syssi commented 1 year ago

Fixed. Please try 2023.6.0.2.

kwxiaozhu commented 1 year ago

still not work 2023.6.0.2 docker image homeassistant/home-assistant latest ffe65a678393

Platform error: climate
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/loader.py", line 833, in get_platform
    cache[full_name] = self._import_platform(platform_name)
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/loader.py", line 850, in _import_platform
    return importlib.import_module(f"{self.pkg_path}.{platform_name}")
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen importlib._bootstrap>", line 1206, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1178, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1149, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 690, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 936, in exec_module
  File "<frozen importlib._bootstrap_external>", line 1074, in get_code
  File "<frozen importlib._bootstrap_external>", line 1004, in source_to_code
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/config/custom_components/xiaomi_miio_airconditioningcompanion/climate.py", line 295
    await self.async_turn_on()
    ^^^^^^^^^^^^^^^^^^^^^^^^^^
SyntaxError: 'await' outside async function

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

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/config.py", line 928, in async_process_component_config
    platform = p_integration.get_platform(domain)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/loader.py", line 842, in get_platform
    raise ImportError(
ImportError: Exception importing custom_components.xiaomi_miio_airconditioningcompanion.climate

Unexpected exception importing platform custom_components.xiaomi_miio_airconditioningcompanion.climate Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/loader.py", line 833, in get_platform cache[full_name] = self._import_platform(platform_name) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/loader.py", line 850, in _import_platform return importlib.import_module(f"{self.pkg_path}.{platform_name}") ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/importlib/init.py", line 126, in import_module return _bootstrap._gcd_import(name[level:], package, level) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "", line 1206, in _gcd_import File "", line 1178, in _find_and_load File "", line 1149, in _find_and_load_unlocked File "", line 690, in _load_unlocked File "", line 936, in exec_module File "", line 1074, in get_code File "", line 1004, in source_to_code File "", line 241, in _call_with_frames_removed File "/config/custom_components/xiaomi_miio_airconditioningcompanion/climate.py", line 295 await self.async_turn_on() ^^^^^^^^^^^^^^^^^^^^^^^^^^ SyntaxError: 'await' outside async function

syssi commented 1 year ago

I've to prepare a test setup now to get an idea what's going on and needs to be changed.

slydiman commented 1 year ago

The source of this issue is python 3.11.

yurtaevalex commented 1 year ago

Logger: homeassistant.loader Source: loader.py:850 First occurred: 08:59:08 (2 occurrences) Last logged: 08:59:08

Unexpected exception importing platform custom_components.xiaomi_miio_airconditioningcompanion.climate Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/loader.py", line 833, in get_platform cache[full_name] = self._import_platform(platform_name) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/loader.py", line 850, in _import_platform return importlib.import_module(f"{self.pkg_path}.{platform_name}") ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/importlib/init.py", line 126, in import_module return _bootstrap._gcd_import(name[level:], package, level) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "", line 1206, in _gcd_import File "", line 1178, in _find_and_load File "", line 1149, in _find_and_load_unlocked File "", line 690, in _load_unlocked File "", line 936, in exec_module File "", line 1074, in get_code File "", line 1004, in source_to_code File "", line 241, in _call_with_frames_removed File "/config/custom_components/xiaomi_miio_airconditioningcompanion/climate.py", line 295 await self.async_turn_on() ^^^^^^^^^^^^^^^^^^^^^^^^^^ SyntaxError: 'await' outside async function

axyskus commented 1 year ago

still not working. the same mistake as in this issue

sebbio commented 1 year ago

the same mistake as in this issue

syssi commented 1 year ago

I've pushed another release. I hope it doesn't make the problem worse. I'm pretty bad in doing things async.

yurtaevalex commented 1 year ago

Я нажал еще один релиз. Надеюсь, это не усугубит проблему. Я довольно плохо делаю что-то асинхронное.

It worked, thanks for the speed

vincentstarjammer commented 1 year ago

I can also confirm, all functionality is restored with 2023.6.0.3. It also works with the new Supervisor 2023.06.1

axyskus commented 1 year ago

yes, it is working now. lots of thanks for speed

sebbio commented 1 year ago

Now working fine

Leo4242 commented 1 year ago

There are still issues, and I still receive error messages when calling learn_command and send_command services

syssi commented 1 year ago

Could you provide the error messages including the stack traces? Thanks in advance!

hoanglongutc commented 1 year ago

Could you provide the error messages including the stack traces? Thanks in advance!

This error originated from a custom integration.

Logger: homeassistant.helpers.script.websocket_api_script Source: custom_components/xiaomi_miio_airconditioningcompanion/climate.py:198 Integration: xiaomi_miio_airconditioningcompanion (documentation, issues) First occurred: 06:35:21 (1 occurrences) Last logged: 06:35:21

websocket_api script: Error executing script. Unexpected error for call_service at pos 1: Passing coroutines is forbidden, use tasks explicitly. Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 452, in _async_step await getattr(self, handler)() File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 685, in _async_call_service_step await service_task File "/usr/src/homeassistant/homeassistant/core.py", line 1910, in async_call task.result() File "/usr/src/homeassistant/homeassistant/core.py", line 1950, in _execute_service await cast(Callable[[ServiceCall], Awaitable[None]], handler.job.target)( File "/config/custom_components/xiaomi_miio_airconditioningcompanion/climate.py", line 198, in async_service_handler await asyncio.wait(update_tasks) File "/usr/local/lib/python3.11/asyncio/tasks.py", line 415, in wait raise TypeError("Passing coroutines is forbidden, use tasks explicitly.") TypeError: Passing coroutines is forbidden, use tasks explicitly.

-----------------------------------------‐---------

Logger: homeassistant.components.websocket_api.http.connection Source: custom_components/xiaomi_miio_airconditioningcompanion/climate.py:198 Integration: Home Assistant WebSocket API (documentation, issues) First occurred: 06:35:21 (1 occurrences) Last logged: 06:35:21

[140459890109840] Error handling message: Unknown error (unknown_error) HA from 192.168.x.x(Mozilla/5.0 (Linux; Android 13; SM-xxx Build/TP1A.220624.014; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/113.0.5672.162 Mobile Safari/537.36 Home Assistant/2023.3.0-3260 (Android 13; SM-xxx)) Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/components/websocket_api/decorators.py", line 26, in _handle_async_response await func(hass, connection, msg) File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 678, in handle_execute_script await script_obj.async_run(msg.get("variables"), context=context) File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 1533, in async_run await asyncio.shield(run.async_run()) File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 410, in async_run await self._async_step(log_exceptions=False) File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 454, in _async_step self._handle_exception( File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 477, in _handle_exception raise exception File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 452, in _async_step await getattr(self, handler)() File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 685, in _async_call_service_step await service_task File "/usr/src/homeassistant/homeassistant/core.py", line 1910, in async_call task.result() File "/usr/src/homeassistant/homeassistant/core.py", line 1950, in _execute_service await cast(Callable[[ServiceCall], Awaitable[None]], handler.job.target)( File "/config/custom_components/xiaomi_miio_airconditioningcompanion/climate.py", line 198, in async_service_handler await asyncio.wait(update_tasks) File "/usr/local/lib/python3.11/asyncio/tasks.py", line 415, in wait raise TypeError("Passing coroutines is forbidden, use tasks explicitly.") TypeError: Passing coroutines is forbidden, use tasks explicitly.

syssi commented 1 year ago

I've pushed another fix & prepared a new release to mitigate this issue.