Async WebSocket client for the Homey Energy Dongle (DSMR smart meter data).
Project description
homey-energy-dongle-ws
Async Python client for the Homey Energy Dongle WebSocket API. It streams DSMR smart-meter data in three layers: raw WebSocket payloads, complete telegram strings, or parsed (dsmr-parser) telegram objects.
Prerequisites
- Python 3.11+
- A Homey Energy Dongle
- Enabling the local API on the Homey Energy Dongle in the Homey app. Please reference this knowledge base article
See Athom’s Homey Energy Dongle WebSocket example for more context.
Install
pip install homey-energy-dongle-ws
Or install from Git:
pip install git+https://github.com/Doekse/homey-energy-dongle-ws.git
Quick start (discovery first)
On the same LAN as the Energy Dongle, call **discover_energy_dongles()**, pick a result that has **ws_path** set when possible, then open **EnergyDongleClient** (or use **build_ws_url** with the chosen host, port, and path).
import asyncio
from homey_energy_dongle_ws import (
DiscoveredEnergyDongle,
EnergyDongleClient,
discover_energy_dongles,
)
async def main() -> None:
found: list[DiscoveredEnergyDongle] = await discover_energy_dongles(timeout_s=5.0)
if not found:
print("No Energy Dongles discovered; use manual connection (below).")
return
d = next((x for x in found if x.ws_path is not None), None)
if d is None:
print("No advertised WebSocket path (TXT p); enable Local API or use manual connection.")
return
async with EnergyDongleClient(d.host, port=d.port, path=d.ws_path) as client:
async for telegram in client.stream_parsed():
print(telegram)
break
asyncio.run(main())
TXT records (mDNS):
**p** — WebSocket path (e.g./ws). If missing, the library setsws_pathtoNone(WebSocket not advertised / Local API off).**v** — Version string (DiscoveredEnergyDongle.version). Full decoded TXT is in**DiscoveredEnergyDongle.txt**.
Firewall / network: the client host must allow mDNS (UDP 5353 inbound/outbound) and LAN traffic to the Energy Dongle. Routers, VLANs, VPNs, or “guest” Wi‑Fi often block multicast, use manual connection instead.
Manual connection (fallback)
Use this when discovery returns nothing, times out, **p** is missing and you know Local API should work, or you are not on the same L2 segment:
- Open the Homey app → your Energy Dongle → Settings → Advanced Settings, then note the IP address which is listed.
- Connect with defaults
**ws://<host>:80/ws** (or passport/pathif yours differ). For IPv6 literals,build_ws_url()andEnergyDongleClient.ws_urluse bracketed hosts (e.g.ws://[2001:db8::1]:80/ws) as required by the WebSocket URL syntax.
import asyncio
from homey_energy_dongle_ws import EnergyDongleClient
async def main() -> None:
async with EnergyDongleClient("192.168.x.x") as client:
async for telegram in client.stream_parsed():
print(telegram)
break
asyncio.run(main())
DSMR version
Parsing uses telegram_specification from [dsmr_parser.telegram_specifications](https://dsmr-parser.readthedocs.io/) (default: V5). If your meter uses another DSMR version, pass the matching spec to EnergyDongleClient(..., telegram_specification=...). A wrong spec typically causes parse errors, not silent wrong data.
For long-running processes, stream_parsed(skip_parse_errors=True) logs and skips a bad telegram instead of stopping the stream (default remains fail-fast).
Limits
The Energy Dongle allows at most two concurrent WebSocket clients. A third connection is rejected with close code 1008; this library raises **ConnectionLimitError**.
Troubleshooting
- Local API disabled in the app → the server closes with 1008 and this library raises
**LocalApiDisabledError** (check**close_code** /**close_reason** on**HomeyWebSocketError** subclasses for logging). - Connection limit →
**ConnectionLimitError** (1008).
For maintainers
Development setup, local checks, and pull requests: see CONTRIBUTING.md. Release history: CHANGELOG.md.
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 homey_energy_dongle_ws-0.2.0.tar.gz.
File metadata
- Download URL: homey_energy_dongle_ws-0.2.0.tar.gz
- Upload date:
- Size: 52.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
eabfe8ffdd2786308bb5e2fdc841ba0be8ab121608e403de88f46363f7de8c31
|
|
| MD5 |
08610620894673808a7a824bd10ff442
|
|
| BLAKE2b-256 |
d2eb9b2278aba15c5d3f831461aabd44bc38cc04205740f392d3b1b448f9276a
|
Provenance
The following attestation bundles were made for homey_energy_dongle_ws-0.2.0.tar.gz:
Publisher:
publish-pypi.yml on Doekse/homey-energy-dongle-ws
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
homey_energy_dongle_ws-0.2.0.tar.gz -
Subject digest:
eabfe8ffdd2786308bb5e2fdc841ba0be8ab121608e403de88f46363f7de8c31 - Sigstore transparency entry: 1278010657
- Sigstore integration time:
-
Permalink:
Doekse/homey-energy-dongle-ws@8bbdb6dafc54daf07d60e8090c5791810f64caf1 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/Doekse
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi.yml@8bbdb6dafc54daf07d60e8090c5791810f64caf1 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file homey_energy_dongle_ws-0.2.0-py3-none-any.whl.
File metadata
- Download URL: homey_energy_dongle_ws-0.2.0-py3-none-any.whl
- Upload date:
- Size: 15.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
485238812e08279cd4cfec82e4245383d46878badbb945088f663fe4b051df42
|
|
| MD5 |
6a9a09cc235ed4255efb857b8fcf08fe
|
|
| BLAKE2b-256 |
d68b089f16e40ab524904abb2e8ead3f8b7704a178b5da7f8aded2129c19d1bb
|
Provenance
The following attestation bundles were made for homey_energy_dongle_ws-0.2.0-py3-none-any.whl:
Publisher:
publish-pypi.yml on Doekse/homey-energy-dongle-ws
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
homey_energy_dongle_ws-0.2.0-py3-none-any.whl -
Subject digest:
485238812e08279cd4cfec82e4245383d46878badbb945088f663fe4b051df42 - Sigstore transparency entry: 1278010697
- Sigstore integration time:
-
Permalink:
Doekse/homey-energy-dongle-ws@8bbdb6dafc54daf07d60e8090c5791810f64caf1 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/Doekse
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi.yml@8bbdb6dafc54daf07d60e8090c5791810f64caf1 -
Trigger Event:
workflow_dispatch
-
Statement type: