From 2186c61b5a4f54aa32c92e2d73d70e1d22347b7e Mon Sep 17 00:00:00 2001 From: James Muscat Date: Sun, 28 Jul 2024 21:59:23 +0100 Subject: [PATCH] Include events and options in discovery messages. --- HADiscovery.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/HADiscovery.py b/HADiscovery.py index 9ca0de4..60748af 100644 --- a/HADiscovery.py +++ b/HADiscovery.py @@ -43,12 +43,15 @@ def publish_ha_discovery(device, client, mqtt_topic): } for feature in device["features"].values(): + name_parts = feature["name"].split(".") + name = name_parts[-1] + feature_type = name_parts[-2] access = feature.get("access", "none") available = feature.get("available", False) - if available and (access == "read" or access == "readWrite"): - name_parts = feature["name"].split(".") - name = name_parts[-1] - # feature_type = name_parts[-2] + + if (feature_type == "Setting" and available and (access == "read" or access == "readWrite")) or \ + feature_type == "Event" or \ + feature_type == "Option": component_type = "sensor" # TODO use appropriate types