core核心2023.12.3下日志不停报错,希望大佬能改进下,另外还有无法生成Id就无法分配房间,也希望大佬一并解决下,麻烦了。
Opened this issue · 4 comments
报错日志取下:
此错误来自自定义集成。
Logger: custom_components.mijia_curtain.cover
Source: custom_components/mijia_curtain/cover.py:489
Integration: mijia_curtain (documentation)
First occurred: 00:04:44 (1 occurrences)
Last logged: 00:04:44
Get property target-position exception
Traceback (most recent call last):
File "/usr/local/lib/python3.11/site-packages/miio/miioprotocol.py", line 193, in send
data, addr = s.recvfrom(4096)
^^^^^^^^^^^^^^^^
TimeoutError: timed out
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/config/custom_components/mijia_curtain/cover.py", line 489, in get_property
results = self.miotDevice.get_property_by(siid, piid)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/miio/click_common.py", line 184, in _wrap
return func(self, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/miio/miot_device.py", line 117, in get_property_by
return self.send(
^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/miio/device.py", line 107, in send
return self._protocol.send(
^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/miio/miioprotocol.py", line 233, in send
return self.send(
^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/miio/miioprotocol.py", line 161, in send
self.send_handshake()
File "/usr/local/lib/python3.11/site-packages/miio/miioprotocol.py", line 74, in send_handshake
raise DeviceException("Unable to discover the device %s" % self.ip)
miio.exceptions.DeviceException: Unable to discover the device 192.168.0.90
或者大佬推荐个比较稳定的老版本homeassistant用也可以
不会改代码,只好让chatgpt修改,经过测试,经过如下修改可以生成unique_id,设备可以生成ID,注册为设备。修改代码如下,老大抽空加上吧。
import re # 添加导入re模块
... (您现有代码的其余部分)
class MijiaCurtain(CoverEntity):
def init(self, name, host, token, model):
self._name = name
self._current_position = 0
self._target_position = 0
self._action = 0
# 生成唯一ID
self._unique_id = self.generate_unique_id(host)
# 其余的初始化代码保持不变...
def generate_unique_id(self, host):
# 从IP地址中去掉 . 并生成唯一ID
ip_numbers = re.sub(r'\.', '', host) # 去掉 .
# 生成唯一ID
unique_id = f"smartj{ip_numbers}"
return unique_id
@property
def unique_id(self):
return self._unique_id
# 其余的代码保持不变...
感谢支持,已经添加
ChatGPT牛皮,但是用ip不是很合适,改用了UUID
嗯,我是不知道,那个合适,测试了能用就没管。