Skip to content

Commit

Permalink
Merge pull request #216 from PiotrMachowski/dev
Browse files Browse the repository at this point in the history
Add fallback for older HA versions
  • Loading branch information
PiotrMachowski authored Jan 3, 2022
2 parents f95db4b + b8c1965 commit 98f28a7
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions custom_components/xiaomi_cloud_map_extractor/camera.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@
from datetime import timedelta
from enum import Enum

import miio
try:
from miio import RoborockVacuum, DeviceException
except ImportError:
from miio import Vacuum as RoborockVacuum, DeviceException
import PIL.Image as Image
import voluptuous as vol
from homeassistant.components.camera import Camera, ENTITY_ID_FORMAT, PLATFORM_SCHEMA, SUPPORT_ON_OFF
Expand Down Expand Up @@ -145,7 +148,7 @@ def __init__(self, entity_id, host, token, username, password, country, name, sh
super().__init__()
self.entity_id = entity_id
self.content_type = CONTENT_TYPE
self._vacuum = miio.RoborockVacuum(host, token)
self._vacuum = RoborockVacuum(host, token)
self._connector = XiaomiCloudConnector(username, password)
self._status = CameraStatus.INITIALIZING
self._device = None
Expand Down Expand Up @@ -300,7 +303,7 @@ def _handle_map_name(self, counter):
_LOGGER.debug("Map name %s", map_name)
except OSError as exc:
_LOGGER.error("Got OSError while fetching the state: %s", exc)
except miio.DeviceException as exc:
except DeviceException as exc:
if self._received_map_name_previously:
_LOGGER.warning("Got exception while fetching the state: %s", exc)
self._received_map_name_previously = False
Expand Down

0 comments on commit 98f28a7

Please sign in to comment.