From b826970b1651d4163fe2f5a68263f8c4bfbd5a53 Mon Sep 17 00:00:00 2001 From: Erik Montnemery Date: Tue, 7 Jul 2020 00:17:13 +0200 Subject: [PATCH] Fix base topic for 'topic' (#37475) --- homeassistant/components/mqtt/discovery.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/homeassistant/components/mqtt/discovery.py b/homeassistant/components/mqtt/discovery.py index 281172b6332..aff66954968 100644 --- a/homeassistant/components/mqtt/discovery.py +++ b/homeassistant/components/mqtt/discovery.py @@ -104,9 +104,9 @@ async def async_start( base = payload.pop(TOPIC_BASE) for key, value in payload.items(): if isinstance(value, str) and value: - if value[0] == TOPIC_BASE and key.endswith("_topic"): + if value[0] == TOPIC_BASE and key.endswith("topic"): payload[key] = f"{base}{value[1:]}" - if value[-1] == TOPIC_BASE and key.endswith("_topic"): + if value[-1] == TOPIC_BASE and key.endswith("topic"): payload[key] = f"{value[:-1]}{base}" # If present, the node_id will be included in the discovered object id