Skip to main content

homey-energy-dongle-ws

PyPI version PyPI downloads Python CI License: MIT

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.

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 sets ws_path to None (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:

  1. Open the Homey app → your Energy Dongle → Settings → Advanced Settings, then note the IP address which is listed.
  2. Connect with defaults ws://<host>:80/ws (or pass port / path if yours differ). For IPv6 literals, EnergyDongleClient.ws_url uses a bracketed host (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

Pass dsmr_version with a code from DSMR_VERSIONS (for example "5", "5B", or "4") to select the matching dsmr-parser telegram specification. Omit it to keep the V5 default. Alternatively, pass a custom telegram_specification mapping; do not set both. A wrong version typically causes parse errors, not silent wrong data.

detect_dsmr_version(telegram) returns one of those codes from a complete telegram string, or None when the profile is not recognized. Parsing is unchanged: pass the code back as dsmr_version.

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

Reconnect behavior

By default (reconnect=True), the client waits and retries after transient connect failures or disconnects. Pass reconnect=False when you want to own the retry policy (for example in a Home Assistant integration): a failed connect or any disconnect then raises ConnectionLostError so you can mark the device unavailable and reconnect on your own schedule.

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.

Metadata

Release files for homey-energy-dongle-ws 0.4.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 homey-energy-dongle-ws 0.4.0
File Size Uploaded Provenance Actions
homey_energy_dongle_ws-0.4.0.tar.gz 55.8 kB Without provenance Details for homey_energy_dongle_ws-0.4.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for homey-energy-dongle-ws 0.4.0
File Interpreter ABI Platform Actions
homey_energy_dongle_ws-0.4.0-py3-none-any.whl Python 3 none any Details for homey_energy_dongle_ws-0.4.0-py3-none-any.whl

Total release size: 71.2 kB

Release files / homey_energy_dongle_ws-0.4.0.tar.gz

Download URL homey_energy_dongle_ws-0.4.0.tar.gz
Size 55.8 kB
Tags Source
SHA-256 checksum
How to use checksums
c9493580d753ab8fd380a2a9c65ee13cb98620b4c987f98aba04e8812f11e893
BLAKE2b-256 checksum
How to use checksums
ad029a3673e907bdaf7f9f45a23d88c643b5308951fb53a59330147660c6d679
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / homey_energy_dongle_ws-0.4.0-py3-none-any.whl

Download URL homey_energy_dongle_ws-0.4.0-py3-none-any.whl
Size 15.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e981d993ea29e212036d68f2e67f00840cd7195e266c7b7b9149103774387ba3
BLAKE2b-256 checksum
How to use checksums
55b9d64391089425f43ea5f48a61b91f36135d71fb6a4a39c8382fd051fd13b9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Security for homey-energy-dongle-ws 0.4.0

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.

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