我手工修改了代码中的这个类名称,但还是有警告
日志详细信息( WARNING )
Logger: homeassistant.components.climate
Source: main.py:356
Integration: 空调 (documentation, issues)
First occurred: 2020年6月27日 下午8:38:28 (1 occurrences)
Last logged: 2020年6月27日 下午8:38:28
Setup of climate platform ds_air is taking over 10 seconds.
后台日记输出为:
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/lib/python3.7/threading.py", line 926, in _bootstrap_inner
self.run()
File "/config/custom_components/ds_air/ds_air_service/service.py", line 82, in run
res = self._sock.recv()
File "/config/custom_components/ds_air/ds_air_service/service.py", line 68, in recv
r, b = decoder(data)
File "/config/custom_components/ds_air/ds_air_service/decoder.py", line 23, in decoder
return result_factory(struct.unpack('<BHBBBBIBIBH' + str(length - 16) + 'sB', b[:length + 4])), b[length + 4:]
File "/config/custom_components/ds_air/ds_air_service/decoder.py", line 60, in result_factory
result.load_bytes(subbody)
File "/config/custom_components/ds_air/ds_air_service/decoder.py", line 292, in load_bytes
device = EnumDevice((8, d.read4()))
File "/usr/local/lib/python3.7/enum.py", line 310, in call
return cls.new(cls, value)
File "/usr/local/lib/python3.7/enum.py", line 564, in new
raise exc
File "/usr/local/lib/python3.7/enum.py", line 548, in new
result = cls.missing(value)
File "/usr/local/lib/python3.7/enum.py", line 577, in missing
raise ValueError("%r is not a valid %s" % (value, cls.name))
ValueError: (8, 25) is not a valid EnumDevice
然后我在EnumDevice里增加了 8,25,错误变成
2020-06-30 01:17:16 WARNING (MainThread) [homeassistant.loader] You are using a custom integration for ds_air which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant.
-------b------ b'\x04\x00\x7f\x00\x00\x05\x0c\x04\x01\x00\x01'
flag: 127
========d.pos==== 11
Exception in thread Thread-3:
Traceback (most recent call last):
File "/usr/local/lib/python3.7/threading.py", line 926, in _bootstrap_inner
self.run()
File "/config/custom_components/ds_air/ds_air_service/service.py", line 82, in run
res = self._sock.recv()
File "/config/custom_components/ds_air/ds_air_service/service.py", line 68, in recv
r, b = decoder(data)
File "/config/custom_components/ds_air/ds_air_service/decoder.py", line 23, in decoder
return result_factory(struct.unpack('<BHBBBBIBIBH' + str(length - 16) + 'sB', b[:length + 4])), b[length + 4:]
File "/config/custom_components/ds_air/ds_air_service/decoder.py", line 77, in result_factory
result.load_bytes(subbody)
File "/config/custom_components/ds_air/ds_air_service/decoder.py", line 486, in load_bytes
self.humidity = EnumControl.Humidity(d.read1())
File "/config/custom_components/ds_air/ds_air_service/decoder.py", line 92, in read1
s = struct.unpack('<B', self._b[pos:pos + 1])[0]
struct.error: unpack requires a buffer of 1 bytes
decode错误, b的长度是11, read 需要 11+1=12 ,读不到数据了
之后我注释掉了读取湿度的那个部分,出现下列错误
$$$$$$$ 36 8 18 4 1 b'\t101190104?\x01\x00<"\x01\x04\x02\r\x00'
$$$$$$$$$$$$$ 41 8 23 6 1 b'\x04\x04\x01\x00\xa7\x18\x87\x0b\x01\x00\xa7\x18\x87\x0c\x01\x00\xa7\x18\x87\x0e\x01\x00\xa7\x18\x87'
$$$$$$$$$$$$$ 17 8 24 6 1 b'\x00'
$$$$$$$$$$$$$ 27 8 23 3 1 b'\x04\x00\x7f\x00\x00\x05\x0c\x04\x01\x00\x01'
-------b------ b'\x04\x00\x7f\x00\x00\x05\x0c\x04\x01\x00\x01'
flag: 127
========== 4 0 Switch.OFF Mode.COLD AirFlow.AUTO 1036 1
$$$$$$$$$$$$$ 27 8 23 3 1 b'\x0b\x00\x7f\x00\x00\x05\x0c\xdc\x00\x00\x01'
-------b------ b'\x0b\x00\x7f\x00\x00\x05\x0c\xdc\x00\x00\x01'
flag: 127
========== 11 0 Switch.OFF Mode.COLD AirFlow.AUTO 56332 0
$$$$$$$$$$$$$ 27 8 23 3 1 b'\x0c\x00\x7f\x00\x00\x00\x0c\xfa\x00\x00\x01'
-------b------ b'\x0c\x00\x7f\x00\x00\x00\x0c\xfa\x00\x00\x01'
flag: 127
========== 12 0 Switch.OFF Mode.COLD AirFlow.SUPER_WEAK 64012 0
$$$$$$$$$$$$$ 27 8 23 3 1 b'\x0e\x00\x7f\x00\x00\x04\x0c\xfa\x00\x00\x01'
-------b------ b'\x0e\x00\x7f\x00\x00\x04\x0c\xfa\x00\x00\x01'
flag: 127
========== 14 0 Switch.OFF Mode.COLD AirFlow.SUPER_STRONG 64012 0
2020-06-30 05:59:37 WARNING (MainThread) [homeassistant.components.climate] Setup of climate platform ds_air is taking over 10 seconds.
2020-06-30 05:59:42 ERROR (MainThread) [homeassistant.components.updater] Timeout fetching Home Assistant update data
$$$$$$$$$$$$$ 21 8 18 2 0 b'\x01\x00\x10\x04\x01'
$$$$$$$$$$$$$ 21 8 18 2 0 b'\x02\x00\x10\x04\x01'
Exception in thread Thread-3:
Traceback (most recent call last):
File "/usr/local/lib/python3.7/threading.py", line 926, in _bootstrap_inner
self.run()
File "/config/custom_components/ds_air/ds_air_service/service.py", line 87, in run
i.do()
AttributeError: 'NoneType' object has no attribute 'do'