Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ All notable changes to `ebus-sdk` are recorded here. Format follows [Keep a Chan

## [Unreleased]

### Fixed

- `homie.Device.as_dict()` no longer raises `TypeError: unhashable type: 'dict'` for a device with a node: it built each node entry as a set literal, `{node_id, node.as_dict()}`, instead of a dict entry ([#87](https://github.com/electrification-bus/python-sdk/issues/87)).

### Changed

- `ebus-mqtt-client` floor raised to 0.6.0. It holds every publish issued while the link is down and flushes it before the SDK's on-connect republish; 0.5.0 left QoS 1 and 2 publishes to paho, which replayed them after that republish and past mosquitto's 20-message receive quota, and mosquitto discarded the excess QoS 2 messages. A root built with `mqtt_cfg=` publishes during construction, before CONNACK, so `simple-device` and `simple-tree-device` ended with the root's retained `$state` on `init` instead of `ready` ([electrification-bus/ebus-mqtt-client#20](https://github.com/electrification-bus/ebus-mqtt-client/issues/20)).
Expand Down
2 changes: 1 addition & 1 deletion src/ebus_sdk/homie.py
Original file line number Diff line number Diff line change
Expand Up @@ -1687,7 +1687,7 @@ def __init__(
def as_dict(self) -> dict:
nodes = {}
for node_id, node in self.nodes().items():
nodes.update({node_id, node.as_dict()})
nodes[node_id] = node.as_dict()
return {
"id": self.id(),
"name": self.name(),
Expand Down
9 changes: 9 additions & 0 deletions tests/test_homie_device.py
Original file line number Diff line number Diff line change
Expand Up @@ -1144,6 +1144,15 @@ def test_as_dict(self):
assert d["name"] == "Core"
assert "temp" in d["properties"]

def test_device_as_dict_keys_nodes_by_id(self):
# GH #87: a set literal here raised TypeError for any device with a node.
dev = Device(id="d1", name="D", type="t", mqttc=_mock_mqtt_client())
dev.add_node(Node(id="core", name="Core", type="sensor"))
d = dev.as_dict()
assert d["id"] == "d1"
assert list(d["nodes"]) == ["core"]
assert d["nodes"]["core"]["id"] == "core"


class TestNodeClearAllProperties:
def test_clear_all_properties(self):
Expand Down
Loading