From a41f560e9bfc317f759d5029e2150834f39ba251 Mon Sep 17 00:00:00 2001 From: Daniel Lando Date: Mon, 2 Sep 2024 09:45:30 +0200 Subject: [PATCH 1/2] fix(discovery): use valueId endpoint device class for multilevel switch CC discovery Fixes #3862 --- api/lib/Gateway.ts | 8 ++++++-- api/lib/ZwaveClient.ts | 3 +++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/api/lib/Gateway.ts b/api/lib/Gateway.ts index 32afa9b6c06..56660bf5ae5 100644 --- a/api/lib/Gateway.ts +++ b/api/lib/Gateway.ts @@ -1237,6 +1237,10 @@ export default class Gateway { const cmdClass = valueId.commandClass + const deviceClass = + node.endpoints[valueId.endpoint]?.deviceClass ?? + node.deviceClass + switch (cmdClass) { case CommandClasses['Binary Switch']: case CommandClasses['All Switch']: @@ -1256,8 +1260,8 @@ export default class Gateway { if (valueId.isCurrentValue) { const specificDeviceClass = Constants.specificDeviceClass( - node.deviceClass.generic, - node.deviceClass.specific, + deviceClass.generic, + deviceClass.specific, ) // Use a cover_position configuration if ... if ( diff --git a/api/lib/ZwaveClient.ts b/api/lib/ZwaveClient.ts index 65b42fd0186..2c97a0e508d 100644 --- a/api/lib/ZwaveClient.ts +++ b/api/lib/ZwaveClient.ts @@ -104,6 +104,7 @@ import { ProvisioningEntryStatus, AssociationCheckResult, LinkReliabilityCheckResult, + DeviceClass, } from 'zwave-js' import { getEnumMemberName, parseQRCodeString } from 'zwave-js/Utils' import { logsDir, nvmBackupsDir, storeDir } from '../config/app' @@ -467,6 +468,7 @@ export interface FwFile { export interface ZUIEndpoint { index: number label?: string + deviceClass?: DeviceClass } export enum ZUIScheduleEntryLockMode { @@ -6007,6 +6009,7 @@ class ZwaveClient extends TypedEventEmitter { return { index: e.index, label: e.endpointLabel || defaultLabel, + deviceClass: e.deviceClass, } }) node.isSecure = zwaveNode.isSecure From aac01fc37b0bfd3f6fccbc970878039b1ea61406 Mon Sep 17 00:00:00 2001 From: Daniel Lando Date: Mon, 2 Sep 2024 10:01:38 +0200 Subject: [PATCH 2/2] fix: build error --- api/lib/ZwaveClient.ts | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/api/lib/ZwaveClient.ts b/api/lib/ZwaveClient.ts index 2c97a0e508d..611eed27b0d 100644 --- a/api/lib/ZwaveClient.ts +++ b/api/lib/ZwaveClient.ts @@ -104,7 +104,6 @@ import { ProvisioningEntryStatus, AssociationCheckResult, LinkReliabilityCheckResult, - DeviceClass, } from 'zwave-js' import { getEnumMemberName, parseQRCodeString } from 'zwave-js/Utils' import { logsDir, nvmBackupsDir, storeDir } from '../config/app' @@ -468,7 +467,11 @@ export interface FwFile { export interface ZUIEndpoint { index: number label?: string - deviceClass?: DeviceClass + deviceClass: { + basic: number + generic: number + specific: number + } } export enum ZUIScheduleEntryLockMode { @@ -6009,7 +6012,11 @@ class ZwaveClient extends TypedEventEmitter { return { index: e.index, label: e.endpointLabel || defaultLabel, - deviceClass: e.deviceClass, + deviceClass: { + basic: e.deviceClass?.basic, + generic: e.deviceClass?.generic.key, + specific: e.deviceClass?.specific.key, + }, } }) node.isSecure = zwaveNode.isSecure