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:
parent
3fb691ead6
commit
dc4b0695b5
1 changed files with 4 additions and 1 deletions
5
homeassistant/components/device_tracker/ubus.py
Normal file → Executable file
5
homeassistant/components/device_tracker/ubus.py
Normal file → Executable 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"]
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue