mirror of
https://github.com/home-assistant/core.git
synced 2025-07-24 21:57:51 +00:00
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,9 +3,7 @@ from boschshcpy import SHCBatteryDevice, SHCSession, SHCShutterContact
|
|||||||
from boschshcpy.device import SHCDevice
|
from boschshcpy.device import SHCDevice
|
||||||
|
|
||||||
from homeassistant.components.binary_sensor import (
|
from homeassistant.components.binary_sensor import (
|
||||||
DEVICE_CLASS_BATTERY,
|
BinarySensorDeviceClass,
|
||||||
DEVICE_CLASS_DOOR,
|
|
||||||
DEVICE_CLASS_WINDOW,
|
|
||||||
BinarySensorEntity,
|
BinarySensorEntity,
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -57,13 +55,13 @@ class ShutterContactSensor(SHCEntity, BinarySensorEntity):
|
|||||||
"""Initialize an SHC shutter contact sensor.."""
|
"""Initialize an SHC shutter contact sensor.."""
|
||||||
super().__init__(device, parent_id, entry_id)
|
super().__init__(device, parent_id, entry_id)
|
||||||
switcher = {
|
switcher = {
|
||||||
"ENTRANCE_DOOR": DEVICE_CLASS_DOOR,
|
"ENTRANCE_DOOR": BinarySensorDeviceClass.DOOR,
|
||||||
"REGULAR_WINDOW": DEVICE_CLASS_WINDOW,
|
"REGULAR_WINDOW": BinarySensorDeviceClass.WINDOW,
|
||||||
"FRENCH_WINDOW": DEVICE_CLASS_DOOR,
|
"FRENCH_WINDOW": BinarySensorDeviceClass.DOOR,
|
||||||
"GENERIC": DEVICE_CLASS_WINDOW,
|
"GENERIC": BinarySensorDeviceClass.WINDOW,
|
||||||
}
|
}
|
||||||
self._attr_device_class = switcher.get(
|
self._attr_device_class = switcher.get(
|
||||||
self._device.device_class, DEVICE_CLASS_WINDOW
|
self._device.device_class, BinarySensorDeviceClass.WINDOW
|
||||||
)
|
)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@ -75,7 +73,7 @@ class ShutterContactSensor(SHCEntity, BinarySensorEntity):
|
|||||||
class BatterySensor(SHCEntity, BinarySensorEntity):
|
class BatterySensor(SHCEntity, BinarySensorEntity):
|
||||||
"""Representation of an SHC battery reporting sensor."""
|
"""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:
|
def __init__(self, device: SHCDevice, parent_id: str, entry_id: str) -> None:
|
||||||
"""Initialize an SHC battery reporting sensor."""
|
"""Initialize an SHC battery reporting sensor."""
|
||||||
|
@ -3,11 +3,11 @@ from boschshcpy import SHCSession, SHCShutterControl
|
|||||||
|
|
||||||
from homeassistant.components.cover import (
|
from homeassistant.components.cover import (
|
||||||
ATTR_POSITION,
|
ATTR_POSITION,
|
||||||
DEVICE_CLASS_SHUTTER,
|
|
||||||
SUPPORT_CLOSE,
|
SUPPORT_CLOSE,
|
||||||
SUPPORT_OPEN,
|
SUPPORT_OPEN,
|
||||||
SUPPORT_SET_POSITION,
|
SUPPORT_SET_POSITION,
|
||||||
SUPPORT_STOP,
|
SUPPORT_STOP,
|
||||||
|
CoverDeviceClass,
|
||||||
CoverEntity,
|
CoverEntity,
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -37,7 +37,7 @@ async def async_setup_entry(hass, config_entry, async_add_entities):
|
|||||||
class ShutterControlCover(SHCEntity, CoverEntity):
|
class ShutterControlCover(SHCEntity, CoverEntity):
|
||||||
"""Representation of a SHC shutter control device."""
|
"""Representation of a SHC shutter control device."""
|
||||||
|
|
||||||
_attr_device_class = DEVICE_CLASS_SHUTTER
|
_attr_device_class = CoverDeviceClass.SHUTTER
|
||||||
_attr_supported_features = (
|
_attr_supported_features = (
|
||||||
SUPPORT_OPEN | SUPPORT_CLOSE | SUPPORT_STOP | SUPPORT_SET_POSITION
|
SUPPORT_OPEN | SUPPORT_CLOSE | SUPPORT_STOP | SUPPORT_SET_POSITION
|
||||||
)
|
)
|
||||||
|
@ -2,13 +2,9 @@
|
|||||||
from boschshcpy import SHCSession
|
from boschshcpy import SHCSession
|
||||||
from boschshcpy.device import SHCDevice
|
from boschshcpy.device import SHCDevice
|
||||||
|
|
||||||
from homeassistant.components.sensor import SensorEntity
|
from homeassistant.components.sensor import SensorDeviceClass, SensorEntity
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
CONCENTRATION_PARTS_PER_MILLION,
|
CONCENTRATION_PARTS_PER_MILLION,
|
||||||
DEVICE_CLASS_ENERGY,
|
|
||||||
DEVICE_CLASS_HUMIDITY,
|
|
||||||
DEVICE_CLASS_POWER,
|
|
||||||
DEVICE_CLASS_TEMPERATURE,
|
|
||||||
ENERGY_KILO_WATT_HOUR,
|
ENERGY_KILO_WATT_HOUR,
|
||||||
PERCENTAGE,
|
PERCENTAGE,
|
||||||
POWER_WATT,
|
POWER_WATT,
|
||||||
@ -146,7 +142,7 @@ async def async_setup_entry(hass, config_entry, async_add_entities):
|
|||||||
class TemperatureSensor(SHCEntity, SensorEntity):
|
class TemperatureSensor(SHCEntity, SensorEntity):
|
||||||
"""Representation of an SHC temperature reporting sensor."""
|
"""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
|
_attr_native_unit_of_measurement = TEMP_CELSIUS
|
||||||
|
|
||||||
def __init__(self, device: SHCDevice, parent_id: str, entry_id: str) -> None:
|
def __init__(self, device: SHCDevice, parent_id: str, entry_id: str) -> None:
|
||||||
@ -164,7 +160,7 @@ class TemperatureSensor(SHCEntity, SensorEntity):
|
|||||||
class HumiditySensor(SHCEntity, SensorEntity):
|
class HumiditySensor(SHCEntity, SensorEntity):
|
||||||
"""Representation of an SHC humidity reporting sensor."""
|
"""Representation of an SHC humidity reporting sensor."""
|
||||||
|
|
||||||
_attr_device_class = DEVICE_CLASS_HUMIDITY
|
_attr_device_class = SensorDeviceClass.HUMIDITY
|
||||||
_attr_native_unit_of_measurement = PERCENTAGE
|
_attr_native_unit_of_measurement = PERCENTAGE
|
||||||
|
|
||||||
def __init__(self, device: SHCDevice, parent_id: str, entry_id: str) -> None:
|
def __init__(self, device: SHCDevice, parent_id: str, entry_id: str) -> None:
|
||||||
@ -267,7 +263,7 @@ class PurityRatingSensor(SHCEntity, SensorEntity):
|
|||||||
class PowerSensor(SHCEntity, SensorEntity):
|
class PowerSensor(SHCEntity, SensorEntity):
|
||||||
"""Representation of an SHC power reporting sensor."""
|
"""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
|
_attr_native_unit_of_measurement = POWER_WATT
|
||||||
|
|
||||||
def __init__(self, device: SHCDevice, parent_id: str, entry_id: str) -> None:
|
def __init__(self, device: SHCDevice, parent_id: str, entry_id: str) -> None:
|
||||||
@ -285,7 +281,7 @@ class PowerSensor(SHCEntity, SensorEntity):
|
|||||||
class EnergySensor(SHCEntity, SensorEntity):
|
class EnergySensor(SHCEntity, SensorEntity):
|
||||||
"""Representation of an SHC energy reporting sensor."""
|
"""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
|
_attr_native_unit_of_measurement = ENERGY_KILO_WATT_HOUR
|
||||||
|
|
||||||
def __init__(self, device: SHCDevice, parent_id: str, entry_id: str) -> None:
|
def __init__(self, device: SHCDevice, parent_id: str, entry_id: str) -> None:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user