Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,9 @@ Besides the local device API, it can:

- Talk to the LaMetric cloud, to list the devices on your account, including
their local IP address and API key.
- Stream frames straight to the screen of the device, see
[`examples/stream.py`](examples/stream.py).
- Stream frames straight to the screen of devices that support it, see
[`examples/stream.py`](examples/stream.py). An LM 37X8 TIME on firmware 2.x
does not.

## Installation

Expand Down
7 changes: 7 additions & 0 deletions examples/stream.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,13 @@
async def main() -> None:
"""Show a green bar sweeping across the screen of your LaMetric device."""
async with LaMetricDevice(HOST, api_key="DEVICE_API_KEY") as lametric:
# Not every device can stream, for example an LM 37X8 TIME on
# firmware 2.x. The device lists the stream endpoints when it can.
api = await lametric.api()
if "stream_url" not in api.endpoints:
print("This device does not support streaming")
return

# The canvas size differs per device, so ask the device for it.
status = await lametric.stream()
if status.canvas.pixel is None:
Expand Down
11 changes: 8 additions & 3 deletions src/demetriek/device.py
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,10 @@ async def display( # noqa: PLR0913 # pylint: disable=too-many-arguments
brightness: Brightness level to set.
brightness_mode: Brightness mode to set.
screensaver_enabled: Whether the screensaver should be enabled.
screensaver_mode: Screensaver mode to configure.
screensaver_mode: Screensaver mode to configure. Only pick a mode
the device reports in `screensaver.modes`. A TIME accepts
screen_off, but only switches its other modes off, leaving
the screensaver without any mode at all.
screensaver_mode_enabled: Whether to enable the screensaver mode.
screensaver_start_time: Time in GMT the screensaver starts,
for the time based mode.
Expand Down Expand Up @@ -712,8 +715,10 @@ async def notification_queue(self) -> list[Notification]:
async def stream(self) -> Stream:
"""Get the stream state and canvas size of the device.

Streaming needs API 2.3.0 or newer, and is not available on every
device. `api()` lists the stream endpoints when the device has them.
Streaming is not available on every device. An LM 37X8 TIME on
firmware 2.3.9 (API 2.3.0) does not have it and answers with a 404,
an sa8 TIME on firmware 3.2.6 (API 2.4.0) does. `api()` lists the
stream endpoints when the device has them.

Returns
-------
Expand Down
Loading