Migrate Overkiz to new entity naming style (#76687)

This commit is contained in:
Mick Vleeshouwer 2022-09-26 03:59:18 +02:00 committed by GitHub
parent 81abeac83e
commit c6fd2bde46
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 58 additions and 60 deletions

View File

@ -27,20 +27,20 @@ BUTTON_DESCRIPTIONS: list[OverkizButtonDescription] = [
# My Position (cover, light)
OverkizButtonDescription(
key="my",
name="My Position",
name="My position",
icon="mdi:star",
),
# Identify
OverkizButtonDescription(
key="identify", # startIdentify and identify are reversed... Swap this when fixed in API.
name="Start Identify",
name="Start identify",
icon="mdi:human-greeting-variant",
entity_category=EntityCategory.DIAGNOSTIC,
entity_registry_enabled_default=False,
),
OverkizButtonDescription(
key="stopIdentify",
name="Stop Identify",
name="Stop identify",
icon="mdi:human-greeting-variant",
entity_category=EntityCategory.DIAGNOSTIC,
entity_registry_enabled_default=False,
@ -52,10 +52,10 @@ BUTTON_DESCRIPTIONS: list[OverkizButtonDescription] = [
entity_category=EntityCategory.DIAGNOSTIC,
),
# RTDIndoorSiren / RTDOutdoorSiren
OverkizButtonDescription(key="dingDong", name="Ding Dong", icon="mdi:bell-ring"),
OverkizButtonDescription(key="dingDong", name="Ding dong", icon="mdi:bell-ring"),
OverkizButtonDescription(key="bip", name="Bip", icon="mdi:bell-ring"),
OverkizButtonDescription(
key="fastBipSequence", name="Fast Bip Sequence", icon="mdi:bell-ring"
key="fastBipSequence", name="Fast bip sequence", icon="mdi:bell-ring"
),
OverkizButtonDescription(key="ring", name="Ring", icon="mdi:bell-ring"),
# DynamicScreen (ogp:blind) uses goToAlias (id 1: favorite1) instead of 'my'

View File

@ -19,6 +19,8 @@ from .executor import OverkizExecutor
class OverkizEntity(CoordinatorEntity[OverkizDataUpdateCoordinator]):
"""Representation of an Overkiz device entity."""
_attr_has_entity_name = True
def __init__(
self, device_url: str, coordinator: OverkizDataUpdateCoordinator
) -> None:
@ -31,7 +33,6 @@ class OverkizEntity(CoordinatorEntity[OverkizDataUpdateCoordinator]):
self._attr_assumed_state = not self.device.states
self._attr_available = self.device.available
self._attr_unique_id = self.device.device_url
self._attr_name = self.device.label
self._attr_device_info = self.generate_device_info()
@ -102,9 +103,6 @@ class OverkizDescriptiveEntity(OverkizEntity):
self.entity_description = description
self._attr_unique_id = f"{super().unique_id}-{self.entity_description.key}"
if self.entity_description.name:
self._attr_name = f"{super().name} {self.entity_description.name}"
# Used by state translations for sensor and select entities
@unique

View File

@ -80,7 +80,7 @@ NUMBER_DESCRIPTIONS: list[OverkizNumberDescription] = [
# Cover: My Position (0 - 100)
OverkizNumberDescription(
key=OverkizState.CORE_MEMORIZED_1_POSITION,
name="My Position",
name="My position",
icon="mdi:content-save-cog",
command=OverkizCommand.SET_MEMORIZED_1_POSITION,
native_min_value=0,
@ -90,7 +90,7 @@ NUMBER_DESCRIPTIONS: list[OverkizNumberDescription] = [
# WaterHeater: Expected Number Of Shower (2 - 4)
OverkizNumberDescription(
key=OverkizState.CORE_EXPECTED_NUMBER_OF_SHOWER,
name="Expected Number Of Shower",
name="Expected number of shower",
icon="mdi:shower-head",
command=OverkizCommand.SET_EXPECTED_NUMBER_OF_SHOWER,
native_min_value=2,
@ -100,7 +100,7 @@ NUMBER_DESCRIPTIONS: list[OverkizNumberDescription] = [
# SomfyHeatingTemperatureInterface
OverkizNumberDescription(
key=OverkizState.CORE_ECO_ROOM_TEMPERATURE,
name="Eco Room Temperature",
name="Eco room temperature",
icon="mdi:thermometer",
command=OverkizCommand.SET_ECO_TEMPERATURE,
device_class=NumberDeviceClass.TEMPERATURE,
@ -111,7 +111,7 @@ NUMBER_DESCRIPTIONS: list[OverkizNumberDescription] = [
),
OverkizNumberDescription(
key=OverkizState.CORE_COMFORT_ROOM_TEMPERATURE,
name="Comfort Room Temperature",
name="Comfort room temperature",
icon="mdi:home-thermometer-outline",
command=OverkizCommand.SET_COMFORT_TEMPERATURE,
device_class=NumberDeviceClass.TEMPERATURE,
@ -122,7 +122,7 @@ NUMBER_DESCRIPTIONS: list[OverkizNumberDescription] = [
),
OverkizNumberDescription(
key=OverkizState.CORE_SECURED_POSITION_TEMPERATURE,
name="Freeze Protection Temperature",
name="Freeze protection temperature",
icon="mdi:sun-thermometer-outline",
command=OverkizCommand.SET_SECURED_POSITION_TEMPERATURE,
device_class=NumberDeviceClass.TEMPERATURE,

View File

@ -76,7 +76,7 @@ SELECT_DESCRIPTIONS: list[OverkizSelectDescription] = [
),
OverkizSelectDescription(
key=OverkizState.IO_MEMORIZED_SIMPLE_VOLUME,
name="Memorized Simple Volume",
name="Memorized simple volume",
icon="mdi:volume-high",
options=[OverkizCommandParam.STANDARD, OverkizCommandParam.HIGHEST],
select_option=_select_option_memorized_simple_volume,
@ -86,7 +86,7 @@ SELECT_DESCRIPTIONS: list[OverkizSelectDescription] = [
# SomfyHeatingTemperatureInterface
OverkizSelectDescription(
key=OverkizState.OVP_HEATING_TEMPERATURE_INTERFACE_OPERATING_MODE,
name="Operating Mode",
name="Operating mode",
icon="mdi:sun-snowflake",
options=[OverkizCommandParam.HEATING, OverkizCommandParam.COOLING],
select_option=lambda option, execute_command: execute_command(
@ -97,7 +97,7 @@ SELECT_DESCRIPTIONS: list[OverkizSelectDescription] = [
# StatefulAlarmController
OverkizSelectDescription(
key=OverkizState.CORE_ACTIVE_ZONES,
name="Active Zones",
name="Active zones",
icon="mdi:shield-lock",
options=["", "A", "B", "C", "A,B", "B,C", "A,C", "A,B,C"],
select_option=_select_option_active_zone,

View File

@ -48,7 +48,7 @@ class OverkizSensorDescription(SensorEntityDescription):
SENSOR_DESCRIPTIONS: list[OverkizSensorDescription] = [
OverkizSensorDescription(
key=OverkizState.CORE_BATTERY_LEVEL,
name="Battery Level",
name="Battery level",
native_unit_of_measurement=PERCENTAGE,
device_class=SensorDeviceClass.BATTERY,
state_class=SensorStateClass.MEASUREMENT,
@ -64,7 +64,7 @@ SENSOR_DESCRIPTIONS: list[OverkizSensorDescription] = [
),
OverkizSensorDescription(
key=OverkizState.CORE_RSSI_LEVEL,
name="RSSI Level",
name="RSSI level",
native_unit_of_measurement=SIGNAL_STRENGTH_DECIBELS,
device_class=SensorDeviceClass.SIGNAL_STRENGTH,
state_class=SensorStateClass.MEASUREMENT,
@ -74,20 +74,20 @@ SENSOR_DESCRIPTIONS: list[OverkizSensorDescription] = [
),
OverkizSensorDescription(
key=OverkizState.CORE_EXPECTED_NUMBER_OF_SHOWER,
name="Expected Number Of Shower",
name="Expected number of shower",
icon="mdi:shower-head",
state_class=SensorStateClass.MEASUREMENT,
),
OverkizSensorDescription(
key=OverkizState.CORE_NUMBER_OF_SHOWER_REMAINING,
name="Number of Shower Remaining",
name="Number of shower remaining",
icon="mdi:shower-head",
state_class=SensorStateClass.MEASUREMENT,
),
# V40 is measured in litres (L) and shows the amount of warm (mixed) water with a temperature of 40 C, which can be drained from a switched off electric water heater.
OverkizSensorDescription(
key=OverkizState.CORE_V40_WATER_VOLUME_ESTIMATION,
name="Water Volume Estimation at 40 °C",
name="Water volume estimation at 40 °C",
icon="mdi:water",
native_unit_of_measurement=VOLUME_LITERS,
entity_registry_enabled_default=False,
@ -95,50 +95,50 @@ SENSOR_DESCRIPTIONS: list[OverkizSensorDescription] = [
),
OverkizSensorDescription(
key=OverkizState.CORE_WATER_CONSUMPTION,
name="Water Consumption",
name="Water consumption",
icon="mdi:water",
native_unit_of_measurement=VOLUME_LITERS,
state_class=SensorStateClass.MEASUREMENT,
),
OverkizSensorDescription(
key=OverkizState.IO_OUTLET_ENGINE,
name="Outlet Engine",
name="Outlet engine",
icon="mdi:fan-chevron-down",
native_unit_of_measurement=VOLUME_LITERS,
state_class=SensorStateClass.MEASUREMENT,
),
OverkizSensorDescription(
key=OverkizState.IO_INLET_ENGINE,
name="Inlet Engine",
name="Inlet engine",
icon="mdi:fan-chevron-up",
native_unit_of_measurement=VOLUME_FLOW_RATE_CUBIC_METERS_PER_HOUR,
state_class=SensorStateClass.MEASUREMENT,
),
OverkizSensorDescription(
key=OverkizState.HLRRWIFI_ROOM_TEMPERATURE,
name="Room Temperature",
name="Room temperature",
device_class=SensorDeviceClass.TEMPERATURE,
state_class=SensorStateClass.MEASUREMENT,
native_unit_of_measurement=TEMP_CELSIUS,
),
OverkizSensorDescription(
key=OverkizState.IO_MIDDLE_WATER_TEMPERATURE,
name="Middle Water Temperature",
name="Middle water temperature",
device_class=SensorDeviceClass.TEMPERATURE,
state_class=SensorStateClass.MEASUREMENT,
native_unit_of_measurement=TEMP_CELSIUS,
),
OverkizSensorDescription(
key=OverkizState.CORE_FOSSIL_ENERGY_CONSUMPTION,
name="Fossil Energy Consumption",
name="Fossil energy consumption",
),
OverkizSensorDescription(
key=OverkizState.CORE_GAS_CONSUMPTION,
name="Gas Consumption",
name="Gas consumption",
),
OverkizSensorDescription(
key=OverkizState.CORE_THERMAL_ENERGY_CONSUMPTION,
name="Thermal Energy Consumption",
name="Thermal energy consumption",
),
# LightSensor/LuminanceSensor
OverkizSensorDescription(
@ -151,21 +151,21 @@ SENSOR_DESCRIPTIONS: list[OverkizSensorDescription] = [
# ElectricitySensor/CumulativeElectricPowerConsumptionSensor
OverkizSensorDescription(
key=OverkizState.CORE_ELECTRIC_ENERGY_CONSUMPTION,
name="Electric Energy Consumption",
name="Electric energy consumption",
device_class=SensorDeviceClass.ENERGY,
native_unit_of_measurement=ENERGY_WATT_HOUR, # core:MeasuredValueType = core:ElectricalEnergyInWh (not for modbus:YutakiV2DHWElectricalEnergyConsumptionComponent)
state_class=SensorStateClass.TOTAL_INCREASING, # core:MeasurementCategory attribute = electric/overall
),
OverkizSensorDescription(
key=OverkizState.CORE_ELECTRIC_POWER_CONSUMPTION,
name="Electric Power Consumption",
name="Electric power consumption",
device_class=SensorDeviceClass.POWER,
native_unit_of_measurement=POWER_WATT, # core:MeasuredValueType = core:ElectricalEnergyInWh (not for modbus:YutakiV2DHWElectricalEnergyConsumptionComponent)
state_class=SensorStateClass.MEASUREMENT,
),
OverkizSensorDescription(
key=OverkizState.CORE_CONSUMPTION_TARIFF1,
name="Consumption Tariff 1",
name="Consumption tariff 1",
device_class=SensorDeviceClass.ENERGY,
native_unit_of_measurement=ENERGY_WATT_HOUR, # core:MeasuredValueType = core:ElectricalEnergyInWh
entity_registry_enabled_default=False,
@ -173,7 +173,7 @@ SENSOR_DESCRIPTIONS: list[OverkizSensorDescription] = [
),
OverkizSensorDescription(
key=OverkizState.CORE_CONSUMPTION_TARIFF2,
name="Consumption Tariff 2",
name="Consumption tariff 2",
device_class=SensorDeviceClass.ENERGY,
native_unit_of_measurement=ENERGY_WATT_HOUR, # core:MeasuredValueType = core:ElectricalEnergyInWh
entity_registry_enabled_default=False,
@ -181,7 +181,7 @@ SENSOR_DESCRIPTIONS: list[OverkizSensorDescription] = [
),
OverkizSensorDescription(
key=OverkizState.CORE_CONSUMPTION_TARIFF3,
name="Consumption Tariff 3",
name="Consumption tariff 3",
device_class=SensorDeviceClass.ENERGY,
native_unit_of_measurement=ENERGY_WATT_HOUR, # core:MeasuredValueType = core:ElectricalEnergyInWh
entity_registry_enabled_default=False,
@ -189,7 +189,7 @@ SENSOR_DESCRIPTIONS: list[OverkizSensorDescription] = [
),
OverkizSensorDescription(
key=OverkizState.CORE_CONSUMPTION_TARIFF4,
name="Consumption Tariff 4",
name="Consumption tariff 4",
device_class=SensorDeviceClass.ENERGY,
native_unit_of_measurement=ENERGY_WATT_HOUR, # core:MeasuredValueType = core:ElectricalEnergyInWh
entity_registry_enabled_default=False,
@ -197,7 +197,7 @@ SENSOR_DESCRIPTIONS: list[OverkizSensorDescription] = [
),
OverkizSensorDescription(
key=OverkizState.CORE_CONSUMPTION_TARIFF5,
name="Consumption Tariff 5",
name="Consumption tariff 5",
device_class=SensorDeviceClass.ENERGY,
native_unit_of_measurement=ENERGY_WATT_HOUR, # core:MeasuredValueType = core:ElectricalEnergyInWh
entity_registry_enabled_default=False,
@ -205,7 +205,7 @@ SENSOR_DESCRIPTIONS: list[OverkizSensorDescription] = [
),
OverkizSensorDescription(
key=OverkizState.CORE_CONSUMPTION_TARIFF6,
name="Consumption Tariff 6",
name="Consumption tariff 6",
device_class=SensorDeviceClass.ENERGY,
native_unit_of_measurement=ENERGY_WATT_HOUR, # core:MeasuredValueType = core:ElectricalEnergyInWh
entity_registry_enabled_default=False,
@ -213,7 +213,7 @@ SENSOR_DESCRIPTIONS: list[OverkizSensorDescription] = [
),
OverkizSensorDescription(
key=OverkizState.CORE_CONSUMPTION_TARIFF7,
name="Consumption Tariff 7",
name="Consumption tariff 7",
device_class=SensorDeviceClass.ENERGY,
native_unit_of_measurement=ENERGY_WATT_HOUR, # core:MeasuredValueType = core:ElectricalEnergyInWh
entity_registry_enabled_default=False,
@ -221,7 +221,7 @@ SENSOR_DESCRIPTIONS: list[OverkizSensorDescription] = [
),
OverkizSensorDescription(
key=OverkizState.CORE_CONSUMPTION_TARIFF8,
name="Consumption Tariff 8",
name="Consumption tariff 8",
device_class=SensorDeviceClass.ENERGY,
native_unit_of_measurement=ENERGY_WATT_HOUR, # core:MeasuredValueType = core:ElectricalEnergyInWh
entity_registry_enabled_default=False,
@ -229,7 +229,7 @@ SENSOR_DESCRIPTIONS: list[OverkizSensorDescription] = [
),
OverkizSensorDescription(
key=OverkizState.CORE_CONSUMPTION_TARIFF9,
name="Consumption Tariff 9",
name="Consumption tariff 9",
device_class=SensorDeviceClass.ENERGY,
native_unit_of_measurement=ENERGY_WATT_HOUR, # core:MeasuredValueType = core:ElectricalEnergyInWh
entity_registry_enabled_default=False,
@ -238,7 +238,7 @@ SENSOR_DESCRIPTIONS: list[OverkizSensorDescription] = [
# HumiditySensor/RelativeHumiditySensor
OverkizSensorDescription(
key=OverkizState.CORE_RELATIVE_HUMIDITY,
name="Relative Humidity",
name="Relative humidity",
native_value=lambda value: round(cast(float, value), 2),
device_class=SensorDeviceClass.HUMIDITY,
native_unit_of_measurement=PERCENTAGE, # core:MeasuredValueType = core:RelativeValueInPercentage
@ -256,21 +256,21 @@ SENSOR_DESCRIPTIONS: list[OverkizSensorDescription] = [
# WeatherSensor/WeatherForecastSensor
OverkizSensorDescription(
key=OverkizState.CORE_WEATHER_STATUS,
name="Weather Status",
name="Weather status",
device_class=SensorDeviceClass.TEMPERATURE,
native_unit_of_measurement=TEMP_CELSIUS,
state_class=SensorStateClass.MEASUREMENT,
),
OverkizSensorDescription(
key=OverkizState.CORE_MINIMUM_TEMPERATURE,
name="Minimum Temperature",
name="Minimum temperature",
device_class=SensorDeviceClass.TEMPERATURE,
native_unit_of_measurement=TEMP_CELSIUS,
state_class=SensorStateClass.MEASUREMENT,
),
OverkizSensorDescription(
key=OverkizState.CORE_MAXIMUM_TEMPERATURE,
name="Maximum Temperature",
name="Maximum temperature",
device_class=SensorDeviceClass.TEMPERATURE,
native_unit_of_measurement=TEMP_CELSIUS,
state_class=SensorStateClass.MEASUREMENT,
@ -278,7 +278,7 @@ SENSOR_DESCRIPTIONS: list[OverkizSensorDescription] = [
# AirSensor/COSensor
OverkizSensorDescription(
key=OverkizState.CORE_CO_CONCENTRATION,
name="CO Concentration",
name="CO concentration",
device_class=SensorDeviceClass.CO,
native_unit_of_measurement=CONCENTRATION_PARTS_PER_MILLION,
state_class=SensorStateClass.MEASUREMENT,
@ -286,7 +286,7 @@ SENSOR_DESCRIPTIONS: list[OverkizSensorDescription] = [
# AirSensor/CO2Sensor
OverkizSensorDescription(
key=OverkizState.CORE_CO2_CONCENTRATION,
name="CO2 Concentration",
name="CO2 concentration",
device_class=SensorDeviceClass.CO2,
native_unit_of_measurement=CONCENTRATION_PARTS_PER_MILLION,
state_class=SensorStateClass.MEASUREMENT,
@ -294,7 +294,7 @@ SENSOR_DESCRIPTIONS: list[OverkizSensorDescription] = [
# SunSensor/SunEnergySensor
OverkizSensorDescription(
key=OverkizState.CORE_SUN_ENERGY,
name="Sun Energy",
name="Sun energy",
native_value=lambda value: round(cast(float, value), 2),
icon="mdi:solar-power",
state_class=SensorStateClass.MEASUREMENT,
@ -302,7 +302,7 @@ SENSOR_DESCRIPTIONS: list[OverkizSensorDescription] = [
# WindSensor/WindSpeedSensor
OverkizSensorDescription(
key=OverkizState.CORE_WIND_SPEED,
name="Wind Speed",
name="Wind speed",
native_value=lambda value: round(cast(float, value), 2),
icon="mdi:weather-windy",
state_class=SensorStateClass.MEASUREMENT,
@ -310,14 +310,14 @@ SENSOR_DESCRIPTIONS: list[OverkizSensorDescription] = [
# SmokeSensor/SmokeSensor
OverkizSensorDescription(
key=OverkizState.IO_SENSOR_ROOM,
name="Sensor Room",
name="Sensor room",
device_class=OverkizDeviceClass.SENSOR_ROOM,
entity_category=EntityCategory.DIAGNOSTIC,
icon="mdi:spray-bottle",
),
OverkizSensorDescription(
key=OverkizState.IO_PRIORITY_LOCK_ORIGINATOR,
name="Priority Lock Originator",
name="Priority lock originator",
device_class=OverkizDeviceClass.PRIORITY_LOCK_ORIGINATOR,
icon="mdi:lock",
entity_registry_enabled_default=False,
@ -327,14 +327,14 @@ SENSOR_DESCRIPTIONS: list[OverkizSensorDescription] = [
),
OverkizSensorDescription(
key=OverkizState.CORE_PRIORITY_LOCK_TIMER,
name="Priority Lock Timer",
name="Priority lock timer",
icon="mdi:lock-clock",
native_unit_of_measurement=TIME_SECONDS,
entity_registry_enabled_default=False,
),
OverkizSensorDescription(
key=OverkizState.CORE_DISCRETE_RSSI_LEVEL,
name="Discrete RSSI Level",
name="Discrete RSSI level",
entity_registry_enabled_default=False,
entity_category=EntityCategory.DIAGNOSTIC,
device_class=OverkizDeviceClass.DISCRETE_RSSI_LEVEL,
@ -342,7 +342,7 @@ SENSOR_DESCRIPTIONS: list[OverkizSensorDescription] = [
),
OverkizSensorDescription(
key=OverkizState.CORE_SENSOR_DEFECT,
name="Sensor Defect",
name="Sensor defect",
entity_registry_enabled_default=False,
entity_category=EntityCategory.DIAGNOSTIC,
device_class=OverkizDeviceClass.SENSOR_DEFECT,
@ -353,14 +353,14 @@ SENSOR_DESCRIPTIONS: list[OverkizSensorDescription] = [
# DomesticHotWaterProduction/WaterHeatingSystem
OverkizSensorDescription(
key=OverkizState.IO_HEAT_PUMP_OPERATING_TIME,
name="Heat Pump Operating Time",
name="Heat pump operating time",
device_class=SensorDeviceClass.DURATION,
entity_category=EntityCategory.DIAGNOSTIC,
native_unit_of_measurement=TIME_SECONDS,
),
OverkizSensorDescription(
key=OverkizState.IO_ELECTRIC_BOOSTER_OPERATING_TIME,
name="Electric Booster Operating Time",
name="Electric booster operating time",
device_class=SensorDeviceClass.DURATION,
native_unit_of_measurement=TIME_SECONDS,
entity_category=EntityCategory.DIAGNOSTIC,
@ -368,14 +368,14 @@ SENSOR_DESCRIPTIONS: list[OverkizSensorDescription] = [
# Cover
OverkizSensorDescription(
key=OverkizState.CORE_TARGET_CLOSURE,
name="Target Closure",
name="Target closure",
native_unit_of_measurement=PERCENTAGE,
entity_registry_enabled_default=False,
),
# ThreeWayWindowHandle/WindowHandle
OverkizSensorDescription(
key=OverkizState.CORE_THREE_WAY_HANDLE_DIRECTION,
name="Three Way Handle Direction",
name="Three way handle direction",
device_class=OverkizDeviceClass.THREE_WAY_HANDLE_DIRECTION,
),
]
@ -454,7 +454,7 @@ class OverkizHomeKitSetupCodeSensor(OverkizEntity, SensorEntity):
) -> None:
"""Initialize the device."""
super().__init__(device_url, coordinator)
self._attr_name = "HomeKit Setup Code"
self._attr_name = "HomeKit setup code"
@property
def native_value(self) -> str | None:

View File

@ -98,7 +98,7 @@ SWITCH_DESCRIPTIONS: list[OverkizSwitchDescription] = [
),
OverkizSwitchDescription(
key=UIWidget.MY_FOX_SECURITY_CAMERA,
name="Camera Shutter",
name="Camera shutter",
turn_on=OverkizCommand.OPEN,
turn_off=OverkizCommand.CLOSE,
icon="mdi:camera-lock",