From 51f989c57a6e73681e40bc222bfad748b43589e5 Mon Sep 17 00:00:00 2001 From: Caius-Bonus <123886836+Caius-Bonus@users.noreply.github.com> Date: Sun, 22 Oct 2023 16:18:38 +0200 Subject: [PATCH] Standardize _select_attr in ZCLEnumSelectEntity (#102454) --- homeassistant/components/zha/select.py | 46 +++++++++++++------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/homeassistant/components/zha/select.py b/homeassistant/components/zha/select.py index b98a0c3f07b..46089dd5a28 100644 --- a/homeassistant/components/zha/select.py +++ b/homeassistant/components/zha/select.py @@ -155,7 +155,7 @@ class ZHADefaultStrobeSelectEntity(ZHANonZCLSelectEntity): class ZCLEnumSelectEntity(ZhaEntity, SelectEntity): """Representation of a ZHA ZCL enum select entity.""" - _select_attr: str + _attribute_name: str _attr_entity_category = EntityCategory.CONFIG _enum: type[Enum] @@ -173,13 +173,13 @@ class ZCLEnumSelectEntity(ZhaEntity, SelectEntity): """ cluster_handler = cluster_handlers[0] if ( - cls._select_attr in cluster_handler.cluster.unsupported_attributes - or cls._select_attr not in cluster_handler.cluster.attributes_by_name - or cluster_handler.cluster.get(cls._select_attr) is None + cls._attribute_name in cluster_handler.cluster.unsupported_attributes + or cls._attribute_name not in cluster_handler.cluster.attributes_by_name + or cluster_handler.cluster.get(cls._attribute_name) is None ): _LOGGER.debug( "%s is not supported - skipping %s entity creation", - cls._select_attr, + cls._attribute_name, cls.__name__, ) return None @@ -201,7 +201,7 @@ class ZCLEnumSelectEntity(ZhaEntity, SelectEntity): @property def current_option(self) -> str | None: """Return the selected entity option to represent the entity state.""" - option = self._cluster_handler.cluster.get(self._select_attr) + option = self._cluster_handler.cluster.get(self._attribute_name) if option is None: return None option = self._enum(option) @@ -210,7 +210,7 @@ class ZCLEnumSelectEntity(ZhaEntity, SelectEntity): async def async_select_option(self, option: str) -> None: """Change the selected option.""" await self._cluster_handler.write_attributes_safe( - {self._select_attr: self._enum[option.replace(" ", "_")]} + {self._attribute_name: self._enum[option.replace(" ", "_")]} ) self.async_write_ha_state() @@ -232,7 +232,7 @@ class ZHAStartupOnOffSelectEntity(ZCLEnumSelectEntity): """Representation of a ZHA startup onoff select entity.""" _unique_id_suffix = OnOff.StartUpOnOff.__name__ - _select_attr = "start_up_on_off" + _attribute_name = "start_up_on_off" _enum = OnOff.StartUpOnOff _attr_translation_key: str = "start_up_on_off" @@ -274,7 +274,7 @@ class TuyaPowerOnStateSelectEntity(ZCLEnumSelectEntity): """Representation of a ZHA power on state select entity.""" _unique_id_suffix = "power_on_state" - _select_attr = "power_on_state" + _attribute_name = "power_on_state" _enum = TuyaPowerOnState _attr_translation_key: str = "power_on_state" @@ -295,7 +295,7 @@ class TuyaBacklightModeSelectEntity(ZCLEnumSelectEntity): """Representation of a ZHA backlight mode select entity.""" _unique_id_suffix = "backlight_mode" - _select_attr = "backlight_mode" + _attribute_name = "backlight_mode" _enum = TuyaBacklightMode _attr_translation_key: str = "backlight_mode" @@ -334,7 +334,7 @@ class MoesBacklightModeSelectEntity(ZCLEnumSelectEntity): """Moes devices have a different backlight mode select options.""" _unique_id_suffix = "backlight_mode" - _select_attr = "backlight_mode" + _attribute_name = "backlight_mode" _enum = MoesBacklightMode _attr_translation_key: str = "backlight_mode" @@ -355,7 +355,7 @@ class AqaraMotionSensitivity(ZCLEnumSelectEntity): """Representation of a ZHA motion sensitivity configuration entity.""" _unique_id_suffix = "motion_sensitivity" - _select_attr = "motion_sensitivity" + _attribute_name = "motion_sensitivity" _enum = AqaraMotionSensitivities _attr_translation_key: str = "motion_sensitivity" @@ -377,7 +377,7 @@ class HueV1MotionSensitivity(ZCLEnumSelectEntity): """Representation of a ZHA motion sensitivity configuration entity.""" _unique_id_suffix = "motion_sensitivity" - _select_attr = "sensitivity" + _attribute_name = "sensitivity" _enum = HueV1MotionSensitivities _attr_translation_key: str = "motion_sensitivity" @@ -401,7 +401,7 @@ class HueV2MotionSensitivity(ZCLEnumSelectEntity): """Representation of a ZHA motion sensitivity configuration entity.""" _unique_id_suffix = "motion_sensitivity" - _select_attr = "sensitivity" + _attribute_name = "sensitivity" _enum = HueV2MotionSensitivities _attr_translation_key: str = "motion_sensitivity" @@ -420,7 +420,7 @@ class AqaraMonitoringMode(ZCLEnumSelectEntity): """Representation of a ZHA monitoring mode configuration entity.""" _unique_id_suffix = "monitoring_mode" - _select_attr = "monitoring_mode" + _attribute_name = "monitoring_mode" _enum = AqaraMonitoringModess _attr_translation_key: str = "monitoring_mode" @@ -440,7 +440,7 @@ class AqaraApproachDistance(ZCLEnumSelectEntity): """Representation of a ZHA approach distance configuration entity.""" _unique_id_suffix = "approach_distance" - _select_attr = "approach_distance" + _attribute_name = "approach_distance" _enum = AqaraApproachDistances _attr_translation_key: str = "approach_distance" @@ -459,7 +459,7 @@ class AqaraCurtainMode(ZCLEnumSelectEntity): """Representation of a ZHA curtain mode configuration entity.""" _unique_id_suffix = "window_covering_mode" - _select_attr = "window_covering_mode" + _attribute_name = "window_covering_mode" _enum = AqaraE1ReverseDirection _attr_translation_key: str = "window_covering_mode" @@ -478,7 +478,7 @@ class InovelliOutputModeEntity(ZCLEnumSelectEntity): """Inovelli output mode control.""" _unique_id_suffix = "output_mode" - _select_attr = "output_mode" + _attribute_name = "output_mode" _enum = InovelliOutputMode _attr_translation_key: str = "output_mode" @@ -499,7 +499,7 @@ class InovelliSwitchTypeEntity(ZCLEnumSelectEntity): """Inovelli switch type control.""" _unique_id_suffix = "switch_type" - _select_attr = "switch_type" + _attribute_name = "switch_type" _enum = InovelliSwitchType _attr_translation_key: str = "switch_type" @@ -518,7 +518,7 @@ class InovelliLedScalingModeEntity(ZCLEnumSelectEntity): """Inovelli led mode control.""" _unique_id_suffix = "led_scaling_mode" - _select_attr = "led_scaling_mode" + _attribute_name = "led_scaling_mode" _enum = InovelliLedScalingMode _attr_translation_key: str = "led_scaling_mode" @@ -537,7 +537,7 @@ class InovelliNonNeutralOutputEntity(ZCLEnumSelectEntity): """Inovelli non neutral output control.""" _unique_id_suffix = "increased_non_neutral_output" - _select_attr = "increased_non_neutral_output" + _attribute_name = "increased_non_neutral_output" _enum = InovelliNonNeutralOutput _attr_translation_key: str = "increased_non_neutral_output" @@ -556,7 +556,7 @@ class AqaraPetFeederMode(ZCLEnumSelectEntity): """Representation of an Aqara pet feeder mode configuration entity.""" _unique_id_suffix = "feeding_mode" - _select_attr = "feeding_mode" + _attribute_name = "feeding_mode" _enum = AqaraFeedingMode _attr_translation_key: str = "feeding_mode" _attr_icon: str = "mdi:wrench-clock" @@ -577,6 +577,6 @@ class AqaraThermostatPreset(ZCLEnumSelectEntity): """Representation of an Aqara thermostat preset configuration entity.""" _unique_id_suffix = "preset" - _select_attr = "preset" + _attribute_name = "preset" _enum = AqaraThermostatPresetMode _attr_translation_key: str = "preset"