WIP: Issue#2

Micke Nordin 3 years ago
parent 707f764a65
commit 80bdb13a81
Signed by: micke
GPG Key ID: 014B273D614BE877

@ -27,6 +27,8 @@ class HueBridge:
else:
self.m_name = self.m_ipaddress
self.m_lights: list[HueLight] = self.discover_lights()
self.discover_new_lights()
self.m_new_lights: list[HueLight] = self.get_new_lights()
self.m_groups: list[HueGroup] = self.discover_groups()
def __str__(self) -> str:
@ -183,6 +185,19 @@ class HueBridge:
"""
return self.m_lights
def get_new_lights(self) -> list[HueLight]:
path: str = "{}/lights/new".format(self.m_username)
response = make_request(self.m_ipaddress, path)
newlights: list[HueLight] = list()
for lightid, nameobj in response.json().items():
if lightid != "lastscan":
print(lightid)
if not self.get_light_by_id(int(lightid)):
lightpath: str = "{}/lights/{}".format(self.m_username, int(lightid))
lightresponse = make_request(self.m_ipaddress, lightpath)
newlights.append(HueLight(int(lightid), lightresponse.json(), self.get_ipaddress(),self.get_user()))
return newlights
def get_user(self) -> str:
"""A user, or username, is more like a password and is needed to authenticate with the Hue API

Loading…
Cancel
Save