From a174a06e5c48d443e310b0334113403395647e01 Mon Sep 17 00:00:00 2001 From: Erik Date: Mon, 4 Jan 2016 19:25:52 +0100 Subject: [PATCH 1/4] No need to call update() here This also fixes a problem where the sensor is left uninitialized when the energy meter temporarily has lost connection with the hub. This caused the ELIQ Online server to return HTTP error 400: "user have no current power data", which in turn caused the used eliq library to fail during JSON parsing (issue reported). --- homeassistant/components/sensor/eliqonline.py | 1 - 1 file changed, 1 deletion(-) diff --git a/homeassistant/components/sensor/eliqonline.py b/homeassistant/components/sensor/eliqonline.py index 151b679b10e..891144c4b5f 100644 --- a/homeassistant/components/sensor/eliqonline.py +++ b/homeassistant/components/sensor/eliqonline.py @@ -46,7 +46,6 @@ class EliqSensor(Entity): self.api = api self.channel_id = channel_id - self.update() @property def name(self): From 66f12afbb14e5f60e5fa505c7021e835ed50cb87 Mon Sep 17 00:00:00 2001 From: Erik Date: Mon, 4 Jan 2016 21:12:10 +0100 Subject: [PATCH 2/4] don't fail if error don't fail if request for updated data raises exception in underlying library --- homeassistant/components/sensor/eliqonline.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/homeassistant/components/sensor/eliqonline.py b/homeassistant/components/sensor/eliqonline.py index 891144c4b5f..f8aaf024813 100644 --- a/homeassistant/components/sensor/eliqonline.py +++ b/homeassistant/components/sensor/eliqonline.py @@ -46,6 +46,7 @@ class EliqSensor(Entity): self.api = api self.channel_id = channel_id + self.update() @property def name(self): @@ -69,5 +70,8 @@ class EliqSensor(Entity): def update(self): """ Gets the latest data. """ - response = self.api.get_data_now(channelid=self.channel_id) - self._state = int(response.power) + try: + response = self.api.get_data_now(channelid=self.channel_id) + self._state = int(response.power) + except: + pass From 82cd2f4ed6fdfc71c6fb52f9b6bcfbe674434b00 Mon Sep 17 00:00:00 2001 From: Erik Date: Mon, 4 Jan 2016 21:31:42 +0100 Subject: [PATCH 3/4] Update eliqonline.py --- homeassistant/components/sensor/eliqonline.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/homeassistant/components/sensor/eliqonline.py b/homeassistant/components/sensor/eliqonline.py index f8aaf024813..91b82f5dc88 100644 --- a/homeassistant/components/sensor/eliqonline.py +++ b/homeassistant/components/sensor/eliqonline.py @@ -73,5 +73,5 @@ class EliqSensor(Entity): try: response = self.api.get_data_now(channelid=self.channel_id) self._state = int(response.power) - except: + except TypeError: # raised by eliqonline library on any HTTP error pass From 5576649d60ec349bcc4c99a3630b1f4970775a3d Mon Sep 17 00:00:00 2001 From: Erik Date: Mon, 4 Jan 2016 21:36:39 +0100 Subject: [PATCH 4/4] Update eliqonline.py --- homeassistant/components/sensor/eliqonline.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/homeassistant/components/sensor/eliqonline.py b/homeassistant/components/sensor/eliqonline.py index 91b82f5dc88..4e6b8a5c342 100644 --- a/homeassistant/components/sensor/eliqonline.py +++ b/homeassistant/components/sensor/eliqonline.py @@ -73,5 +73,5 @@ class EliqSensor(Entity): try: response = self.api.get_data_now(channelid=self.channel_id) self._state = int(response.power) - except TypeError: # raised by eliqonline library on any HTTP error + except TypeError: # raised by eliqonline library on any HTTP error pass