deCONZ support Xiaomi vibration sensor (#22366)

* Martin pointed out in previous PR that no ending '.' in logging

* Add support for Xiaomi vibration sensor
This commit is contained in:
Robert Svensson 2019-03-26 07:43:58 +01:00 committed by Jason Hu
parent 73b38572f0
commit 79445a7ccc
5 changed files with 14 additions and 6 deletions

View File

@ -12,7 +12,7 @@ from .config_flow import configured_hosts
from .const import DEFAULT_PORT, DOMAIN, _LOGGER from .const import DEFAULT_PORT, DOMAIN, _LOGGER
from .gateway import DeconzGateway from .gateway import DeconzGateway
REQUIREMENTS = ['pydeconz==53'] REQUIREMENTS = ['pydeconz==54']
CONFIG_SCHEMA = vol.Schema({ CONFIG_SCHEMA = vol.Schema({
DOMAIN: vol.Schema({ DOMAIN: vol.Schema({

View File

@ -11,6 +11,10 @@ from .deconz_device import DeconzDevice
DEPENDENCIES = ['deconz'] DEPENDENCIES = ['deconz']
ATTR_ORIENTATION = 'orientation'
ATTR_TILTANGLE = 'tiltangle'
ATTR_VIBRATIONSTRENGTH = 'vibrationstrength'
async def async_setup_platform( async def async_setup_platform(
hass, config, async_add_entities, discovery_info=None): hass, config, async_add_entities, discovery_info=None):
@ -74,7 +78,7 @@ class DeconzBinarySensor(DeconzDevice, BinarySensorDevice):
@property @property
def device_state_attributes(self): def device_state_attributes(self):
"""Return the state attributes of the sensor.""" """Return the state attributes of the sensor."""
from pydeconz.sensor import PRESENCE from pydeconz.sensor import PRESENCE, VIBRATION
attr = {} attr = {}
if self._device.battery: if self._device.battery:
attr[ATTR_BATTERY_LEVEL] = self._device.battery attr[ATTR_BATTERY_LEVEL] = self._device.battery
@ -82,4 +86,8 @@ class DeconzBinarySensor(DeconzDevice, BinarySensorDevice):
attr[ATTR_ON] = self._device.on attr[ATTR_ON] = self._device.on
if self._device.type in PRESENCE and self._device.dark is not None: if self._device.type in PRESENCE and self._device.dark is not None:
attr[ATTR_DARK] = self._device.dark attr[ATTR_DARK] = self._device.dark
elif self._device.type in VIBRATION:
attr[ATTR_ORIENTATION] = self._device.orientation
attr[ATTR_TILTANGLE] = self._device.tiltangle
attr[ATTR_VIBRATIONSTRENGTH] = self._device.vibrationstrength
return attr return attr

View File

@ -44,7 +44,7 @@ class DeconzGateway:
raise ConfigEntryNotReady raise ConfigEntryNotReady
except Exception: # pylint: disable=broad-except except Exception: # pylint: disable=broad-except
_LOGGER.error('Error connecting with deCONZ gateway.') _LOGGER.error('Error connecting with deCONZ gateway')
return False return False
for component in SUPPORTED_PLATFORMS: for component in SUPPORTED_PLATFORMS:
@ -135,7 +135,7 @@ async def get_gateway(hass, config, async_add_device_callback,
return deconz return deconz
except errors.Unauthorized: except errors.Unauthorized:
_LOGGER.warning("Invalid key for deCONZ at %s.", config[CONF_HOST]) _LOGGER.warning("Invalid key for deCONZ at %s", config[CONF_HOST])
raise AuthenticationRequired raise AuthenticationRequired
except (asyncio.TimeoutError, errors.RequestError): except (asyncio.TimeoutError, errors.RequestError):

View File

@ -1004,7 +1004,7 @@ pydaikin==1.2.0
pydanfossair==0.0.7 pydanfossair==0.0.7
# homeassistant.components.deconz # homeassistant.components.deconz
pydeconz==53 pydeconz==54
# homeassistant.components.zwave # homeassistant.components.zwave
pydispatcher==2.0.5 pydispatcher==2.0.5

View File

@ -203,7 +203,7 @@ pyHS100==0.3.4
pyblackbird==0.5 pyblackbird==0.5
# homeassistant.components.deconz # homeassistant.components.deconz
pydeconz==53 pydeconz==54
# homeassistant.components.zwave # homeassistant.components.zwave
pydispatcher==2.0.5 pydispatcher==2.0.5