Use new DeviceClass enums in bosch_shc (#61324)
Co-authored-by: epenet <epenet@users.noreply.github.com>
This commit is contained in:
parent
f7f50563dd
commit
76bdf9bc25
3 changed files with 14 additions and 20 deletions
|
@ -3,9 +3,7 @@ from boschshcpy import SHCBatteryDevice, SHCSession, SHCShutterContact
|
|||
from boschshcpy.device import SHCDevice
|
||||
|
||||
from homeassistant.components.binary_sensor import (
|
||||
DEVICE_CLASS_BATTERY,
|
||||
DEVICE_CLASS_DOOR,
|
||||
DEVICE_CLASS_WINDOW,
|
||||
BinarySensorDeviceClass,
|
||||
BinarySensorEntity,
|
||||
)
|
||||
|
||||
|
@ -57,13 +55,13 @@ class ShutterContactSensor(SHCEntity, BinarySensorEntity):
|
|||
"""Initialize an SHC shutter contact sensor.."""
|
||||
super().__init__(device, parent_id, entry_id)
|
||||
switcher = {
|
||||
"ENTRANCE_DOOR": DEVICE_CLASS_DOOR,
|
||||
"REGULAR_WINDOW": DEVICE_CLASS_WINDOW,
|
||||
"FRENCH_WINDOW": DEVICE_CLASS_DOOR,
|
||||
"GENERIC": DEVICE_CLASS_WINDOW,
|
||||
"ENTRANCE_DOOR": BinarySensorDeviceClass.DOOR,
|
||||
"REGULAR_WINDOW": BinarySensorDeviceClass.WINDOW,
|
||||
"FRENCH_WINDOW": BinarySensorDeviceClass.DOOR,
|
||||
"GENERIC": BinarySensorDeviceClass.WINDOW,
|
||||
}
|
||||
self._attr_device_class = switcher.get(
|
||||
self._device.device_class, DEVICE_CLASS_WINDOW
|
||||
self._device.device_class, BinarySensorDeviceClass.WINDOW
|
||||
)
|
||||
|
||||
@property
|
||||
|
@ -75,7 +73,7 @@ class ShutterContactSensor(SHCEntity, BinarySensorEntity):
|
|||
class BatterySensor(SHCEntity, BinarySensorEntity):
|
||||
"""Representation of an SHC battery reporting sensor."""
|
||||
|
||||
_attr_device_class = DEVICE_CLASS_BATTERY
|
||||
_attr_device_class = BinarySensorDeviceClass.BATTERY
|
||||
|
||||
def __init__(self, device: SHCDevice, parent_id: str, entry_id: str) -> None:
|
||||
"""Initialize an SHC battery reporting sensor."""
|
||||
|
|
|
@ -3,11 +3,11 @@ from boschshcpy import SHCSession, SHCShutterControl
|
|||
|
||||
from homeassistant.components.cover import (
|
||||
ATTR_POSITION,
|
||||
DEVICE_CLASS_SHUTTER,
|
||||
SUPPORT_CLOSE,
|
||||
SUPPORT_OPEN,
|
||||
SUPPORT_SET_POSITION,
|
||||
SUPPORT_STOP,
|
||||
CoverDeviceClass,
|
||||
CoverEntity,
|
||||
)
|
||||
|
||||
|
@ -37,7 +37,7 @@ async def async_setup_entry(hass, config_entry, async_add_entities):
|
|||
class ShutterControlCover(SHCEntity, CoverEntity):
|
||||
"""Representation of a SHC shutter control device."""
|
||||
|
||||
_attr_device_class = DEVICE_CLASS_SHUTTER
|
||||
_attr_device_class = CoverDeviceClass.SHUTTER
|
||||
_attr_supported_features = (
|
||||
SUPPORT_OPEN | SUPPORT_CLOSE | SUPPORT_STOP | SUPPORT_SET_POSITION
|
||||
)
|
||||
|
|
|
@ -2,13 +2,9 @@
|
|||
from boschshcpy import SHCSession
|
||||
from boschshcpy.device import SHCDevice
|
||||
|
||||
from homeassistant.components.sensor import SensorEntity
|
||||
from homeassistant.components.sensor import SensorDeviceClass, SensorEntity
|
||||
from homeassistant.const import (
|
||||
CONCENTRATION_PARTS_PER_MILLION,
|
||||
DEVICE_CLASS_ENERGY,
|
||||
DEVICE_CLASS_HUMIDITY,
|
||||
DEVICE_CLASS_POWER,
|
||||
DEVICE_CLASS_TEMPERATURE,
|
||||
ENERGY_KILO_WATT_HOUR,
|
||||
PERCENTAGE,
|
||||
POWER_WATT,
|
||||
|
@ -146,7 +142,7 @@ async def async_setup_entry(hass, config_entry, async_add_entities):
|
|||
class TemperatureSensor(SHCEntity, SensorEntity):
|
||||
"""Representation of an SHC temperature reporting sensor."""
|
||||
|
||||
_attr_device_class = DEVICE_CLASS_TEMPERATURE
|
||||
_attr_device_class = SensorDeviceClass.TEMPERATURE
|
||||
_attr_native_unit_of_measurement = TEMP_CELSIUS
|
||||
|
||||
def __init__(self, device: SHCDevice, parent_id: str, entry_id: str) -> None:
|
||||
|
@ -164,7 +160,7 @@ class TemperatureSensor(SHCEntity, SensorEntity):
|
|||
class HumiditySensor(SHCEntity, SensorEntity):
|
||||
"""Representation of an SHC humidity reporting sensor."""
|
||||
|
||||
_attr_device_class = DEVICE_CLASS_HUMIDITY
|
||||
_attr_device_class = SensorDeviceClass.HUMIDITY
|
||||
_attr_native_unit_of_measurement = PERCENTAGE
|
||||
|
||||
def __init__(self, device: SHCDevice, parent_id: str, entry_id: str) -> None:
|
||||
|
@ -267,7 +263,7 @@ class PurityRatingSensor(SHCEntity, SensorEntity):
|
|||
class PowerSensor(SHCEntity, SensorEntity):
|
||||
"""Representation of an SHC power reporting sensor."""
|
||||
|
||||
_attr_device_class = DEVICE_CLASS_POWER
|
||||
_attr_device_class = SensorDeviceClass.POWER
|
||||
_attr_native_unit_of_measurement = POWER_WATT
|
||||
|
||||
def __init__(self, device: SHCDevice, parent_id: str, entry_id: str) -> None:
|
||||
|
@ -285,7 +281,7 @@ class PowerSensor(SHCEntity, SensorEntity):
|
|||
class EnergySensor(SHCEntity, SensorEntity):
|
||||
"""Representation of an SHC energy reporting sensor."""
|
||||
|
||||
_attr_device_class = DEVICE_CLASS_ENERGY
|
||||
_attr_device_class = SensorDeviceClass.ENERGY
|
||||
_attr_native_unit_of_measurement = ENERGY_KILO_WATT_HOUR
|
||||
|
||||
def __init__(self, device: SHCDevice, parent_id: str, entry_id: str) -> None:
|
||||
|
|
Loading…
Add table
Reference in a new issue