Skip to main content

Lunatone REST API Client

lunatone-rest-api-client is a Python package providing access to the Lunatone REST API.

It includes async clients for Lunatones REST API endpoints.

The following devices are supported:

Installation

Use pip to install the latest stable version of lunatone-rest-api-client

pip install --upgrade lunatone-rest-api-client

The current development version is available on [GitLab.com] (https://gitlab.com/lunatone-public/lunatone-rest-api-client) and can be installed directly from the git repository:

pip install git+https://gitlab.com/lunatone-public/lunatone-rest-api-client.git

Usage

import asyncio

import aiohttp

from lunatone_rest_api_client import Auth, Devices


async def main() -> None:
    """Show example of fetching devices."""
    async with aiohttp.ClientSession() as session:
        auth = Auth(session, "http://10.0.0.31")
        devices = Devices(auth)
        await devices.async_update()
        print(devices.data)


if __name__ == "__main__":
    asyncio.run(main())

WebSocket events

Register callbacks on the websocket client before opening the connection, then close the connection when event updates are no longer needed. Use this inside your async application after creating an Auth instance:

import asyncio

import aiohttp

from lunatone_rest_api_client import Auth, Devices


async def main() -> None:
    """Show example of controlling a device combined with websocket push updates."""
    async with aiohttp.ClientSession() as session:
        auth = Auth(session, "http://10.0.0.31")
        devices = Devices(auth)

        def on_devices_update(device_id: int) -> None:
            print(devices.devices[device_id])

        devices.register_update_callback(on_devices_update)
        await auth.websocket.open()
        try:
            device = devices.devices[0]
            await device.fade_to_brightness(100.0)
        finally:
            await auth.websocket.close()

        print(devices.data)


if __name__ == "__main__":
    asyncio.run(main())

Setting up development environment

This Python project is fully managed using the uv dependency manager.

Requirements:

To install all packages, including all development requirements:

uv sync

To run just the Python tests:

uv run pytest

Scripts

API tests:

This script sends a POST request and right after two GET requests to check if the status is changed immediately.

uv run ./scripts/api_tests.py --ip <ip-address>

Metadata

Release files for lunatone-rest-api-client 0.11.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for lunatone-rest-api-client 0.11.2
File Size Uploaded Provenance Actions
lunatone_rest_api_client-0.11.2.tar.gz 84.7 kB Without provenance Details for lunatone_rest_api_client-0.11.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for lunatone-rest-api-client 0.11.2
File Interpreter ABI Platform Actions
lunatone_rest_api_client-0.11.2-py3-none-any.whl Python 3 none any Details for lunatone_rest_api_client-0.11.2-py3-none-any.whl

Total release size: 118.5 kB

Release files / lunatone_rest_api_client-0.11.2.tar.gz

Download URL lunatone_rest_api_client-0.11.2.tar.gz
Size 84.7 kB
Tags Source
SHA-256 checksum
How to use checksums
f3af9de82f582f4f84b847b7d0377f2e45c42cb39bcf9af4a036f4b1b249b320
BLAKE2b-256 checksum
How to use checksums
c9f64142008422955cb11407dc6a1ff27a6582d796c77a98bf7761ae0efc3091
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.5

Release files / lunatone_rest_api_client-0.11.2-py3-none-any.whl

Download URL lunatone_rest_api_client-0.11.2-py3-none-any.whl
Size 33.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a23ddd39c0c2487c48153054c457b08d14e984fbbd7babbeb29aa3ad6bbd48db
BLAKE2b-256 checksum
How to use checksums
1d3d23ba2fc5c661817f32069b8a1706e6973eecb183e1e99d36dd5ac6c7392c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.5

Security for lunatone-rest-api-client 0.11.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.11.2 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page