From be7f616a0ceb144347d2a630560c3ebe9f0cc129 Mon Sep 17 00:00:00 2001 From: "Ryan C. Boykin" Date: Sun, 7 Sep 2025 14:25:50 -0500 Subject: [PATCH 1/2] Fix for #19 while trying to prevent breaking other devices. --- nanoleafapi/nanoleaf.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/nanoleafapi/nanoleaf.py b/nanoleafapi/nanoleaf.py index 0c67c7d..b8c9057 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: From deba9b5a05fd8f92138e7f2a62a0d2a256754b82 Mon Sep 17 00:00:00 2001 From: "Ryan C. Boykin" Date: Thu, 11 Sep 2025 23:07:09 -0500 Subject: [PATCH 2/2] Other API endpoints need to be extracted too --- nanoleafapi/nanoleaf.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/nanoleafapi/nanoleaf.py b/nanoleafapi/nanoleaf.py index b8c9057..f44319d 100644 --- a/nanoleafapi/nanoleaf.py +++ b/nanoleafapi/nanoleaf.py @@ -286,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'] ####################################################### @@ -332,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'] ####################################################### @@ -367,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'] ####################################################### @@ -402,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'] #######################################################