diff --git a/homeassistant/components/zwave_js/discovery.py b/homeassistant/components/zwave_js/discovery.py index 761c80bb0bb..25c342cf87d 100644 --- a/homeassistant/components/zwave_js/discovery.py +++ b/homeassistant/components/zwave_js/discovery.py @@ -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, diff --git a/homeassistant/components/zwave_js/light.py b/homeassistant/components/zwave_js/light.py index a90515cd040..9b7c0222410 100644 --- a/homeassistant/components/zwave_js/light.py +++ b/homeassistant/components/zwave_js/light.py @@ -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" diff --git a/tests/components/zwave_js/fixtures/nabu_casa_zwa2_legacy_state.json b/tests/components/zwave_js/fixtures/nabu_casa_zwa2_legacy_state.json index 662f7893493..8ea8cdbd009 100644 --- a/tests/components/zwave_js/fixtures/nabu_casa_zwa2_legacy_state.json +++ b/tests/components/zwave_js/fixtures/nabu_casa_zwa2_legacy_state.json @@ -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, diff --git a/tests/components/zwave_js/fixtures/nabu_casa_zwa2_state.json b/tests/components/zwave_js/fixtures/nabu_casa_zwa2_state.json index 31ca446dafc..e0c57462440 100644 --- a/tests/components/zwave_js/fixtures/nabu_casa_zwa2_state.json +++ b/tests/components/zwave_js/fixtures/nabu_casa_zwa2_state.json @@ -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, diff --git a/tests/components/zwave_js/test_discovery.py b/tests/components/zwave_js/test_discovery.py index 200c77ce443..9109d6a4048 100644 --- a/tests/components/zwave_js/test_discovery.py +++ b/tests/components/zwave_js/test_discovery.py @@ -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" + )