Update Z-Wave LED entity name for ZWA-2 (#149323)

This commit is contained in:
AlCalzone 2025-07-23 16:55:00 +02:00 committed by GitHub
parent b6db10340e
commit 391b144033
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 57 additions and 11 deletions

View File

@ -779,7 +779,7 @@ DISCOVERY_SCHEMAS = [
manufacturer_id={0x0466},
product_id={0x0001},
product_type={0x0001},
hint="color_onoff",
hint="zwa2_led_color",
primary_value=COLOR_SWITCH_CURRENT_VALUE_SCHEMA,
absent_values=[
SWITCH_BINARY_CURRENT_VALUE_SCHEMA,
@ -793,7 +793,7 @@ DISCOVERY_SCHEMAS = [
manufacturer_id={0x0466},
product_id={0x0001},
product_type={0x0001},
hint="onoff",
hint="zwa2_led_onoff",
primary_value=SWITCH_BINARY_CURRENT_VALUE_SCHEMA,
absent_values=[
COLOR_SWITCH_CURRENT_VALUE_SCHEMA,

View File

@ -77,7 +77,11 @@ async def async_setup_entry(
driver = client.driver
assert driver is not None # Driver is ready before platforms are loaded.
if info.platform_hint == "color_onoff":
if info.platform_hint == "zwa2_led_color":
async_add_entities([ZWA2LEDColorLight(config_entry, driver, info)])
elif info.platform_hint == "zwa2_led_onoff":
async_add_entities([ZWA2LEDOnOffLight(config_entry, driver, info)])
elif info.platform_hint == "color_onoff":
async_add_entities([ZwaveColorOnOffLight(config_entry, driver, info)])
else:
async_add_entities([ZwaveLight(config_entry, driver, info)])
@ -680,3 +684,29 @@ class ZwaveColorOnOffLight(ZwaveLight):
colors,
kwargs.get(ATTR_TRANSITION),
)
class ZWA2LEDColorLight(ZwaveColorOnOffLight):
"""LED entity specific to the ZWA-2 (legacy firmware)."""
_attr_has_entity_name = True
def __init__(
self, config_entry: ZwaveJSConfigEntry, driver: Driver, info: ZwaveDiscoveryInfo
) -> None:
"""Initialize the ZWA-2 LED entity."""
super().__init__(config_entry, driver, info)
self._attr_name = "LED"
class ZWA2LEDOnOffLight(ZwaveLight):
"""LED entity specific to the ZWA-2."""
_attr_has_entity_name = True
def __init__(
self, config_entry: ZwaveJSConfigEntry, driver: Driver, info: ZwaveDiscoveryInfo
) -> None:
"""Initialize the ZWA-2 LED entity."""
super().__init__(config_entry, driver, info)
self._attr_name = "LED"

View File

@ -14,8 +14,8 @@
"isEmbedded": true,
"manufacturer": "Nabu Casa",
"manufacturerId": 1126,
"label": "Home Assistant Connect ZWA-2",
"description": "Z-Wave Adapter",
"label": "NC-ZWA-9734",
"description": "Home Assistant Connect ZWA-2",
"devices": [
{
"productType": 1,
@ -28,7 +28,7 @@
},
"preferred": false
},
"label": "Home Assistant Connect ZWA-2",
"label": "NC-ZWA-9734",
"interviewAttempts": 0,
"isFrequentListening": false,
"maxDataRate": 100000,

View File

@ -14,8 +14,8 @@
"isEmbedded": true,
"manufacturer": "Nabu Casa",
"manufacturerId": 1126,
"label": "Home Assistant Connect ZWA-2",
"description": "Z-Wave Adapter",
"label": "NC-ZWA-9734",
"description": "Home Assistant Connect ZWA-2",
"devices": [
{
"productType": 1,
@ -28,7 +28,7 @@
},
"preferred": false
},
"label": "Home Assistant Connect ZWA-2",
"label": "NC-ZWA-9734",
"interviewAttempts": 0,
"isFrequentListening": false,
"maxDataRate": 100000,

View File

@ -504,7 +504,7 @@ async def test_nabu_casa_zwa2(
integration: MockConfigEntry,
) -> None:
"""Test ZWA-2 discovery."""
state = hass.states.get("light.z_wave_adapter")
state = hass.states.get("light.home_assistant_connect_zwa_2_led")
assert state, "The LED indicator should be enabled by default"
entry = entity_registry.async_get(state.entity_id)
@ -520,6 +520,14 @@ async def test_nabu_casa_zwa2(
"The LED indicator should be configuration"
)
# Test that the entity name is properly set to "LED"
assert entry.original_name == "LED", (
"The LED entity should have the original name 'LED'"
)
assert state.attributes["friendly_name"] == "Home Assistant Connect ZWA-2 LED", (
"The LED should have the correct friendly name"
)
async def test_nabu_casa_zwa2_legacy(
hass: HomeAssistant,
@ -528,7 +536,7 @@ async def test_nabu_casa_zwa2_legacy(
integration: MockConfigEntry,
) -> None:
"""Test ZWA-2 discovery with legacy firmware."""
state = hass.states.get("light.z_wave_adapter")
state = hass.states.get("light.home_assistant_connect_zwa_2_led")
assert state, "The LED indicator should be enabled by default"
entry = entity_registry.async_get(state.entity_id)
@ -543,3 +551,11 @@ async def test_nabu_casa_zwa2_legacy(
assert entry.entity_category is EntityCategory.CONFIG, (
"The LED indicator should be configuration"
)
# Test that the entity name is properly set to "LED"
assert entry.original_name == "LED", (
"The LED entity should have the original name 'LED'"
)
assert state.attributes["friendly_name"] == "Home Assistant Connect ZWA-2 LED", (
"The LED should have the correct friendly name"
)