ebus-sdk 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
ebus_sdk-0.1.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Electrification Bus (eBus) Contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,139 @@
1
+ Metadata-Version: 2.4
2
+ Name: ebus-sdk
3
+ Version: 0.1.0
4
+ Summary: Python SDK for Homie MQTT Convention (eBus)
5
+ Author: eBus Contributors
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://ebus.energy
8
+ Project-URL: Repository, https://github.com/electrification-bus/python-sdk
9
+ Keywords: mqtt,homie,iot,ebus
10
+ Classifier: Development Status :: 3 - Alpha
11
+ Classifier: Intended Audience :: Developers
12
+ Classifier: Programming Language :: Python :: 3
13
+ Classifier: Programming Language :: Python :: 3.10
14
+ Classifier: Programming Language :: Python :: 3.11
15
+ Classifier: Programming Language :: Python :: 3.12
16
+ Classifier: Topic :: Home Automation
17
+ Classifier: Topic :: Internet :: WWW/HTTP
18
+ Requires-Python: >=3.10
19
+ Description-Content-Type: text/markdown
20
+ License-File: LICENSE
21
+ Requires-Dist: paho-mqtt>=1.6.1
22
+ Provides-Extra: mdns
23
+ Requires-Dist: zeroconf>=0.131.0; extra == "mdns"
24
+ Provides-Extra: dev
25
+ Requires-Dist: pytest; extra == "dev"
26
+ Dynamic: license-file
27
+
28
+ # ebus-sdk
29
+
30
+ Python SDK for the [Electrification Bus (eBus)](https://ebus.energy) integration framework, which adopts and supports the [Homie Convention](https://homieiot.github.io).
31
+
32
+ ## Installation
33
+
34
+ ```bash
35
+ pip install ebus-sdk
36
+ ```
37
+
38
+ ## Quick Start
39
+
40
+ ### Device Role
41
+
42
+ Create a Homie device that publishes sensor data:
43
+
44
+ ```python
45
+ from ebus_sdk import Device, Node, PropertyDatatype, Unit
46
+
47
+ # Create device
48
+ device = Device('my-device-id', name='My Sensor', mqtt_cfg={
49
+ 'host': 'mqtt.example.com',
50
+ 'port': 1883
51
+ })
52
+
53
+ # Add a node with properties
54
+ node = device.add_node_from_dict({
55
+ 'id': 'sensors',
56
+ 'name': 'Sensors',
57
+ 'type': 'sensor'
58
+ })
59
+
60
+ # Add a temperature property
61
+ temp = node.add_property_from_dict({
62
+ 'id': 'temperature',
63
+ 'name': 'Temperature',
64
+ 'datatype': PropertyDatatype.FLOAT,
65
+ 'unit': Unit.DEGREE_CELSIUS
66
+ })
67
+
68
+ # Start and publish
69
+ device.start_mqtt_client()
70
+ temp.set_value(23.5)
71
+ ```
72
+
73
+ ### Controller Role
74
+
75
+ Discover and monitor Homie devices:
76
+
77
+ ```python
78
+ from ebus_sdk import Controller, DiscoveredDevice
79
+
80
+ def on_device_discovered(device: DiscoveredDevice):
81
+ print(f'Found: {device.device_id}')
82
+
83
+ def on_property_changed(device_id, node_id, prop_id, new_val, old_val):
84
+ print(f'{device_id}/{node_id}/{prop_id} = {new_val}')
85
+
86
+ controller = Controller(mqtt_cfg={'host': 'mqtt.example.com', 'port': 1883})
87
+ controller.set_on_device_discovered_callback(on_device_discovered)
88
+ controller.set_on_property_changed_callback(on_property_changed)
89
+ controller.start_discovery()
90
+ ```
91
+
92
+ ## Module Structure
93
+
94
+ ```
95
+ src/ebus_sdk/
96
+ ├── __init__.py # Package exports
97
+ ├── homie.py # Homie convention implementation
98
+ ├── mqtt.py # MQTT client wrapper
99
+ └── property.py # Property abstractions
100
+ ```
101
+
102
+ ### homie.py
103
+
104
+ Core Homie convention implementation:
105
+
106
+ - **Device** - Represents a Homie device with nodes and properties
107
+ - **Node** - Groups related properties within a device
108
+ - **Property** - Individual data points (sensors, controls)
109
+ - **Controller** - Discovers and monitors Homie devices on a broker
110
+ - **DiscoveredDevice** - Represents a device found by the controller
111
+ - **DeviceState** - Enum: `init`, `ready`, `disconnected`, `sleeping`, `lost`
112
+ - **PropertyDatatype** - Enum: `STRING`, `INTEGER`, `FLOAT`, `BOOLEAN`, `ENUM`, `COLOR`, `DATETIME`, `DURATION`, `JSON`
113
+ - **Unit** - Common units: `DEGREE_CELSIUS`, `PERCENT`, `WATT`, `KILOWATT_HOUR`, etc.
114
+
115
+ ### mqtt.py
116
+
117
+ - **MqttClient** - Wrapper around paho-mqtt with automatic reconnection, TLS support, and subscription management
118
+
119
+ ### property.py
120
+
121
+ Application-level property abstractions for bridging application state to Homie:
122
+
123
+ - **Property** - Thread-safe observable property with change callbacks
124
+ - **GroupedPropertyDict** - Two-level dictionary organizing properties by group
125
+ - **PropertyDict** - Simple property dictionary
126
+ - **ChangeEvent** - Enum for property change event types
127
+
128
+ ## Examples
129
+
130
+ See [`examples/README.md`](examples/README.md) for example scripts demonstrating device and controller usage.
131
+
132
+ ## Requirements
133
+
134
+ - Python 3.10+
135
+ - paho-mqtt >= 1.6.1
136
+
137
+ ## License
138
+
139
+ MIT
@@ -0,0 +1,112 @@
1
+ # ebus-sdk
2
+
3
+ Python SDK for the [Electrification Bus (eBus)](https://ebus.energy) integration framework, which adopts and supports the [Homie Convention](https://homieiot.github.io).
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ pip install ebus-sdk
9
+ ```
10
+
11
+ ## Quick Start
12
+
13
+ ### Device Role
14
+
15
+ Create a Homie device that publishes sensor data:
16
+
17
+ ```python
18
+ from ebus_sdk import Device, Node, PropertyDatatype, Unit
19
+
20
+ # Create device
21
+ device = Device('my-device-id', name='My Sensor', mqtt_cfg={
22
+ 'host': 'mqtt.example.com',
23
+ 'port': 1883
24
+ })
25
+
26
+ # Add a node with properties
27
+ node = device.add_node_from_dict({
28
+ 'id': 'sensors',
29
+ 'name': 'Sensors',
30
+ 'type': 'sensor'
31
+ })
32
+
33
+ # Add a temperature property
34
+ temp = node.add_property_from_dict({
35
+ 'id': 'temperature',
36
+ 'name': 'Temperature',
37
+ 'datatype': PropertyDatatype.FLOAT,
38
+ 'unit': Unit.DEGREE_CELSIUS
39
+ })
40
+
41
+ # Start and publish
42
+ device.start_mqtt_client()
43
+ temp.set_value(23.5)
44
+ ```
45
+
46
+ ### Controller Role
47
+
48
+ Discover and monitor Homie devices:
49
+
50
+ ```python
51
+ from ebus_sdk import Controller, DiscoveredDevice
52
+
53
+ def on_device_discovered(device: DiscoveredDevice):
54
+ print(f'Found: {device.device_id}')
55
+
56
+ def on_property_changed(device_id, node_id, prop_id, new_val, old_val):
57
+ print(f'{device_id}/{node_id}/{prop_id} = {new_val}')
58
+
59
+ controller = Controller(mqtt_cfg={'host': 'mqtt.example.com', 'port': 1883})
60
+ controller.set_on_device_discovered_callback(on_device_discovered)
61
+ controller.set_on_property_changed_callback(on_property_changed)
62
+ controller.start_discovery()
63
+ ```
64
+
65
+ ## Module Structure
66
+
67
+ ```
68
+ src/ebus_sdk/
69
+ ├── __init__.py # Package exports
70
+ ├── homie.py # Homie convention implementation
71
+ ├── mqtt.py # MQTT client wrapper
72
+ └── property.py # Property abstractions
73
+ ```
74
+
75
+ ### homie.py
76
+
77
+ Core Homie convention implementation:
78
+
79
+ - **Device** - Represents a Homie device with nodes and properties
80
+ - **Node** - Groups related properties within a device
81
+ - **Property** - Individual data points (sensors, controls)
82
+ - **Controller** - Discovers and monitors Homie devices on a broker
83
+ - **DiscoveredDevice** - Represents a device found by the controller
84
+ - **DeviceState** - Enum: `init`, `ready`, `disconnected`, `sleeping`, `lost`
85
+ - **PropertyDatatype** - Enum: `STRING`, `INTEGER`, `FLOAT`, `BOOLEAN`, `ENUM`, `COLOR`, `DATETIME`, `DURATION`, `JSON`
86
+ - **Unit** - Common units: `DEGREE_CELSIUS`, `PERCENT`, `WATT`, `KILOWATT_HOUR`, etc.
87
+
88
+ ### mqtt.py
89
+
90
+ - **MqttClient** - Wrapper around paho-mqtt with automatic reconnection, TLS support, and subscription management
91
+
92
+ ### property.py
93
+
94
+ Application-level property abstractions for bridging application state to Homie:
95
+
96
+ - **Property** - Thread-safe observable property with change callbacks
97
+ - **GroupedPropertyDict** - Two-level dictionary organizing properties by group
98
+ - **PropertyDict** - Simple property dictionary
99
+ - **ChangeEvent** - Enum for property change event types
100
+
101
+ ## Examples
102
+
103
+ See [`examples/README.md`](examples/README.md) for example scripts demonstrating device and controller usage.
104
+
105
+ ## Requirements
106
+
107
+ - Python 3.10+
108
+ - paho-mqtt >= 1.6.1
109
+
110
+ ## License
111
+
112
+ MIT
@@ -0,0 +1,39 @@
1
+ [build-system]
2
+ requires = ["setuptools>=61.0"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "ebus-sdk"
7
+ version = "0.1.0"
8
+ description = "Python SDK for Homie MQTT Convention (eBus)"
9
+ readme = "README.md"
10
+ requires-python = ">=3.10"
11
+ license = "MIT"
12
+ authors = [
13
+ {name = "eBus Contributors"}
14
+ ]
15
+ keywords = ["mqtt", "homie", "iot", "ebus"]
16
+ classifiers = [
17
+ "Development Status :: 3 - Alpha",
18
+ "Intended Audience :: Developers",
19
+ "Programming Language :: Python :: 3",
20
+ "Programming Language :: Python :: 3.10",
21
+ "Programming Language :: Python :: 3.11",
22
+ "Programming Language :: Python :: 3.12",
23
+ "Topic :: Home Automation",
24
+ "Topic :: Internet :: WWW/HTTP",
25
+ ]
26
+ dependencies = [
27
+ "paho-mqtt>=1.6.1",
28
+ ]
29
+
30
+ [project.optional-dependencies]
31
+ mdns = ["zeroconf>=0.131.0"]
32
+ dev = ["pytest"]
33
+
34
+ [project.urls]
35
+ Homepage = "https://ebus.energy"
36
+ Repository = "https://github.com/electrification-bus/python-sdk"
37
+
38
+ [tool.setuptools.packages.find]
39
+ where = ["src"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,67 @@
1
+ """
2
+ ebus-sdk: Python SDK for Homie MQTT Convention (eBus)
3
+
4
+ This SDK provides Device and Controller roles for the Homie MQTT convention.
5
+ """
6
+
7
+ # Core Homie classes
8
+ from .homie import (
9
+ Device,
10
+ Node,
11
+ Property,
12
+ Controller,
13
+ DiscoveredDevice,
14
+ StateTransitionContext,
15
+ )
16
+
17
+ # Enums
18
+ from .homie import (
19
+ DeviceState,
20
+ PropertyDatatype,
21
+ Unit,
22
+ )
23
+
24
+ # Utility functions
25
+ from .homie import (
26
+ datatype_from_type,
27
+ ebus_cfg_add_auth,
28
+ )
29
+
30
+ # Property abstractions
31
+ from .property import (
32
+ Property as ObservableProperty,
33
+ GroupedPropertyDict,
34
+ PropertyDict,
35
+ ChangeEvent,
36
+ BulkUpdateContext,
37
+ )
38
+
39
+ # MQTT client
40
+ from .mqtt import MqttClient
41
+
42
+ __version__ = "0.1.0"
43
+
44
+ __all__ = [
45
+ # Homie classes
46
+ "Device",
47
+ "Node",
48
+ "Property",
49
+ "Controller",
50
+ "DiscoveredDevice",
51
+ "StateTransitionContext",
52
+ # Enums
53
+ "DeviceState",
54
+ "PropertyDatatype",
55
+ "Unit",
56
+ # Utilities
57
+ "datatype_from_type",
58
+ "ebus_cfg_add_auth",
59
+ # Property abstractions
60
+ "ObservableProperty",
61
+ "GroupedPropertyDict",
62
+ "PropertyDict",
63
+ "ChangeEvent",
64
+ "BulkUpdateContext",
65
+ # MQTT
66
+ "MqttClient",
67
+ ]