diff --git a/README.rst b/README.rst index 345a1c0c..78d2d27a 100644 --- a/README.rst +++ b/README.rst @@ -65,8 +65,8 @@ Listing devices linked to your account myring.doorbells [] -Playing with the attributes ---------------------------- +Playing with the attributes and functions +----------------------------------------- .. code-block:: python for dev in list(myring.chimes + myring.doorbells): @@ -88,7 +88,8 @@ Playing with the attributes # play dev test shound if dev.family == 'chimes' - dev.test_sound + dev.test_sound(kind = 'ding') + dev.test_sound(kind = 'motion') Showing door bell events diff --git a/ring_doorbell/__init__.py b/ring_doorbell/__init__.py index 4d875044..1de6f4d1 100644 --- a/ring_doorbell/__init__.py +++ b/ring_doorbell/__init__.py @@ -25,7 +25,7 @@ MSG_GENERIC_FAIL, MSG_VOL_OUTBOUND, NOT_FOUND, URL_DOORBELL_HISTORY, URL_RECORDING, POST_DATA, PERSIST_TOKEN_ENDPOINT, PERSIST_TOKEN_DATA, - RETRY_TOKEN, TESTSOUND_CHIME_ENDPOINT) + RETRY_TOKEN, TESTSOUND_CHIME_ENDPOINT, CHIME_TEST_SOUND_KINDS, KIND_DING) _LOGGER = logging.getLogger(__name__) @@ -388,11 +388,12 @@ def linked_tree(self): url = API_URI + LINKED_CHIMES_ENDPOINT.format(self.account_id) return self._ring.query(url) - @property - def test_sound(self): + def test_sound(self, kind=KIND_DING): """Play chime to test sound.""" + if kind not in CHIME_TEST_SOUND_KINDS: + return False url = API_URI + TESTSOUND_CHIME_ENDPOINT.format(self.account_id) - self._ring.query(url, method='POST') + self._ring.query(url, method='POST', extra_params={"kind": kind}) return True diff --git a/ring_doorbell/const.py b/ring_doorbell/const.py index 084ccfe1..00d6ec3c 100644 --- a/ring_doorbell/const.py +++ b/ring_doorbell/const.py @@ -40,6 +40,11 @@ URL_DOORBELL_HISTORY = DOORBELLS_ENDPOINT + '/history' URL_RECORDING = '/clients_api/dings/{0}/recording' +# chime test sound kinds +KIND_DING = 'ding' +KIND_MOTION = 'motion' +CHIME_TEST_SOUND_KINDS = (KIND_DING, KIND_MOTION) + # default values CHIME_VOL_MIN = 0 CHIME_VOL_MAX = 10