Async Python library for communicating with EARN-E P1 energy meters via UDP
Project description
earn-e-p1
Async Python library for communicating with EARN-E P1 energy meters via UDP.
The EARN-E P1 meter reads a smart meter's P1 port and broadcasts real-time energy data via UDP on the local network. This library listens for those broadcasts and provides parsed device data.
Installation
pip install earn-e-p1
Usage
Persistent listener
For long-running applications (e.g., Home Assistant integrations) that need continuous updates:
import asyncio
from earn_e_p1 import EarnEP1Listener, EarnEP1Device
def on_update(device: EarnEP1Device, raw: dict) -> None:
print(f"Power: {device.data.get('power_delivered')} kW")
print(f"Serial: {device.serial}")
async def main() -> None:
listener = EarnEP1Listener()
listener.register("192.168.1.100", callback=on_update)
await listener.start()
try:
await asyncio.sleep(3600) # listen for 1 hour
finally:
await listener.stop()
asyncio.run(main())
The listener supports multiple devices — call register() for each device IP. Packets are demultiplexed by source IP and each device maintains its own merged state.
Discover devices
Find EARN-E devices on the network:
from earn_e_p1 import discover
devices = await discover(timeout=10)
for device in devices:
print(f"Found {device.host} (serial: {device.serial})")
Validate a specific host
Check if a specific IP is an EARN-E device:
from earn_e_p1 import validate
device = await validate("192.168.1.100", timeout=10)
if device:
print(f"Confirmed: {device.serial}")
Discover/validate while a listener is running
If a listener is already active, use the instance methods to avoid port conflicts:
# Discover using the active socket
devices = await listener.discover(timeout=10)
# Validate using the active socket
device = await listener.validate("192.168.1.100", timeout=10)
Data Model
The callback receives two arguments:
device(EarnEP1Device) — accumulated device state with merged data from all packetsraw(dict) — the raw packet as received
@dataclass
class EarnEP1Device:
host: str # Device IP address
serial: str | None = None # Serial number (set once from first full telegram)
model: str | None = None # Device model
sw_version: str | None = None # Firmware version
data: dict[str, Any] = field(...) # Merged sensor data from all packets
The device sends two types of UDP broadcasts:
| Type | Keys | Frequency |
|---|---|---|
| Realtime | power_delivered, power_returned, voltage_l1, current_l1 |
~1s |
| Full telegram | energy_delivered_tariff1/2, energy_returned_tariff1/2, gas_delivered, wifiRSSI, serial, model, swVersion |
~10s |
The library merges all packets into device.data, so it always contains the latest value for every key.
License
MIT
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 earn_e_p1-0.1.0.tar.gz.
File metadata
- Download URL: earn_e_p1-0.1.0.tar.gz
- Upload date:
- Size: 18.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
382cb80ae8c45661b91254e2ff6549446992b53b69832f2290f26a502bc45a93
|
|
| MD5 |
d1c3ea865fd7391875d70d25da296c9c
|
|
| BLAKE2b-256 |
db81c0a59cf4b160672f361c4be526108594ab49ae680b3e2e5410b79550a7e5
|
Provenance
The following attestation bundles were made for earn_e_p1-0.1.0.tar.gz:
Publisher:
publish.yml on Miggets7/earn-e-p1
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
earn_e_p1-0.1.0.tar.gz -
Subject digest:
382cb80ae8c45661b91254e2ff6549446992b53b69832f2290f26a502bc45a93 - Sigstore transparency entry: 1154541237
- Sigstore integration time:
-
Permalink:
Miggets7/earn-e-p1@e85ce4030b028ccb0a2c8d1f4ba29385b35c917c -
Branch / Tag:
refs/tags/0.1.0 - Owner: https://github.com/Miggets7
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@e85ce4030b028ccb0a2c8d1f4ba29385b35c917c -
Trigger Event:
push
-
Statement type:
File details
Details for the file earn_e_p1-0.1.0-py3-none-any.whl.
File metadata
- Download URL: earn_e_p1-0.1.0-py3-none-any.whl
- Upload date:
- Size: 6.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
40709b3b759730c3877eb76618888eaead65559c2a7491704dbc150284c4f7a7
|
|
| MD5 |
f5470a68a108b95986d933af4f6e1a30
|
|
| BLAKE2b-256 |
176d451a048e6d57b612150f9298b4e903b29283476c7a99dc7a0a8c288c5295
|
Provenance
The following attestation bundles were made for earn_e_p1-0.1.0-py3-none-any.whl:
Publisher:
publish.yml on Miggets7/earn-e-p1
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
earn_e_p1-0.1.0-py3-none-any.whl -
Subject digest:
40709b3b759730c3877eb76618888eaead65559c2a7491704dbc150284c4f7a7 - Sigstore transparency entry: 1154541241
- Sigstore integration time:
-
Permalink:
Miggets7/earn-e-p1@e85ce4030b028ccb0a2c8d1f4ba29385b35c917c -
Branch / Tag:
refs/tags/0.1.0 - Owner: https://github.com/Miggets7
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@e85ce4030b028ccb0a2c8d1f4ba29385b35c917c -
Trigger Event:
push
-
Statement type: