midea-ac-py: AC doesn't connect.
Versions (版本信息)
- midea_ac custom component installed with HACS, at version (commit) 718aba1
- AC: “sysplit wall smart 12 v2 evo hp q”. Works with NetHome Plus Android application
- Wi-Fi module: probably SK-105
- Home Assistant version: core-2022.2.7
- Home Assistant OS version: 7.4
- Supervisor version: supervisor-2022.01.1
- Midea msmart version: msmart-0.2.0-py3-none-any
- Platform: Raspberry Pi
Describe the bug (描述一下问题) The issue very similar to https://github.com/mac-zhou/midea-ac-py/issues/121 . midea-discover returns different token and key at each run: First run:
c:\Python310\Scripts>midea-discover
INFO:msmart.cli:msmart version: 0.2.0 Currently only supports ac devices.
ERROR:msmart.security:authentication failed
INFO:msmart.lan:Got TCP key for 192.168.0.107:51577 -> 192.168.0.104:6444 retries: 0 time: 0.32 e994220f1b2281c899e02cbcfc61c844a2149ff05fc10b9f0224a88301590029
INFO:msmart.cli:*** Found a device: ←[94m←[1m{'type': 'ac', 'support': True, 'version': 3, 'ip': '192.168.0.104', 'id': 35184372114367, 'port': 6444, 'token': '9D0C185355F5F1D4EFABDF9739D0AA74EF98DBE0906700933F36DC98082F6D61F7BAFB21CE19C54FE9E16C7383A7838BB33EA27BEE0B333B50D94FF24FC4FB90', 'key': '0D6C677656294787A73F6CF29607890971585DBD265149D3A761EBCF7172C365', 'ssid': 'net_ac_093C'} ←[0m
Second run:
c:\Python310\Scripts>midea-discover
INFO:msmart.cli:msmart version: 0.2.0 Currently only supports ac devices.
ERROR:msmart.security:authentication failed
INFO:msmart.lan:Got TCP key for 192.168.0.107:51586 -> 192.168.0.104:6444 retries: 0 time: 0.37 e420e1174300eaa7cce4f002004e2aad198ca2341135e68a43e0da38912a3185
INFO:msmart.cli:*** Found a device: ←[94m←[1m{'type': 'ac', 'support': True, 'version': 3, 'ip': '192.168.0.104', 'id': 35184372114367, 'port': 6444, 'token': '507AA10FD3CD08B5351520B8360C49B5AEC09C9EA10123FF45F771C96892BF3125B20A1FA70C05E208E0952D7D74D9574CE2CC0809B6F7FAE0BC613099A213AB', 'key': '40E2C85D7D8B41CCBBA25A683A2C01C78748095E29234DE0A9A5715228069AEF', 'ssid': 'net_ac_093C'} ←[0m
With configuration
climate:
- platform: midea_ac
host: 192.168.1.104
id: 35184372114367
# v3 need token and k1(key)
token: 507AA10FD3CD08B5351520B8360C49B5AEC09C9EA10123FF45F771C96892BF3125B20A1FA70C05E208E0952D7D74D9574CE2CC0809B6F7FAE0BC613099A213AB
k1: 40E2C85D7D8B41CCBBA25A683A2C01C78748095E29234DE0A9A5715228069AEF
HA can’t connect to AC, with errors in logs:
2022-02-21 01:41:32 ERROR (MainThread) [homeassistant.components.automation.update_input_select_fan_mode] Update Input Select Fan Mode: Error executing script. Invalid data for call_service at pos 1: string value is None for dictionary value @ data['option']
2022-02-21 01:41:32 ERROR (MainThread) [homeassistant.components.automation.update_input_select_fan_mode] Error while executing automation automation.update_input_select_fan_mode: string value is None for dictionary value @ data['option']
2022-02-21 01:41:35 ERROR (SyncWorker_3) [msmart.lan] Connect Error: 192.168.1.104:6444 timed out
2022-02-21 01:41:35 ERROR (SyncWorker_3) [msmart.lan] Sokcet is None: 192.168.1.104:6444
2022-02-21 01:41:35 ERROR (SyncWorker_3) [msmart.security] unexpected data length
2022-02-21 01:41:35 ERROR (MainThread) [homeassistant.helpers.entity] Update for climate.midea_ac_35184372114367 fails
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 521, in async_update_ha_state
await self.async_device_update()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 725, in async_device_update
raise exc
File "/config/custom_components/midea_ac/climate.py", line 133, in async_update
await self.hass.async_add_executor_job(self._device.refresh)
File "/usr/local/lib/python3.9/concurrent/futures/thread.py", line 52, in run
result = self.fn(*self.args, **self.kwargs)
File "/usr/local/lib/python3.9/site-packages/msmart/device.py", line 198, in refresh
self._send_cmd(cmd)
File "/usr/local/lib/python3.9/site-packages/msmart/device.py", line 208, in _send_cmd
responses = self._lan_service.appliance_transparent_send_8370(data)
File "/usr/local/lib/python3.9/site-packages/msmart/lan.py", line 136, in appliance_transparent_send_8370
data = self.security.encode_8370(data, msgtype)
File "/usr/local/lib/python3.9/site-packages/msmart/security.py", line 120, in encode_8370
data = self.aes_cbc_encrypt(data, self._tcp_key) + sign
File "/usr/local/lib/python3.9/site-packages/msmart/security.py", line 57, in aes_cbc_encrypt
return AES.new(key, AES.MODE_CBC, iv=self.iv).encrypt(raw)
File "/usr/local/lib/python3.9/site-packages/Cryptodome/Cipher/AES.py", line 232, in new
return _create_cipher(sys.modules[__name__], key, mode, *args, **kwargs)
File "/usr/local/lib/python3.9/site-packages/Cryptodome/Cipher/__init__.py", line 79, in _create_cipher
return modes[mode](factory, **kwargs)
File "/usr/local/lib/python3.9/site-packages/Cryptodome/Cipher/_mode_cbc.py", line 274, in _create_cbc_cipher
cipher_state = factory._create_base_cipher(kwargs)
File "/usr/local/lib/python3.9/site-packages/Cryptodome/Cipher/AES.py", line 92, in _create_base_cipher
if len(key) not in key_size:
TypeError: object of type 'NoneType' has no len()
2022-02-21 01:41:50 ERROR (SyncWorker_0) [msmart.lan] Connect Error: 192.168.1.104:6444 timed out
2022-02-21 01:41:50 ERROR (SyncWorker_0) [msmart.lan] Sokcet is None: 192.168.1.104:6444
2022-02-21 01:41:50 ERROR (SyncWorker_0) [msmart.security] unexpected data length
2022-02-21 01:41:50 ERROR (MainThread) [homeassistant.helpers.entity] Update for climate.midea_ac_35184372114367 fails
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 521, in async_update_ha_state
await self.async_device_update()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 725, in async_device_update
raise exc
File "/config/custom_components/midea_ac/climate.py", line 133, in async_update
await self.hass.async_add_executor_job(self._device.refresh)
File "/usr/local/lib/python3.9/concurrent/futures/thread.py", line 52, in run
result = self.fn(*self.args, **self.kwargs)
File "/usr/local/lib/python3.9/site-packages/msmart/device.py", line 198, in refresh
self._send_cmd(cmd)
File "/usr/local/lib/python3.9/site-packages/msmart/device.py", line 208, in _send_cmd
responses = self._lan_service.appliance_transparent_send_8370(data)
File "/usr/local/lib/python3.9/site-packages/msmart/lan.py", line 136, in appliance_transparent_send_8370
data = self.security.encode_8370(data, msgtype)
File "/usr/local/lib/python3.9/site-packages/msmart/security.py", line 120, in encode_8370
data = self.aes_cbc_encrypt(data, self._tcp_key) + sign
File "/usr/local/lib/python3.9/site-packages/msmart/security.py", line 57, in aes_cbc_encrypt
return AES.new(key, AES.MODE_CBC, iv=self.iv).encrypt(raw)
File "/usr/local/lib/python3.9/site-packages/Cryptodome/Cipher/AES.py", line 232, in new
return _create_cipher(sys.modules[__name__], key, mode, *args, **kwargs)
File "/usr/local/lib/python3.9/site-packages/Cryptodome/Cipher/__init__.py", line 79, in _create_cipher
return modes[mode](factory, **kwargs)
File "/usr/local/lib/python3.9/site-packages/Cryptodome/Cipher/_mode_cbc.py", line 274, in _create_cbc_cipher
cipher_state = factory._create_base_cipher(kwargs)
File "/usr/local/lib/python3.9/site-packages/Cryptodome/Cipher/AES.py", line 92, in _create_base_cipher
if len(key) not in key_size:
TypeError: object of type 'NoneType' has no len()
Here is log file attached home-assistant.zip
When I scan opened ports of 192.168.1.104 with Network Scanner (Android app), I see one opened port 6444/tcp (unknown).
When I trying to connect with telnet
telnet 192.168.1.104 6444
Connect failed:
C:\Users\art>telnet 192.168.1.104 6444
Connecting To 192.168.1.104...Could not open connection to the host, on port 6444: Connect failed
So, AC has opened port, that can’t be accessed with telnet and, probably, HA too (ERROR (SyncWorker_3) [msmart.lan] Connect Error: 192.168.1.104:6444 timed out).
Any ideas, my friends?..
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 15 (4 by maintainers)
I guess you have solved it? 😄