diff --git a/README.rst b/README.rst index 78d2d27a..94a319dd 100644 --- a/README.rst +++ b/README.rst @@ -65,11 +65,15 @@ Listing devices linked to your account myring.doorbells [] + # All stickup cams + myring.stickup_cams + [] + Playing with the attributes and functions ----------------------------------------- .. code-block:: python - for dev in list(myring.chimes + myring.doorbells): + for dev in list(myring.stickup_cams + myring.chimes + myring.doorbells): # refresh data dev.update() diff --git a/ring_doorbell/__init__.py b/ring_doorbell/__init__.py index 62474b9a..1a2310e7 100644 --- a/ring_doorbell/__init__.py +++ b/ring_doorbell/__init__.py @@ -207,6 +207,7 @@ def devices(self): """Return all devices.""" devs = {} devs['chimes'] = self.chimes + devs['stickup_cams'] = self.stickup_cams devs['doorbells'] = self.doorbells return devs @@ -215,6 +216,11 @@ def __devices(self, device_type): lst = [] url = API_URI + DEVICES_ENDPOINT try: + if device_type == 'stickup_cams': + req = self.query(url).get('stickup_cams') + for member in list((obj['description'] for obj in req)): + lst.append(RingStickUpCam(self, member)) + if device_type == 'chime': req = self.query(url).get('chimes') for member in list((obj['description'] for obj in req)): @@ -239,6 +245,11 @@ def chimes(self): """Return a list of RingDoorChime objects.""" return self.__devices('chime') + @property + def stickup_cams(self): + """Return a list of RingStickUpCam objects.""" + return self.__devices('stickup_cams') + @property def doorbells(self): """Return a list of RingDoorBell objects.""" @@ -396,7 +407,6 @@ def test_sound(self, kind=KIND_DING): self._ring.query(url, method='POST', extra_params={"kind": kind}) return True - class RingDoorBell(RingGeneric): """Implementation for Ring Doorbell.""" @@ -653,8 +663,21 @@ def volume(self, value): self._ring.query(url, extra_params=params, method='PUT') self.update() return True - + @property def connection_status(self): """Return connection status.""" return self._attrs.get('alerts').get('connection') + + +class RingStickUpCam(RingDoorBell): + """Implementation for Ring RingStickUpCam.""" + + def __init__(self, ring, name): + super(RingDoorBell, self).__init__() + self._attrs = None + self._ring = ring + self.debug = self._ring.debug + self.family = 'stickup_cams' + self.name = name + self.update() \ No newline at end of file