From 1ec392a49420175187e274e982f474a44d3b20f5 Mon Sep 17 00:00:00 2001 From: Fabian Affolter Date: Thu, 10 Sep 2015 19:11:20 +0200 Subject: [PATCH] Add update --- homeassistant/components/switch/arest.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/homeassistant/components/switch/arest.py b/homeassistant/components/switch/arest.py index e171e954a12..4f235c3bcd5 100644 --- a/homeassistant/components/switch/arest.py +++ b/homeassistant/components/switch/arest.py @@ -93,12 +93,6 @@ class ArestSwitch(SwitchDevice): @property def is_on(self): """ True if device is on. """ - request = get('{}/digital/{}'.format(self._resource, self._pin)) - if request.json()['return_value'] == 0: - self._state = False - else: - self._state = True - return self._state def turn_on(self, **kwargs): @@ -114,3 +108,8 @@ class ArestSwitch(SwitchDevice): if request.status_code is not 200: _LOGGER.error("Can't turn off the pin. Is device offline?") self._state = False + + def update(self): + """ Gets the latest data from aREST API and updates the state. """ + request = get('{}/digital/{}'.format(self._resource, self._pin)) + self._state = request.json()['return_value'] != 0