Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions nanoleafapi/nanoleaf.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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']

#######################################################
Expand Down Expand Up @@ -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']

#######################################################
Expand Down Expand Up @@ -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']

#######################################################
Expand Down Expand Up @@ -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']

#######################################################
Expand Down