Skip to main content

No project description provided

Project description

lametric-py

CI PyPI Python License Docs Contributing

Async Python client for LaMetric devices and the LaMetric cloud API.

The package wraps the documented local device API, notification models, and the LaMetric Streaming Protocol (LMSP) used by LaMetric SKY devices.

Features

  • Async local device client for display, audio, Bluetooth, apps, notifications, and streaming
  • Async cloud client for account and device lookup
  • Typed dataclass models for API payloads and responses
  • Notification builders for text, goal, and chart frames
  • LMSP helpers for starting a stream and sending RGB888 UDP frames

Requirements

  • Python 3.14+
  • A LaMetric device on the local network for device API features
  • A LaMetric developer token for cloud API features

Installation

This repository is currently set up as a source install.

git clone https://github.com/ElectroAttacks/lametric-py.git
cd lametric-py
uv sync --dev

If you prefer pip:

pip install -e .

Quick Start

Local Device Client

import asyncio

from lametric import LaMetricDevice


async def main() -> None:
	async with LaMetricDevice(host="192.168.1.42", api_key="device-api-key") as device:
		state = await device.state
		print(state.name)


asyncio.run(main())

Send a Notification

import asyncio

from lametric import (
	BuiltinSound,
	LaMetricDevice,
	Notification,
	NotificationData,
	NotificationPriority,
	NotificationSound,
	SimpleFrame,
)


async def main() -> None:
	notification = Notification(
		priority=NotificationPriority.INFO,
		model=NotificationData(
			frames=[SimpleFrame(text="Deploy finished")],
			sound=BuiltinSound(id=NotificationSound.POSITIVE1),
		),
	)

	async with LaMetricDevice(host="192.168.1.42", api_key="device-api-key") as device:
		notification_id = await device.send_notification(notification)
		print(notification_id)


asyncio.run(main())

Query the Cloud API

import asyncio

from lametric import LaMetricCloud


async def main() -> None:
	async with LaMetricCloud(token="developer-token") as cloud:
		user = await cloud.current_user
		devices = await cloud.devices
		print(user.email, len(devices))


asyncio.run(main())

Streaming Example

import asyncio

from lametric import (
	CanvasFillType,
	CanvasPostProcess,
	CanvasPostProcessType,
	CanvasRenderMode,
	LaMetricDevice,
	StreamConfig,
)


async def main() -> None:
	config = StreamConfig(
		fill_type=CanvasFillType.SCALE,
		render_mode=CanvasRenderMode.PIXEL,
		post_process=CanvasPostProcess(type=CanvasPostProcessType.NONE),
	)

	async with LaMetricDevice(host="192.168.1.42", api_key="device-api-key") as device:
		session_id = await device.start_stream(config)
		if session_id is None:
			return

		stream_state = await device.stream_state
		frame = bytes(
			[255, 0, 0]
			* (stream_state.canvas.pixel.size.width * stream_state.canvas.pixel.size.height)
		)
		await device.send_stream_data(session_id, frame)
		await device.stop_stream()


asyncio.run(main())

Public API

The package re-exports its public surface from lametric.

  • Clients: LaMetricDevice, LaMetricCloud
  • Exceptions: LaMetricApiError, LaMetricConnectionError, LaMetricAuthenticationError, LaMetricUnsupportedError
  • Models: apps, notifications, state payloads, stream config/state types
  • Enums: notification, screensaver, display, and streaming constants

Documentation

Full documentation is available at electroattacks.github.io/lametric-py.

Source pages:

Development

Useful commands:

uv run ruff check .
uv run ruff format .
uv run mypy .
uv run pytest

The CI workflow runs Ruff, mypy, pytest, coverage export, and semantic-release.

Support

If this package is useful to you, consider sponsoring the project. ❤️

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

lametric_py-1.3.9.tar.gz (92.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

lametric_py-1.3.9-py3-none-any.whl (16.1 kB view details)

Uploaded Python 3

File details

Details for the file lametric_py-1.3.9.tar.gz.

File metadata

  • Download URL: lametric_py-1.3.9.tar.gz
  • Upload date:
  • Size: 92.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for lametric_py-1.3.9.tar.gz
Algorithm Hash digest
SHA256 d44461913c49703a85fb141bd74208e7af7f4dfbdb6d429465a18c9957627331
MD5 2d6538a5c9e2d6a4278df47368bb8cb2
BLAKE2b-256 2115f5465d7e9b7128bc962d7062c1732ed884e3491760d4fae1af9877554fe2

See more details on using hashes here.

Provenance

The following attestation bundles were made for lametric_py-1.3.9.tar.gz:

Publisher: ci.yml on ElectroAttacks/lametric-py

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file lametric_py-1.3.9-py3-none-any.whl.

File metadata

  • Download URL: lametric_py-1.3.9-py3-none-any.whl
  • Upload date:
  • Size: 16.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for lametric_py-1.3.9-py3-none-any.whl
Algorithm Hash digest
SHA256 b5febff760ca8238e5597d75b9905fa256ba36f1199eca5bc1e8bd54111523b1
MD5 7e33bab23b3f2183bb95d297e6e3f061
BLAKE2b-256 d578eea4a669740e014efa2c1e03854e19290666e026195b4a4e22cca012e668

See more details on using hashes here.

Provenance

The following attestation bundles were made for lametric_py-1.3.9-py3-none-any.whl:

Publisher: ci.yml on ElectroAttacks/lametric-py

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page