ECHONET Lite library for Home Energy Management System (HEMS)
Project description
pyhems
ECHONET Lite library for Home Energy Management System (HEMS).
Features
- ECHONET Lite frame encoding/decoding
- UDP multicast device discovery
- Async runtime client with event subscription
- Device state management with
DeviceManager - Adaptive poll scheduler for non-notifying properties via
PropertyPoller - Entity definitions based on MRA data
- Full type hints (
py.typed)
Requirements
- Python 3.14+
- bidict>=0.23.0
License
MIT License
Installation
pip install pyhems
Quick Start
import asyncio
from pyhems import EOJ, HemsClient, HemsFrameEvent, HemsInstanceListEvent
async def main():
client = HemsClient(interface="0.0.0.0")
await client.start()
def on_event(event):
if isinstance(event, HemsInstanceListEvent):
print(f"Node: {event.node_id}, Instances: {event.instances}")
elif isinstance(event, HemsFrameEvent):
print(f"Frame from {event.node_id}: {event.frame}")
unsubscribe = client.subscribe(on_event)
# Read properties from a discovered device
# node_id = "fe..." # obtained from HemsInstanceListEvent
# props = await client.get(node_id, EOJ(0x013001), [0x80, 0xB3])
# Write a property (example: power ON)
# await client.set_property(node_id, EOJ(0x013001), 0x80, b"\x30")
await asyncio.sleep(60)
unsubscribe()
await client.stop()
asyncio.run(main())
Runtime API Overview
HemsClient.start()/HemsClient.stop(): Start and stop UDP transport.HemsClient.subscribe(callback): Subscribe to runtime events.HemsClient.probe_nodes(): Trigger multicast node discovery.HemsClient.get(node_id, deoj, epcs): Read property values.HemsClient.set_property(node_id, deoj, epc, edt): Write a single property.HemsClient.set_properties(node_id, deoj, properties): Write multiple properties.
Adaptive Property Polling
PropertyPoller uses an adaptive scheduler designed for mixed ECHONET Lite devices:
- TID-correlated in-flight tracking avoids request pileups on slow devices.
- Poll cadence is adjusted from latency EWMA and failure backoff, starting from the base interval.
- Instantaneous-value EPCs can be scheduled on a separate fast lane (
fast_poll_epcs). - When devices truncate large responses, batch size is learned (
observed_batch_capacity) and reused. - Poll targets can be narrowed dynamically through
DeviceManager.subscribe_epcs(...).
Definitions
from pyhems import REGISTRY
print(REGISTRY.version, REGISTRY.mra_version)
# Mapping: class_code -> tuple[EntityDefinition, ...]
ac_entities = REGISTRY.entities.get(0x0130, ())
for entity in ac_entities[:3]:
print(entity.epc, entity.name_en)
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 pyhems-0.8.1.tar.gz.
File metadata
- Download URL: pyhems-0.8.1.tar.gz
- Upload date:
- Size: 89.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cfe74329c1f9d6ef868b747ea98a5cf70c5b67b9ebc2c120c3f296b9f5253c09
|
|
| MD5 |
0e99e6904d48e8d8abc622bb3b08a674
|
|
| BLAKE2b-256 |
45f5b99d0589fcfb5f8953ca21c2c3dde181bf8b0c26b620e0bd6bbdde2468f1
|
Provenance
The following attestation bundles were made for pyhems-0.8.1.tar.gz:
Publisher:
release.yml on sayurin/pyhems
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pyhems-0.8.1.tar.gz -
Subject digest:
cfe74329c1f9d6ef868b747ea98a5cf70c5b67b9ebc2c120c3f296b9f5253c09 - Sigstore transparency entry: 2197256712
- Sigstore integration time:
-
Permalink:
sayurin/pyhems@e3fd743317d9c3ad56f4a5ab3058f97be700f9c3 -
Branch / Tag:
refs/heads/master - Owner: https://github.com/sayurin
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@e3fd743317d9c3ad56f4a5ab3058f97be700f9c3 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file pyhems-0.8.1-py3-none-any.whl.
File metadata
- Download URL: pyhems-0.8.1-py3-none-any.whl
- Upload date:
- Size: 71.0 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 |
59b815a7c2cc2055c52fb8080f3c5af283134fcd6c15e65c0c0cbfc9f5871cb2
|
|
| MD5 |
227bd81fe57c6886dd674234439113a6
|
|
| BLAKE2b-256 |
9b5b71297efbe5c5cbd09f476a1853c32a28c94e6591eee4c6c8d013937a0b25
|
Provenance
The following attestation bundles were made for pyhems-0.8.1-py3-none-any.whl:
Publisher:
release.yml on sayurin/pyhems
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pyhems-0.8.1-py3-none-any.whl -
Subject digest:
59b815a7c2cc2055c52fb8080f3c5af283134fcd6c15e65c0c0cbfc9f5871cb2 - Sigstore transparency entry: 2197256823
- Sigstore integration time:
-
Permalink:
sayurin/pyhems@e3fd743317d9c3ad56f4a5ab3058f97be700f9c3 -
Branch / Tag:
refs/heads/master - Owner: https://github.com/sayurin
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@e3fd743317d9c3ad56f4a5ab3058f97be700f9c3 -
Trigger Event:
workflow_dispatch
-
Statement type: