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
7 changes: 4 additions & 3 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ Listing devices linked to your account
myring.doorbells
[<RingDoorBell: Front Door>]

Playing with the attributes
---------------------------
Playing with the attributes and functions
-----------------------------------------
.. code-block:: python

for dev in list(myring.chimes + myring.doorbells):
Expand All @@ -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
Expand Down
9 changes: 5 additions & 4 deletions ring_doorbell/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__)

Expand Down Expand Up @@ -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})

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this be expanded to the "ringtone" the user selected to play?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It probably should be. But i'll leave that to a follow-up. Don't have my phone set-up to do the proxy again right now. :)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes make sense.. You got a good point!!

return True


Expand Down
5 changes: 5 additions & 0 deletions ring_doorbell/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's make a list instead a map

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm sorry, but can you please explain what the key and value of the map would be?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CHIME_TEST_SOUND_KINDS = [KIND_DING, KIND_MOTION]

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why does it have to be a list? What i've used is a tuple which is basically an immutable list (not a map). Which is exactly what we need here.


# default values
CHIME_VOL_MIN = 0
CHIME_VOL_MAX = 10
Expand Down