From 6f5283448ea5490f8cd3e09b10d7103bde86e1b1 Mon Sep 17 00:00:00 2001 From: brentrubell Date: Mon, 20 May 2019 15:21:59 -0400 Subject: [PATCH] Revert "Allow kwargs for set_color" --- adafruit_lifx.py | 26 +++++++++++++++++++------- examples/lifx_simpletest.py | 2 +- 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/adafruit_lifx.py b/adafruit_lifx.py index 212c0cb..d4aadcb 100644 --- a/adafruit_lifx.py +++ b/adafruit_lifx.py @@ -123,8 +123,9 @@ def toggle_light(self, selector, all_lights=False, duration=0): """ if all_lights: selector = 'all' + path = LIFX_URL+selector+'/toggle' data = {'duration':duration} - return self._post(LIFX_URL+selector+'/toggle', data) + return self._post(path, data) def move_effect(self, selector, move_direction, period, power_on): """Performs a linear move effect on a light, or lights. @@ -132,32 +133,43 @@ def move_effect(self, selector, move_direction, period, power_on): :param double period: Time in second per effect cycle. :param bool power_on: Turn on a light before performing the move. """ + path = LIFX_URL+selector+'/effects/move' data = {'direction':move_direction, 'period':period, 'power_on':power_on} - return self._post(LIFX_URL+selector+'/effects/move', data) + return self._post(path, data) def effects_off(self, selector, power_off=False): """Turns off any running effects on the selected device. :param dict selector: Selector to control which lights are requested. :param bool power_off: If true, the devices will also be turned off. """ + path = LIFX_URL+selector+'/effects/off' data = {'power_off', power_off} - return self._post(LIFX_URL+selector+'/effects/off', data) + return self._post(path, data) def set_brightness(self, selector, brightness): """Sets the state of the lights within the selector. :param dict selector: Selector to control which lights are requested. :param double brightness: Brightness level of the light, from 0.0 to 1.0. """ + path = LIFX_URL+selector+'/state' data = {'brightness':brightness} - return self._put(LIFX_URL+selector+'/state', data) + return self._put(path, data) - def set_color(self, selector, **kwargs): + def set_color(self, selector, power, color, brightness=1.0): """Sets the state of the light's color within the selector. - Valid arguments: https://api.developer.lifx.com/docs/set-state + :param dict selector: Selector to control which lights are requested. + :param str power: Sets the power state of the light (on/off). + :param str color: Color to set the light to (https://api.developer.lifx.com/v1/docs/colors). + :param double brightness: Brightness level of the light from 0.0 to 1.0. """ - return self._put(LIFX_URL+selector+'/state', kwargs) + path = LIFX_URL+selector+'/state' + data = {'power':power, + 'color':color, + 'brightness':brightness + } + return self._put(path, data) def list_lights(self): """Enumerates all the lights associated with the LIFX Cloud Account diff --git a/examples/lifx_simpletest.py b/examples/lifx_simpletest.py index 6ef30c8..9baf000 100644 --- a/examples/lifx_simpletest.py +++ b/examples/lifx_simpletest.py @@ -49,7 +49,7 @@ colors = ['yellow', 'blue', 'white'] for color in colors: print('Setting light to: ', color) - lifx.set_color(lifx_light, power='on', color=color, brightness=light_brightness) + lifx.set_color(lifx_light, 'on', color, brightness=light_brightness) # Turn off the light print('Turning off light...')