Skip to content

Commit

Permalink
Add fallback for older HA versions
Browse files Browse the repository at this point in the history
  • Loading branch information
PiotrMachowski committed Jan 3, 2022
1 parent 162ef22 commit b8c1965
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 b8c1965

Please sign in to comment.