mirror of
https://github.com/home-assistant/core.git
synced 2025-05-05 06:29:16 +00:00
Use current HA logic in fibaro binary sensor (#70816)
This commit is contained in:
parent
84f38578e9
commit
c4e85b78ba
@ -15,7 +15,7 @@ from . import FIBARO_DEVICES, FibaroDevice
|
|||||||
from .const import DOMAIN
|
from .const import DOMAIN
|
||||||
|
|
||||||
SENSOR_TYPES = {
|
SENSOR_TYPES = {
|
||||||
"com.fibaro.floodSensor": ["Flood", "mdi:water", "flood"],
|
"com.fibaro.floodSensor": ["Flood", "mdi:water", BinarySensorDeviceClass.MOISTURE],
|
||||||
"com.fibaro.motionSensor": ["Motion", "mdi:run", BinarySensorDeviceClass.MOTION],
|
"com.fibaro.motionSensor": ["Motion", "mdi:run", BinarySensorDeviceClass.MOTION],
|
||||||
"com.fibaro.doorSensor": ["Door", "mdi:window-open", BinarySensorDeviceClass.DOOR],
|
"com.fibaro.doorSensor": ["Door", "mdi:window-open", BinarySensorDeviceClass.DOOR],
|
||||||
"com.fibaro.windowSensor": [
|
"com.fibaro.windowSensor": [
|
||||||
@ -25,7 +25,7 @@ SENSOR_TYPES = {
|
|||||||
],
|
],
|
||||||
"com.fibaro.smokeSensor": ["Smoke", "mdi:smoking", BinarySensorDeviceClass.SMOKE],
|
"com.fibaro.smokeSensor": ["Smoke", "mdi:smoking", BinarySensorDeviceClass.SMOKE],
|
||||||
"com.fibaro.FGMS001": ["Motion", "mdi:run", BinarySensorDeviceClass.MOTION],
|
"com.fibaro.FGMS001": ["Motion", "mdi:run", BinarySensorDeviceClass.MOTION],
|
||||||
"com.fibaro.heatDetector": ["Heat", "mdi:fire", "heat"],
|
"com.fibaro.heatDetector": ["Heat", "mdi:fire", BinarySensorDeviceClass.HEAT],
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -51,7 +51,6 @@ class FibaroBinarySensor(FibaroDevice, BinarySensorEntity):
|
|||||||
|
|
||||||
def __init__(self, fibaro_device):
|
def __init__(self, fibaro_device):
|
||||||
"""Initialize the binary_sensor."""
|
"""Initialize the binary_sensor."""
|
||||||
self._state = None
|
|
||||||
super().__init__(fibaro_device)
|
super().__init__(fibaro_device)
|
||||||
self.entity_id = ENTITY_ID_FORMAT.format(self.ha_id)
|
self.entity_id = ENTITY_ID_FORMAT.format(self.ha_id)
|
||||||
stype = None
|
stype = None
|
||||||
@ -60,27 +59,9 @@ class FibaroBinarySensor(FibaroDevice, BinarySensorEntity):
|
|||||||
elif fibaro_device.baseType in SENSOR_TYPES:
|
elif fibaro_device.baseType in SENSOR_TYPES:
|
||||||
stype = fibaro_device.baseType
|
stype = fibaro_device.baseType
|
||||||
if stype:
|
if stype:
|
||||||
self._device_class = SENSOR_TYPES[stype][2]
|
self._attr_device_class = SENSOR_TYPES[stype][2]
|
||||||
self._icon = SENSOR_TYPES[stype][1]
|
self._attr_icon = SENSOR_TYPES[stype][1]
|
||||||
else:
|
|
||||||
self._device_class = None
|
|
||||||
self._icon = None
|
|
||||||
|
|
||||||
@property
|
|
||||||
def icon(self):
|
|
||||||
"""Icon to use in the frontend, if any."""
|
|
||||||
return self._icon
|
|
||||||
|
|
||||||
@property
|
|
||||||
def device_class(self):
|
|
||||||
"""Return the device class of the sensor."""
|
|
||||||
return self._device_class
|
|
||||||
|
|
||||||
@property
|
|
||||||
def is_on(self):
|
|
||||||
"""Return true if sensor is on."""
|
|
||||||
return self._state
|
|
||||||
|
|
||||||
def update(self):
|
def update(self):
|
||||||
"""Get the latest data and update the state."""
|
"""Get the latest data and update the state."""
|
||||||
self._state = self.current_binary_state
|
self._attr_is_on = self.current_binary_state
|
||||||
|
Loading…
x
Reference in New Issue
Block a user