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

更新Home Assistant 2023.6.0后小米空调失效 #516

Open
xdilian opened this issue Jun 8, 2023 · 25 comments
Open

更新Home Assistant 2023.6.0后小米空调失效 #516

xdilian opened this issue Jun 8, 2023 · 25 comments

Comments

@xdilian
Copy link

xdilian commented Jun 8, 2023

更新Home Assistant 2023.6.0后小米空调失效,以下是日志,希望作者百忙之中更新一下,辛苦了。

日志1:
Logger: homeassistant.loader
Source: custom_components/xiaomi_miot_raw/basic_dev_class.py:684
Integration: Xiaomi MIoT (documentation, issues)
First occurred: 11:41:29 (48 occurrences)
Last logged: 12:43:36

Unexpected exception importing platform custom_components.xiaomi_miot_raw.select
Unexpected exception importing platform custom_components.xiaomi_miot_raw.number
Unexpected exception importing platform custom_components.xiaomi_miot_raw.light
Unexpected exception importing platform custom_components.xiaomi_miot_raw.sensor
Unexpected exception importing platform custom_components.xiaomi_miot_raw.binary_sensor
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_miot_raw/sensor.py", line 20, in
from .basic_dev_class import (
File "/config/custom_components/xiaomi_miot_raw/basic_dev_class.py", line 63, in
class GenericMiotDevice(Entity):
File "/config/custom_components/xiaomi_miot_raw/basic_dev_class.py", line 684, in GenericMiotDevice
@asyncio.coroutine
^^^^^^^^^^^^^^^^^
AttributeError: module 'asyncio' has no attribute 'coroutine'

日志2:
Logger: homeassistant.setup
Source: setup.py:374
First occurred: 11:41:29 (48 occurrences)
Last logged: 12:43:36

Unable to prepare setup for platform xiaomi_miot_raw.select: Platform not found (Exception importing custom_components.xiaomi_miot_raw.select).
Unable to prepare setup for platform xiaomi_miot_raw.number: Platform not found (Exception importing custom_components.xiaomi_miot_raw.number).
Unable to prepare setup for platform xiaomi_miot_raw.light: Platform not found (Exception importing custom_components.xiaomi_miot_raw.light).
Unable to prepare setup for platform xiaomi_miot_raw.sensor: Platform not found (Exception importing custom_components.xiaomi_miot_raw.sensor).
Unable to prepare setup for platform xiaomi_miot_raw.binary_sensor: Platform not found (Exception importing custom_components.xiaomi_miot_raw.binary_sensor).

@kroona
Copy link

kroona commented Jun 8, 2023

Same here with the Humidifier2

Logboek Details (FOUT)
Logger: homeassistant.setup
Source: setup.py:374
First occurred: 10:29:13 (23 occurrences)
Last logged: 10:31:35

Unable to prepare setup for platform xiaomi_miot_raw.climate: Platform not found (Exception importing custom_components.xiaomi_miot_raw.climate).
Unable to prepare setup for platform xiaomi_miot_raw.fan: Platform not found (Exception importing custom_components.xiaomi_miot_raw.fan).
Unable to prepare setup for platform xiaomi_miot_raw.number: Platform not found (Exception importing custom_components.xiaomi_miot_raw.number).
Unable to prepare setup for platform xiaomi_miot_raw.select: Platform not found (Exception importing custom_components.xiaomi_miot_raw.select).
Unable to prepare setup for platform xiaomi_miot_raw.binary_sensor: Platform not found (Exception importing custom_components.xiaomi_miot_raw.binary_sensor).

@xdilian
Copy link
Author

xdilian commented Jun 8, 2023

Same here with the Humidifier2

Logboek Details (FOUT) Logger: homeassistant.setup Source: setup.py:374 First occurred: 10:29:13 (23 occurrences) Last logged: 10:31:35

Unable to prepare setup for platform xiaomi_miot_raw.climate: Platform not found (Exception importing custom_components.xiaomi_miot_raw.climate). Unable to prepare setup for platform xiaomi_miot_raw.fan: Platform not found (Exception importing custom_components.xiaomi_miot_raw.fan). Unable to prepare setup for platform xiaomi_miot_raw.number: Platform not found (Exception importing custom_components.xiaomi_miot_raw.number). Unable to prepare setup for platform xiaomi_miot_raw.select: Platform not found (Exception importing custom_components.xiaomi_miot_raw.select). Unable to prepare setup for platform xiaomi_miot_raw.binary_sensor: Platform not found (Exception importing custom_components.xiaomi_miot_raw.binary_sensor).

I have reverted to Homeassistant 2023.5.4 pending an update from the author.

@Gerrett84
Copy link

Same here with the Humidifier2
Logboek Details (FOUT) Logger: homeassistant.setup Source: setup.py:374 First occurred: 10:29:13 (23 occurrences) Last logged: 10:31:35
Unable to prepare setup for platform xiaomi_miot_raw.climate: Platform not found (Exception importing custom_components.xiaomi_miot_raw.climate). Unable to prepare setup for platform xiaomi_miot_raw.fan: Platform not found (Exception importing custom_components.xiaomi_miot_raw.fan). Unable to prepare setup for platform xiaomi_miot_raw.number: Platform not found (Exception importing custom_components.xiaomi_miot_raw.number). Unable to prepare setup for platform xiaomi_miot_raw.select: Platform not found (Exception importing custom_components.xiaomi_miot_raw.select). Unable to prepare setup for platform xiaomi_miot_raw.binary_sensor: Platform not found (Exception importing custom_components.xiaomi_miot_raw.binary_sensor).

I have reverted to Homeassistant 2023.5.4 pending an update from the author.

There will be no update from the author.
Here's a workaround:
#518 (comment)

@xdilian
Copy link
Author

xdilian commented Jun 8, 2023

Same here with the Humidifier2
Logboek Details (FOUT) Logger: homeassistant.setup Source: setup.py:374 First occurred: 10:29:13 (23 occurrences) Last logged: 10:31:35
Unable to prepare setup for platform xiaomi_miot_raw.climate: Platform not found (Exception importing custom_components.xiaomi_miot_raw.climate). Unable to prepare setup for platform xiaomi_miot_raw.fan: Platform not found (Exception importing custom_components.xiaomi_miot_raw.fan). Unable to prepare setup for platform xiaomi_miot_raw.number: Platform not found (Exception importing custom_components.xiaomi_miot_raw.number). Unable to prepare setup for platform xiaomi_miot_raw.select: Platform not found (Exception importing custom_components.xiaomi_miot_raw.select). Unable to prepare setup for platform xiaomi_miot_raw.binary_sensor: Platform not found (Exception importing custom_components.xiaomi_miot_raw.binary_sensor).

I have reverted to Homeassistant 2023.5.4 pending an update from the author.

There will be no update from the author. Here's a workaround: #518 (comment)

It worked,thanks.

@lhyfjzz
Copy link

lhyfjzz commented Jun 9, 2023

IMG_1097
按图修改就可以了

@xdilian
Copy link
Author

xdilian commented Jun 9, 2023

IMG_1097 按图修改就可以了

已修复,非常感谢。

@leolai16
Copy link

leolai16 commented Jun 9, 2023

請問yield from在那?

@xdilian
Copy link
Author

xdilian commented Jun 10, 2023

請問yield from在那?

我使用的另外一种方案,把../custom_components/xiaomi_miot_raw文件夹下每一个.py文件打开查找删除下面两个关键词

1:import asyncio
2:@asyncio.coroutine
删除后重载即可。

@leolai16
Copy link

請問yield from在那?

我使用的另外一种方案,把../custom_components/xiaomi_miot_raw文件夹下每一个.py文件打开查找删除下面两个关键词

1:import asyncio 2:@asyncio.coroutine 删除后重载即可。

謝謝你,解決了

@Ricricric109
Copy link

mine still not working

@xdilian
Copy link
Author

xdilian commented Jun 11, 2023

mine still not working

Open the ../custom_components/xiaomi_miot_raw folder, open each .py file under the folder to find two keywords to delete,
1: import asyncio
2: @asyncio.coroutine
Then reload the addon.

@Ricricric109
Copy link

yes i did but still not working....

@kongh9
Copy link

kongh9 commented Jun 11, 2023

請問yield from在那?

我使用的另外一种方案,把../custom_components/xiaomi_miot_raw文件夹下每一个.py文件打开查找删除下面两个关键词

1:import asyncio 2:@asyncio.coroutine 删除后重载即可。

还需要把basic_dev_class.py中的yield from改为await

@xdilian
Copy link
Author

xdilian commented Jun 12, 2023

請問yield from在那?

我使用的另外一种方案,把../custom_components/xiaomi_miot_raw文件夹下每一个.py文件打开查找删除下面两个关键词
1:import asyncio 2:@asyncio.coroutine 删除后重载即可。

还需要把basic_dev_class.py中的yield from改为await

我把basic_dev_class.py中的yield from改为await后无法正常运行,改回去可以运行。

@xdilian
Copy link
Author

xdilian commented Jun 12, 2023

yes i did but still not working....

You can try to change the “yield from” in basic_dev_class.py to “await”.

@kongh9
Copy link

kongh9 commented Jun 12, 2023

我这样做了就可以了。你看看日志有什么错误提示?

請問yield from在那?

我使用的另外一种方案,把../custom_components/xiaomi_miot_raw文件夹下每一个.py文件打开查找删除下面两个关键词
1:import asyncio 2:@asyncio.coroutine 删除后重载即可。

还需要把basic_dev_class.py中的yield from改为await

我把basic_dev_class.py中的yield from改为await后无法正常运行,改回去可以运行。

@Ricricric109
Copy link

:(

Logger: homeassistant.loader
Source: custom_components/xiaomi_miot_raw/switch.py:16
Integration: Xiaomi MIoT (documentation, issues)
First occurred: 2:08:49 PM (4 occurrences)
Last logged: 2:08:50 PM

Unexpected exception importing platform custom_components.xiaomi_miot_raw.switch
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_miot_raw/switch.py", line 16, in
from .basic_dev_class import (
File "/config/custom_components/xiaomi_miot_raw/basic_dev_class.py", line 705
await getattr(device, method["method"])(**params)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
SyntaxError: 'await' outside async function

@xdilian
Copy link
Author

xdilian commented Jun 12, 2023

我这样做了就可以了。你看看日志有什么错误提示?

請問yield from在那?

我使用的另外一种方案,把../custom_components/xiaomi_miot_raw文件夹下每一个.py文件打开查找删除下面两个关键词
1:import asyncio 2:@asyncio.coroutine 删除后重载即可。

还需要把basic_dev_class.py中的yield from改为await

我把basic_dev_class.py中的yield from改为await后无法正常运行,改回去可以运行。

Logger: homeassistant.loader
Source: custom_components/xiaomi_miot_raw/switch.py:16
Integration: Xiaomi MIoT (documentation, issues)
First occurred: 2:08:49 PM (4 occurrences)
Last logged: 2:08:50 PM

Unexpected exception importing platform custom_components.xiaomi_miot_raw.switch
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_miot_raw/switch.py", line 16, in
from .basic_dev_class import (
File "/config/custom_components/xiaomi_miot_raw/basic_dev_class.py", line 705
await getattr(device, method["method"])(**params)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
SyntaxError: 'await' outside async function

你楼下这位按issues的两个方案修改均不成功,你可以帮忙看一下,我能力有限帮不了他,他这个日志就是把yield from改为await后报错。

@kongh9
Copy link

kongh9 commented Jun 12, 2023

这个问题发生的原因是目前版本的home assistant container用的是python 3.11,已经不支持python 3.10以及以前版本的@asyncio.coroutine/yield from的操作了,而是改用了async def/await的方式。这个小米插件是很久之前写的,所以部分地方还在用python3.10的方法。所以我们要做以下修改:
1、删除所有.py文件中的@asyncio.coroutine这一行,但是仅仅删除这行还不够,你还要看看这一行下面的函数定义中有没有:
async def ....这样的定义函数方式,大部分文件是有这样写的,但是在最重要的basic_dev_class.py里面的第685行直接写了def...而不是async def...,所以要把这个地方改成async def...
2、将yield from改为await

这样应该可以了,我就是这么做的。

我这样做了就可以了。你看看日志有什么错误提示?

請問yield from在那?

我使用的另外一种方案,把../custom_components/xiaomi_miot_raw文件夹下每一个.py文件打开查找删除下面两个关键词
1:import asyncio 2:@asyncio.coroutine 删除后重载即可。

还需要把basic_dev_class.py中的yield from改为await

我把basic_dev_class.py中的yield from改为await后无法正常运行,改回去可以运行。

Logger: homeassistant.loader Source: custom_components/xiaomi_miot_raw/switch.py:16 Integration: Xiaomi MIoT (documentation, issues) First occurred: 2:08:49 PM (4 occurrences) Last logged: 2:08:50 PM

Unexpected exception importing platform custom_components.xiaomi_miot_raw.switch 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_miot_raw/switch.py", line 16, in from .basic_dev_class import ( File "/config/custom_components/xiaomi_miot_raw/basic_dev_class.py", line 705 await getattr(device, method["method"])(**params) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SyntaxError: 'await' outside async function

你楼下这位按issues的两个方案修改均不成功,你可以帮忙看一下,我能力有限帮不了他,他这个日志就是把yield from改为await后报错。

@kongh9
Copy link

kongh9 commented Jun 12, 2023

  1. change "yield from" to "await"

  2. change line 685 of basic_dev_class.py from " def async_service_handler(self, service):" to "async def async_service_handler(self, service): "

:(

Logger: homeassistant.loader Source: custom_components/xiaomi_miot_raw/switch.py:16 Integration: Xiaomi MIoT (documentation, issues) First occurred: 2:08:49 PM (4 occurrences) Last logged: 2:08:50 PM

Unexpected exception importing platform custom_components.xiaomi_miot_raw.switch 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_miot_raw/switch.py", line 16, in from .basic_dev_class import ( File "/config/custom_components/xiaomi_miot_raw/basic_dev_class.py", line 705 await getattr(device, method["method"])(**params) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SyntaxError: 'await' outside async function

@xdilian
Copy link
Author

xdilian commented Jun 12, 2023

这个问题发生的原因是目前版本的home assistant container用的是python 3.11,已经不支持python 3.10以及以前版本的@asyncio.coroutine/yield from的操作了,而是改用了async def/await的方式。这个小米插件是很久之前写的,所以部分地方还在用python3.10的方法。所以我们要做以下修改: 1、删除所有.py文件中的@asyncio.coroutine这一行,但是仅仅删除这行还不够,你还要看看这一行下面的函数定义中有没有: async def ....这样的定义函数方式,大部分文件是有这样写的,但是在最重要的basic_dev_class.py里面的第685行直接写了def...而不是async def...,所以要把这个地方改成async def... 2、将yield from改为await

这样应该可以了,我就是这么做的。

我这样做了就可以了。你看看日志有什么错误提示?

請問yield from在那?

我使用的另外一种方案,把../custom_components/xiaomi_miot_raw文件夹下每一个.py文件打开查找删除下面两个关键词
1:import asyncio 2:@asyncio.coroutine 删除后重载即可。

还需要把basic_dev_class.py中的yield from改为await

我把basic_dev_class.py中的yield from改为await后无法正常运行,改回去可以运行。

Logger: homeassistant.loader Source: custom_components/xiaomi_miot_raw/switch.py:16 Integration: Xiaomi MIoT (documentation, issues) First occurred: 2:08:49 PM (4 occurrences) Last logged: 2:08:50 PM
Unexpected exception importing platform custom_components.xiaomi_miot_raw.switch 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_miot_raw/switch.py", line 16, in from .basic_dev_class import ( File "/config/custom_components/xiaomi_miot_raw/basic_dev_class.py", line 705 await getattr(device, method["method"])(**params) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ SyntaxError: 'await' outside async function
你楼下这位按issues的两个方案修改均不成功,你可以帮忙看一下,我能力有限帮不了他,他这个日志就是把yield from改为await后报错。

受教了,感谢科普,目前能使用我就先不改了,我只删除了每个文件的这两个词:1: import asyncio 2: @asyncio.coroutine 然后重载插件就正常运行了。

@Ricricric109
Copy link

我也能用了~ 謝謝!!!

@kpblca
Copy link

kpblca commented Jun 14, 2023

It helped me too, thank you guys!

@lekoOwO
Copy link

lekoOwO commented Jul 8, 2023

https://github.com/lekoOwO/xiaomi_miot_raw

I've modified the code according to the previous suggestions if anyone need this

@dufi67
Copy link

dufi67 commented Jul 20, 2023

https://github.com/lekoOwO/xiaomi_miot_raw

I've modified the code according to the previous suggestions if anyone need this

Thx a lot. Clean & Dry feeling... :-)

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

No branches or pull requests

10 participants