From dc4b0695b5edc799cc6a242b296b69da9917e518 Mon Sep 17 00:00:00 2001 From: tobygray Date: Mon, 22 May 2017 01:26:05 +0100 Subject: [PATCH] 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. --- homeassistant/components/device_tracker/ubus.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) mode change 100644 => 100755 homeassistant/components/device_tracker/ubus.py diff --git a/homeassistant/components/device_tracker/ubus.py b/homeassistant/components/device_tracker/ubus.py old mode 100644 new mode 100755 index 31c7d32c4c1357..b1d5aa499b5802 --- a/homeassistant/components/device_tracker/ubus.py +++ b/homeassistant/components/device_tracker/ubus.py @@ -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"]