Skip to content

Commit 313c665

Browse files
unverbrauchtandrewjw
authored andcommitted
Fix HA script topics (merbanan#2593)
1 parent a40d3b0 commit 313c665

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

examples/rtl_433_mqtt_hass.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -720,7 +720,7 @@ def sanitize(text):
720720
.replace(".", "_")
721721
.replace("&", ""))
722722

723-
def rtl_433_device_info(data):
723+
def rtl_433_device_info(data, topic_prefix):
724724
"""Return rtl_433 device topic to subscribe to for a data element, based on the
725725
rtl_433 device topic argument, as well as the device identifier"""
726726

@@ -745,7 +745,7 @@ def rtl_433_device_info(data):
745745

746746
path = ''.join(list(filter(lambda item: item, path_elements)))
747747
id = '-'.join(id_elements)
748-
return (path, id)
748+
return (f"{topic_prefix}/{path}", id)
749749

750750

751751
def publish_config(mqttc, topic, model, object_id, mapping, value=None):
@@ -793,7 +793,7 @@ def publish_config(mqttc, topic, model, object_id, mapping, value=None):
793793

794794
return True
795795

796-
def bridge_event_to_hass(mqttc, topicprefix, data):
796+
def bridge_event_to_hass(mqttc, topic_prefix, data):
797797
"""Translate some rtl_433 sensor data to Home Assistant auto discovery."""
798798

799799
if "model" not in data:
@@ -806,7 +806,7 @@ def bridge_event_to_hass(mqttc, topicprefix, data):
806806
skipped_keys = []
807807
published_keys = []
808808

809-
base_topic, device_id = rtl_433_device_info(data)
809+
base_topic, device_id = rtl_433_device_info(data, topic_prefix)
810810
if not device_id:
811811
# no unique device identifier
812812
logging.warning("No suitable identifier found for model: ", model)

0 commit comments

Comments
 (0)