deCONZ - new sensor attribute 'on' and new sensor GenericFlag (#15247)

* New sensor attribute 'on'
* New sensor GenericFlag
This commit is contained in:
Robert Svensson 2018-07-02 23:14:38 +02:00 committed by GitHub
parent 120111ceee
commit bedd2d7e41
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 22 additions and 13 deletions

View file

@ -5,9 +5,9 @@ For more details about this component, please refer to the documentation at
https://home-assistant.io/components/binary_sensor.deconz/
"""
from homeassistant.components.binary_sensor import BinarySensorDevice
from homeassistant.components.deconz import (
CONF_ALLOW_CLIP_SENSOR, DOMAIN as DATA_DECONZ, DATA_DECONZ_ID,
DATA_DECONZ_UNSUB)
from homeassistant.components.deconz.const import (
ATTR_DARK, ATTR_ON, CONF_ALLOW_CLIP_SENSOR, DOMAIN as DATA_DECONZ,
DATA_DECONZ_ID, DATA_DECONZ_UNSUB)
from homeassistant.const import ATTR_BATTERY_LEVEL
from homeassistant.core import callback
from homeassistant.helpers.dispatcher import async_dispatcher_connect
@ -62,7 +62,8 @@ class DeconzBinarySensor(BinarySensorDevice):
"""
if reason['state'] or \
'reachable' in reason['attr'] or \
'battery' in reason['attr']:
'battery' in reason['attr'] or \
'on' in reason['attr']:
self.async_schedule_update_ha_state()
@property
@ -107,6 +108,8 @@ class DeconzBinarySensor(BinarySensorDevice):
attr = {}
if self._sensor.battery:
attr[ATTR_BATTERY_LEVEL] = self._sensor.battery
if self._sensor.on is not None:
attr[ATTR_ON] = self._sensor.on
if self._sensor.type in PRESENCE and self._sensor.dark is not None:
attr['dark'] = self._sensor.dark
attr[ATTR_DARK] = self._sensor.dark
return attr