ha0y / xiaomi_miot_raw

All-in-one & Easy-to-use. Integrate all your Xiaomi Smart Home - with a single integration and NO YAML files - into Home Assistant.
Apache License 2.0
2.17k stars 230 forks source link

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

Open xdilian opened 1 year ago

xdilian commented 1 year ago

更新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 commented 1 year ago

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 commented 1 year ago

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 commented 1 year ago

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: https://github.com/ha0y/xiaomi_miot_raw/issues/518#issuecomment-1582633668

xdilian commented 1 year ago

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 commented 1 year ago

IMG_1097 按图修改就可以了

xdilian commented 1 year ago

IMG_1097 按图修改就可以了

已修复,非常感谢。

leolai16 commented 1 year ago

請問yield from在那?

xdilian commented 1 year ago

請問yield from在那?

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

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

leolai16 commented 1 year ago

請問yield from在那?

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

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

謝謝你,解決了

Ricricric109 commented 1 year ago

mine still not working

xdilian commented 1 year ago

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 commented 1 year ago

yes i did but still not working....

kongh9 commented 1 year ago

請問yield from在那?

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

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

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

xdilian commented 1 year ago

請問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 commented 1 year ago

yes i did but still not working....

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

kongh9 commented 1 year ago

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

請問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 commented 1 year ago

:(

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 commented 1 year ago

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

請問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 commented 1 year ago

这个问题发生的原因是目前版本的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 commented 1 year ago
  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 commented 1 year ago

这个问题发生的原因是目前版本的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 commented 1 year ago

我也能用了~ 謝謝!!!

kpblca commented 1 year ago

It helped me too, thank you guys!

lekoOwO commented 1 year ago

https://github.com/lekoOwO/xiaomi_miot_raw

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

dufi67 commented 1 year ago

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... :-)