Async Python client for NetLink desk and display control
Project description
Asynchronous Python client for NetLink desk and display control.
About
NetLink is the operating software for smart standing desks, developed by NetOS. The system powers smart desks in commercial office environments, most notably at Mr.Green Offices locations throughout the Netherlands.
This Python package provides a modern, fully typed client for controlling NetLink-equipped desks. It offers both WebSocket (for real-time state updates and fast commands) and REST API support, making it ideal for integration with Home Assistant and other automation systems.
Target Audience: This package is primarily intended for organizations and developers working with NetLink-equipped office environments. While publicly available on PyPI, the NetLink system itself is designed for commercial office spaces.
Key Features
- 🔌 Real-time state updates via WebSocket (desk position, display settings)
- ⚡ Fast WebSocket commands with acknowledgements (~50% faster than REST)
- 🔄 Smart transport - automatic fallback from WebSocket to REST when needed
- 🔍 mDNS/Zeroconf discovery - automatically find NetLink devices on your network
- 📦 Type-safe with full type hints and mashumaro data models
- 🏠 Home Assistant ready with auto-reconnection and exponential backoff
- ⚡ Async-first using modern Python async/await patterns
- 🧪 Production-ready with 100% test coverage
Installation
pip install pynetlink
Quick Start
import asyncio
from pynetlink import NetlinkClient
async def main() -> None:
"""Quick start example."""
async with NetlinkClient("192.168.1.100", "your-token") as client:
# Connect via WebSocket for real-time updates
await client.connect()
# Get current desk state
if client.desk_state:
print(f"Desk height: {client.desk_state.height}cm")
# Control desk (automatically uses WebSocket when connected)
await client.set_desk_height(120.0)
# Control displays
await client.set_display_brightness(bus_id=0, brightness=80)
# Optional: Force specific transport if needed
await client.set_desk_height(110.0, transport="rest")
if __name__ == "__main__":
asyncio.run(main())
Documentation
📚 Complete Examples & Documentation
The examples folder contains comprehensive guides for:
- Device discovery with mDNS
- Real-time WebSocket events
- Desk control (height, calibration, presets)
- Display control (power, brightness, volume, input source)
- Browser control
- Error handling
- Advanced usage patterns
Usage Examples
Discover Devices
from pynetlink import NetlinkClient
# Auto-discover devices on network
devices = await NetlinkClient.discover_devices(discovery_timeout=5.0)
for device in devices:
print(f"Found: {device.device_name} at {device.host}")
Real-time Events
async with NetlinkClient(host, token) as client:
await client.connect()
@client.on("desk.state")
async def on_desk_state(data: dict) -> None:
print(f"Desk: {data['height']}cm")
await asyncio.sleep(60) # Listen for events
Control Desk & Displays
# Desk control
await client.set_desk_height(120.0)
await client.stop_desk()
await client.calibrate_desk()
# Display control
displays = await client.get_displays()
await client.set_display_power(bus_id=0, state="on")
await client.set_display_brightness(bus_id=0, brightness=80)
await client.set_display_source(bus_id=0, source="HDMI1")
More examples:
basic_usage.py- Comprehensive usage with REST and WebSocketdiscover_devices.py- Device discovery with mDNSdesk_state_listener.py- Real-time desk state monitoring
Read Current Daily Access Codes
async with NetlinkClient(host, token) as client:
access_codes = await client.get_access_codes()
if access_codes.web_login:
print(access_codes.web_login.code)
if access_codes.signing_maintenance:
print(access_codes.signing_maintenance.valid_until)
This uses the privileged admin endpoint GET /api/v1/admin/access-codes and therefore requires the device REST_BEARER_TOKEN.
web_login or signing_maintenance can be omitted when that login does not expose a current daily code.
Contributing
This is an active open-source project. We are always open to people who want to use the code or contribute to it.
We've set up a separate document for our contribution guidelines.
Thank you for being involved! :heart_eyes:
Setting up development environment
The simplest way to begin is by utilizing the Dev Container feature of Visual Studio Code or by opening a CodeSpace directly on GitHub. By clicking the button below you immediately start a Dev Container in Visual Studio Code.
This Python project relies on Poetry as its dependency manager, providing comprehensive management and control over project dependencies.
You need at least:
- Python 3.12+
- Poetry
Installation
Install all packages, including all development requirements:
poetry install
Poetry creates by default an virtual environment where it installs all necessary pip packages.
Prek
This repository uses the prek framework, all changes are linted and tested with each commit. To setup the prek check, run:
poetry run prek install
And to run all checks and tests manually, use the following command:
poetry run prek run --all-files
Testing
It uses pytest as the test framework. To run the tests:
poetry run pytest
To update the syrupy snapshot tests:
poetry run pytest --snapshot-update
License
This project is licensed under the GNU Lesser General Public License v3.0 or later (LGPL-3.0-or-later). See the LICENSE file for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pynetlink-1.4.0.tar.gz.
File metadata
- Download URL: pynetlink-1.4.0.tar.gz
- Upload date:
- Size: 23.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cac2be65447fe093b2c2e0bbeb51a714d6d7000f1a5ca3e7d94ebeb6b0d4b5a2
|
|
| MD5 |
64752787459b5e0653a40e476fdbd818
|
|
| BLAKE2b-256 |
76d3bdfa5f14d6e90fd91b7c8af9db651e36c265e203d6e39fbf36a34c252317
|
Provenance
The following attestation bundles were made for pynetlink-1.4.0.tar.gz:
Publisher:
release.yaml on MrGreenBoutiqueOffices/python-netlink
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pynetlink-1.4.0.tar.gz -
Subject digest:
cac2be65447fe093b2c2e0bbeb51a714d6d7000f1a5ca3e7d94ebeb6b0d4b5a2 - Sigstore transparency entry: 1519469445
- Sigstore integration time:
-
Permalink:
MrGreenBoutiqueOffices/python-netlink@ebf3c99f81a26c297546509921bc363d992b36bf -
Branch / Tag:
refs/tags/v1.4.0 - Owner: https://github.com/MrGreenBoutiqueOffices
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yaml@ebf3c99f81a26c297546509921bc363d992b36bf -
Trigger Event:
release
-
Statement type:
File details
Details for the file pynetlink-1.4.0-py3-none-any.whl.
File metadata
- Download URL: pynetlink-1.4.0-py3-none-any.whl
- Upload date:
- Size: 25.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ffc580f5974e26980092caf2dd135494157ce0fa119a48a02986f6bd51804dcf
|
|
| MD5 |
7a95e42e4f95204cd08289e3660bc3a8
|
|
| BLAKE2b-256 |
5fbc647936f72e1ae89a4966aa9e6afa9afbda6240398a4030e6dabd0868d01e
|
Provenance
The following attestation bundles were made for pynetlink-1.4.0-py3-none-any.whl:
Publisher:
release.yaml on MrGreenBoutiqueOffices/python-netlink
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pynetlink-1.4.0-py3-none-any.whl -
Subject digest:
ffc580f5974e26980092caf2dd135494157ce0fa119a48a02986f6bd51804dcf - Sigstore transparency entry: 1519469471
- Sigstore integration time:
-
Permalink:
MrGreenBoutiqueOffices/python-netlink@ebf3c99f81a26c297546509921bc363d992b36bf -
Branch / Tag:
refs/tags/v1.4.0 - Owner: https://github.com/MrGreenBoutiqueOffices
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yaml@ebf3c99f81a26c297546509921bc363d992b36bf -
Trigger Event:
release
-
Statement type: