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 <engrbm87@gmail.com>
This commit is contained in:
engrbm87 2019-03-09 02:48:54 +02:00 committed by Paulus Schoutsen
parent d8ac761bb6
commit 76d11e4b74

View File

@ -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'):