Add set_states method - #17
Conversation
|
@cydrobolt I am really enjoying using your Pifx library. I needed to add a method for an endpoint that wasn't in the library. Will you consider accepting my PR? Please let me know if you'd like me to make any other changes to this PR. Thanks in advance! |
| method='put', endpoint='lights/{}/state', | ||
| endpoint_args=[selector], argument_tuples=argument_tuples) | ||
|
|
||
| def set_states(self, states=[{'selector': 'all', |
There was a problem hiding this comment.
This default argument seems potentially error-prone. See https://docs.python-guide.org/writing/gotchas/#mutable-default-arguments
It might be better to write states=None and then if states is None: states = [] in the method itself.
There was a problem hiding this comment.
@cydrobolt I have updated the method to remove the mutable default argument. I added a usage example in the docstring so users will hopefully know how to call it. Let me know if you'd like to see any other changes!
This PR simply adds a method for the Lifx "Set States" endpoint so that multiple lights can be set simultaneously. It also addresses a defect in "client.py" which was preventing
json_bodyparameters from being sent in requests to the Lifx API.