55from yarl import URL
66
77from . import _request as request
8- from .constants import API , DEVICE_INFO , TEMPERATURE
8+ from .constants import API , DEVICE_INFO , TEMPERATURE , LIGHT
99
1010_LOGGER = logging .getLogger (__name__ )
1111
@@ -20,22 +20,31 @@ def __init__(self, host: str, session: aiohttp.client.ClientSession = None) -> N
2020 self ._session = session
2121 self ._device_details = None
2222 self ._temperature = None
23+ self ._intensity = None
24+ self ._day = None
2325 self .uri = URL .build (scheme = "http" , host = self ._host ).join (URL (API ))
2426
2527 async def get_device_info (self ) -> None :
26- """Get the details from the switch ."""
28+ """Get the details from the dingz ."""
2729 url = URL (self .uri ).join (URL (DEVICE_INFO ))
2830 response = await request (self , uri = url )
2931 self ._device_details = response
3032
3133 async def get_temperature (self ) -> None :
32- """Get the details from the switch ."""
34+ """Get the room temperature from the dingz ."""
3335 url = URL (self .uri ).join (URL (TEMPERATURE ))
3436 response = await request (self , uri = url )
3537 self ._temperature = response ["temperature" ]
3638
39+ async def get_light (self ) -> None :
40+ """Get the light details from the switch."""
41+ url = URL (self .uri ).join (URL (LIGHT ))
42+ response = await request (self , uri = url )
43+ self ._intensity = response ["intensity" ]
44+ self ._day = response ["day" ]
45+
3746 @property
38- def device_details (self ) -> float :
47+ def device_details (self ) -> str :
3948 """Return the current device details."""
4049 return self ._device_details
4150
@@ -44,6 +53,16 @@ def temperature(self) -> float:
4453 """Return the current temperature in celsius."""
4554 return round (self ._temperature , 1 )
4655
56+ @property
57+ def day (self ) -> bool :
58+ """Return true if the sensor thinks it's day."""
59+ return bool (self ._day )
60+
61+ @property
62+ def intensity (self ) -> float :
63+ """Return the current light intensity in lux."""
64+ return round (self ._intensity , 1 )
65+
4766 async def close (self ) -> None :
4867 """Close an open client session."""
4968 if self ._session and self ._close_session :
0 commit comments