Skip to content

Commit eaff201

Browse files
committed
Add night
1 parent 8cbc328 commit eaff201

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

dingz/dingz.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ def __init__(self, host: str, session: aiohttp.client.ClientSession = None) -> N
3737
self._temperature = None
3838
self._intensity = None
3939
self._day = None
40+
self._night = None
41+
self._hour_of_day = None
4042
self.uri = URL.build(scheme="http", host=self._host).join(URL(API))
4143

4244
async def get_device_info(self) -> None:
@@ -74,8 +76,9 @@ async def get_light(self) -> None:
7476
"""Get the light details from the switch."""
7577
url = URL(self.uri).join(URL(LIGHT))
7678
response = await make_call(self, uri=url)
79+
print(response)
7780
self._intensity = response["intensity"]
78-
self._day = response["day"]
81+
self._hour_of_day = response["state"]
7982

8083
async def enabled(self) -> bool:
8184
"""Return true if front LED is on."""
@@ -118,7 +121,12 @@ def temperature(self) -> float:
118121
@property
119122
def day(self) -> bool:
120123
"""Return true if the sensor thinks it's day."""
121-
return bool(self._day)
124+
return True if self._hour_of_day == "day" else False
125+
126+
@property
127+
def night(self) -> bool:
128+
"""Return true if the sensor thinks it's night."""
129+
return True if self._hour_of_day == "night" else False
122130

123131
@property
124132
def intensity(self) -> float:

0 commit comments

Comments
 (0)