Change deCONZ sensor device classes (#36352)
* Change vibration type to vibration instead of motion * Also replace icon and unit of measurement
This commit is contained in:
1 parent
bde94d187c
commit
37f7d262d7
4 files changed
+73
-11
No files matched your search
@@ -1,7 +1,15 @@
|
||||
"""Support for deCONZ binary sensors."""
|
||||
from pydeconz.sensor import Presence, Vibration
|
||||
from pydeconz.sensor import CarbonMonoxide, Fire, OpenClose, Presence, Vibration, Water
|
||||
|
||||
from homeassistant.components.binary_sensor import BinarySensorEntity
|
||||
from homeassistant.components.binary_sensor import (
|
||||
DEVICE_CLASS_GAS,
|
||||
DEVICE_CLASS_MOISTURE,
|
||||
DEVICE_CLASS_MOTION,
|
||||
DEVICE_CLASS_OPENING,
|
||||
DEVICE_CLASS_SMOKE,
|
||||
DEVICE_CLASS_VIBRATION,
|
||||
BinarySensorEntity,
|
||||
)
|
||||
from homeassistant.const import ATTR_TEMPERATURE
|
||||
from homeassistant.core import callback
|
||||
from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
||||
@@ -14,6 +22,15 @@ ATTR_ORIENTATION = "orientation"
|
||||
ATTR_TILTANGLE = "tiltangle"
|
||||
ATTR_VIBRATIONSTRENGTH = "vibrationstrength"
|
||||
|
||||
DEVICE_CLASS = {
|
||||
CarbonMonoxide: DEVICE_CLASS_GAS,
|
||||
Fire: DEVICE_CLASS_SMOKE,
|
||||
OpenClose: DEVICE_CLASS_OPENING,
|
||||
Presence: DEVICE_CLASS_MOTION,
|
||||
Vibration: DEVICE_CLASS_VIBRATION,
|
||||
Water: DEVICE_CLASS_MOISTURE,
|
||||
}
|
||||
|
||||
|
||||
async def async_setup_platform(hass, config, async_add_entities, discovery_info=None):
|
||||
"""Old way of setting up deCONZ platforms."""
|
||||
@@ -74,12 +91,7 @@ class DeconzBinarySensor(DeconzDevice, BinarySensorEntity):
|
||||
@property
|
||||
def device_class(self):
|
||||
"""Return the class of the sensor."""
|
||||
return self._device.SENSOR_CLASS
|
||||
|
||||
@property
|
||||
def icon(self):
|
||||
"""Return the icon to use in the frontend."""
|
||||
return self._device.SENSOR_ICON
|
||||
return DEVICE_CLASS.get(type(self._device))
|
||||
|
||||
@property
|
||||
def device_state_attributes(self):
|
||||
|
||||
Reference in new issue
Block a user