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:
Eugenio Panadero 2017-10-15 00:46:06 +02:00 committed by Paulus Schoutsen
parent 00244380a8
commit 26cb67dec2

View file

@ -75,6 +75,7 @@ def async_setup_scanner(hass, config, async_see, discovery_info=None):
except ValueError:
# If invalid JSON
_LOGGER.error("Unable to parse payload as JSON: %s", payload)
return
message['topic'] = topic
@ -91,7 +92,11 @@ def _parse_topic(topic):
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