Use shorthand device_type attr for plaato sensors (#100385)
parent
d4a2927ebe
commit
89eec9990b
|
@ -39,20 +39,17 @@ async def async_setup_entry(
|
|||
class PlaatoBinarySensor(PlaatoEntity, BinarySensorEntity):
|
||||
"""Representation of a Binary Sensor."""
|
||||
|
||||
def __init__(self, data, sensor_type, coordinator=None) -> None:
|
||||
"""Initialize plaato binary sensor."""
|
||||
super().__init__(data, sensor_type, coordinator)
|
||||
if sensor_type is PlaatoKeg.Pins.LEAK_DETECTION:
|
||||
self._attr_device_class = BinarySensorDeviceClass.PROBLEM
|
||||
elif sensor_type is PlaatoKeg.Pins.POURING:
|
||||
self._attr_device_class = BinarySensorDeviceClass.OPENING
|
||||
|
||||
@property
|
||||
def is_on(self):
|
||||
"""Return true if the binary sensor is on."""
|
||||
if self._coordinator is not None:
|
||||
return self._coordinator.data.binary_sensors.get(self._sensor_type)
|
||||
return False
|
||||
|
||||
@property
|
||||
def device_class(self) -> BinarySensorDeviceClass | None:
|
||||
"""Return the class of this device, from BinarySensorDeviceClass."""
|
||||
if self._coordinator is None:
|
||||
return None
|
||||
if self._sensor_type is PlaatoKeg.Pins.LEAK_DETECTION:
|
||||
return BinarySensorDeviceClass.PROBLEM
|
||||
if self._sensor_type is PlaatoKeg.Pins.POURING:
|
||||
return BinarySensorDeviceClass.OPENING
|
||||
return None
|
||||
|
|
|
@ -72,17 +72,11 @@ async def async_setup_entry(
|
|||
class PlaatoSensor(PlaatoEntity, SensorEntity):
|
||||
"""Representation of a Plaato Sensor."""
|
||||
|
||||
@property
|
||||
def device_class(self) -> SensorDeviceClass | None:
|
||||
"""Return the class of this device, from SensorDeviceClass."""
|
||||
if (
|
||||
self._coordinator is not None
|
||||
and self._sensor_type == PlaatoKeg.Pins.TEMPERATURE
|
||||
):
|
||||
return SensorDeviceClass.TEMPERATURE
|
||||
if self._sensor_type == ATTR_TEMP:
|
||||
return SensorDeviceClass.TEMPERATURE
|
||||
return None
|
||||
def __init__(self, data, sensor_type, coordinator=None) -> None:
|
||||
"""Initialize plaato sensor."""
|
||||
super().__init__(data, sensor_type, coordinator)
|
||||
if sensor_type is PlaatoKeg.Pins.TEMPERATURE or sensor_type == ATTR_TEMP:
|
||||
self._attr_device_class = SensorDeviceClass.TEMPERATURE
|
||||
|
||||
@property
|
||||
def native_value(self):
|
||||
|
|
Loading…
Reference in New Issue