mirror of
https://github.com/home-assistant/core.git
synced 2025-07-22 04:37:06 +00:00
parent
7c8d235356
commit
16d16585ae
@ -1,10 +1,10 @@
|
||||
"""Support for Plaato Airlock sensors."""
|
||||
from __future__ import annotations
|
||||
|
||||
from pyplaato.plaato import PlaatoKeg
|
||||
|
||||
from homeassistant.components.binary_sensor import (
|
||||
DEVICE_CLASS_OPENING,
|
||||
DEVICE_CLASS_PROBLEM,
|
||||
BinarySensorDeviceClass,
|
||||
BinarySensorEntity,
|
||||
)
|
||||
|
||||
@ -40,11 +40,11 @@ class PlaatoBinarySensor(PlaatoEntity, BinarySensorEntity):
|
||||
return False
|
||||
|
||||
@property
|
||||
def device_class(self):
|
||||
"""Return the class of this device, from component DEVICE_CLASSES."""
|
||||
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 DEVICE_CLASS_PROBLEM
|
||||
return BinarySensorDeviceClass.PROBLEM
|
||||
if self._sensor_type is PlaatoKeg.Pins.POURING:
|
||||
return DEVICE_CLASS_OPENING
|
||||
return BinarySensorDeviceClass.OPENING
|
||||
|
@ -4,7 +4,7 @@ from __future__ import annotations
|
||||
from pyplaato.models.device import PlaatoDevice
|
||||
from pyplaato.plaato import PlaatoKeg
|
||||
|
||||
from homeassistant.components.sensor import DEVICE_CLASS_TEMPERATURE, SensorEntity
|
||||
from homeassistant.components.sensor import SensorDeviceClass, SensorEntity
|
||||
from homeassistant.helpers.dispatcher import (
|
||||
async_dispatcher_connect,
|
||||
async_dispatcher_send,
|
||||
@ -63,15 +63,15 @@ class PlaatoSensor(PlaatoEntity, SensorEntity):
|
||||
"""Representation of a Plaato Sensor."""
|
||||
|
||||
@property
|
||||
def device_class(self) -> str | None:
|
||||
"""Return the class of this device, from component DEVICE_CLASSES."""
|
||||
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 DEVICE_CLASS_TEMPERATURE
|
||||
return SensorDeviceClass.TEMPERATURE
|
||||
if self._sensor_type == ATTR_TEMP:
|
||||
return DEVICE_CLASS_TEMPERATURE
|
||||
return SensorDeviceClass.TEMPERATURE
|
||||
return None
|
||||
|
||||
@property
|
||||
|
Loading…
x
Reference in New Issue
Block a user