Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ring_doorbell/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ def query(self,
response = req.json()
break

if self.debug:
if self.debug and response is None:
_LOGGER.debug("%s", MSG_GENERIC_FAIL)
return response

Expand Down
18 changes: 14 additions & 4 deletions ring_doorbell/chime.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from ring_doorbell.const import (
API_URI, CHIMES_ENDPOINT, CHIME_VOL_MIN, CHIME_VOL_MAX,
LINKED_CHIMES_ENDPOINT, MSG_VOL_OUTBOUND, TESTSOUND_CHIME_ENDPOINT,
CHIME_TEST_SOUND_KINDS, KIND_DING)
CHIME_TEST_SOUND_KINDS, KIND_DING, CHIME_KINDS, CHIME_PRO_KINDS)

_LOGGER = logging.getLogger(__name__)

Expand All @@ -21,9 +21,19 @@ def family(self):
return 'chimes'

@property
def battery_life(self):
"""Return battery life."""
return int(self._health_attrs.get('battery_percentage'))
def model(self):
"""Return Ring device model name."""
if self.kind in CHIME_KINDS:
return 'Chime'
elif self.kind in CHIME_PRO_KINDS:
return 'Chime Pro'
return None

def has_capability(self, capability):
"""Return if device has specific capability."""
if capability == 'volume':
return True
return False

@property
def volume(self):
Expand Down
16 changes: 16 additions & 0 deletions ring_doorbell/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,22 @@
SIREN_DURATION_MIN = 0
SIREN_DURATION_MAX = 120

# device model kinds
CHIME_KINDS = ['chime']
CHIME_PRO_KINDS = ['chime_pro']

DOORBELL_KINDS = ['doorbot', 'doorbell', 'doorbell_v3']
DOORBELL_2_KINDS = ['doorbell_v4', 'doorbell_v5']
DOORBELL_PRO_KINDS = ['lpd_v1', 'lpd_v2']
DOORBELL_ELITE_KINDS = ['jbox_v1']

FLOODLIGHT_CAM_KINDS = ['hp_cam_v1']
SPOTLIGHT_CAM_BATTERY_KINDS = ['stickup_cam_v4']
SPOTLIGHT_CAM_WIRED_KINDS = ['hp_cam_v2']
STICKUP_CAM_KINDS = ['stickup_cam', 'stickup_cam_v3']
STICKUP_CAM_BATTERY_KINDS = ['stickup_cam_lunar']
STICKUP_CAM_WIRED_KINDS = ['stickup_cam_elite']

# error strings
MSG_BOOLEAN_REQUIRED = "Boolean value is required."
MSG_EXISTING_TYPE = "Integer value where {0}.".format(DOORBELL_EXISTING_TYPE)
Expand Down
32 changes: 28 additions & 4 deletions ring_doorbell/doorbot.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,12 @@
from ring_doorbell.utils import _save_cache
from ring_doorbell.const import (
API_URI, DOORBELLS_ENDPOINT, DOORBELL_VOL_MIN, DOORBELL_VOL_MAX,
DOORBELL_EXISTING_TYPE, DINGS_ENDPOINT, FILE_EXISTS,
LIVE_STREAMING_ENDPOINT, MSG_BOOLEAN_REQUIRED, MSG_EXISTING_TYPE,
MSG_VOL_OUTBOUND, SNAPSHOT_ENDPOINT, SNAPSHOT_TIMESTAMP_ENDPOINT,
URL_DOORBELL_HISTORY, URL_RECORDING)
DOORBELL_EXISTING_TYPE, DINGS_ENDPOINT, DOORBELL_KINDS,
DOORBELL_2_KINDS, DOORBELL_PRO_KINDS, DOORBELL_ELITE_KINDS,
FILE_EXISTS, LIVE_STREAMING_ENDPOINT, MSG_BOOLEAN_REQUIRED,
MSG_EXISTING_TYPE, MSG_VOL_OUTBOUND, SNAPSHOT_ENDPOINT,
SNAPSHOT_TIMESTAMP_ENDPOINT, URL_DOORBELL_HISTORY,
URL_RECORDING)

_LOGGER = logging.getLogger(__name__)

Expand All @@ -29,6 +31,28 @@ def family(self):
"""Return Ring device family type."""
return 'doorbots'

@property
def model(self):
"""Return Ring device model name."""
if self.kind in DOORBELL_KINDS:
return 'Doorbell'
elif self.kind in DOORBELL_2_KINDS:
return 'Doorbell 2'
elif self.kind in DOORBELL_PRO_KINDS:
return 'Doorbell Pro'
elif self.kind in DOORBELL_ELITE_KINDS:
return 'Doorbell Elite'
return None

def has_capability(self, capability):
"""Return if device has specific capability."""
if capability == 'battery':
return self.kind in (DOORBELL_KINDS +
DOORBELL_2_KINDS)
elif capability == 'volume':
return True
return False

@property
def battery_life(self):
"""Return battery life."""
Expand Down
9 changes: 9 additions & 0 deletions ring_doorbell/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,15 @@ def family(self):
"""Return Ring device family type."""
return None

