mac-zhou / midea-msmart

This is a library to allow communicating to a Midea AC via the Local area network.
MIT License
147 stars 40 forks source link

Exception if the host is unreachable #12

Closed zvldz closed 4 years ago

zvldz commented 4 years ago

If the host is unreachable, there are errors in HA logs.

2020-06-16 08:49:47 ERROR (MainThread) [homeassistant.helpers.entity] Update for climate.midea_ac_81YY000000XX fails
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 279, in async_update_ha_state
    await self.async_device_update()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 470, in async_device_update
    await self.async_update()
  File "/config/custom_components/midea_ac/climate.py", line 108, in async_update
    await self.hass.async_add_executor_job(self._device.refresh)
  File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/local/lib/python3.7/site-packages/msmart/device.py", line 179, in refresh
    data = self._lan_service.appliance_transparent_send(data)
  File "/usr/local/lib/python3.7/site-packages/msmart/lan.py", line 76, in appliance_transparent_send
    response = bytearray(self.request(data))
  File "/usr/local/lib/python3.7/site-packages/msmart/lan.py", line 34, in request
    sock.connect(device_address)
OSError: [Errno 113] Host is unreachable
mac-zhou commented 4 years ago

LGTM, Thanks 👍