Skip to content

Commit

Permalink
fix empty TOPIC_BASE issue (#21740)
Browse files Browse the repository at this point in the history
* 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>
  • Loading branch information
engrbm87 authored and balloob committed Mar 9, 2019
1 parent d8ac761 commit 76d11e4
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions homeassistant/components/mqtt/discovery.py
Expand Up @@ -235,8 +235,8 @@ async def async_device_message_received(topic, payload, qos):
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'):
Expand Down

0 comments on commit 76d11e4

Please sign in to comment.