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

core核心2023.12.3下日志不停报错,希望大佬能改进下,另外还有无法生成Id就无法分配房间,也希望大佬一并解决下,麻烦了。 #18

Open
jarod360 opened this issue Dec 28, 2023 · 4 comments

Comments

@jarod360
Copy link

报错日志取下:
此错误来自自定义集成。

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

@jarod360
Copy link
Author

或者大佬推荐个比较稳定的老版本homeassistant用也可以

@jarod360
Copy link
Author

jarod360 commented Jan 4, 2024

不会改代码,只好让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

# 其余的代码保持不变...

@tiandeyu
Copy link
Owner

tiandeyu commented Jan 5, 2024

感谢支持,已经添加
ChatGPT牛皮,但是用ip不是很合适,改用了UUID

@jarod360
Copy link
Author

jarod360 commented Jan 5, 2024

嗯,我是不知道,那个合适,测试了能用就没管。

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

2 participants