mirror of
https://github.com/home-assistant/core.git
synced 2025-07-22 04:37:06 +00:00
Add update
This commit is contained in:
parent
d719dd72fe
commit
1ec392a494
@ -93,12 +93,6 @@ class ArestSwitch(SwitchDevice):
|
|||||||
@property
|
@property
|
||||||
def is_on(self):
|
def is_on(self):
|
||||||
""" True if device is on. """
|
""" 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
|
return self._state
|
||||||
|
|
||||||
def turn_on(self, **kwargs):
|
def turn_on(self, **kwargs):
|
||||||
@ -114,3 +108,8 @@ class ArestSwitch(SwitchDevice):
|
|||||||
if request.status_code is not 200:
|
if request.status_code is not 200:
|
||||||
_LOGGER.error("Can't turn off the pin. Is device offline?")
|
_LOGGER.error("Can't turn off the pin. Is device offline?")
|
||||||
self._state = False
|
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
|
||||||
|
Loading…
x
Reference in New Issue
Block a user