mirror of
https://github.com/home-assistant/core.git
synced 2025-07-21 12:17:07 +00:00
don't poll (turns out a request for state immediately a state turn on/off request will not return the newly updated state. import constants from tellive, not tellcore
This commit is contained in:
parent
c8fa6cc127
commit
27e35d5f34
@ -38,7 +38,7 @@ class TelldusLiveSwitch(ToggleEntity):
|
|||||||
@property
|
@property
|
||||||
def should_poll(self):
|
def should_poll(self):
|
||||||
""" Tells Home Assistant to poll this entity. """
|
""" Tells Home Assistant to poll this entity. """
|
||||||
return True
|
return False
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def name(self):
|
def name(self):
|
||||||
@ -46,25 +46,28 @@ class TelldusLiveSwitch(ToggleEntity):
|
|||||||
return self._name
|
return self._name
|
||||||
|
|
||||||
def update(self):
|
def update(self):
|
||||||
from tellcore.constants import (
|
from tellive.live import const
|
||||||
TELLSTICK_TURNON, TELLSTICK_TURNOFF)
|
|
||||||
states = {TELLSTICK_TURNON: STATE_ON,
|
|
||||||
TELLSTICK_TURNOFF: STATE_OFF}
|
|
||||||
state = tellduslive.NETWORK.get_switch_state(self._id)
|
state = tellduslive.NETWORK.get_switch_state(self._id)
|
||||||
self._state = states[state]
|
if state == const.TELLSTICK_TURNON:
|
||||||
|
self._state = STATE_ON
|
||||||
|
elif state == const.TELLSTICK_TURNOFF:
|
||||||
|
self._state = STATE_OFF
|
||||||
|
else:
|
||||||
|
self._state = STATE_UNKNOWN
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def is_on(self):
|
def is_on(self):
|
||||||
""" True if switch is on. """
|
""" True if switch is on. """
|
||||||
self.update()
|
|
||||||
return self._state == STATE_ON
|
return self._state == STATE_ON
|
||||||
|
|
||||||
def turn_on(self, **kwargs):
|
def turn_on(self, **kwargs):
|
||||||
""" Turns the switch on. """
|
""" Turns the switch on. """
|
||||||
if tellduslive.NETWORK.turn_switch_on(self._id):
|
if tellduslive.NETWORK.turn_switch_on(self._id):
|
||||||
self._state = STATE_ON
|
self._state = STATE_ON
|
||||||
|
self.update_ha_state()
|
||||||
|
|
||||||
def turn_off(self, **kwargs):
|
def turn_off(self, **kwargs):
|
||||||
""" Turns the switch off. """
|
""" Turns the switch off. """
|
||||||
if tellduslive.NETWORK.turn_switch_off(self._id):
|
if tellduslive.NETWORK.turn_switch_off(self._id):
|
||||||
self._state = STATE_OFF
|
self._state = STATE_OFF
|
||||||
|
self.update_ha_state()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user