Black
This commit is contained in:
1 parent
da05dfe708
commit
4de97abc3a
2676 files changed
+163166
-140084
No files matched your search
@@ -4,28 +4,25 @@ import time
|
||||
from homeassistant.core import callback
|
||||
from homeassistant.components.switch import DOMAIN, SwitchDevice
|
||||
from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
||||
from . import (
|
||||
ZWaveDeviceEntity,
|
||||
workaround,
|
||||
)
|
||||
from . import ZWaveDeviceEntity, workaround
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
||||
async def async_setup_platform(hass, config, async_add_entities,
|
||||
discovery_info=None):
|
||||
async def async_setup_platform(hass, config, async_add_entities, discovery_info=None):
|
||||
"""Old method of setting up Z-Wave switches."""
|
||||
pass
|
||||
|
||||
|
||||
async def async_setup_entry(hass, config_entry, async_add_entities):
|
||||
"""Set up Z-Wave Switch from Config Entry."""
|
||||
|
||||
@callback
|
||||
def async_add_switch(switch):
|
||||
"""Add Z-Wave Switch."""
|
||||
async_add_entities([switch])
|
||||
|
||||
async_dispatcher_connect(hass, 'zwave_new_switch', async_add_switch)
|
||||
async_dispatcher_connect(hass, "zwave_new_switch", async_add_switch)
|
||||
|
||||
|
||||
def get_device(values, **kwargs):
|
||||
@@ -40,16 +37,16 @@ class ZwaveSwitch(ZWaveDeviceEntity, SwitchDevice):
|
||||
"""Initialize the Z-Wave switch device."""
|
||||
ZWaveDeviceEntity.__init__(self, values, DOMAIN)
|
||||
self.refresh_on_update = (
|
||||
workaround.get_device_mapping(values.primary) ==
|
||||
workaround.WORKAROUND_REFRESH_NODE_ON_UPDATE)
|
||||
workaround.get_device_mapping(values.primary)
|
||||
== workaround.WORKAROUND_REFRESH_NODE_ON_UPDATE
|
||||
)
|
||||
self.last_update = time.perf_counter()
|
||||
self._state = self.values.primary.data
|
||||
|
||||
def update_properties(self):
|
||||
"""Handle data changes for node values."""
|
||||
self._state = self.values.primary.data
|
||||
if self.refresh_on_update and \
|
||||
time.perf_counter() - self.last_update > 30:
|
||||
if self.refresh_on_update and time.perf_counter() - self.last_update > 30:
|
||||
self.last_update = time.perf_counter()
|
||||
self.node.request_state()
|
||||
|
||||
|
||||
Reference in new issue
Block a user