Black
This commit is contained in:
1 parent
da05dfe708
commit
4de97abc3a
2676 files changed
+163166
-140084
No files matched your search
@@ -5,33 +5,27 @@ import homeassistant.util.dt as dt_util
|
||||
from homeassistant.core import callback
|
||||
from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
||||
from homeassistant.helpers.event import track_point_in_time
|
||||
from homeassistant.components.binary_sensor import (
|
||||
DOMAIN,
|
||||
BinarySensorDevice)
|
||||
from . import (
|
||||
workaround,
|
||||
ZWaveDeviceEntity
|
||||
)
|
||||
from homeassistant.components.binary_sensor import DOMAIN, BinarySensorDevice
|
||||
from . import workaround, ZWaveDeviceEntity
|
||||
from .const import COMMAND_CLASS_SENSOR_BINARY
|
||||
|
||||
_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 binary sensors."""
|
||||
pass
|
||||
|
||||
|
||||
async def async_setup_entry(hass, config_entry, async_add_entities):
|
||||
"""Set up Z-Wave binary sensors from Config Entry."""
|
||||
|
||||
@callback
|
||||
def async_add_binary_sensor(binary_sensor):
|
||||
"""Add Z-Wave binary sensor."""
|
||||
async_add_entities([binary_sensor])
|
||||
|
||||
async_dispatcher_connect(
|
||||
hass, 'zwave_new_binary_sensor', async_add_binary_sensor)
|
||||
async_dispatcher_connect(hass, "zwave_new_binary_sensor", async_add_binary_sensor)
|
||||
|
||||
|
||||
def get_device(values, **kwargs):
|
||||
@@ -85,24 +79,25 @@ class ZWaveTriggerSensor(ZWaveBinarySensor):
|
||||
def update_properties(self):
|
||||
"""Handle value changes for this entity's node."""
|
||||
self._state = self.values.primary.data
|
||||
_LOGGER.debug('off_delay=%s', self.values.off_delay)
|
||||
_LOGGER.debug("off_delay=%s", self.values.off_delay)
|
||||
# Set re_arm_sec if off_delay is provided from the sensor
|
||||
if self.values.off_delay:
|
||||
_LOGGER.debug('off_delay.data=%s', self.values.off_delay.data)
|
||||
_LOGGER.debug("off_delay.data=%s", self.values.off_delay.data)
|
||||
self.re_arm_sec = self.values.off_delay.data * 8
|
||||
# only allow this value to be true for re_arm secs
|
||||
if not self.hass:
|
||||
return
|
||||
|
||||
self.invalidate_after = dt_util.utcnow() + datetime.timedelta(
|
||||
seconds=self.re_arm_sec)
|
||||
seconds=self.re_arm_sec
|
||||
)
|
||||
track_point_in_time(
|
||||
self.hass, self.async_update_ha_state,
|
||||
self.invalidate_after)
|
||||
self.hass, self.async_update_ha_state, self.invalidate_after
|
||||
)
|
||||
|
||||
@property
|
||||
def is_on(self):
|
||||
"""Return true if movement has happened within the rearm time."""
|
||||
return self._state and \
|
||||
(self.invalidate_after is None or
|
||||
self.invalidate_after > dt_util.utcnow())
|
||||
return self._state and (
|
||||
self.invalidate_after is None or self.invalidate_after > dt_util.utcnow()
|
||||
)
|
||||
Reference in new issue
Block a user