device_tracker.ubus: Handle empty results (#7673)

If OpenWRT isn't running the DHCP server then some OpenWRT hardware,
such as TP-Link TL-WDR3600 v1, can't determine the host
corresponding to an associated wifi client. This change handles that
by returning None when the request has no data in the result.
This commit is contained in:
tobygray 2017-05-22 01:26:05 +01:00 committed by Paulus Schoutsen
parent 3fb691ead6
commit dc4b0695b5

5
homeassistant/components/device_tracker/ubus.py Normal file → Executable file
View file

@ -144,7 +144,10 @@ def _req_json_rpc(url, session_id, rpcmethod, subsystem, method, **params):
response = res.json()
if rpcmethod == "call":
return response["result"][1]
try:
return response["result"][1]
except IndexError:
return
else:
return response["result"]