mirror of
https://github.com/home-assistant/core.git
synced 2025-07-24 21:57:51 +00:00
Use enum sensor device class in Overkiz (#83342)
This commit is contained in:
parent
3f891ef4ee
commit
30db947d99
@ -1,13 +1,11 @@
|
|||||||
"""Parent class for every Overkiz device."""
|
"""Parent class for every Overkiz device."""
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from enum import unique
|
|
||||||
from typing import cast
|
from typing import cast
|
||||||
|
|
||||||
from pyoverkiz.enums import OverkizAttribute, OverkizState
|
from pyoverkiz.enums import OverkizAttribute, OverkizState
|
||||||
from pyoverkiz.models import Device
|
from pyoverkiz.models import Device
|
||||||
|
|
||||||
from homeassistant.backports.enum import StrEnum
|
|
||||||
from homeassistant.helpers.entity import DeviceInfo, EntityDescription
|
from homeassistant.helpers.entity import DeviceInfo, EntityDescription
|
||||||
from homeassistant.helpers.update_coordinator import CoordinatorEntity
|
from homeassistant.helpers.update_coordinator import CoordinatorEntity
|
||||||
|
|
||||||
@ -118,16 +116,3 @@ class OverkizDescriptiveEntity(OverkizEntity):
|
|||||||
if self.is_sub_device:
|
if self.is_sub_device:
|
||||||
# In case of sub device, use the provided label and append the name of the type of entity
|
# In case of sub device, use the provided label and append the name of the type of entity
|
||||||
self._attr_name = f"{self.device.label} {description.name}"
|
self._attr_name = f"{self.device.label} {description.name}"
|
||||||
|
|
||||||
|
|
||||||
# Used by state translations for sensor and select entities
|
|
||||||
@unique
|
|
||||||
class OverkizDeviceClass(StrEnum):
|
|
||||||
"""Device class for Overkiz specific devices."""
|
|
||||||
|
|
||||||
BATTERY = "overkiz__battery"
|
|
||||||
DISCRETE_RSSI_LEVEL = "overkiz__discrete_rssi_level"
|
|
||||||
PRIORITY_LOCK_ORIGINATOR = "overkiz__priority_lock_originator"
|
|
||||||
SENSOR_DEFECT = "overkiz__sensor_defect"
|
|
||||||
SENSOR_ROOM = "overkiz__sensor_room"
|
|
||||||
THREE_WAY_HANDLE_DIRECTION = "overkiz__three_way_handle_direction"
|
|
||||||
|
@ -35,7 +35,7 @@ from homeassistant.helpers.typing import StateType
|
|||||||
from . import HomeAssistantOverkizData
|
from . import HomeAssistantOverkizData
|
||||||
from .const import DOMAIN, IGNORED_OVERKIZ_DEVICES, OVERKIZ_STATE_TO_TRANSLATION
|
from .const import DOMAIN, IGNORED_OVERKIZ_DEVICES, OVERKIZ_STATE_TO_TRANSLATION
|
||||||
from .coordinator import OverkizDataUpdateCoordinator
|
from .coordinator import OverkizDataUpdateCoordinator
|
||||||
from .entity import OverkizDescriptiveEntity, OverkizDeviceClass, OverkizEntity
|
from .entity import OverkizDescriptiveEntity, OverkizEntity
|
||||||
|
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
@ -60,7 +60,9 @@ SENSOR_DESCRIPTIONS: list[OverkizSensorDescription] = [
|
|||||||
name="Battery",
|
name="Battery",
|
||||||
entity_category=EntityCategory.DIAGNOSTIC,
|
entity_category=EntityCategory.DIAGNOSTIC,
|
||||||
icon="mdi:battery",
|
icon="mdi:battery",
|
||||||
device_class=OverkizDeviceClass.BATTERY,
|
device_class=SensorDeviceClass.ENUM,
|
||||||
|
options=["full", "normal", "low", "verylow"],
|
||||||
|
translation_key="battery",
|
||||||
),
|
),
|
||||||
OverkizSensorDescription(
|
OverkizSensorDescription(
|
||||||
key=OverkizState.CORE_RSSI_LEVEL,
|
key=OverkizState.CORE_RSSI_LEVEL,
|
||||||
@ -314,16 +316,18 @@ SENSOR_DESCRIPTIONS: list[OverkizSensorDescription] = [
|
|||||||
OverkizSensorDescription(
|
OverkizSensorDescription(
|
||||||
key=OverkizState.IO_SENSOR_ROOM,
|
key=OverkizState.IO_SENSOR_ROOM,
|
||||||
name="Sensor room",
|
name="Sensor room",
|
||||||
device_class=OverkizDeviceClass.SENSOR_ROOM,
|
device_class=SensorDeviceClass.ENUM,
|
||||||
|
options=["clean", "dirty"],
|
||||||
entity_category=EntityCategory.DIAGNOSTIC,
|
entity_category=EntityCategory.DIAGNOSTIC,
|
||||||
icon="mdi:spray-bottle",
|
icon="mdi:spray-bottle",
|
||||||
|
translation_key="sensor_room",
|
||||||
),
|
),
|
||||||
OverkizSensorDescription(
|
OverkizSensorDescription(
|
||||||
key=OverkizState.IO_PRIORITY_LOCK_ORIGINATOR,
|
key=OverkizState.IO_PRIORITY_LOCK_ORIGINATOR,
|
||||||
name="Priority lock originator",
|
name="Priority lock originator",
|
||||||
device_class=OverkizDeviceClass.PRIORITY_LOCK_ORIGINATOR,
|
|
||||||
icon="mdi:lock",
|
icon="mdi:lock",
|
||||||
entity_registry_enabled_default=False,
|
entity_registry_enabled_default=False,
|
||||||
|
translation_key="priority_lock_originator",
|
||||||
native_value=lambda value: OVERKIZ_STATE_TO_TRANSLATION.get(
|
native_value=lambda value: OVERKIZ_STATE_TO_TRANSLATION.get(
|
||||||
cast(str, value), cast(str, value)
|
cast(str, value), cast(str, value)
|
||||||
),
|
),
|
||||||
@ -340,15 +344,17 @@ SENSOR_DESCRIPTIONS: list[OverkizSensorDescription] = [
|
|||||||
name="Discrete RSSI level",
|
name="Discrete RSSI level",
|
||||||
entity_registry_enabled_default=False,
|
entity_registry_enabled_default=False,
|
||||||
entity_category=EntityCategory.DIAGNOSTIC,
|
entity_category=EntityCategory.DIAGNOSTIC,
|
||||||
device_class=OverkizDeviceClass.DISCRETE_RSSI_LEVEL,
|
|
||||||
icon="mdi:wifi",
|
icon="mdi:wifi",
|
||||||
|
device_class=SensorDeviceClass.ENUM,
|
||||||
|
options=["verylow", "low", "normal", "good"],
|
||||||
|
translation_key="discrete_rssi_level",
|
||||||
),
|
),
|
||||||
OverkizSensorDescription(
|
OverkizSensorDescription(
|
||||||
key=OverkizState.CORE_SENSOR_DEFECT,
|
key=OverkizState.CORE_SENSOR_DEFECT,
|
||||||
name="Sensor defect",
|
name="Sensor defect",
|
||||||
entity_registry_enabled_default=False,
|
entity_registry_enabled_default=False,
|
||||||
entity_category=EntityCategory.DIAGNOSTIC,
|
entity_category=EntityCategory.DIAGNOSTIC,
|
||||||
device_class=OverkizDeviceClass.SENSOR_DEFECT,
|
translation_key="sensor_defect",
|
||||||
native_value=lambda value: OVERKIZ_STATE_TO_TRANSLATION.get(
|
native_value=lambda value: OVERKIZ_STATE_TO_TRANSLATION.get(
|
||||||
cast(str, value), cast(str, value)
|
cast(str, value), cast(str, value)
|
||||||
),
|
),
|
||||||
@ -379,7 +385,9 @@ SENSOR_DESCRIPTIONS: list[OverkizSensorDescription] = [
|
|||||||
OverkizSensorDescription(
|
OverkizSensorDescription(
|
||||||
key=OverkizState.CORE_THREE_WAY_HANDLE_DIRECTION,
|
key=OverkizState.CORE_THREE_WAY_HANDLE_DIRECTION,
|
||||||
name="Three way handle direction",
|
name="Three way handle direction",
|
||||||
device_class=OverkizDeviceClass.THREE_WAY_HANDLE_DIRECTION,
|
device_class=SensorDeviceClass.ENUM,
|
||||||
|
options=["open", "tilt", "close"],
|
||||||
|
translation_key="three_way_handle_direction",
|
||||||
),
|
),
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -42,6 +42,62 @@
|
|||||||
"standard": "Standard"
|
"standard": "Standard"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"sensor": {
|
||||||
|
"battery": {
|
||||||
|
"state": {
|
||||||
|
"full": "Full",
|
||||||
|
"low": "Low",
|
||||||
|
"normal": "Normal",
|
||||||
|
"verylow": "Very low"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"discrete_rssi_level": {
|
||||||
|
"state": {
|
||||||
|
"good": "Good",
|
||||||
|
"low": "Low",
|
||||||
|
"normal": "Normal",
|
||||||
|
"verylow": "Very low"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"priority_lock_originator": {
|
||||||
|
"state": {
|
||||||
|
"lsc": "LSC",
|
||||||
|
"saac": "SAAC",
|
||||||
|
"sfc": "SFC",
|
||||||
|
"ups": "UPS",
|
||||||
|
"external_gateway": "External gateway",
|
||||||
|
"local_user": "Local user",
|
||||||
|
"myself": "Myself",
|
||||||
|
"rain": "Rain",
|
||||||
|
"security": "Security",
|
||||||
|
"temperature": "Temperature",
|
||||||
|
"timer": "Timer",
|
||||||
|
"user": "User",
|
||||||
|
"wind": "Wind"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"sensor_room": {
|
||||||
|
"state": {
|
||||||
|
"clean": "Clean",
|
||||||
|
"dirty": "Dirty"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"sensor_defect": {
|
||||||
|
"state": {
|
||||||
|
"dead": "Dead",
|
||||||
|
"low_battery": "Low battery",
|
||||||
|
"maintenance_required": "Maintenance required",
|
||||||
|
"no_defect": "No defect"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"three_way_handle_direction": {
|
||||||
|
"state": {
|
||||||
|
"closed": "Closed",
|
||||||
|
"open": "Open",
|
||||||
|
"tilt": "Tilt"
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,46 +0,0 @@
|
|||||||
{
|
|
||||||
"state": {
|
|
||||||
"overkiz__battery": {
|
|
||||||
"full": "Full",
|
|
||||||
"low": "Low",
|
|
||||||
"normal": "Normal",
|
|
||||||
"verylow": "Very low"
|
|
||||||
},
|
|
||||||
"overkiz__discrete_rssi_level": {
|
|
||||||
"good": "Good",
|
|
||||||
"low": "Low",
|
|
||||||
"normal": "Normal",
|
|
||||||
"verylow": "Very low"
|
|
||||||
},
|
|
||||||
"overkiz__priority_lock_originator": {
|
|
||||||
"lsc": "LSC",
|
|
||||||
"saac": "SAAC",
|
|
||||||
"sfc": "SFC",
|
|
||||||
"ups": "UPS",
|
|
||||||
"external_gateway": "External gateway",
|
|
||||||
"local_user": "Local user",
|
|
||||||
"myself": "Myself",
|
|
||||||
"rain": "Rain",
|
|
||||||
"security": "Security",
|
|
||||||
"temperature": "Temperature",
|
|
||||||
"timer": "Timer",
|
|
||||||
"user": "User",
|
|
||||||
"wind": "Wind"
|
|
||||||
},
|
|
||||||
"overkiz__sensor_room": {
|
|
||||||
"clean": "Clean",
|
|
||||||
"dirty": "Dirty"
|
|
||||||
},
|
|
||||||
"overkiz__sensor_defect": {
|
|
||||||
"dead": "Dead",
|
|
||||||
"low_battery": "Low battery",
|
|
||||||
"maintenance_required": "Maintenance required",
|
|
||||||
"no_defect": "No defect"
|
|
||||||
},
|
|
||||||
"overkiz__three_way_handle_direction": {
|
|
||||||
"closed": "Closed",
|
|
||||||
"open": "Open",
|
|
||||||
"tilt": "Tilt"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -42,6 +42,62 @@
|
|||||||
"pedestrian": "Pedestrian"
|
"pedestrian": "Pedestrian"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"sensor": {
|
||||||
|
"battery": {
|
||||||
|
"state": {
|
||||||
|
"full": "Full",
|
||||||
|
"low": "Low",
|
||||||
|
"normal": "Normal",
|
||||||
|
"verylow": "Very low"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"discrete_rssi_level": {
|
||||||
|
"state": {
|
||||||
|
"good": "Good",
|
||||||
|
"low": "Low",
|
||||||
|
"normal": "Normal",
|
||||||
|
"verylow": "Very low"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"priority_lock_originator": {
|
||||||
|
"state": {
|
||||||
|
"external_gateway": "External gateway",
|
||||||
|
"local_user": "Local user",
|
||||||
|
"lsc": "LSC",
|
||||||
|
"myself": "Myself",
|
||||||
|
"rain": "Rain",
|
||||||
|
"saac": "SAAC",
|
||||||
|
"security": "Security",
|
||||||
|
"sfc": "SFC",
|
||||||
|
"temperature": "Temperature",
|
||||||
|
"timer": "Timer",
|
||||||
|
"ups": "UPS",
|
||||||
|
"user": "User",
|
||||||
|
"wind": "Wind"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"sensor_defect": {
|
||||||
|
"state": {
|
||||||
|
"dead": "Dead",
|
||||||
|
"low_battery": "Low battery",
|
||||||
|
"maintenance_required": "Maintenance required",
|
||||||
|
"no_defect": "No defect"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"sensor_room": {
|
||||||
|
"state": {
|
||||||
|
"clean": "Clean",
|
||||||
|
"dirty": "Dirty"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"three_way_handle_direction": {
|
||||||
|
"state": {
|
||||||
|
"closed": "Closed",
|
||||||
|
"open": "Open",
|
||||||
|
"tilt": "Tilt"
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user