diff --git a/nanoleafapi/nanoleaf.py b/nanoleafapi/nanoleaf.py index 0c67c7d..f44319d 100644 --- a/nanoleafapi/nanoleaf.py +++ b/nanoleafapi/nanoleaf.py @@ -216,6 +216,8 @@ def get_power(self) -> bool: """ response = requests.get(self.url + "/state/on") ans = json.loads(response.text) + if 'on' in ans: + ans = ans['on'] return ans['value'] def toggle_power(self) -> bool: @@ -284,6 +286,8 @@ def get_brightness(self) -> int: """Returns the current brightness value of the lights""" response = requests.get(self.url + "/state/brightness") ans = json.loads(response.text) + if 'brightness' in ans: + ans = ans['brightness'] return ans['value'] ####################################################### @@ -330,6 +334,8 @@ def get_hue(self) -> int: """Returns the current hue value of the lights""" response = requests.get(self.url + "/state/hue") ans = json.loads(response.text) + if 'hue' in ans: + ans = ans['hue'] return ans['value'] ####################################################### @@ -365,6 +371,8 @@ def get_saturation(self) -> int: """Returns the current saturation value of the lights""" response = requests.get(self.url + "/state/sat") ans = json.loads(response.text) + if 'sat' in ans: + ans = ans['sat'] return ans['value'] ####################################################### @@ -400,6 +408,8 @@ def get_color_temp(self) -> int: """Returns the current colour temperature of the lights""" response = requests.get(self.url + "/state/ct") ans = json.loads(response.text) + if 'ct' in ans: + ans = ans['ct'] return ans['value'] #######################################################