@property
def model(self):
"""Return Ring device model name."""
return None

def has_capability(self, capability):
"""Return if device has specific capability."""
return False

def update(self):
"""Refresh attributes."""
self._get_attrs()
Expand Down
40 changes: 40 additions & 0 deletions ring_doorbell/stickup_cam.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
from ring_doorbell import RingDoorBell
from ring_doorbell.const import (
API_URI, LIGHTS_ENDPOINT, MSG_ALLOWED_VALUES, MSG_VOL_OUTBOUND,
FLOODLIGHT_CAM_KINDS, SPOTLIGHT_CAM_BATTERY_KINDS,
SPOTLIGHT_CAM_WIRED_KINDS, STICKUP_CAM_KINDS,
STICKUP_CAM_BATTERY_KINDS, STICKUP_CAM_WIRED_KINDS,
SIREN_DURATION_MIN, SIREN_DURATION_MAX, SIREN_ENDPOINT)

_LOGGER = logging.getLogger(__name__)
Expand All @@ -19,6 +22,43 @@ def family(self):
"""Return Ring device family type."""
return 'stickup_cams'

@property
def model(self):
"""Return Ring device model name."""
if self.kind in FLOODLIGHT_CAM_KINDS:
return 'Floodlight Cam'
elif self.kind in SPOTLIGHT_CAM_BATTERY_KINDS:
return 'Spotlight Cam {}'.format(
self._attrs.get('ring_cam_setup_flow', 'battery').title())
elif self.kind in SPOTLIGHT_CAM_WIRED_KINDS:
return 'Spotlight Cam {}'.format(
self._attrs.get('ring_cam_setup_flow', 'wired').title())
elif self.kind in STICKUP_CAM_KINDS:
return 'Stick Up Cam'
elif self.kind in STICKUP_CAM_BATTERY_KINDS:
return 'Stick Up Cam Battery'
elif self.kind in STICKUP_CAM_WIRED_KINDS:
return 'Stick Up Cam Wired'
return None

def has_capability(self, capability):
"""Return if device has specific capability."""
if capability == 'battery':
return self.kind in (SPOTLIGHT_CAM_BATTERY_KINDS +
STICKUP_CAM_KINDS +
STICKUP_CAM_BATTERY_KINDS)
elif capability == 'light':
return self.kind in (FLOODLIGHT_CAM_KINDS +
SPOTLIGHT_CAM_BATTERY_KINDS +
SPOTLIGHT_CAM_WIRED_KINDS)
elif capability == 'siren':
return self.kind in (FLOODLIGHT_CAM_KINDS +
SPOTLIGHT_CAM_BATTERY_KINDS +
SPOTLIGHT_CAM_WIRED_KINDS +
STICKUP_CAM_BATTERY_KINDS +
STICKUP_CAM_WIRED_KINDS)
return False

@property
def lights(self):
"""Return lights status."""
Expand Down
13 changes: 13 additions & 0 deletions tests/test_ring.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ def test_chime_attributes(self, mock):
self.assertNotEqual(99999, dev.account_id)
self.assertEqual('abcdef123', dev.id)
self.assertEqual('chime', dev.kind)
self.assertEqual('Chime', dev.model)
self.assertEqual(False, dev.has_capability('battery'))
self.assertEqual(True, dev.has_capability('volume'))
self.assertIsNotNone(dev.latitude)
self.assertEqual('America/New_York', dev.timezone)
self.assertEqual(2, dev.volume)
Expand All @@ -71,6 +74,9 @@ def test_doorbell_attributes(self, mock):
self.assertEqual(987652, dev.account_id)
self.assertEqual('123 Main St', dev.address)
self.assertEqual('lpd_v1', dev.kind)
self.assertEqual('Doorbell Pro', dev.model)
self.assertEqual(False, dev.has_capability('battery'))
self.assertEqual(True, dev.has_capability('volume'))
self.assertEqual(-70.12345, dev.longitude)
self.assertEqual('America/New_York', dev.timezone)
self.assertEqual(1, dev.volume)
Expand Down Expand Up @@ -109,6 +115,9 @@ def test_shared_doorbell_attributes(self, mock):
self.assertEqual(51, dev.battery_life)
self.assertEqual('123 Second St', dev.address)
self.assertEqual('lpd_v1', dev.kind)
self.assertEqual('Doorbell Pro', dev.model)
self.assertEqual(False, dev.has_capability('battery'))
self.assertEqual(True, dev.has_capability('volume'))
self.assertEqual(-70.12345, dev.longitude)
self.assertEqual('America/New_York', dev.timezone)
self.assertEqual(5, dev.volume)
Expand Down Expand Up @@ -146,6 +155,10 @@ def test_stickup_cam_attributes(self, mock):

data = self.ring_persistent
for dev in data.stickup_cams:
self.assertEqual('hp_cam_v1', dev.kind)
self.assertEqual('Floodlight Cam', dev.model)
self.assertEqual(False, dev.has_capability('battery'))
self.assertEqual(True, dev.has_capability('light'))
self.assertEqual('off', dev.lights)
self.assertEqual(0, dev.siren)

Expand Down