From 0a44c9456cda357fcc2e2cc5f682351834289a9e Mon Sep 17 00:00:00 2001 From: puddly <32534428+puddly@users.noreply.github.com> Date: Wed, 25 Sep 2024 12:44:51 -0400 Subject: [PATCH] Bump ZHA to 0.0.34 (#126766) --- homeassistant/components/zha/const.py | 1 - homeassistant/components/zha/entity.py | 31 ++++++++++++++-------- homeassistant/components/zha/helpers.py | 3 --- homeassistant/components/zha/light.py | 8 ------ homeassistant/components/zha/manifest.json | 2 +- homeassistant/components/zha/strings.json | 1 - requirements_all.txt | 2 +- requirements_test_all.txt | 2 +- tests/components/zha/data.py | 14 ---------- 9 files changed, 23 insertions(+), 41 deletions(-) diff --git a/homeassistant/components/zha/const.py b/homeassistant/components/zha/const.py index 18705c40608..270a3d3fb66 100644 --- a/homeassistant/components/zha/const.py +++ b/homeassistant/components/zha/const.py @@ -43,7 +43,6 @@ CONF_CUSTOM_QUIRKS_PATH = "custom_quirks_path" CONF_DEFAULT_LIGHT_TRANSITION = "default_light_transition" CONF_ENABLE_ENHANCED_LIGHT_TRANSITION = "enhanced_light_transition" CONF_ENABLE_LIGHT_TRANSITIONING_FLAG = "light_transitioning_flag" -CONF_ALWAYS_PREFER_XY_COLOR_MODE = "always_prefer_xy_color_mode" CONF_GROUP_MEMBERS_ASSUME_STATE = "group_members_assume_state" CONF_ENABLE_IDENTIFY_ON_JOIN = "enable_identify_on_join" diff --git a/homeassistant/components/zha/entity.py b/homeassistant/components/zha/entity.py index 348e545f1c4..b9e2e0fb3d2 100644 --- a/homeassistant/components/zha/entity.py +++ b/homeassistant/components/zha/entity.py @@ -4,7 +4,7 @@ from __future__ import annotations import asyncio from collections.abc import Callable -import functools +from functools import cached_property, partial import logging from typing import Any @@ -16,6 +16,7 @@ from homeassistant.helpers.device_registry import CONNECTION_ZIGBEE, DeviceInfo from homeassistant.helpers.dispatcher import async_dispatcher_connect from homeassistant.helpers.entity import Entity from homeassistant.helpers.restore_state import RestoreEntity +from homeassistant.helpers.typing import UNDEFINED, UndefinedType from .const import DOMAIN from .helpers import SIGNAL_REMOVE_ENTITIES, EntityData, convert_zha_error_to_ha_error @@ -43,15 +44,6 @@ class ZHAEntity(LogMixin, RestoreEntity, Entity): meta = self.entity_data.entity.info_object self._attr_unique_id = meta.unique_id - if meta.translation_key is not None: - self._attr_translation_key = meta.translation_key - elif meta.fallback_name is not None: - # Only custom quirks will create entities with just a fallback name! - # - # This is to allow local development and to register niche devices, since - # their translation_key will probably never be added to `zha/strings.json`. - self._attr_name = meta.fallback_name - if meta.entity_category is not None: self._attr_entity_category = EntityCategory(meta.entity_category) @@ -59,6 +51,23 @@ class ZHAEntity(LogMixin, RestoreEntity, Entity): meta.entity_registry_enabled_default ) + if meta.translation_key is not None: + self._attr_translation_key = meta.translation_key + + @cached_property + def name(self) -> str | UndefinedType | None: + """Return the name of the entity.""" + meta = self.entity_data.entity.info_object + original_name = super().name + + if original_name not in (UNDEFINED, None) or meta.fallback_name is None: + return original_name + + # This is to allow local development and to register niche devices, since + # their translation_key will probably never be added to `zha/strings.json`. + self._attr_name = meta.fallback_name + return super().name + @property def available(self) -> bool: """Return entity availability.""" @@ -102,7 +111,7 @@ class ZHAEntity(LogMixin, RestoreEntity, Entity): async_dispatcher_connect( self.hass, remove_signal, - functools.partial(self.async_remove, force_remove=True), + partial(self.async_remove, force_remove=True), ) ) self.entity_data.device_proxy.gateway_proxy.register_entity_reference( diff --git a/homeassistant/components/zha/helpers.py b/homeassistant/components/zha/helpers.py index cc3fb2898e6..b91565835a7 100644 --- a/homeassistant/components/zha/helpers.py +++ b/homeassistant/components/zha/helpers.py @@ -140,7 +140,6 @@ from .const import ( CONF_ALARM_ARM_REQUIRES_CODE, CONF_ALARM_FAILED_TRIES, CONF_ALARM_MASTER_CODE, - CONF_ALWAYS_PREFER_XY_COLOR_MODE, CONF_BAUDRATE, CONF_CONSIDER_UNAVAILABLE_BATTERY, CONF_CONSIDER_UNAVAILABLE_MAINS, @@ -1153,7 +1152,6 @@ CONF_ZHA_OPTIONS_SCHEMA = vol.Schema( ), vol.Required(CONF_ENABLE_ENHANCED_LIGHT_TRANSITION, default=False): cv.boolean, vol.Required(CONF_ENABLE_LIGHT_TRANSITIONING_FLAG, default=True): cv.boolean, - vol.Required(CONF_ALWAYS_PREFER_XY_COLOR_MODE, default=True): cv.boolean, vol.Required(CONF_GROUP_MEMBERS_ASSUME_STATE, default=True): cv.boolean, vol.Required(CONF_ENABLE_IDENTIFY_ON_JOIN, default=True): cv.boolean, vol.Optional( @@ -1230,7 +1228,6 @@ def create_zha_config(hass: HomeAssistant, ha_zha_data: HAZHAData) -> ZHAData: enable_light_transitioning_flag=zha_options.get( CONF_ENABLE_LIGHT_TRANSITIONING_FLAG ), - always_prefer_xy_color_mode=zha_options.get(CONF_ALWAYS_PREFER_XY_COLOR_MODE), group_members_assume_state=zha_options.get(CONF_GROUP_MEMBERS_ASSUME_STATE), ) device_options: DeviceOptions = DeviceOptions( diff --git a/homeassistant/components/zha/light.py b/homeassistant/components/zha/light.py index 4a36030a0dd..fa83ad1cab6 100644 --- a/homeassistant/components/zha/light.py +++ b/homeassistant/components/zha/light.py @@ -18,7 +18,6 @@ from homeassistant.components.light import ( ATTR_COLOR_TEMP, ATTR_EFFECT, ATTR_FLASH, - ATTR_HS_COLOR, ATTR_TRANSITION, ATTR_XY_COLOR, ColorMode, @@ -143,11 +142,6 @@ class Light(LightEntity, ZHAEntity): """Return the warmest color_temp that this light supports.""" return self.entity_data.entity.max_mireds - @property - def hs_color(self) -> tuple[float, float] | None: - """Return the hs color value [int, int].""" - return self.entity_data.entity.hs_color - @property def xy_color(self) -> tuple[float, float] | None: """Return the xy color value [float, float].""" @@ -185,7 +179,6 @@ class Light(LightEntity, ZHAEntity): flash=kwargs.get(ATTR_FLASH), color_temp=kwargs.get(ATTR_COLOR_TEMP), xy_color=kwargs.get(ATTR_XY_COLOR), - hs_color=kwargs.get(ATTR_HS_COLOR), ) self.async_write_ha_state() @@ -207,7 +200,6 @@ class Light(LightEntity, ZHAEntity): brightness=state.attributes.get(ATTR_BRIGHTNESS), color_temp=state.attributes.get(ATTR_COLOR_TEMP), xy_color=state.attributes.get(ATTR_XY_COLOR), - hs_color=state.attributes.get(ATTR_HS_COLOR), color_mode=( HA_TO_ZHA_COLOR_MODE[ColorMode(state.attributes[ATTR_COLOR_MODE])] if state.attributes.get(ATTR_COLOR_MODE) is not None diff --git a/homeassistant/components/zha/manifest.json b/homeassistant/components/zha/manifest.json index 7046642160c..dd15fb99960 100644 --- a/homeassistant/components/zha/manifest.json +++ b/homeassistant/components/zha/manifest.json @@ -21,7 +21,7 @@ "zha", "universal_silabs_flasher" ], - "requirements": ["universal-silabs-flasher==0.0.22", "zha==0.0.33"], + "requirements": ["universal-silabs-flasher==0.0.22", "zha==0.0.34"], "usb": [ { "vid": "10C4", diff --git a/homeassistant/components/zha/strings.json b/homeassistant/components/zha/strings.json index f98ad170e0a..6123081fcd7 100644 --- a/homeassistant/components/zha/strings.json +++ b/homeassistant/components/zha/strings.json @@ -178,7 +178,6 @@ "title": "Global Options", "enhanced_light_transition": "Enable enhanced light color/temperature transition from an off-state", "light_transitioning_flag": "Enable enhanced brightness slider during light transition", - "always_prefer_xy_color_mode": "Always prefer XY color mode", "group_members_assume_state": "Group members assume state of group", "enable_identify_on_join": "Enable identify effect when devices join the network", "default_light_transition": "Default light transition time (seconds)", diff --git a/requirements_all.txt b/requirements_all.txt index 3901e93c6f6..7f878b5dcdc 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -3047,7 +3047,7 @@ zeroconf==0.135.0 zeversolar==0.3.1 # homeassistant.components.zha -zha==0.0.33 +zha==0.0.34 # homeassistant.components.zhong_hong zhong-hong-hvac==1.0.12 diff --git a/requirements_test_all.txt b/requirements_test_all.txt index 4fb03e9e878..1bdbdbb6058 100644 --- a/requirements_test_all.txt +++ b/requirements_test_all.txt @@ -2427,7 +2427,7 @@ zeroconf==0.135.0 zeversolar==0.3.1 # homeassistant.components.zha -zha==0.0.33 +zha==0.0.34 # homeassistant.components.zwave_js zwave-js-server-python==0.58.0 diff --git a/tests/components/zha/data.py b/tests/components/zha/data.py index e5ed43e26a0..80a3df524cd 100644 --- a/tests/components/zha/data.py +++ b/tests/components/zha/data.py @@ -23,12 +23,6 @@ BASE_CUSTOM_CONFIGURATION = { "required": True, "default": True, }, - { - "type": "boolean", - "name": "always_prefer_xy_color_mode", - "required": True, - "default": True, - }, { "type": "boolean", "name": "group_members_assume_state", @@ -68,7 +62,6 @@ BASE_CUSTOM_CONFIGURATION = { "enhanced_light_transition": True, "default_light_transition": 0, "light_transitioning_flag": True, - "always_prefer_xy_color_mode": True, "group_members_assume_state": False, "enable_identify_on_join": True, "enable_mains_startup_polling": True, @@ -101,12 +94,6 @@ CONFIG_WITH_ALARM_OPTIONS = { "required": True, "default": True, }, - { - "type": "boolean", - "name": "always_prefer_xy_color_mode", - "required": True, - "default": True, - }, { "type": "boolean", "name": "group_members_assume_state", @@ -167,7 +154,6 @@ CONFIG_WITH_ALARM_OPTIONS = { "enhanced_light_transition": True, "default_light_transition": 0, "light_transitioning_flag": True, - "always_prefer_xy_color_mode": True, "group_members_assume_state": False, "enable_identify_on_join": True, "enable_mains_startup_polling": True,