Skip to main content

suplalite

PyPI Python versions CI License

A lightweight implementation of SUPLA server and devices in Python.

Install using pip install suplalite

Source code, examples and issues are on GitHub.

Note: this project is not affiliated with SUPLA or Zamel. It is not an "official" library.

suplalite.server

Provides a lightweight implementation of supla-server and supla-cloud. Has just enough functionality to coordinate a set of SUPLA devices and clients on a local network. Use over the public internet is not recommended.

This implementation does not require/provide:

  • A MySQL database
  • supla-cloud web interface
  • Logging of historical sensor data
  • Dynamic registration of devices

Configuration of the server is static, i.e. devices must be configured before starting the server. The server listens on three ports: a plain port for devices, a TLS-secured port for devices and clients, and an HTTPS REST API port. TLS requires a certificate and key file.

See examples/server.py for an example.

Authentication

Devices and clients authenticate when you turn it on:

server = Server(..., device_auth=True, client_auth=True)

Both settings default to False. The server then accepts a device whose GUID and channels match the configuration, and accepts any client. That suits a trusted local network.

Everything allowed to connect is listed in the static configuration. An unconfigured peer is rejected with REGISTRATION_DISABLED, and a wrong credential with BAD_CREDENTIALS.

Registration is accepted on both device ports. A device registering on the plain port sends its AuthKey in the clear, so use the TLS port on an untrusted network.

Devices

A device authenticates with the GUID and AuthKey you give to state.add_device():

server.state.add_device("test", guid, authkey=authkey)

With device_auth=True every configured device needs an AuthKey. The server raises a ValueError at start up when one is missing.

Clients

The SUPLA app signs in with an access identifier or with an email address. Configure whichever mode the app uses.

An access identifier is an access id and a password, both chosen by you:

server.state.add_access_id(1, "access-id-password")

Email mode sends an email address, a GUID and an AuthKey. The app generates the GUID and AuthKey itself, so let the client register once and read them from the warning the server logs:

server.state.add_client_credentials("email@email.com", guid, authkey)

Reinstalling the app changes the GUID and AuthKey. The password field of this message is unused.

Failed Registrations

A failed registration is answered, then held open for auth_failure_delay seconds (2 by default). This applies with authentication turned off, as a device is still rejected for an unknown GUID or the wrong channels.

Rejecting a client logs the AuthKey it sent, so you can copy it into the configuration. An EventId.REQUEST event handler also receives whole decoded registration messages. Both put client credentials in your logs. Registration needs no credentials to send, so any peer that can reach the port controls how much of this is logged.

Superuser Authorization

Superuser authorization is separate from registration. A client sends the email and password you give to Server(), and must do so before it can change device configuration.

suplalite.device

Provides functionality necessary to create a SUPLA device using Python. Supports both plain and TLS-secured connections to the server.

Currently supports the following kinds of channel:

  • Relay/switch
  • Temperature sensor
  • Humidity sensor
  • Temperature and humidity sensor
  • General purpose measurement
  • Dimmer
  • RGB dimmer
  • RGBW dimmer

See examples/device.py for an example.

Examples

examples/ holds a server, a device and a client that talk to each other. Set up the environment once, which also generates the certificate the server uses:

hatch env create

Run each example in its own terminal, from the root of the repository:

hatch run python examples/server.py
hatch run python examples/device.py
hatch run python examples/client.py

The device registers with the server and pushes channel values, and the client receives them.

The server listens on port 2015 for devices, port 2016 for devices and clients over TLS, and port 5000 for the REST API:

curl -sk https://127.0.0.1:5000/api/3/user-icons

The device and client connect to 127.0.0.1:2016 without verifying the certificate, so the self-signed one works. Their guids and authkeys are the ones examples/server.py configures. Superuser authorization uses email@email.com with password 1, and access id 1 has the password access-id-password.

To connect the SUPLA app, set host in examples/server.py to the address of your machine. Clients fetch icons from the REST API at that address.

Metadata

Release files for suplalite 2.0.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 suplalite 2.0.2
File Size Uploaded
suplalite-2.0.2.tar.gz 112.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for suplalite 2.0.2
File Interpreter ABI Platform
suplalite-2.0.2-py3-none-any.whl Python 3 none any Details

Total release size: 168.7 kB

Release files / suplalite-2.0.2.tar.gz

Download URL suplalite-2.0.2.tar.gz
Size 112.8 kB
Tags Source
SHA-256 checksum
How to use checksums
a7bf7f6aa1dcfeb8dcc642fc8ecee2b9fd765e2cd9ea642c37b055136b756671
BLAKE2b-256 checksum
How to use checksums
113e1cfa55dfbe89fbca3bb6eb49e5095f4333c427fcc3716d2d8f5fd9ea49da
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via Hatch/1.16.5 cpython/3.14.5 HTTPX/0.28.1

Release files / suplalite-2.0.2-py3-none-any.whl

Download URL suplalite-2.0.2-py3-none-any.whl
Size 55.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a1f2b8b913a14511c78f8d77945576e5b26f6fbaeb4840f2320dc7b3852dc201
BLAKE2b-256 checksum
How to use checksums
5a7bd4ded983800303ebc00dd660d626abb535411787373ed34c819c6a5c5afa
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via Hatch/1.16.5 cpython/3.14.5 HTTPX/0.28.1

Release history Release notifications | RSS feed

This release

2.0.2 This release

2 release files

2.0.1

1 release file

2.0.0

1 release file

1.1.1

1 release file

1.1.0

1 release file

1.0.0

1 release file

0.5.0

1 release file

0.4.0

1 release file

0.3.1

1 release file

0.3.0

1 release file

0.2.0

1 release file

0.1.0

1 release file

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