Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(#2591): Remove device name from Home Assistant entities #2594

Merged
Merged
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
11 changes: 6 additions & 5 deletions examples/rtl_433_mqtt_hass.py
Original file line number Diff line number Diff line change
Expand Up @@ -748,7 +748,7 @@ def rtl_433_device_info(data):
return (path, id)


def publish_config(mqttc, topic, model, object_id, mapping, value=None):
def publish_config(mqttc, topic, model, object_id, mapping, key=None):
"""Publish Home Assistant auto discovery data."""
global discovery_timeouts

Expand Down Expand Up @@ -776,9 +776,10 @@ def publish_config(mqttc, topic, model, object_id, mapping, value=None):
config["topic"] = topic
config["platform"] = 'mqtt'
else:
readable_name = mapping["config"]["name"] if "name" in mapping["config"] else key
config["state_topic"] = topic
config["unique_id"] = object_name
config["name"] = object_name
config["name"] = readable_name
config["device"] = { "identifiers": [object_id], "name": object_id, "model": model, "manufacturer": "rtl_433" }

if args.force_update:
Expand All @@ -793,7 +794,7 @@ def publish_config(mqttc, topic, model, object_id, mapping, value=None):

return True

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

if "model" not in data:
Expand Down Expand Up @@ -822,7 +823,7 @@ def bridge_event_to_hass(mqttc, topicprefix, data):
if key in mappings:
# topic = "/".join([topicprefix,"devices",model,instance,key])
topic = "/".join([base_topic, key])
if publish_config(mqttc, topic, model, device_id, mappings[key]):
if publish_config(mqttc, topic, model, device_id, mappings[key], key):
published_keys.append(key)
else:
if key not in SKIP_KEYS:
Expand All @@ -831,7 +832,7 @@ def bridge_event_to_hass(mqttc, topicprefix, data):
if "secret_knock" in data.keys():
for m in secret_knock_mappings:
topic = "/".join([base_topic, "secret_knock"])
if publish_config(mqttc, topic, model, device_id, m):
if publish_config(mqttc, topic, model, device_id, m, "secret_knock"):
published_keys.append("secret_knock")

if published_keys:
Expand Down
Loading