Fix base topic for 'topic' (#37475)

pull/37586/head
Erik Montnemery 2020-07-07 00:17:13 +02:00 committed by Paulus Schoutsen
parent ddb049e884
commit 050a558243
1 changed files with 2 additions and 2 deletions

View File

@ -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