From 76d11e4b746b70b8bcb231273831b16651feead6 Mon Sep 17 00:00:00 2001 From: engrbm87 Date: Sat, 9 Mar 2019 02:48:54 +0200 Subject: [PATCH] fix empty TOPIC_BASE issue (#21740) * fix empty TOPIC_BASE issue if the value of the TOPIC_BASE is empty then we need to remove "~" from the topic value if it exists. by doing `if base:` on line 239 the condition will be false if the value is empty so the '~' will not be stripped from the topic value. I simply removed the `if base:` line and added `if TOPIC_BASE in payload:` * Update homeassistant/components/mqtt/discovery.py Co-Authored-By: engrbm87 --- 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 688912070bd..885c14f609f 100644 --- a/homeassistant/components/mqtt/discovery.py +++ b/homeassistant/components/mqtt/discovery.py @@ -235,8 +235,8 @@ async def async_start(hass: HomeAssistantType, discovery_topic, hass_config, key = DEVICE_ABBREVIATIONS.get(key, key) device[key] = device.pop(abbreviated_key) - base = payload.pop(TOPIC_BASE, None) - if base: + if TOPIC_BASE in payload: + 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'):