diff --git a/src/demetriek/device.py b/src/demetriek/device.py index a78a1506..1256c7de 100644 --- a/src/demetriek/device.py +++ b/src/demetriek/device.py @@ -145,6 +145,7 @@ async def display( brightness: int | None = None, brightness_mode: BrightnessMode | None = None, screensaver_enabled: bool | None = None, + on: bool | None = None, ) -> Display: """Get or set LaMetric device display information. @@ -153,6 +154,7 @@ async def display( brightness: Brightness level to set. brightness_mode: Brightness mode to set. screensaver_enabled: Whether the screensaver should be enabled. + on: Whether the display should be turned on or off. Returns: ------- @@ -171,6 +173,9 @@ async def display( if screensaver_enabled is not None: data["screensaver"] = {"enabled": screensaver_enabled} + if on is not None: + data["on"] = on + if data: response = await self._request( "/api/v2/device/display", diff --git a/src/demetriek/models.py b/src/demetriek/models.py index b06bebce..3fc2981e 100644 --- a/src/demetriek/models.py +++ b/src/demetriek/models.py @@ -72,6 +72,7 @@ class Display(DataClassORJSONMixin): default=None, metadata=field_options(alias="type") ) height: int + on: bool | None = None screensaver: DisplayScreensaver width: int diff --git a/tests/fixtures/display.json b/tests/fixtures/display.json index 955aa4cb..97545dce 100644 --- a/tests/fixtures/display.json +++ b/tests/fixtures/display.json @@ -10,6 +10,7 @@ "min": 0 }, "height": 8, + "on": true, "screensaver": { "enabled": false, "modes": { diff --git a/tests/fixtures/display_set.json b/tests/fixtures/display_set.json index 823f8eb7..954c77bb 100644 --- a/tests/fixtures/display_set.json +++ b/tests/fixtures/display_set.json @@ -12,6 +12,7 @@ "min": 0 }, "height": 8, + "on": true, "screensaver": { "enabled": false, "modes": { diff --git a/tests/test_display.py b/tests/test_display.py index ba2bd73e..bec4ab95 100644 --- a/tests/test_display.py +++ b/tests/test_display.py @@ -32,6 +32,7 @@ async def test_get_display(aresponses: ResponsesMockServer) -> None: assert display.width == 37 assert display.height == 8 assert display.display_type is DisplayType.MIXED + assert display.on is True async def test_set_display(aresponses: ResponsesMockServer) -> None: @@ -46,6 +47,7 @@ async def response_handler(request: aiohttp.ClientResponse) -> Response: "screensaver": { "enabled": False, }, + "on": True, } return aresponses.Response( status=200, @@ -61,6 +63,7 @@ async def response_handler(request: aiohttp.ClientResponse) -> Response: brightness=99, brightness_mode=BrightnessMode.MANUAL, screensaver_enabled=False, + on=True, ) assert display @@ -70,3 +73,4 @@ async def response_handler(request: aiohttp.ClientResponse) -> Response: assert display.height == 8 assert display.display_type is DisplayType.MIXED assert display.screensaver.enabled is False + assert display.on is True