|
5 | 5 | from yarl import URL |
6 | 6 |
|
7 | 7 | from . import _request as request |
8 | | -from .constants import API, DEVICE_INFO, TEMPERATURE, LIGHT |
| 8 | +from .constants import API, DEVICE_INFO, TEMPERATURE, LIGHT, FRONT_LED_GET, FRONT_LED_SET |
| 9 | +from .exceptions import DingzError |
9 | 10 |
|
10 | 11 | _LOGGER = logging.getLogger(__name__) |
11 | 12 |
|
@@ -43,6 +44,23 @@ async def get_light(self) -> None: |
43 | 44 | self._intensity = response["intensity"] |
44 | 45 | self._day = response["day"] |
45 | 46 |
|
| 47 | + async def enabled(self) -> bool: |
| 48 | + """Return true if front LED is on.""" |
| 49 | + url = URL(self.uri).join(URL(FRONT_LED_GET)) |
| 50 | + response = await request(self, uri=url) |
| 51 | + return bool(response["on"]) |
| 52 | + |
| 53 | + async def turn_on(self) -> None: |
| 54 | + """Enable/turn on the front LED.""" |
| 55 | + data = {"action": "on"} |
| 56 | + url = URL(self.uri).join(URL(FRONT_LED_SET)) |
| 57 | + await request(self, uri=url, method="POST", data=data) |
| 58 | + |
| 59 | + async def turn_off(self) -> None: |
| 60 | + """Disable/turn off the front LED.""" |
| 61 | + url = URL(self.uri).join(URL(FRONT_LED_SET)) |
| 62 | + await request(self, uri=url, method="POST", data={"action": "off"}) |
| 63 | + |
46 | 64 | @property |
47 | 65 | def device_details(self) -> str: |
48 | 66 | """Return the current device details.""" |
|
0 commit comments