diff --git a/homeassistant/components/binary_sensor/zwave.py b/homeassistant/components/binary_sensor/zwave.py index cc5fb3ed572..fc18648f907 100644 --- a/homeassistant/components/binary_sensor/zwave.py +++ b/homeassistant/components/binary_sensor/zwave.py @@ -23,9 +23,7 @@ def get_device(values, **kwargs): """Create Z-Wave entity device.""" device_mapping = workaround.get_device_mapping(values.primary) if device_mapping == workaround.WORKAROUND_NO_OFF_EVENT: - # Default the multiplier to 4 - re_arm_multiplier = zwave.get_config_value(values.primary.node, 9) or 4 - return ZWaveTriggerSensor(values, "motion", re_arm_multiplier * 8) + return ZWaveTriggerSensor(values, "motion") if workaround.get_device_component_mapping(values.primary) == DOMAIN: return ZWaveBinarySensor(values, None) @@ -62,15 +60,21 @@ class ZWaveBinarySensor(BinarySensorDevice, zwave.ZWaveDeviceEntity): class ZWaveTriggerSensor(ZWaveBinarySensor): """Representation of a stateless sensor within Z-Wave.""" - def __init__(self, values, device_class, re_arm_sec=60): + def __init__(self, values, device_class): """Initialize the sensor.""" super(ZWaveTriggerSensor, self).__init__(values, device_class) - self.re_arm_sec = re_arm_sec + # Set default off delay to 60 sec + self.re_arm_sec = 60 self.invalidate_after = None 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) + # 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) + 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 diff --git a/homeassistant/components/zwave/discovery_schemas.py b/homeassistant/components/zwave/discovery_schemas.py index f38bc308649..19f428484f8 100644 --- a/homeassistant/components/zwave/discovery_schemas.py +++ b/homeassistant/components/zwave/discovery_schemas.py @@ -28,7 +28,12 @@ DISCOVERY_SCHEMAS = [ const.DISC_PRIMARY: { const.DISC_COMMAND_CLASS: [const.COMMAND_CLASS_SENSOR_BINARY], const.DISC_TYPE: const.TYPE_BOOL, - const.DISC_GENRE: const.GENRE_USER + const.DISC_GENRE: const.GENRE_USER, + }, + 'off_delay': { + const.DISC_COMMAND_CLASS: [const.COMMAND_CLASS_CONFIGURATION], + const.DISC_INDEX: [9], + const.DISC_OPTIONAL: True, }})}, {const.DISC_COMPONENT: 'climate', const.DISC_GENERIC_DEVICE_CLASS: [const.GENERIC_TYPE_THERMOSTAT], diff --git a/tests/components/binary_sensor/test_zwave.py b/tests/components/binary_sensor/test_zwave.py index eb52dc0c825..a5dabf6953a 100644 --- a/tests/components/binary_sensor/test_zwave.py +++ b/tests/components/binary_sensor/test_zwave.py @@ -77,7 +77,8 @@ def test_trigger_sensor_value_changed(hass, mock_openzwave): node = MockNode( manufacturer_id='013c', product_type='0002', product_id='0002') value = MockValue(data=False, node=node) - values = MockEntityValues(primary=value) + value_off_delay = MockValue(data=15, node=node) + values = MockEntityValues(primary=value, off_delay=value_off_delay) device = zwave.get_device(node=node, values=values, node_config={}) assert not device.is_on