minimal fixes in the owntracks mqtt device tracker (#9866)
* fix UnboundLocalError when unable to parse payload, and show bad topics that cannot be parsed ok * Update owntracks.py
This commit is contained in:
parent
00244380a8
commit
26cb67dec2
1 changed files with 6 additions and 1 deletions
|
@ -75,6 +75,7 @@ def async_setup_scanner(hass, config, async_see, discovery_info=None):
|
||||||
except ValueError:
|
except ValueError:
|
||||||
# If invalid JSON
|
# If invalid JSON
|
||||||
_LOGGER.error("Unable to parse payload as JSON: %s", payload)
|
_LOGGER.error("Unable to parse payload as JSON: %s", payload)
|
||||||
|
return
|
||||||
|
|
||||||
message['topic'] = topic
|
message['topic'] = topic
|
||||||
|
|
||||||
|
@ -91,7 +92,11 @@ def _parse_topic(topic):
|
||||||
|
|
||||||
Async friendly.
|
Async friendly.
|
||||||
"""
|
"""
|
||||||
_, user, device, *_ = topic.split('/', 3)
|
try:
|
||||||
|
_, user, device, *_ = topic.split('/', 3)
|
||||||
|
except ValueError:
|
||||||
|
_LOGGER.error("Can't parse topic: '%s'", topic)
|
||||||
|
raise
|
||||||
|
|
||||||
return user, device
|
return user, device
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue