mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 05:07:41 +00:00
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:
parent
d8ac761bb6
commit
76d11e4b74
@ -235,8 +235,8 @@ async def async_start(hass: HomeAssistantType, discovery_topic, hass_config,
|
|||||||
key = DEVICE_ABBREVIATIONS.get(key, key)
|
key = DEVICE_ABBREVIATIONS.get(key, key)
|
||||||
device[key] = device.pop(abbreviated_key)
|
device[key] = device.pop(abbreviated_key)
|
||||||
|
|
||||||
base = payload.pop(TOPIC_BASE, None)
|
if TOPIC_BASE in payload:
|
||||||
if base:
|
base = payload.pop(TOPIC_BASE)
|
||||||
for key, value in payload.items():
|
for key, value in payload.items():
|
||||||
if isinstance(value, str) and value:
|
if isinstance(value, str) and value:
|
||||||
if value[0] == TOPIC_BASE and key.endswith('_topic'):
|
if value[0] == TOPIC_BASE and key.endswith('_topic'):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user