Skip to content

Refactored project to make it more Pythonish and transparent - #14

Merged
tchellomello merged 8 commits into
devfrom
refactor_python
Feb 25, 2017
Merged

Refactored project to make it more Pythonish and transparent#14
tchellomello merged 8 commits into
devfrom
refactor_python

Conversation

@tchellomello

@tchellomello tchellomello commented Feb 24, 2017

Copy link
Copy Markdown
Member

BREAK CHANGES (not ready to commit yet)

This PR is basically a rewrite from the project which nows allows to treat the devices as objects and not as functions anymore. This change will introduce more transparency to the user.

In [1]: from ring_doorbell import Ring
In [2]: myring = Ring('user@email.com', 'password')

In [3]: myring.devices
Out[3]: 
{'chimes': [<RingChime: Downstairs>],
 'doorbells': [<RingDoorBell: Front Door>]}
 
In [4]: myring.chimes
Out[4]: [<RingChime: Downstairs>]

In [5]: myring.doorbells
Out[5]: [<RingDoorBell: Front Door>]

In [6]: mychime = myring.chimes[0]

In [7]: mychime.
         mychime.account_id         mychime.firmware           mychime.linked_tree        mychime.subscribed_motions 
         mychime.address            mychime.id                 mychime.longitude          mychime.timezone           
         mychime.debug              mychime.kind               mychime.name               mychime.update             
         mychime.family             mychime.latitude           mychime.subscribed         mychime.volume  

In [7]: mychime.volume
Out[7]: 5
    
#updating volume
In [8]: mychime.volume = 200
Must be within the 0-10.

In [9]: mychime.volume = 4

In [10]: mychime.volume
Out[10]: 4

# DoorBells 
In [11]: mydoorbell = myring.doorbells[0]

In [12]: mydoorbell.
                     mydoorbell.account_id                      mydoorbell.kind                            
                     mydoorbell.address                         mydoorbell.last_recording_id               
                     mydoorbell.battery_life                    mydoorbell.latitude                        
                     mydoorbell.check_activity                  mydoorbell.live_streaming_json             
                     mydoorbell.debug                           mydoorbell.longitude                       
                     mydoorbell.existing_doorbell_type          mydoorbell.name                            
                     mydoorbell.existing_doorbell_type_duration mydoorbell.recording_download              
                     mydoorbell.existing_doorbell_type_enabled  mydoorbell.recording_url                   
                     mydoorbell.family                          mydoorbell.timezone                        
                     mydoorbell.firmware                        mydoorbell.update                          
                     mydoorbell.history                         mydoorbell.volume                          
                     mydoorbell.id                                                                
                     
In [12]: mydoorbell.last_recording_id
Out[12]: 2222222221

In [14]: mydoorbell.existing_doorbell_type
Out[14]: 'Mechanical'

In [15]: mydoorbell.existing_doorbell_type_enabled
Out[15]: True

In [16]: mydoorbell.existing_doorbell_type_enabled = False

In [17]: mydoorbell.existing_doorbell_type_enabled
Out[17]: False

Fixes issue #13

@tchellomello tchellomello added this to the v0.1.0 milestone Feb 24, 2017
@tchellomello tchellomello self-assigned this Feb 24, 2017
Comment thread ring_doorbell/__init__.py Outdated
def test_sound(self):
"""Play chime to test sound."""
url = API_URI + TESTSOUND_CHIME_ENDPOINT.format(self.account_id)
response = self._ring.query(url, method='POST')

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

local variable 'response' is assigned to but never used

@syphernl

Copy link
Copy Markdown

Seems to work fine except for existing_doorbell_type which seems to throws an exception.

However, odd thing: If I press tab after mychime. to autocomplete it somehow triggers the mychime.test_sound. My dog did not appreciate that 😆

@tchellomello

tchellomello commented Feb 24, 2017

Copy link
Copy Markdown
Member Author

@syphernl could you please test it again? And my dogs also love this feature :)
Thank you 👍

@tchellomello
tchellomello merged commit 0fe5a0e into dev Feb 25, 2017
@tchellomello
tchellomello deleted the refactor_python branch February 25, 2017 09:02
@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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants