Discover ZWA-2 LED as a configuration entity in Z-Wave (#149298)

This commit is contained in:
AlCalzone 2025-07-23 15:33:52 +02:00 committed by GitHub
parent d9b25770ad
commit 22fa863984
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 496 additions and 1 deletions

View File

@ -772,6 +772,35 @@ DISCOVERY_SCHEMAS = [
},
),
),
# ZWA-2, discover LED control as configuration, default disabled
## Production firmware (1.0) -> Color Switch CC
ZWaveDiscoverySchema(
platform=Platform.LIGHT,
manufacturer_id={0x0466},
product_id={0x0001},
product_type={0x0001},
hint="color_onoff",
primary_value=COLOR_SWITCH_CURRENT_VALUE_SCHEMA,
absent_values=[
SWITCH_BINARY_CURRENT_VALUE_SCHEMA,
SWITCH_MULTILEVEL_CURRENT_VALUE_SCHEMA,
],
entity_category=EntityCategory.CONFIG,
),
## Day-1 firmware update (1.1) -> Binary Switch CC
ZWaveDiscoverySchema(
platform=Platform.LIGHT,
manufacturer_id={0x0466},
product_id={0x0001},
product_type={0x0001},
hint="onoff",
primary_value=SWITCH_BINARY_CURRENT_VALUE_SCHEMA,
absent_values=[
COLOR_SWITCH_CURRENT_VALUE_SCHEMA,
SWITCH_MULTILEVEL_CURRENT_VALUE_SCHEMA,
],
entity_category=EntityCategory.CONFIG,
),
# ====== START OF GENERIC MAPPING SCHEMAS =======
# locks
# Door Lock CC

View File

@ -183,6 +183,9 @@ class ZwaveLight(ZWaveBaseEntity, LightEntity):
if self._supports_color_temp:
self._supported_color_modes.add(ColorMode.COLOR_TEMP)
if not self._supported_color_modes:
if self.info.primary_value.command_class == CommandClass.SWITCH_BINARY:
self._supported_color_modes.add(ColorMode.ONOFF)
else:
self._supported_color_modes.add(ColorMode.BRIGHTNESS)
self._calculate_color_values()

View File

@ -538,6 +538,24 @@ def zcombo_smoke_co_alarm_state_fixture() -> NodeDataType:
)
@pytest.fixture(name="nabu_casa_zwa2_state")
def nabu_casa_zwa2_state_fixture() -> NodeDataType:
"""Load node with fixture data for Nabu Casa ZWA-2."""
return cast(
NodeDataType,
load_json_object_fixture("nabu_casa_zwa2_state.json", DOMAIN),
)
@pytest.fixture(name="nabu_casa_zwa2_legacy_state")
def nabu_casa_zwa2_legacy_state_fixture() -> NodeDataType:
"""Load node with fixture data for Nabu Casa ZWA-2 (legacy firmware)."""
return cast(
NodeDataType,
load_json_object_fixture("nabu_casa_zwa2_legacy_state.json", DOMAIN),
)
# model fixtures
@ -1358,3 +1376,23 @@ def zcombo_smoke_co_alarm_fixture(
node = Node(client, zcombo_smoke_co_alarm_state)
client.driver.controller.nodes[node.node_id] = node
return node
@pytest.fixture(name="nabu_casa_zwa2")
def nabu_casa_zwa2_fixture(
client: MagicMock, nabu_casa_zwa2_state: NodeDataType
) -> Node:
"""Load node for Nabu Casa ZWA-2."""
node = Node(client, nabu_casa_zwa2_state)
client.driver.controller.nodes[node.node_id] = node
return node
@pytest.fixture(name="nabu_casa_zwa2_legacy")
def nabu_casa_zwa2_legacy_fixture(
client: MagicMock, nabu_casa_zwa2_legacy_state: NodeDataType
) -> Node:
"""Load node for Nabu Casa ZWA-2 (legacy firmware)."""
node = Node(client, nabu_casa_zwa2_legacy_state)
client.driver.controller.nodes[node.node_id] = node
return node

View File

@ -0,0 +1,231 @@
{
"nodeId": 1,
"index": 0,
"status": 4,
"ready": true,
"isListening": true,
"isRouting": true,
"manufacturerId": 1126,
"productId": 1,
"productType": 1,
"firmwareVersion": "1.0",
"deviceConfig": {
"filename": "/data/db/devices/0x0466/zwa-2.json",
"isEmbedded": true,
"manufacturer": "Nabu Casa",
"manufacturerId": 1126,
"label": "Home Assistant Connect ZWA-2",
"description": "Z-Wave Adapter",
"devices": [
{
"productType": 1,
"productId": 1
}
],
"firmwareVersion": {
"min": "0.0",
"max": "255.255"
},
"preferred": false
},
"label": "Home Assistant Connect ZWA-2",
"interviewAttempts": 0,
"isFrequentListening": false,
"maxDataRate": 100000,
"supportedDataRates": [40000, 100000],
"protocolVersion": 3,
"supportsBeaming": true,
"supportsSecurity": false,
"deviceClass": {
"basic": {
"key": 2,
"label": "Static Controller"
},
"generic": {
"key": 2,
"label": "Static Controller"
},
"specific": {
"key": 1,
"label": "PC Controller"
}
},
"interviewStage": "Complete",
"deviceDatabaseUrl": "https://devices.zwave-js.io/?jumpTo=0x0466:0x0001:0x0001:1.0",
"statistics": {
"commandsTX": 0,
"commandsRX": 0,
"commandsDroppedRX": 0,
"commandsDroppedTX": 0,
"timeoutResponse": 0
},
"isControllerNode": true,
"keepAwake": false,
"protocol": 0,
"sdkVersion": "7.23.1",
"values": [
{
"commandClass": 51,
"commandClassName": "Color Switch",
"property": "currentColor",
"propertyKey": 2,
"propertyName": "currentColor",
"propertyKeyName": "Red",
"ccVersion": 0,
"metadata": {
"type": "number",
"readable": true,
"writeable": false,
"description": "The current value of the Red channel.",
"label": "Current value (Red)",
"min": 0,
"max": 255,
"stateful": true,
"secret": false
},
"value": 255
},
{
"commandClass": 51,
"commandClassName": "Color Switch",
"property": "currentColor",
"propertyKey": 3,
"propertyName": "currentColor",
"propertyKeyName": "Green",
"ccVersion": 0,
"metadata": {
"type": "number",
"readable": true,
"writeable": false,
"description": "The current value of the Green channel.",
"label": "Current value (Green)",
"min": 0,
"max": 255,
"stateful": true,
"secret": false
},
"value": 227
},
{
"commandClass": 51,
"commandClassName": "Color Switch",
"property": "currentColor",
"propertyKey": 4,
"propertyName": "currentColor",
"propertyKeyName": "Blue",
"ccVersion": 0,
"metadata": {
"type": "number",
"readable": true,
"writeable": false,
"description": "The current value of the Blue channel.",
"label": "Current value (Blue)",
"min": 0,
"max": 255,
"stateful": true,
"secret": false
},
"value": 181
},
{
"commandClass": 51,
"commandClassName": "Color Switch",
"property": "currentColor",
"propertyName": "currentColor",
"ccVersion": 0,
"metadata": {
"type": "any",
"readable": true,
"writeable": false,
"label": "Current color",
"stateful": true,
"secret": false
},
"value": {
"red": 255,
"green": 227,
"blue": 181
}
},
{
"commandClass": 51,
"commandClassName": "Color Switch",
"property": "targetColor",
"propertyName": "targetColor",
"ccVersion": 0,
"metadata": {
"type": "any",
"readable": true,
"writeable": true,
"label": "Target color",
"valueChangeOptions": ["transitionDuration"],
"stateful": true,
"secret": false
}
},
{
"commandClass": 51,
"commandClassName": "Color Switch",
"property": "hexColor",
"propertyName": "hexColor",
"ccVersion": 0,
"metadata": {
"type": "color",
"readable": true,
"writeable": true,
"label": "RGB Color",
"valueChangeOptions": ["transitionDuration"],
"minLength": 6,
"maxLength": 7,
"stateful": true,
"secret": false
},
"value": "ffe3b5"
},
{
"commandClass": 112,
"commandClassName": "Configuration",
"property": 0,
"propertyName": "enableTiltIndicator",
"ccVersion": 0,
"metadata": {
"type": "number",
"readable": true,
"writeable": true,
"label": "Enable Tilt Indicator",
"default": 1,
"min": 0,
"max": 1,
"states": {
"0": "Disable",
"1": "Enable"
},
"valueSize": 1,
"format": 1,
"allowManualEntry": false
},
"value": 1
}
],
"endpoints": [
{
"nodeId": 1,
"index": 0,
"deviceClass": {
"basic": {
"key": 2,
"label": "Static Controller"
},
"generic": {
"key": 2,
"label": "Static Controller"
},
"specific": {
"key": 1,
"label": "PC Controller"
}
},
"commandClasses": []
}
]
}

View File

@ -0,0 +1,146 @@
{
"nodeId": 1,
"index": 0,
"status": 4,
"ready": true,
"isListening": true,
"isRouting": true,
"manufacturerId": 1126,
"productId": 1,
"productType": 1,
"firmwareVersion": "1.0",
"deviceConfig": {
"filename": "/home/dominic/Repositories/zwavejs2mqtt/store/.config-db/devices/0x0466/zwa-2.json",
"isEmbedded": true,
"manufacturer": "Nabu Casa",
"manufacturerId": 1126,
"label": "Home Assistant Connect ZWA-2",
"description": "Z-Wave Adapter",
"devices": [
{
"productType": 1,
"productId": 1
}
],
"firmwareVersion": {
"min": "0.0",
"max": "255.255"
},
"preferred": false
},
"label": "Home Assistant Connect ZWA-2",
"interviewAttempts": 0,
"isFrequentListening": false,
"maxDataRate": 100000,
"supportedDataRates": [40000, 100000],
"protocolVersion": 3,
"supportsBeaming": true,
"supportsSecurity": false,
"deviceClass": {
"basic": {
"key": 2,
"label": "Static Controller"
},
"generic": {
"key": 2,
"label": "Static Controller"
},
"specific": {
"key": 1,
"label": "PC Controller"
}
},
"interviewStage": "Complete",
"deviceDatabaseUrl": "https://devices.zwave-js.io/?jumpTo=0x0466:0x0001:0x0001:1.0",
"statistics": {
"commandsTX": 0,
"commandsRX": 0,
"commandsDroppedRX": 0,
"commandsDroppedTX": 0,
"timeoutResponse": 0
},
"isControllerNode": true,
"keepAwake": false,
"protocol": 0,
"sdkVersion": "7.23.1",
"values": [
{
"commandClass": 37,
"commandClassName": "Binary Switch",
"property": "currentValue",
"propertyName": "currentValue",
"ccVersion": 0,
"metadata": {
"type": "boolean",
"readable": true,
"writeable": false,
"label": "Current value",
"stateful": true,
"secret": false
},
"value": true
},
{
"commandClass": 37,
"commandClassName": "Binary Switch",
"property": "targetValue",
"propertyName": "targetValue",
"ccVersion": 0,
"metadata": {
"type": "boolean",
"readable": true,
"writeable": true,
"label": "Target value",
"valueChangeOptions": ["transitionDuration"],
"stateful": true,
"secret": false
},
"value": true
},
{
"commandClass": 112,
"commandClassName": "Configuration",
"property": 0,
"propertyName": "enableTiltIndicator",
"ccVersion": 0,
"metadata": {
"type": "number",
"readable": true,
"writeable": true,
"label": "Enable Tilt Indicator",
"default": 1,
"min": 0,
"max": 1,
"states": {
"0": "Disable",
"1": "Enable"
},
"valueSize": 1,
"format": 1,
"allowManualEntry": false
},
"value": 1
}
],
"endpoints": [
{
"nodeId": 1,
"index": 0,
"deviceClass": {
"basic": {
"key": 2,
"label": "Static Controller"
},
"generic": {
"key": 2,
"label": "Static Controller"
},
"specific": {
"key": 1,
"label": "PC Controller"
}
},
"commandClasses": []
}
]
}

View File

@ -495,3 +495,51 @@ async def test_aeotec_smart_switch_7(
entity_entry = entity_registry.async_get(state.entity_id)
assert entity_entry
assert entity_entry.entity_category is EntityCategory.CONFIG
async def test_nabu_casa_zwa2(
hass: HomeAssistant,
entity_registry: er.EntityRegistry,
nabu_casa_zwa2: Node,
integration: MockConfigEntry,
) -> None:
"""Test ZWA-2 discovery."""
state = hass.states.get("light.z_wave_adapter")
assert state, "The LED indicator should be enabled by default"
entry = entity_registry.async_get(state.entity_id)
assert entry, "Entity for the LED indicator not found"
assert entry.capabilities.get(ATTR_SUPPORTED_COLOR_MODES) == [
ColorMode.ONOFF,
], "The LED indicator should be an ON/OFF light"
assert not entry.disabled, "The entity should be enabled by default"
assert entry.entity_category is EntityCategory.CONFIG, (
"The LED indicator should be configuration"
)
async def test_nabu_casa_zwa2_legacy(
hass: HomeAssistant,
entity_registry: er.EntityRegistry,
nabu_casa_zwa2_legacy: Node,
integration: MockConfigEntry,
) -> None:
"""Test ZWA-2 discovery with legacy firmware."""
state = hass.states.get("light.z_wave_adapter")
assert state, "The LED indicator should be enabled by default"
entry = entity_registry.async_get(state.entity_id)
assert entry, "Entity for the LED indicator not found"
assert entry.capabilities.get(ATTR_SUPPORTED_COLOR_MODES) == [
ColorMode.HS,
], "The LED indicator should be a color light"
assert not entry.disabled, "The entity should be enabled by default"
assert entry.entity_category is EntityCategory.CONFIG, (
"The LED indicator should be configuration"
)