mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 11:17:21 +00:00
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:
parent
ab8c127a4a
commit
7e702d3caa
@ -202,10 +202,11 @@ async def async_start(hass: HomeAssistantType, discovery_topic, hass_config,
|
|||||||
if TOPIC_BASE in payload:
|
if TOPIC_BASE in payload:
|
||||||
base = payload[TOPIC_BASE]
|
base = payload[TOPIC_BASE]
|
||||||
for key, value in payload.items():
|
for key, value in payload.items():
|
||||||
if value[0] == TOPIC_BASE and key.endswith('_topic'):
|
if isinstance(value, str):
|
||||||
payload[key] = "{}{}".format(base, value[1:])
|
if value[0] == TOPIC_BASE and key.endswith('_topic'):
|
||||||
if value[-1] == TOPIC_BASE and key.endswith('_topic'):
|
payload[key] = "{}{}".format(base, value[1:])
|
||||||
payload[key] = "{}{}".format(value[:-1], base)
|
if value[-1] == TOPIC_BASE and key.endswith('_topic'):
|
||||||
|
payload[key] = "{}{}".format(value[:-1], base)
|
||||||
|
|
||||||
# If present, the node_id will be included in the discovered object id
|
# If present, the node_id will be included in the discovered object id
|
||||||
discovery_id = '_'.join((node_id, object_id)) if node_id else object_id
|
discovery_id = '_'.join((node_id, object_id)) if node_id else object_id
|
||||||
|
Loading…
x
Reference in New Issue
Block a user