Fix small issue related to topic prefix (#18512)

Fix expansion of topic prefix when discovery message contains non string-type items.
This commit is contained in:
emontnemery 2018-11-19 09:59:07 +01:00 committed by Paulus Schoutsen
parent ab8c127a4a
commit 7e702d3caa

View File

@ -202,6 +202,7 @@ async def async_start(hass: HomeAssistantType, discovery_topic, hass_config,
if TOPIC_BASE in payload:
base = payload[TOPIC_BASE]
for key, value in payload.items():
if isinstance(value, str):
if value[0] == TOPIC_BASE and key.endswith('_topic'):
payload[key] = "{}{}".format(base, value[1:])
if value[-1] == TOPIC_BASE and key.endswith('_topic'):