[*.zwave] Refactor of zwave value_changed (#5512)
* Refactor of zwave value_changed * Rename update_properties to update * Revert "Rename update_properties to update" This reverts commit 723578e7d4e2156507c70f649a124a6193edc0db.
This commit is contained in:
1 parent
d0538fe3aa
commit
923431110a
8 files changed
+58
-136
No files matched your search
@@ -37,26 +37,12 @@ class ZwaveSwitch(zwave.ZWaveDeviceEntity, SwitchDevice):
|
||||
|
||||
def __init__(self, value):
|
||||
"""Initialize the Z-Wave switch device."""
|
||||
from openzwave.network import ZWaveNetwork
|
||||
from pydispatch import dispatcher
|
||||
|
||||
zwave.ZWaveDeviceEntity.__init__(self, value, DOMAIN)
|
||||
|
||||
self._state = value.data
|
||||
dispatcher.connect(
|
||||
self._value_changed, ZWaveNetwork.SIGNAL_VALUE_CHANGED)
|
||||
|
||||
def _value_changed(self, value):
|
||||
"""Called when a value has changed on the network."""
|
||||
if self._value.value_id == value.value_id:
|
||||
_LOGGER.debug('Value changed for label %s', self._value.label)
|
||||
self._state = value.data
|
||||
self.schedule_update_ha_state()
|
||||
|
||||
@property
|
||||
def is_on(self):
|
||||
"""Return true if device is on."""
|
||||
return self._state
|
||||
return self._value.data
|
||||
|
||||
def turn_on(self, **kwargs):
|
||||
"""Turn the device on."""
|
||||
|
||||
Reference in new issue
Block a user