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.0

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.0
File Size Uploaded
lunatone_rest_api_client-0.11.0.tar.gz 84.3 kB Details

Built distribution (wheel)

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

Total release size: 118.3 kB

Release files / lunatone_rest_api_client-0.11.0.tar.gz

Download URL lunatone_rest_api_client-0.11.0.tar.gz
Size 84.3 kB
Tags Source
SHA-256 checksum
How to use checksums
a782c04ebf39685f470740ff041667e0f1b1d98e3557328dd711ebc8a55d150b
BLAKE2b-256 checksum
How to use checksums
84bde2d5eba48181c779d63c87af479e7c6eb98652be028fc1e37f6a40acd488
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.0-py3-none-any.whl

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

Release history Release notifications | RSS feed

This release

0.11.0 This release

2 release files

0.10.2

2 release files

0.10.1

2 release files

0.10.0

2 release files

0.9.2

2 release files

0.9.1

2 release files

0.9.0

2 release files

0.8.1

2 release files

0.8.0

2 release files

0.7.2

2 release files

0.7.1

2 release files

0.7.0

2 release files

0.6.3

2 release files

0.6.2

2 release files

0.6.1

2 release files

0.6.0

2 release files

0.5.7

2 release files

0.5.6

2 release files

0.5.5

2 release files

0.5.4

2 release files

0.5.3

2 release files

0.5.2

2 release files

0.5.1

2 release files

0.5.0

2 release files

0.4.8

2 release files

0.4.7

2 release files

0.4.6

2 release files

0.4.5

2 release files

0.4.4

2 release files

0.4.3

2 release files

0.4.2

2 release files

0.4.1

2 release files

0.4.0

2 release files

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