Skip to main content

Python SDK for Homie MQTT Convention (eBus)

Project description

ebus-sdk

PyPI Ruff

Python SDK for the Electrification Bus (eBus) integration framework, which adopts and supports the Homie Convention.

Installation

pip install ebus-sdk

Quick Start

Device Role

Create a Homie device that publishes sensor data:

from ebus_sdk import Device, Node, PropertyDatatype, Unit

# Create device
device = Device('my-device-id', name='My Sensor', mqtt_cfg={
    'host': 'mqtt.example.com',
    'port': 1883
})

# Add a node with properties
node = device.add_node_from_dict({
    'id': 'sensors',
    'name': 'Sensors',
    'type': 'sensor'
})

# Add a temperature property
temp = node.add_property_from_dict({
    'id': 'temperature',
    'name': 'Temperature',
    'datatype': PropertyDatatype.FLOAT,
    'unit': Unit.DEGREE_CELSIUS
})

# Start and publish
device.start_mqtt_client()
temp.set_value(23.5)

Controller Role

Discover and monitor Homie devices:

from ebus_sdk import Controller, DiscoveredDevice

def on_device_discovered(device: DiscoveredDevice):
    print(f'Found: {device.device_id}')

def on_property_changed(device_id, node_id, prop_id, new_val, old_val):
    print(f'{device_id}/{node_id}/{prop_id} = {new_val}')

controller = Controller(mqtt_cfg={'host': 'mqtt.example.com', 'port': 1883})
controller.set_on_device_discovered_callback(on_device_discovered)
controller.set_on_property_changed_callback(on_property_changed)
controller.start_discovery()

Module Structure

src/ebus_sdk/
├── __init__.py     # Package exports
├── homie.py        # Homie convention implementation
├── mqtt.py         # MQTT client wrapper
└── property.py     # Property abstractions

homie.py

Core Homie convention implementation:

  • Device - Represents a Homie device with nodes and properties
  • Node - Groups related properties within a device
  • Property - Individual data points (sensors, controls)
  • Controller - Discovers and monitors Homie devices on a broker
  • DiscoveredDevice - Represents a device found by the controller
  • DeviceState - Enum: init, ready, disconnected, sleeping, lost
  • PropertyDatatype - Enum: STRING, INTEGER, FLOAT, BOOLEAN, ENUM, COLOR, DATETIME, DURATION, JSON
  • Unit - Common units: DEGREE_CELSIUS, PERCENT, WATT, KILOWATT_HOUR, etc.

mqtt.py

  • MqttClient - Wrapper around paho-mqtt with automatic reconnection, TLS support, and subscription management

property.py

Application-level property abstractions for bridging application state to Homie:

  • Property - Thread-safe observable property with change callbacks
  • GroupedPropertyDict - Two-level dictionary organizing properties by group
  • PropertyDict - Simple property dictionary
  • ChangeEvent - Enum for property change event types

Examples

See examples/README.md for example scripts demonstrating device and controller usage.

Requirements

  • Python 3.10+
  • paho-mqtt >= 1.6.1

License

MIT License — Copyright (c) 2026 Clark Communications Corporation

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

ebus_sdk-0.1.7.tar.gz (37.1 kB view details)

Uploaded Source

Built Distribution

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

ebus_sdk-0.1.7-py3-none-any.whl (25.3 kB view details)

Uploaded Python 3

File details

Details for the file ebus_sdk-0.1.7.tar.gz.

File metadata

  • Download URL: ebus_sdk-0.1.7.tar.gz
  • Upload date:
  • Size: 37.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for ebus_sdk-0.1.7.tar.gz
Algorithm Hash digest
SHA256 9cdc5d5eae8763fa57d464e023651f20ba1617b99ecd815cd32e5efcf1827c38
MD5 994c0bc1c42ff1a6048aeab15da520d2
BLAKE2b-256 7fb33de35d62da0f0b32d7df0811fea3b732f64091350501ab485e0720990701

See more details on using hashes here.

Provenance

The following attestation bundles were made for ebus_sdk-0.1.7.tar.gz:

Publisher: publish.yml on electrification-bus/python-sdk

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

File details

Details for the file ebus_sdk-0.1.7-py3-none-any.whl.

File metadata

  • Download URL: ebus_sdk-0.1.7-py3-none-any.whl
  • Upload date:
  • Size: 25.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for ebus_sdk-0.1.7-py3-none-any.whl
Algorithm Hash digest
SHA256 c270e1fb4f4a660c59f8ad187dd2b668effec0d9bba413cdc1418796a4085c48
MD5 a44bb196ceef22cfafd8252cce9bd34e
BLAKE2b-256 9563755235426aaf5e301e2745c01aaea0a11a8f653b2ad8d39db25d2d8fbd15

See more details on using hashes here.

Provenance

The following attestation bundles were made for ebus_sdk-0.1.7-py3-none-any.whl:

Publisher: publish.yml on electrification-bus/python-sdk

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