Skip to main content

ECHONET Lite library for Home Energy Management System (HEMS)

Project description

pyhems

Python Version License

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
  • Poll scheduler for non-notifying properties via PropertyPoller
  • Entity definitions based on MRA data
  • Full type hints (py.typed)

Requirements

  • Python 3.13+
  • 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.

Definitions

from pyhems import load_definitions_registry

registry = load_definitions_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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyhems-0.5.2.tar.gz (73.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pyhems-0.5.2-py3-none-any.whl (65.2 kB view details)

Uploaded Python 3

File details

Details for the file pyhems-0.5.2.tar.gz.

File metadata

  • Download URL: pyhems-0.5.2.tar.gz
  • Upload date:
  • Size: 73.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for pyhems-0.5.2.tar.gz
Algorithm Hash digest
SHA256 34e60e3613bb83e9f9d8377ec632e9aada59d2a8f29ab42fe01c936d17cae3bc
MD5 83beb12ecb5bd7fc107b61868bc18d69
BLAKE2b-256 6ab5fce2ce42c26f388173dd0960579ccd4cfba44ed4724d6c2c0fd3a1320659

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyhems-0.5.2.tar.gz:

Publisher: release.yml on sayurin/pyhems

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyhems-0.5.2-py3-none-any.whl.

File metadata

  • Download URL: pyhems-0.5.2-py3-none-any.whl
  • Upload date:
  • Size: 65.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for pyhems-0.5.2-py3-none-any.whl
Algorithm Hash digest
SHA256 b064d71ac69394bf6b1f3caa065b906e6abffb04e5b32199cd8979a54a7f10c0
MD5 6dc9d25b15213f1220fa9f13a694de3c
BLAKE2b-256 82db5ccf0f8e9bdc3ea57a4db42d22bc8fefcee0976af3e5406d00c2335ccfa5

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyhems-0.5.2-py3-none-any.whl:

Publisher: release.yml on sayurin/pyhems

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page