Skip to content

Allows history to enforce to return minimum number of events for a given type - #56

Merged
tchellomello merged 1 commit into
masterfrom
history_limit_issue_45
Oct 17, 2017
Merged

Allows history to enforce to return minimum number of events for a given type#56
tchellomello merged 1 commit into
masterfrom
history_limit_issue_45

Conversation

@tchellomello

Copy link
Copy Markdown
Member

Allow the user to call history() to select a specific number of events of a given kind.

Fixes: #45

from ring_doorbell import Ring
myring = Ring('user', 'password')
doorbell = myring.doorbells[0]


# showing all my last 3 events captured by the camera
[z.get('kind') for z in doorbell.history(limit=3)]
['motion', 'motion', 'motion']

# no events were listed because it looked up the last 3 events which are motion not kind
[z.get('kind') for z in doorbell.history(limit=3, kind='ding')]
[] 

# however it can be enforced now with this PR
[z.get('kind') for z in doorbell.history(limit=3, kind='ding', enforce_limit=True)]
['ding', 'ding', 'ding']

# it is also possible to determine how many times the query will be executed until the limit is reached
[z.get('kind') for z in doorbell.history(limit=3, kind='ding', enforce_limit=True, retry=1)]
WARNING:ring_doorbell.doorbot:Could not find total of 3 of kind ding
[]

[z.get('kind') for z in doorbell.history(limit=3, kind='ding', enforce_limit=True, retry=4)]
WARNING:ring_doorbell.doorbot:Could not find total of 3 of kind ding
['ding', 'ding']

[z.get('kind') for z in doorbell.history(limit=3, kind='ding', enforce_limit=True, retry=8)]
['ding', 'ding', 'ding']

@asantaga I had to add the new parameter enforce_limit to don't the current API. So this way, the old behavior continues the same, however it can be enforced now with the new parameters.

Please give a try or let me know if that looks for your so then we can commit and publish the newer version since this is the last issue for the 0.1.5 milestone.

Thank you!

@coveralls

coveralls commented Oct 16, 2017

Copy link
Copy Markdown

Coverage Status

Coverage increased (+1.4%) to 65.405% when pulling b7e4bb5 on history_limit_issue_45 into ae9f717 on master.

@tchellomello tchellomello added the bug Label for issues that report a bug label Oct 16, 2017
@tchellomello
tchellomello merged commit 7739c76 into master Oct 17, 2017
@tchellomello

Copy link
Copy Markdown
Member Author

Committed for now. I've tested it and so far worked as expected.

@tchellomello
tchellomello deleted the history_limit_issue_45 branch October 17, 2017 04:01
@github-actions github-actions Bot locked and limited conversation to collaborators Apr 18, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

bug Label for issues that report a bug enhancement feature-request unittest

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants