WMP / midea-ac-py

This is a custom component for Home Assistant to integrate the Midea Air Conditioners via the Local area network.
MIT License
26 stars 13 forks source link

Climate is "Unavailable" #2

Open andr2000 opened 4 years ago

andr2000 commented 4 years ago

While starting HA I sometimes see:

Aug 18 00:23:01 a2khome python3.7[1250]: 2020-08-18 00:23:01 ERROR (MainThread) [homeassistant.helpers.entity] Update for climate.midea_ac_20890720943210 fails
Aug 18 00:23:01 a2khome python3.7[1250]: Traceback (most recent call last):
Aug 18 00:23:01 a2khome python3.7[1250]:   File "/home/a2k/smarthome/homeassistant/home-assistant/homeassistant/helpers/entity.py", line 263, in async_update_ha_state
Aug 18 00:23:01 a2khome python3.7[1250]:     await self.async_device_update()
Aug 18 00:23:01 a2khome python3.7[1250]:   File "/home/a2k/smarthome/homeassistant/home-assistant/homeassistant/helpers/entity.py", line 454, in async_device_update
Aug 18 00:23:01 a2khome python3.7[1250]:     await self.async_update()  # type: ignore
Aug 18 00:23:01 a2khome python3.7[1250]:   File "/home/a2k/smarthome/homeassistant/homeassistant-config/custom_components/midea/climate.py", line 129, in async_update
Aug 18 00:23:01 a2khome python3.7[1250]:     await self.hass.async_add_executor_job(self._device.refresh)
Aug 18 00:23:01 a2khome python3.7[1250]:   File "/usr/lib/python3.7/concurrent/futures/thread.py", line 57, in run
Aug 18 00:23:01 a2khome python3.7[1250]:     result = self.fn(*self.args, **self.kwargs)
Aug 18 00:23:01 a2khome python3.7[1250]:   File "/home/a2k/smarthome/homeassistant/home-assistant/venv/lib/python3.7/site-packages/msmart/device.py", line 174, in refresh
Aug 18 00:23:01 a2khome python3.7[1250]:     self._send_cmd(cmd)
Aug 18 00:23:01 a2khome python3.7[1250]:   File "/home/a2k/smarthome/homeassistant/home-assistant/venv/lib/python3.7/site-packages/msmart/device.py", line 181, in _send_cmd
Aug 18 00:23:01 a2khome python3.7[1250]:     responses = self._lan_service.appliance_transparent_send_8370(data)
Aug 18 00:23:01 a2khome python3.7[1250]:   File "/home/a2k/smarthome/homeassistant/home-assistant/venv/lib/python3.7/site-packages/msmart/lan.py", line 84, in appliance_transparent_send_8370
Aug 18 00:23:01 a2khome python3.7[1250]:     self._authenticate()
Aug 18 00:23:01 a2khome python3.7[1250]:   File "/home/a2k/smarthome/homeassistant/home-assistant/venv/lib/python3.7/site-packages/msmart/lan.py", line 80, in _authenticate
Aug 18 00:23:01 a2khome python3.7[1250]:     raise error
Aug 18 00:23:01 a2khome python3.7[1250]:   File "/home/a2k/smarthome/homeassistant/home-assistant/venv/lib/python3.7/site-packages/msmart/lan.py", line 76, in _authenticate
Aug 18 00:23:01 a2khome python3.7[1250]:     tcp_key = self.security.tcp_key(response, self._key)
Aug 18 00:23:01 a2khome python3.7[1250]:   File "/home/a2k/smarthome/homeassistant/home-assistant/venv/lib/python3.7/site-packages/msmart/security.py", line 92, in tcp_key
Aug 18 00:23:01 a2khome python3.7[1250]:     raise Exception('unexpected data length')
Aug 18 00:23:01 a2khome python3.7[1250]: Exception: unexpected data length

When this happens the climate in HA is stuck in "Unavailable" state. It seems that an error on integration start is not recoverable, so one needs to restart HA

andr2000 commented 4 years ago

This is the log at HA start:

Aug 17 21:37:17 a2khome python3.7[1250]: 2020-08-17 21:37:17 ERROR (MainThread) [homeassistant.components.climate] Error while setting up midea platform for climate
Aug 17 21:37:17 a2khome python3.7[1250]: Traceback (most recent call last):
Aug 17 21:37:17 a2khome python3.7[1250]:   File "/home/a2k/smarthome/homeassistant/home-assistant/homeassistant/helpers/entity_platform.py", line 184, in _async_setup_platform
Aug 17 21:37:17 a2khome python3.7[1250]:     await asyncio.shield(task)
Aug 17 21:37:17 a2khome python3.7[1250]:   File "/home/a2k/smarthome/homeassistant/homeassistant-config/custom_components/midea/climate.py", line 73, in async_setup_platform
Aug 17 21:37:17 a2khome python3.7[1250]:     device.authenticate(device_8370_only_ac_mac, device_8370_only_wifi_ssid, device_8370_only_wifi_pw)
Aug 17 21:37:17 a2khome python3.7[1250]:   File "/home/a2k/smarthome/homeassistant/home-assistant/venv/lib/python3.7/site-packages/msmart/device.py", line 43, in authenticate
Aug 17 21:37:17 a2khome python3.7[1250]:     self._authenticate()
Aug 17 21:37:17 a2khome python3.7[1250]:   File "/home/a2k/smarthome/homeassistant/home-assistant/venv/lib/python3.7/site-packages/msmart/device.py", line 46, in _authenticate
Aug 17 21:37:17 a2khome python3.7[1250]:     self._lan_service.authenticate(self._mac, self._wifi_ssid, self._wifi_pw)
Aug 17 21:37:17 a2khome python3.7[1250]:   File "/home/a2k/smarthome/homeassistant/home-assistant/venv/lib/python3.7/site-packages/msmart/lan.py", line 68, in authenticate
Aug 17 21:37:17 a2khome python3.7[1250]:     self._authenticate()
Aug 17 21:37:17 a2khome python3.7[1250]:   File "/home/a2k/smarthome/homeassistant/home-assistant/venv/lib/python3.7/site-packages/msmart/lan.py", line 80, in _authenticate
Aug 17 21:37:17 a2khome python3.7[1250]:     raise error
Aug 17 21:37:17 a2khome python3.7[1250]:   File "/home/a2k/smarthome/homeassistant/home-assistant/venv/lib/python3.7/site-packages/msmart/lan.py", line 76, in _authenticate
Aug 17 21:37:17 a2khome python3.7[1250]:     tcp_key = self.security.tcp_key(response, self._key)
Aug 17 21:37:17 a2khome python3.7[1250]:   File "/home/a2k/smarthome/homeassistant/home-assistant/venv/lib/python3.7/site-packages/msmart/security.py", line 92, in tcp_key
Aug 17 21:37:17 a2khome python3.7[1250]:     raise Exception('unexpected data length')
Aug 17 21:37:17 a2khome python3.7[1250]: Exception: unexpected data length

The previous log is for "run-time" after the climate component is added to HA

witteschnitte commented 3 years ago

I have the same issue. Is there any solution for this? I cannot use the Integration because of this Error.

I hope for some help and an answer.