diff --git a/packages/cc/src/cc/AlarmSensorCC.ts b/packages/cc/src/cc/AlarmSensorCC.ts index 4228ff54f087..87003a31dea6 100644 --- a/packages/cc/src/cc/AlarmSensorCC.ts +++ b/packages/cc/src/cc/AlarmSensorCC.ts @@ -31,7 +31,7 @@ import { import { API, CCCommand, - ccValue, + ccValueProperty, ccValues, commandClass, expectedCCResponse, @@ -474,6 +474,10 @@ export interface AlarmSensorCCSupportedReportOptions { } @CCCommand(AlarmSensorCommand.SupportedReport) +@ccValueProperty( + "supportedSensorTypes", + AlarmSensorCCValues.supportedSensorTypes, +) export class AlarmSensorCCSupportedReport extends AlarmSensorCC { public constructor( options: WithAddress, @@ -502,7 +506,6 @@ export class AlarmSensorCCSupportedReport extends AlarmSensorCC { }); } - @ccValue(AlarmSensorCCValues.supportedSensorTypes) public supportedSensorTypes: AlarmSensorType[]; public persistValues(ctx: PersistValuesContext): boolean { diff --git a/packages/cc/src/cc/AssociationCC.ts b/packages/cc/src/cc/AssociationCC.ts index 2414039f1ced..d4a4b2502837 100644 --- a/packages/cc/src/cc/AssociationCC.ts +++ b/packages/cc/src/cc/AssociationCC.ts @@ -33,7 +33,7 @@ import { import { API, CCCommand, - ccValue, + ccValueProperty, ccValues, commandClass, expectedCCResponse, @@ -630,6 +630,16 @@ export interface AssociationCCReportOptions { } @CCCommand(AssociationCommand.Report) +@ccValueProperty( + "maxNodes", + AssociationCCValues.maxNodes, + (self) => [self.groupId], +) +@ccValueProperty( + "nodeIds", + AssociationCCValues.nodeIds, + (self) => [self.groupId], +) export class AssociationCCReport extends AssociationCC { public constructor( options: WithAddress, @@ -660,16 +670,8 @@ export class AssociationCCReport extends AssociationCC { public groupId: number; - @ccValue( - AssociationCCValues.maxNodes, - (self: AssociationCCReport) => [self.groupId] as const, - ) public maxNodes: number; - @ccValue( - AssociationCCValues.nodeIds, - (self: AssociationCCReport) => [self.groupId] as const, - ) public nodeIds: number[]; public reportsToFollow: number; @@ -768,6 +770,7 @@ export interface AssociationCCSupportedGroupingsReportOptions { } @CCCommand(AssociationCommand.SupportedGroupingsReport) +@ccValueProperty("groupCount", AssociationCCValues.groupCount) export class AssociationCCSupportedGroupingsReport extends AssociationCC { public constructor( options: WithAddress, @@ -790,7 +793,6 @@ export class AssociationCCSupportedGroupingsReport extends AssociationCC { }); } - @ccValue(AssociationCCValues.groupCount) public groupCount: number; public serialize(ctx: CCEncodingContext): Bytes { diff --git a/packages/cc/src/cc/AssociationGroupInfoCC.ts b/packages/cc/src/cc/AssociationGroupInfoCC.ts index 887d00b4db20..c4b8c99fa358 100644 --- a/packages/cc/src/cc/AssociationGroupInfoCC.ts +++ b/packages/cc/src/cc/AssociationGroupInfoCC.ts @@ -31,7 +31,7 @@ import { import { API, CCCommand, - ccValue, + ccValueProperty, ccValues, commandClass, expectedCCResponse, @@ -598,6 +598,7 @@ export interface AssociationGroupInfoCCInfoReportOptions { } @CCCommand(AssociationGroupInfoCommand.InfoReport) +@ccValueProperty("hasDynamicInfo", AssociationGroupInfoCCValues.hasDynamicInfo) export class AssociationGroupInfoCCInfoReport extends AssociationGroupInfoCC { public constructor( options: WithAddress, @@ -641,7 +642,6 @@ export class AssociationGroupInfoCCInfoReport extends AssociationGroupInfoCC { public readonly isListMode: boolean; - @ccValue(AssociationGroupInfoCCValues.hasDynamicInfo) public readonly hasDynamicInfo: boolean; public readonly groups: readonly AssociationGroupInfo[]; @@ -789,6 +789,11 @@ export interface AssociationGroupInfoCCCommandListReportOptions { } @CCCommand(AssociationGroupInfoCommand.CommandListReport) +@ccValueProperty( + "commands", + AssociationGroupInfoCCValues.commands, + (self) => [self.groupId], +) export class AssociationGroupInfoCCCommandListReport extends AssociationGroupInfoCC { @@ -830,11 +835,6 @@ export class AssociationGroupInfoCCCommandListReport public readonly groupId: number; - @ccValue( - AssociationGroupInfoCCValues.commands, - (self: AssociationGroupInfoCCCommandListReport) => - [self.groupId] as const, - ) public readonly commands: ReadonlyMap; public serialize(ctx: CCEncodingContext): Bytes { diff --git a/packages/cc/src/cc/BarrierOperatorCC.ts b/packages/cc/src/cc/BarrierOperatorCC.ts index f77aea5cf056..851aeb2a92e8 100644 --- a/packages/cc/src/cc/BarrierOperatorCC.ts +++ b/packages/cc/src/cc/BarrierOperatorCC.ts @@ -51,7 +51,7 @@ import { import { API, CCCommand, - ccValue, + ccValueProperty, ccValues, commandClass, expectedCCResponse, @@ -592,6 +592,8 @@ export interface BarrierOperatorCCReportOptions { } @CCCommand(BarrierOperatorCommand.Report) +@ccValueProperty("currentState", BarrierOperatorCCValues.currentState) +@ccValueProperty("position", BarrierOperatorCCValues.position) export class BarrierOperatorCCReport extends BarrierOperatorCC { public constructor( options: WithAddress, @@ -644,10 +646,8 @@ export class BarrierOperatorCCReport extends BarrierOperatorCC { }); } - @ccValue(BarrierOperatorCCValues.currentState) public readonly currentState: MaybeUnknown; - @ccValue(BarrierOperatorCCValues.position) public readonly position: MaybeUnknown; public toLogEntry(ctx?: GetValueDB): MessageOrCCLogEntry { @@ -673,6 +673,10 @@ export interface BarrierOperatorCCSignalingCapabilitiesReportOptions { } @CCCommand(BarrierOperatorCommand.SignalingCapabilitiesReport) +@ccValueProperty( + "supportedSubsystemTypes", + BarrierOperatorCCValues.supportedSubsystemTypes, +) export class BarrierOperatorCCSignalingCapabilitiesReport extends BarrierOperatorCC { @@ -702,7 +706,6 @@ export class BarrierOperatorCCSignalingCapabilitiesReport }); } - @ccValue(BarrierOperatorCCValues.supportedSubsystemTypes) public readonly supportedSubsystemTypes: readonly SubsystemType[]; public toLogEntry(ctx?: GetValueDB): MessageOrCCLogEntry { diff --git a/packages/cc/src/cc/BasicCC.ts b/packages/cc/src/cc/BasicCC.ts index 9ac6907512ad..9da6cd326962 100644 --- a/packages/cc/src/cc/BasicCC.ts +++ b/packages/cc/src/cc/BasicCC.ts @@ -52,7 +52,7 @@ import { import { API, CCCommand, - ccValue, + ccValueProperty, ccValues, commandClass, expectedCCResponse, @@ -418,6 +418,9 @@ export interface BasicCCReportOptions { } @CCCommand(BasicCommand.Report) +@ccValueProperty("currentValue", BasicCCValues.currentValue) +@ccValueProperty("targetValue", BasicCCValues.targetValue) +@ccValueProperty("duration", BasicCCValues.duration) export class BasicCCReport extends BasicCC { // @noCCValues See comment in the constructor public constructor( @@ -455,13 +458,10 @@ export class BasicCCReport extends BasicCC { }); } - @ccValue(BasicCCValues.currentValue) public currentValue: MaybeUnknown | undefined; - @ccValue(BasicCCValues.targetValue) public readonly targetValue: MaybeUnknown | undefined; - @ccValue(BasicCCValues.duration) public readonly duration: Duration | undefined; public persistValues(ctx: PersistValuesContext): boolean { diff --git a/packages/cc/src/cc/BatteryCC.ts b/packages/cc/src/cc/BatteryCC.ts index cae36cdb8b5d..c5965e377f0b 100644 --- a/packages/cc/src/cc/BatteryCC.ts +++ b/packages/cc/src/cc/BatteryCC.ts @@ -45,7 +45,7 @@ import { import { API, CCCommand, - ccValue, + ccValueProperty, ccValues, commandClass, expectedCCResponse, @@ -427,6 +427,16 @@ export type BatteryCCReportOptions = }>; @CCCommand(BatteryCommand.Report) +@ccValueProperty("level", BatteryCCValues.level) +@ccValueProperty("isLow", BatteryCCValues.isLow) +@ccValueProperty("chargingStatus", BatteryCCValues.chargingStatus) +@ccValueProperty("rechargeable", BatteryCCValues.rechargeable) +@ccValueProperty("backup", BatteryCCValues.backup) +@ccValueProperty("overheating", BatteryCCValues.overheating) +@ccValueProperty("lowFluid", BatteryCCValues.lowFluid) +@ccValueProperty("rechargeOrReplace", BatteryCCValues.rechargeOrReplace) +@ccValueProperty("disconnected", BatteryCCValues.disconnected) +@ccValueProperty("lowTemperatureStatus", BatteryCCValues.lowTemperatureStatus) export class BatteryCCReport extends BatteryCC { public constructor( options: WithAddress, @@ -535,34 +545,24 @@ export class BatteryCCReport extends BatteryCC { return true; } - @ccValue(BatteryCCValues.level) public readonly level: number; - @ccValue(BatteryCCValues.isLow) public readonly isLow: boolean; - @ccValue(BatteryCCValues.chargingStatus) public readonly chargingStatus: BatteryChargingStatus | undefined; - @ccValue(BatteryCCValues.rechargeable) public readonly rechargeable: boolean | undefined; - @ccValue(BatteryCCValues.backup) public readonly backup: boolean | undefined; - @ccValue(BatteryCCValues.overheating) public readonly overheating: boolean | undefined; - @ccValue(BatteryCCValues.lowFluid) public readonly lowFluid: boolean | undefined; - @ccValue(BatteryCCValues.rechargeOrReplace) public readonly rechargeOrReplace: BatteryReplacementStatus | undefined; - @ccValue(BatteryCCValues.disconnected) public readonly disconnected: boolean | undefined; - @ccValue(BatteryCCValues.lowTemperatureStatus) public readonly lowTemperatureStatus: boolean | undefined; public serialize(ctx: CCEncodingContext): Bytes { @@ -644,6 +644,8 @@ export interface BatteryCCHealthReportOptions { } @CCCommand(BatteryCommand.HealthReport) +@ccValueProperty("maximumCapacity", BatteryCCValues.maximumCapacity) +@ccValueProperty("temperature", BatteryCCValues.temperature) export class BatteryCCHealthReport extends BatteryCC { public constructor( options: WithAddress, @@ -693,10 +695,8 @@ export class BatteryCCHealthReport extends BatteryCC { return true; } - @ccValue(BatteryCCValues.maximumCapacity) public readonly maximumCapacity: number | undefined; - @ccValue(BatteryCCValues.temperature) public readonly temperature: number | undefined; private readonly temperatureScale: number | undefined; diff --git a/packages/cc/src/cc/BinarySensorCC.ts b/packages/cc/src/cc/BinarySensorCC.ts index 0b50c8aafd85..63001aa9b483 100644 --- a/packages/cc/src/cc/BinarySensorCC.ts +++ b/packages/cc/src/cc/BinarySensorCC.ts @@ -36,7 +36,7 @@ import { import { API, CCCommand, - ccValue, + ccValueProperty, ccValues, commandClass, expectedCCResponse, @@ -484,6 +484,10 @@ export interface BinarySensorCCSupportedReportOptions { } @CCCommand(BinarySensorCommand.SupportedReport) +@ccValueProperty( + "supportedSensorTypes", + BinarySensorCCValues.supportedSensorTypes, +) export class BinarySensorCCSupportedReport extends BinarySensorCC { public constructor( options: WithAddress, @@ -514,7 +518,6 @@ export class BinarySensorCCSupportedReport extends BinarySensorCC { }); } - @ccValue(BinarySensorCCValues.supportedSensorTypes) public supportedSensorTypes: BinarySensorType[]; public serialize(ctx: CCEncodingContext): Bytes { diff --git a/packages/cc/src/cc/BinarySwitchCC.ts b/packages/cc/src/cc/BinarySwitchCC.ts index e0d4a179d058..b1b179666df5 100644 --- a/packages/cc/src/cc/BinarySwitchCC.ts +++ b/packages/cc/src/cc/BinarySwitchCC.ts @@ -43,7 +43,7 @@ import { import { API, CCCommand, - ccValue, + ccValueProperty, ccValues, commandClass, expectedCCResponse, @@ -381,6 +381,9 @@ export interface BinarySwitchCCReportOptions { } @CCCommand(BinarySwitchCommand.Report) +@ccValueProperty("currentValue", BinarySwitchCCValues.currentValue) +@ccValueProperty("targetValue", BinarySwitchCCValues.targetValue) +@ccValueProperty("duration", BinarySwitchCCValues.duration) export class BinarySwitchCCReport extends BinarySwitchCC { public constructor( options: WithAddress, @@ -417,13 +420,10 @@ export class BinarySwitchCCReport extends BinarySwitchCC { }); } - @ccValue(BinarySwitchCCValues.currentValue) public readonly currentValue: MaybeUnknown | undefined; - @ccValue(BinarySwitchCCValues.targetValue) public readonly targetValue: MaybeUnknown | undefined; - @ccValue(BinarySwitchCCValues.duration) public readonly duration: Duration | undefined; public serialize(ctx: CCEncodingContext): Bytes { diff --git a/packages/cc/src/cc/CentralSceneCC.ts b/packages/cc/src/cc/CentralSceneCC.ts index 0bb971860374..6123a58c2cc8 100644 --- a/packages/cc/src/cc/CentralSceneCC.ts +++ b/packages/cc/src/cc/CentralSceneCC.ts @@ -42,7 +42,7 @@ import { import { API, CCCommand, - ccValue, + ccValueProperty, ccValues, commandClass, expectedCCResponse, @@ -392,6 +392,15 @@ export interface CentralSceneCCSupportedReportOptions { } @CCCommand(CentralSceneCommand.SupportedReport) +@ccValueProperty("sceneCount", CentralSceneCCValues.sceneCount) +@ccValueProperty( + "supportsSlowRefresh", + CentralSceneCCValues.supportsSlowRefresh, +) +@ccValueProperty( + "supportedKeyAttributes", + CentralSceneCCValues.supportedKeyAttributes, +) export class CentralSceneCCSupportedReport extends CentralSceneCC { public constructor( options: WithAddress, @@ -473,11 +482,10 @@ export class CentralSceneCCSupportedReport extends CentralSceneCC { return true; } - @ccValue(CentralSceneCCValues.sceneCount) public readonly sceneCount: number; // TODO: Only offer `slowRefresh` if this is true - @ccValue(CentralSceneCCValues.supportsSlowRefresh) + public readonly supportsSlowRefresh: MaybeNotKnown; private _supportedKeyAttributes = new Map< @@ -485,7 +493,6 @@ export class CentralSceneCCSupportedReport extends CentralSceneCC { readonly CentralSceneKeys[] >(); - @ccValue(CentralSceneCCValues.supportedKeyAttributes) public get supportedKeyAttributes(): ReadonlyMap< number, readonly CentralSceneKeys[] @@ -522,6 +529,7 @@ export interface CentralSceneCCConfigurationReportOptions { } @CCCommand(CentralSceneCommand.ConfigurationReport) +@ccValueProperty("slowRefresh", CentralSceneCCValues.slowRefresh) export class CentralSceneCCConfigurationReport extends CentralSceneCC { public constructor( options: WithAddress, @@ -545,7 +553,6 @@ export class CentralSceneCCConfigurationReport extends CentralSceneCC { }); } - @ccValue(CentralSceneCCValues.slowRefresh) public readonly slowRefresh: boolean; public toLogEntry(ctx?: GetValueDB): MessageOrCCLogEntry { diff --git a/packages/cc/src/cc/ClimateControlScheduleCC.ts b/packages/cc/src/cc/ClimateControlScheduleCC.ts index e2d05cd5ebe8..d87ae993bf3e 100644 --- a/packages/cc/src/cc/ClimateControlScheduleCC.ts +++ b/packages/cc/src/cc/ClimateControlScheduleCC.ts @@ -24,7 +24,7 @@ import { type CCRaw, CommandClass } from "../lib/CommandClass.js"; import { API, CCCommand, - ccValue, + ccValueProperty, ccValues, commandClass, expectedCCResponse, @@ -296,6 +296,11 @@ export interface ClimateControlScheduleCCReportOptions { } @CCCommand(ClimateControlScheduleCommand.Report) +@ccValueProperty( + "schedule", + ClimateControlScheduleCCValues.schedule, + (self) => [self.weekday], +) export class ClimateControlScheduleCCReport extends ClimateControlScheduleCC { public constructor( options: WithAddress, @@ -333,10 +338,6 @@ export class ClimateControlScheduleCCReport extends ClimateControlScheduleCC { public readonly weekday: Weekday; - @ccValue( - ClimateControlScheduleCCValues.schedule, - (self: ClimateControlScheduleCCReport) => [self.weekday] as const, - ) public readonly schedule: readonly Switchpoint[]; public toLogEntry(ctx?: GetValueDB): MessageOrCCLogEntry { @@ -461,6 +462,8 @@ export interface ClimateControlScheduleCCOverrideReportOptions { } @CCCommand(ClimateControlScheduleCommand.OverrideReport) +@ccValueProperty("overrideType", ClimateControlScheduleCCValues.overrideType) +@ccValueProperty("overrideState", ClimateControlScheduleCCValues.overrideState) export class ClimateControlScheduleCCOverrideReport extends ClimateControlScheduleCC { @@ -490,10 +493,8 @@ export class ClimateControlScheduleCCOverrideReport }); } - @ccValue(ClimateControlScheduleCCValues.overrideType) public readonly overrideType: ScheduleOverrideType; - @ccValue(ClimateControlScheduleCCValues.overrideState) public readonly overrideState: SetbackState; public toLogEntry(ctx?: GetValueDB): MessageOrCCLogEntry { diff --git a/packages/cc/src/cc/ColorSwitchCC.ts b/packages/cc/src/cc/ColorSwitchCC.ts index 0d20f4c810f1..7a599b2bb011 100644 --- a/packages/cc/src/cc/ColorSwitchCC.ts +++ b/packages/cc/src/cc/ColorSwitchCC.ts @@ -54,7 +54,7 @@ import { import { API, CCCommand, - ccValue, + ccValueProperty, ccValues, commandClass, expectedCCResponse, @@ -685,6 +685,10 @@ export interface ColorSwitchCCSupportedReportOptions { } @CCCommand(ColorSwitchCommand.SupportedReport) +@ccValueProperty( + "supportedColorComponents", + ColorSwitchCCValues.supportedColorComponents, +) export class ColorSwitchCCSupportedReport extends ColorSwitchCC { public constructor( options: WithAddress, @@ -711,7 +715,6 @@ export class ColorSwitchCCSupportedReport extends ColorSwitchCC { }); } - @ccValue(ColorSwitchCCValues.supportedColorComponents) public readonly supportedColorComponents: readonly ColorComponent[]; public serialize(ctx: CCEncodingContext): Bytes { @@ -748,6 +751,17 @@ export interface ColorSwitchCCReportOptions { } @CCCommand(ColorSwitchCommand.Report) +@ccValueProperty( + "currentValue", + ColorSwitchCCValues.currentColorChannel, + (self) => [self.colorComponent], +) +@ccValueProperty( + "targetValue", + ColorSwitchCCValues.targetColorChannel, + (self) => [self.colorComponent], +) +@ccValueProperty("duration", ColorSwitchCCValues.duration) export class ColorSwitchCCReport extends ColorSwitchCC { public constructor( options: WithAddress, @@ -844,19 +858,11 @@ export class ColorSwitchCCReport extends ColorSwitchCC { } public readonly colorComponent: ColorComponent; - @ccValue( - ColorSwitchCCValues.currentColorChannel, - (self: ColorSwitchCCReport) => [self.colorComponent] as const, - ) + public readonly currentValue: number; - @ccValue( - ColorSwitchCCValues.targetColorChannel, - (self: ColorSwitchCCReport) => [self.colorComponent] as const, - ) public readonly targetValue: number | undefined; - @ccValue(ColorSwitchCCValues.duration) public readonly duration: Duration | undefined; public serialize(ctx: CCEncodingContext): Bytes { diff --git a/packages/cc/src/cc/DoorLockCC.ts b/packages/cc/src/cc/DoorLockCC.ts index d122c68de592..0175e2f135ab 100644 --- a/packages/cc/src/cc/DoorLockCC.ts +++ b/packages/cc/src/cc/DoorLockCC.ts @@ -45,7 +45,7 @@ import { import { API, CCCommand, - ccValue, + ccValueProperty, ccValues, commandClass, expectedCCResponse, @@ -888,6 +888,18 @@ export interface DoorLockCCOperationReportOptions { } @CCCommand(DoorLockCommand.OperationReport) +@ccValueProperty("currentMode", DoorLockCCValues.currentMode) +@ccValueProperty("targetMode", DoorLockCCValues.targetMode) +@ccValueProperty("duration", DoorLockCCValues.duration) +@ccValueProperty( + "outsideHandlesCanOpenDoor", + DoorLockCCValues.outsideHandlesCanOpenDoor, +) +@ccValueProperty( + "insideHandlesCanOpenDoor", + DoorLockCCValues.insideHandlesCanOpenDoor, +) +@ccValueProperty("lockTimeout", DoorLockCCValues.lockTimeout) export class DoorLockCCOperationReport extends DoorLockCC { public constructor( options: WithAddress, @@ -1004,26 +1016,20 @@ export class DoorLockCCOperationReport extends DoorLockCC { return true; } - @ccValue(DoorLockCCValues.currentMode) public readonly currentMode: DoorLockMode; - @ccValue(DoorLockCCValues.targetMode) public readonly targetMode?: DoorLockMode; - @ccValue(DoorLockCCValues.duration) public readonly duration?: Duration; - @ccValue(DoorLockCCValues.outsideHandlesCanOpenDoor) public readonly outsideHandlesCanOpenDoor: DoorHandleStatus; - @ccValue(DoorLockCCValues.insideHandlesCanOpenDoor) public readonly insideHandlesCanOpenDoor: DoorHandleStatus; public readonly latchStatus?: "open" | "closed"; public readonly boltStatus?: "locked" | "unlocked"; public readonly doorStatus?: "open" | "closed"; - @ccValue(DoorLockCCValues.lockTimeout) public readonly lockTimeout?: number; // in seconds public toLogEntry(ctx?: GetValueDB): MessageOrCCLogEntry { @@ -1079,6 +1085,19 @@ export interface DoorLockCCConfigurationReportOptions { } @CCCommand(DoorLockCommand.ConfigurationReport) +@ccValueProperty("operationType", DoorLockCCValues.operationType) +@ccValueProperty( + "outsideHandlesCanOpenDoorConfiguration", + DoorLockCCValues.outsideHandlesCanOpenDoorConfiguration, +) +@ccValueProperty( + "insideHandlesCanOpenDoorConfiguration", + DoorLockCCValues.insideHandlesCanOpenDoorConfiguration, +) +@ccValueProperty( + "lockTimeoutConfiguration", + DoorLockCCValues.lockTimeoutConfiguration, +) export class DoorLockCCConfigurationReport extends DoorLockCC { public constructor( options: WithAddress, @@ -1152,16 +1171,12 @@ export class DoorLockCCConfigurationReport extends DoorLockCC { }); } - @ccValue(DoorLockCCValues.operationType) public readonly operationType: DoorLockOperationType; - @ccValue(DoorLockCCValues.outsideHandlesCanOpenDoorConfiguration) public readonly outsideHandlesCanOpenDoorConfiguration: DoorHandleStatus; - @ccValue(DoorLockCCValues.insideHandlesCanOpenDoorConfiguration) public readonly insideHandlesCanOpenDoorConfiguration: DoorHandleStatus; - @ccValue(DoorLockCCValues.lockTimeoutConfiguration) public readonly lockTimeoutConfiguration?: number; // These are not always supported and have to be persisted manually @@ -1443,6 +1458,24 @@ export interface DoorLockCCCapabilitiesReportOptions { } @CCCommand(DoorLockCommand.CapabilitiesReport) +@ccValueProperty( + "supportedOutsideHandles", + DoorLockCCValues.supportedOutsideHandles, +) +@ccValueProperty( + "supportedInsideHandles", + DoorLockCCValues.supportedInsideHandles, +) +@ccValueProperty("autoRelockSupported", DoorLockCCValues.autoRelockSupported) +@ccValueProperty( + "holdAndReleaseSupported", + DoorLockCCValues.holdAndReleaseSupported, +) +@ccValueProperty("twistAssistSupported", DoorLockCCValues.twistAssistSupported) +@ccValueProperty( + "blockToBlockSupported", + DoorLockCCValues.blockToBlockSupported, +) export class DoorLockCCCapabilitiesReport extends DoorLockCC { public constructor( options: WithAddress, @@ -1525,10 +1558,8 @@ export class DoorLockCCCapabilitiesReport extends DoorLockCC { public readonly supportedOperationTypes: readonly DoorLockOperationType[]; public readonly supportedDoorLockModes: readonly DoorLockMode[]; - @ccValue(DoorLockCCValues.supportedOutsideHandles) public readonly supportedOutsideHandles: DoorHandleStatus; - @ccValue(DoorLockCCValues.supportedInsideHandles) public readonly supportedInsideHandles: DoorHandleStatus; // These 3 are not automatically persisted because in CC version 3 @@ -1537,16 +1568,12 @@ export class DoorLockCCCapabilitiesReport extends DoorLockCC { public readonly boltSupported: boolean; public readonly doorSupported: boolean; - @ccValue(DoorLockCCValues.autoRelockSupported) public readonly autoRelockSupported: boolean; - @ccValue(DoorLockCCValues.holdAndReleaseSupported) public readonly holdAndReleaseSupported: boolean; - @ccValue(DoorLockCCValues.twistAssistSupported) public readonly twistAssistSupported: boolean; - @ccValue(DoorLockCCValues.blockToBlockSupported) public readonly blockToBlockSupported: boolean; public toLogEntry(ctx?: GetValueDB): MessageOrCCLogEntry { diff --git a/packages/cc/src/cc/DoorLockLoggingCC.ts b/packages/cc/src/cc/DoorLockLoggingCC.ts index 750cb50f9f99..93c43f8b96cf 100644 --- a/packages/cc/src/cc/DoorLockLoggingCC.ts +++ b/packages/cc/src/cc/DoorLockLoggingCC.ts @@ -27,7 +27,7 @@ import { import { API, CCCommand, - ccValue, + ccValueProperty, ccValues, commandClass, expectedCCResponse, @@ -236,6 +236,7 @@ export interface DoorLockLoggingCCRecordsSupportedReportOptions { } @CCCommand(DoorLockLoggingCommand.RecordsSupportedReport) +@ccValueProperty("recordsCount", DoorLockLoggingCCValues.recordsCount) export class DoorLockLoggingCCRecordsSupportedReport extends DoorLockLoggingCC { public constructor( options: WithAddress, @@ -259,7 +260,6 @@ export class DoorLockLoggingCCRecordsSupportedReport extends DoorLockLoggingCC { }); } - @ccValue(DoorLockLoggingCCValues.recordsCount) public readonly recordsCount: number; public toLogEntry(ctx?: GetValueDB): MessageOrCCLogEntry { diff --git a/packages/cc/src/cc/EntryControlCC.ts b/packages/cc/src/cc/EntryControlCC.ts index 6118de5e69b5..b128d27d1675 100644 --- a/packages/cc/src/cc/EntryControlCC.ts +++ b/packages/cc/src/cc/EntryControlCC.ts @@ -41,7 +41,7 @@ import { import { API, CCCommand, - ccValue, + ccValueProperty, ccValues, commandClass, expectedCCResponse, @@ -526,6 +526,7 @@ export interface EntryControlCCKeySupportedReportOptions { } @CCCommand(EntryControlCommand.KeySupportedReport) +@ccValueProperty("supportedKeys", EntryControlCCValues.supportedKeys) export class EntryControlCCKeySupportedReport extends EntryControlCC { public constructor( options: WithAddress, @@ -554,7 +555,6 @@ export class EntryControlCCKeySupportedReport extends EntryControlCC { }); } - @ccValue(EntryControlCCValues.supportedKeys) public readonly supportedKeys: readonly number[]; public toLogEntry(ctx?: GetValueDB): MessageOrCCLogEntry { @@ -580,6 +580,11 @@ export interface EntryControlCCEventSupportedReportOptions { } @CCCommand(EntryControlCommand.EventSupportedReport) +@ccValueProperty("supportedDataTypes", EntryControlCCValues.supportedDataTypes) +@ccValueProperty( + "supportedEventTypes", + EntryControlCCValues.supportedEventTypes, +) export class EntryControlCCEventSupportedReport extends EntryControlCC { public constructor( options: WithAddress, @@ -662,10 +667,8 @@ export class EntryControlCCEventSupportedReport extends EntryControlCC { return true; } - @ccValue(EntryControlCCValues.supportedDataTypes) public readonly supportedDataTypes: readonly EntryControlDataTypes[]; - @ccValue(EntryControlCCValues.supportedEventTypes) public readonly supportedEventTypes: readonly EntryControlEventTypes[]; public readonly minKeyCacheSize: number; @@ -703,6 +706,8 @@ export interface EntryControlCCConfigurationReportOptions { } @CCCommand(EntryControlCommand.ConfigurationReport) +@ccValueProperty("keyCacheSize", EntryControlCCValues.keyCacheSize) +@ccValueProperty("keyCacheTimeout", EntryControlCCValues.keyCacheTimeout) export class EntryControlCCConfigurationReport extends EntryControlCC { public constructor( options: WithAddress, @@ -730,10 +735,8 @@ export class EntryControlCCConfigurationReport extends EntryControlCC { }); } - @ccValue(EntryControlCCValues.keyCacheSize) public readonly keyCacheSize: number; - @ccValue(EntryControlCCValues.keyCacheTimeout) public readonly keyCacheTimeout: number; public toLogEntry(ctx?: GetValueDB): MessageOrCCLogEntry { diff --git a/packages/cc/src/cc/FirmwareUpdateMetaDataCC.ts b/packages/cc/src/cc/FirmwareUpdateMetaDataCC.ts index c0864fbccc06..95f93f951718 100644 --- a/packages/cc/src/cc/FirmwareUpdateMetaDataCC.ts +++ b/packages/cc/src/cc/FirmwareUpdateMetaDataCC.ts @@ -33,7 +33,7 @@ import { import { API, CCCommand, - ccValue, + ccValueProperty, ccValues, commandClass, expectedCCResponse, @@ -325,6 +325,30 @@ export interface FirmwareUpdateMetaDataCCMetaDataReportOptions { } @CCCommand(FirmwareUpdateMetaDataCommand.MetaDataReport) +@ccValueProperty( + "firmwareUpgradable", + FirmwareUpdateMetaDataCCValues.firmwareUpgradable, +) +@ccValueProperty( + "additionalFirmwareIDs", + FirmwareUpdateMetaDataCCValues.additionalFirmwareIDs, +) +@ccValueProperty( + "continuesToFunction", + FirmwareUpdateMetaDataCCValues.continuesToFunction, +) +@ccValueProperty( + "supportsActivation", + FirmwareUpdateMetaDataCCValues.supportsActivation, +) +@ccValueProperty( + "supportsResuming", + FirmwareUpdateMetaDataCCValues.supportsResuming, +) +@ccValueProperty( + "supportsNonSecureTransfer", + FirmwareUpdateMetaDataCCValues.supportsNonSecureTransfer, +) export class FirmwareUpdateMetaDataCCMetaDataReport extends FirmwareUpdateMetaDataCC implements FirmwareUpdateMetaData @@ -422,19 +446,19 @@ export class FirmwareUpdateMetaDataCCMetaDataReport public readonly manufacturerId: number; public readonly firmwareId: number; public readonly checksum: number; - @ccValue(FirmwareUpdateMetaDataCCValues.firmwareUpgradable) + public readonly firmwareUpgradable: boolean; public readonly maxFragmentSize?: number; - @ccValue(FirmwareUpdateMetaDataCCValues.additionalFirmwareIDs) + public readonly additionalFirmwareIDs: readonly number[] = []; public readonly hardwareVersion?: number; - @ccValue(FirmwareUpdateMetaDataCCValues.continuesToFunction) + public readonly continuesToFunction: MaybeNotKnown; - @ccValue(FirmwareUpdateMetaDataCCValues.supportsActivation) + public readonly supportsActivation: MaybeNotKnown; - @ccValue(FirmwareUpdateMetaDataCCValues.supportsResuming) + public readonly supportsResuming?: MaybeNotKnown; - @ccValue(FirmwareUpdateMetaDataCCValues.supportsNonSecureTransfer) + public readonly supportsNonSecureTransfer?: MaybeNotKnown; public serialize(ctx: CCEncodingContext): Bytes { diff --git a/packages/cc/src/cc/HumidityControlModeCC.ts b/packages/cc/src/cc/HumidityControlModeCC.ts index 2e57ddee5310..86df2cb7c1c2 100644 --- a/packages/cc/src/cc/HumidityControlModeCC.ts +++ b/packages/cc/src/cc/HumidityControlModeCC.ts @@ -40,7 +40,7 @@ import { import { API, CCCommand, - ccValue, + ccValueProperty, ccValues, commandClass, expectedCCResponse, @@ -334,6 +334,7 @@ export interface HumidityControlModeCCReportOptions { } @CCCommand(HumidityControlModeCommand.Report) +@ccValueProperty("mode", HumidityControlModeCCValues.mode) export class HumidityControlModeCCReport extends HumidityControlModeCC { public constructor( options: WithAddress, @@ -357,7 +358,6 @@ export class HumidityControlModeCCReport extends HumidityControlModeCC { }); } - @ccValue(HumidityControlModeCCValues.mode) public readonly mode: HumidityControlMode; public toLogEntry(ctx?: GetValueDB): MessageOrCCLogEntry { @@ -380,6 +380,7 @@ export interface HumidityControlModeCCSupportedReportOptions { } @CCCommand(HumidityControlModeCommand.SupportedReport) +@ccValueProperty("supportedModes", HumidityControlModeCCValues.supportedModes) export class HumidityControlModeCCSupportedReport extends HumidityControlModeCC { @@ -427,7 +428,6 @@ export class HumidityControlModeCCSupportedReport return true; } - @ccValue(HumidityControlModeCCValues.supportedModes) public supportedModes: HumidityControlMode[]; public toLogEntry(ctx?: GetValueDB): MessageOrCCLogEntry { diff --git a/packages/cc/src/cc/HumidityControlOperatingStateCC.ts b/packages/cc/src/cc/HumidityControlOperatingStateCC.ts index 0de2c16eb538..b4eabf30ce0b 100644 --- a/packages/cc/src/cc/HumidityControlOperatingStateCC.ts +++ b/packages/cc/src/cc/HumidityControlOperatingStateCC.ts @@ -25,7 +25,7 @@ import { import { API, CCCommand, - ccValue, + ccValueProperty, ccValues, commandClass, expectedCCResponse, @@ -167,6 +167,7 @@ export interface HumidityControlOperatingStateCCReportOptions { } @CCCommand(HumidityControlOperatingStateCommand.Report) +@ccValueProperty("state", HumidityControlOperatingStateCCValues.state) export class HumidityControlOperatingStateCCReport extends HumidityControlOperatingStateCC { @@ -192,7 +193,6 @@ export class HumidityControlOperatingStateCCReport }); } - @ccValue(HumidityControlOperatingStateCCValues.state) public readonly state: HumidityControlOperatingState; public toLogEntry(ctx?: GetValueDB): MessageOrCCLogEntry { diff --git a/packages/cc/src/cc/HumidityControlSetpointCC.ts b/packages/cc/src/cc/HumidityControlSetpointCC.ts index 8c64c4f31178..4a8735a47cc1 100644 --- a/packages/cc/src/cc/HumidityControlSetpointCC.ts +++ b/packages/cc/src/cc/HumidityControlSetpointCC.ts @@ -45,7 +45,7 @@ import { import { API, CCCommand, - ccValue, + ccValueProperty, ccValues, commandClass, expectedCCResponse, @@ -741,6 +741,10 @@ export interface HumidityControlSetpointCCSupportedReportOptions { } @CCCommand(HumidityControlSetpointCommand.SupportedReport) +@ccValueProperty( + "supportedSetpointTypes", + HumidityControlSetpointCCValues.supportedSetpointTypes, +) export class HumidityControlSetpointCCSupportedReport extends HumidityControlSetpointCC { @@ -770,7 +774,6 @@ export class HumidityControlSetpointCCSupportedReport }); } - @ccValue(HumidityControlSetpointCCValues.supportedSetpointTypes) public readonly supportedSetpointTypes: readonly HumidityControlSetpointType[]; diff --git a/packages/cc/src/cc/IrrigationCC.ts b/packages/cc/src/cc/IrrigationCC.ts index 95cfe5d2f358..f65b4b2e218a 100644 --- a/packages/cc/src/cc/IrrigationCC.ts +++ b/packages/cc/src/cc/IrrigationCC.ts @@ -46,7 +46,7 @@ import { import { API, CCCommand, - ccValue, + ccValueProperty, ccValues, commandClass, expectedCCResponse, @@ -1357,6 +1357,10 @@ export interface IrrigationCCSystemInfoReportOptions { } @CCCommand(IrrigationCommand.SystemInfoReport) +@ccValueProperty("numValves", IrrigationCCValues.numValves) +@ccValueProperty("numValveTables", IrrigationCCValues.numValveTables) +@ccValueProperty("supportsMasterValve", IrrigationCCValues.supportsMasterValve) +@ccValueProperty("maxValveTableSize", IrrigationCCValues.maxValveTableSize) export class IrrigationCCSystemInfoReport extends IrrigationCC { public constructor( options: WithAddress, @@ -1389,16 +1393,12 @@ export class IrrigationCCSystemInfoReport extends IrrigationCC { }); } - @ccValue(IrrigationCCValues.numValves) public readonly numValves: number; - @ccValue(IrrigationCCValues.numValveTables) public readonly numValveTables: number; - @ccValue(IrrigationCCValues.supportsMasterValve) public readonly supportsMasterValve: boolean; - @ccValue(IrrigationCCValues.maxValveTableSize) public readonly maxValveTableSize: number; public toLogEntry(ctx?: GetValueDB): MessageOrCCLogEntry { @@ -1438,6 +1438,30 @@ export interface IrrigationCCSystemStatusReportOptions { } @CCCommand(IrrigationCommand.SystemStatusReport) +@ccValueProperty("systemVoltage", IrrigationCCValues.systemVoltage) +@ccValueProperty("flowSensorActive", IrrigationCCValues.flowSensorActive) +@ccValueProperty( + "pressureSensorActive", + IrrigationCCValues.pressureSensorActive, +) +@ccValueProperty("rainSensorActive", IrrigationCCValues.rainSensorActive) +@ccValueProperty( + "moistureSensorActive", + IrrigationCCValues.moistureSensorActive, +) +@ccValueProperty("flow", IrrigationCCValues.flow) +@ccValueProperty("pressure", IrrigationCCValues.pressure) +@ccValueProperty("shutoffDuration", IrrigationCCValues.shutoffDuration) +@ccValueProperty("errorNotProgrammed", IrrigationCCValues.errorNotProgrammed) +@ccValueProperty( + "errorEmergencyShutdown", + IrrigationCCValues.errorEmergencyShutdown, +) +@ccValueProperty("errorHighPressure", IrrigationCCValues.errorHighPressure) +@ccValueProperty("errorLowPressure", IrrigationCCValues.errorLowPressure) +@ccValueProperty("errorValve", IrrigationCCValues.errorValve) +@ccValueProperty("masterValveOpen", IrrigationCCValues.masterValveOpen) +@ccValueProperty("firstOpenZoneId", IrrigationCCValues.firstOpenZoneId) export class IrrigationCCSystemStatusReport extends IrrigationCC { public constructor( options: WithAddress, @@ -1526,49 +1550,34 @@ export class IrrigationCCSystemStatusReport extends IrrigationCC { }); } - @ccValue(IrrigationCCValues.systemVoltage) public systemVoltage: number; - @ccValue(IrrigationCCValues.flowSensorActive) public flowSensorActive: boolean; - @ccValue(IrrigationCCValues.pressureSensorActive) public pressureSensorActive: boolean; - @ccValue(IrrigationCCValues.rainSensorActive) public rainSensorActive: boolean; - @ccValue(IrrigationCCValues.moistureSensorActive) public moistureSensorActive: boolean; - @ccValue(IrrigationCCValues.flow) public flow?: number; - @ccValue(IrrigationCCValues.pressure) public pressure?: number; - @ccValue(IrrigationCCValues.shutoffDuration) public shutoffDuration: number; - @ccValue(IrrigationCCValues.errorNotProgrammed) public errorNotProgrammed: boolean; - @ccValue(IrrigationCCValues.errorEmergencyShutdown) public errorEmergencyShutdown: boolean; - @ccValue(IrrigationCCValues.errorHighPressure) public errorHighPressure: boolean; - @ccValue(IrrigationCCValues.errorLowPressure) public errorLowPressure: boolean; - @ccValue(IrrigationCCValues.errorValve) public errorValve: boolean; - @ccValue(IrrigationCCValues.masterValveOpen) public masterValveOpen: boolean; - @ccValue(IrrigationCCValues.firstOpenZoneId) public firstOpenZoneId?: number; public toLogEntry(ctx?: GetValueDB): MessageOrCCLogEntry { @@ -1721,6 +1730,20 @@ export interface IrrigationCCSystemConfigReportOptions { } @CCCommand(IrrigationCommand.SystemConfigReport) +@ccValueProperty("masterValveDelay", IrrigationCCValues.masterValveDelay) +@ccValueProperty( + "highPressureThreshold", + IrrigationCCValues.highPressureThreshold, +) +@ccValueProperty( + "lowPressureThreshold", + IrrigationCCValues.lowPressureThreshold, +) +@ccValueProperty("rainSensorPolarity", IrrigationCCValues.rainSensorPolarity) +@ccValueProperty( + "moistureSensorPolarity", + IrrigationCCValues.moistureSensorPolarity, +) export class IrrigationCCSystemConfigReport extends IrrigationCC { public constructor( options: WithAddress, @@ -1782,19 +1805,14 @@ export class IrrigationCCSystemConfigReport extends IrrigationCC { }); } - @ccValue(IrrigationCCValues.masterValveDelay) public readonly masterValveDelay: number; - @ccValue(IrrigationCCValues.highPressureThreshold) public readonly highPressureThreshold: number; - @ccValue(IrrigationCCValues.lowPressureThreshold) public readonly lowPressureThreshold: number; - @ccValue(IrrigationCCValues.rainSensorPolarity) public readonly rainSensorPolarity?: IrrigationSensorPolarity; - @ccValue(IrrigationCCValues.moistureSensorPolarity) public readonly moistureSensorPolarity?: IrrigationSensorPolarity; public toLogEntry(ctx?: GetValueDB): MessageOrCCLogEntry { diff --git a/packages/cc/src/cc/LanguageCC.ts b/packages/cc/src/cc/LanguageCC.ts index d721abb27131..d15c2829ca1b 100644 --- a/packages/cc/src/cc/LanguageCC.ts +++ b/packages/cc/src/cc/LanguageCC.ts @@ -31,7 +31,7 @@ import { import { API, CCCommand, - ccValue, + ccValueProperty, ccValues, commandClass, expectedCCResponse, @@ -254,6 +254,8 @@ export interface LanguageCCReportOptions { } @CCCommand(LanguageCommand.Report) +@ccValueProperty("language", LanguageCCValues.language) +@ccValueProperty("country", LanguageCCValues.country) export class LanguageCCReport extends LanguageCC { public constructor( options: WithAddress, @@ -278,10 +280,8 @@ export class LanguageCCReport extends LanguageCC { }); } - @ccValue(LanguageCCValues.language) public readonly language: string; - @ccValue(LanguageCCValues.country) public readonly country: MaybeNotKnown; public toLogEntry(ctx?: GetValueDB): MessageOrCCLogEntry { diff --git a/packages/cc/src/cc/LockCC.ts b/packages/cc/src/cc/LockCC.ts index ffbcaa64dc7f..5dcd84dff1bb 100644 --- a/packages/cc/src/cc/LockCC.ts +++ b/packages/cc/src/cc/LockCC.ts @@ -37,7 +37,7 @@ import { import { API, CCCommand, - ccValue, + ccValueProperty, ccValues, commandClass, expectedCCResponse, @@ -230,6 +230,7 @@ export interface LockCCReportOptions { } @CCCommand(LockCommand.Report) +@ccValueProperty("locked", LockCCValues.locked) export class LockCCReport extends LockCC { public constructor( options: WithAddress, @@ -250,7 +251,6 @@ export class LockCCReport extends LockCC { }); } - @ccValue(LockCCValues.locked) public readonly locked: boolean; public toLogEntry(ctx?: GetValueDB): MessageOrCCLogEntry { diff --git a/packages/cc/src/cc/ManufacturerSpecificCC.ts b/packages/cc/src/cc/ManufacturerSpecificCC.ts index 705d94df22d8..c2c15a375f76 100644 --- a/packages/cc/src/cc/ManufacturerSpecificCC.ts +++ b/packages/cc/src/cc/ManufacturerSpecificCC.ts @@ -25,7 +25,7 @@ import { import { API, CCCommand, - ccValue, + ccValueProperty, ccValues, commandClass, expectedCCResponse, @@ -234,6 +234,9 @@ export interface ManufacturerSpecificCCReportOptions { } @CCCommand(ManufacturerSpecificCommand.Report) +@ccValueProperty("manufacturerId", ManufacturerSpecificCCValues.manufacturerId) +@ccValueProperty("productType", ManufacturerSpecificCCValues.productType) +@ccValueProperty("productId", ManufacturerSpecificCCValues.productId) export class ManufacturerSpecificCCReport extends ManufacturerSpecificCC { public constructor( options: WithAddress, @@ -262,13 +265,10 @@ export class ManufacturerSpecificCCReport extends ManufacturerSpecificCC { }); } - @ccValue(ManufacturerSpecificCCValues.manufacturerId) public readonly manufacturerId: number; - @ccValue(ManufacturerSpecificCCValues.productType) public readonly productType: number; - @ccValue(ManufacturerSpecificCCValues.productId) public readonly productId: number; public serialize(ctx: CCEncodingContext): Bytes { @@ -302,6 +302,11 @@ export interface ManufacturerSpecificCCDeviceSpecificReportOptions { } @CCCommand(ManufacturerSpecificCommand.DeviceSpecificReport) +@ccValueProperty( + "deviceId", + ManufacturerSpecificCCValues.deviceId, + (self) => [self.type], +) export class ManufacturerSpecificCCDeviceSpecificReport extends ManufacturerSpecificCC { @@ -338,11 +343,6 @@ export class ManufacturerSpecificCCDeviceSpecificReport public readonly type: DeviceIdType; - @ccValue( - ManufacturerSpecificCCValues.deviceId, - (self: ManufacturerSpecificCCDeviceSpecificReport) => - [self.type] as const, - ) public readonly deviceId: string; public toLogEntry(ctx?: GetValueDB): MessageOrCCLogEntry { diff --git a/packages/cc/src/cc/MeterCC.ts b/packages/cc/src/cc/MeterCC.ts index 9dfc7cf98dc7..2232780a2359 100644 --- a/packages/cc/src/cc/MeterCC.ts +++ b/packages/cc/src/cc/MeterCC.ts @@ -71,7 +71,7 @@ import { import { API, CCCommand, - ccValue, + ccValueProperty, ccValues, commandClass, expectedCCResponse, @@ -1228,6 +1228,10 @@ export interface MeterCCSupportedReportOptions { } @CCCommand(MeterCommand.SupportedReport) +@ccValueProperty("type", MeterCCValues.type) +@ccValueProperty("supportsReset", MeterCCValues.supportsReset) +@ccValueProperty("supportedScales", MeterCCValues.supportedScales) +@ccValueProperty("supportedRateTypes", MeterCCValues.supportedRateTypes) export class MeterCCSupportedReport extends MeterCC { public constructor( options: WithAddress, @@ -1286,16 +1290,12 @@ export class MeterCCSupportedReport extends MeterCC { }); } - @ccValue(MeterCCValues.type) public readonly type: number; - @ccValue(MeterCCValues.supportsReset) public readonly supportsReset: boolean; - @ccValue(MeterCCValues.supportedScales) public readonly supportedScales: readonly number[]; - @ccValue(MeterCCValues.supportedRateTypes) public readonly supportedRateTypes: readonly RateType[]; public persistValues(ctx: PersistValuesContext): boolean { diff --git a/packages/cc/src/cc/MultiChannelAssociationCC.ts b/packages/cc/src/cc/MultiChannelAssociationCC.ts index 3530213d9dc2..8105920848f9 100644 --- a/packages/cc/src/cc/MultiChannelAssociationCC.ts +++ b/packages/cc/src/cc/MultiChannelAssociationCC.ts @@ -34,7 +34,7 @@ import { import { API, CCCommand, - ccValue, + ccValueProperty, ccValues, commandClass, expectedCCResponse, @@ -777,6 +777,21 @@ export interface MultiChannelAssociationCCReportOptions { } @CCCommand(MultiChannelAssociationCommand.Report) +@ccValueProperty( + "maxNodes", + MultiChannelAssociationCCValues.maxNodes, + (self) => [self.groupId], +) +@ccValueProperty( + "nodeIds", + MultiChannelAssociationCCValues.nodeIds, + (self) => [self.groupId], +) +@ccValueProperty( + "endpoints", + MultiChannelAssociationCCValues.endpoints, + (self) => [self.groupId], +) export class MultiChannelAssociationCCReport extends MultiChannelAssociationCC { public constructor( options: WithAddress, @@ -816,22 +831,10 @@ export class MultiChannelAssociationCCReport extends MultiChannelAssociationCC { public readonly groupId: number; - @ccValue( - MultiChannelAssociationCCValues.maxNodes, - (self: MultiChannelAssociationCCReport) => [self.groupId] as const, - ) public maxNodes: number; - @ccValue( - MultiChannelAssociationCCValues.nodeIds, - (self: MultiChannelAssociationCCReport) => [self.groupId] as const, - ) public nodeIds: number[]; - @ccValue( - MultiChannelAssociationCCValues.endpoints, - (self: MultiChannelAssociationCCReport) => [self.groupId] as const, - ) public endpoints: EndpointAddress[]; public reportsToFollow: number; @@ -943,6 +946,7 @@ export interface MultiChannelAssociationCCSupportedGroupingsReportOptions { } @CCCommand(MultiChannelAssociationCommand.SupportedGroupingsReport) +@ccValueProperty("groupCount", MultiChannelAssociationCCValues.groupCount) export class MultiChannelAssociationCCSupportedGroupingsReport extends MultiChannelAssociationCC { @@ -969,7 +973,6 @@ export class MultiChannelAssociationCCSupportedGroupingsReport }); } - @ccValue(MultiChannelAssociationCCValues.groupCount) public readonly groupCount: number; public serialize(ctx: CCEncodingContext): Bytes { diff --git a/packages/cc/src/cc/MultiChannelCC.ts b/packages/cc/src/cc/MultiChannelCC.ts index 7fa26113f3ea..22c2e8113c7e 100644 --- a/packages/cc/src/cc/MultiChannelCC.ts +++ b/packages/cc/src/cc/MultiChannelCC.ts @@ -38,7 +38,7 @@ import { import { API, CCCommand, - ccValue, + ccValueProperty, ccValues, commandClass, expectedCCResponse, @@ -815,6 +815,19 @@ export interface MultiChannelCCEndPointReportOptions { } @CCCommand(MultiChannelCommand.EndPointReport) +@ccValueProperty("countIsDynamic", MultiChannelCCValues.endpointCountIsDynamic) +@ccValueProperty( + "identicalCapabilities", + MultiChannelCCValues.endpointsHaveIdenticalCapabilities, +) +@ccValueProperty( + "individualCount", + MultiChannelCCValues.individualEndpointCount, +) +@ccValueProperty( + "aggregatedCount", + MultiChannelCCValues.aggregatedEndpointCount, +) export class MultiChannelCCEndPointReport extends MultiChannelCC { public constructor( options: WithAddress, @@ -850,16 +863,12 @@ export class MultiChannelCCEndPointReport extends MultiChannelCC { }); } - @ccValue(MultiChannelCCValues.endpointCountIsDynamic) public countIsDynamic: boolean; - @ccValue(MultiChannelCCValues.endpointsHaveIdenticalCapabilities) public identicalCapabilities: boolean; - @ccValue(MultiChannelCCValues.individualEndpointCount) public individualCount: number; - @ccValue(MultiChannelCCValues.aggregatedEndpointCount) public aggregatedCount: MaybeNotKnown; public serialize(ctx: CCEncodingContext): Bytes { @@ -1227,6 +1236,11 @@ export interface MultiChannelCCAggregatedMembersReportOptions { } @CCCommand(MultiChannelCommand.AggregatedMembersReport) +@ccValueProperty( + "members", + MultiChannelCCValues.aggregatedEndpointMembers, + (self) => [self.aggregatedEndpointIndex], +) export class MultiChannelCCAggregatedMembersReport extends MultiChannelCC { public constructor( options: WithAddress, @@ -1258,11 +1272,6 @@ export class MultiChannelCCAggregatedMembersReport extends MultiChannelCC { public readonly aggregatedEndpointIndex: number; - @ccValue( - MultiChannelCCValues.aggregatedEndpointMembers, - (self: MultiChannelCCAggregatedMembersReport) => - [self.aggregatedEndpointIndex] as const, - ) public readonly members: readonly number[]; public toLogEntry(ctx?: GetValueDB): MessageOrCCLogEntry { diff --git a/packages/cc/src/cc/MultilevelSensorCC.ts b/packages/cc/src/cc/MultilevelSensorCC.ts index e82072a695b9..77fd80b5c021 100644 --- a/packages/cc/src/cc/MultilevelSensorCC.ts +++ b/packages/cc/src/cc/MultilevelSensorCC.ts @@ -62,7 +62,7 @@ import { import { API, CCCommand, - ccValue, + ccValueProperty, ccValues, commandClass, expectedCCResponse, @@ -869,6 +869,10 @@ export interface MultilevelSensorCCSupportedSensorReportOptions { } @CCCommand(MultilevelSensorCommand.SupportedSensorReport) +@ccValueProperty( + "supportedSensorTypes", + MultilevelSensorCCValues.supportedSensorTypes, +) export class MultilevelSensorCCSupportedSensorReport extends MultilevelSensorCC { @@ -894,7 +898,7 @@ export class MultilevelSensorCCSupportedSensorReport } // TODO: Use this during interview to precreate values - @ccValue(MultilevelSensorCCValues.supportedSensorTypes) + public supportedSensorTypes: readonly number[]; public serialize(ctx: CCEncodingContext): Bytes { @@ -925,6 +929,11 @@ export interface MultilevelSensorCCSupportedScaleReportOptions { } @CCCommand(MultilevelSensorCommand.SupportedScaleReport) +@ccValueProperty( + "supportedScales", + MultilevelSensorCCValues.supportedScales, + (self) => [self.sensorType], +) export class MultilevelSensorCCSupportedScaleReport extends MultilevelSensorCC { public constructor( options: WithAddress, @@ -955,11 +964,6 @@ export class MultilevelSensorCCSupportedScaleReport extends MultilevelSensorCC { public readonly sensorType: number; - @ccValue( - MultilevelSensorCCValues.supportedScales, - (self: MultilevelSensorCCSupportedScaleReport) => - [self.sensorType] as const, - ) public readonly supportedScales: readonly number[]; public serialize(ctx: CCEncodingContext): Bytes { diff --git a/packages/cc/src/cc/MultilevelSwitchCC.ts b/packages/cc/src/cc/MultilevelSwitchCC.ts index efcbeccdac13..9bce0d771af7 100644 --- a/packages/cc/src/cc/MultilevelSwitchCC.ts +++ b/packages/cc/src/cc/MultilevelSwitchCC.ts @@ -44,7 +44,7 @@ import { import { API, CCCommand, - ccValue, + ccValueProperty, ccValues, commandClass, expectedCCResponse, @@ -699,6 +699,9 @@ export interface MultilevelSwitchCCReportOptions { } @CCCommand(MultilevelSwitchCommand.Report) +@ccValueProperty("targetValue", MultilevelSwitchCCValues.targetValue) +@ccValueProperty("duration", MultilevelSwitchCCValues.duration) +@ccValueProperty("currentValue", MultilevelSwitchCCValues.currentValue) export class MultilevelSwitchCCReport extends MultilevelSwitchCC { public constructor( options: WithAddress, @@ -736,13 +739,10 @@ export class MultilevelSwitchCCReport extends MultilevelSwitchCC { }); } - @ccValue(MultilevelSwitchCCValues.targetValue) public targetValue: MaybeUnknown | undefined; - @ccValue(MultilevelSwitchCCValues.duration) public duration: Duration | undefined; - @ccValue(MultilevelSwitchCCValues.currentValue) public currentValue: MaybeUnknown | undefined; public serialize(ctx: CCEncodingContext): Bytes { @@ -884,6 +884,7 @@ export interface MultilevelSwitchCCSupportedReportOptions { } @CCCommand(MultilevelSwitchCommand.SupportedReport) +@ccValueProperty("switchType", MultilevelSwitchCCValues.switchType) export class MultilevelSwitchCCSupportedReport extends MultilevelSwitchCC { public constructor( options: WithAddress, @@ -907,7 +908,7 @@ export class MultilevelSwitchCCSupportedReport extends MultilevelSwitchCC { } // This is the primary switch type. We're not supporting secondary switch types - @ccValue(MultilevelSwitchCCValues.switchType) + public readonly switchType: SwitchType; public persistValues(ctx: PersistValuesContext): boolean { diff --git a/packages/cc/src/cc/NodeNamingCC.ts b/packages/cc/src/cc/NodeNamingCC.ts index 786fea6deae9..d8c219dfd18a 100644 --- a/packages/cc/src/cc/NodeNamingCC.ts +++ b/packages/cc/src/cc/NodeNamingCC.ts @@ -40,7 +40,7 @@ import { import { API, CCCommand, - ccValue, + ccValueProperty, ccValues, commandClass, expectedCCResponse, @@ -337,6 +337,7 @@ export interface NodeNamingAndLocationCCNameReportOptions { } @CCCommand(NodeNamingAndLocationCommand.NameReport) +@ccValueProperty("name", NodeNamingAndLocationCCValues.name) export class NodeNamingAndLocationCCNameReport extends NodeNamingAndLocationCC { public constructor( options: WithAddress, @@ -366,7 +367,6 @@ export class NodeNamingAndLocationCCNameReport extends NodeNamingAndLocationCC { }); } - @ccValue(NodeNamingAndLocationCCValues.name) public readonly name: string; public toLogEntry(ctx?: GetValueDB): MessageOrCCLogEntry { @@ -449,6 +449,7 @@ export interface NodeNamingAndLocationCCLocationReportOptions { } @CCCommand(NodeNamingAndLocationCommand.LocationReport) +@ccValueProperty("location", NodeNamingAndLocationCCValues.location) export class NodeNamingAndLocationCCLocationReport extends NodeNamingAndLocationCC { @@ -480,7 +481,6 @@ export class NodeNamingAndLocationCCLocationReport }); } - @ccValue(NodeNamingAndLocationCCValues.location) public readonly location: string; public toLogEntry(ctx?: GetValueDB): MessageOrCCLogEntry { diff --git a/packages/cc/src/cc/NotificationCC.ts b/packages/cc/src/cc/NotificationCC.ts index b0058fae4481..e03b15a08f49 100644 --- a/packages/cc/src/cc/NotificationCC.ts +++ b/packages/cc/src/cc/NotificationCC.ts @@ -68,7 +68,7 @@ import { import { API, CCCommand, - ccValue, + ccValueProperty, ccValues, commandClass, expectedCCResponse, @@ -1563,6 +1563,11 @@ export interface NotificationCCSupportedReportOptions { } @CCCommand(NotificationCommand.SupportedReport) +@ccValueProperty("supportsV1Alarm", NotificationCCValues.supportsV1Alarm) +@ccValueProperty( + "supportedNotificationTypes", + NotificationCCValues.supportedNotificationTypes, +) export class NotificationCCSupportedReport extends NotificationCC { public constructor( options: WithAddress, @@ -1601,10 +1606,8 @@ export class NotificationCCSupportedReport extends NotificationCC { }); } - @ccValue(NotificationCCValues.supportsV1Alarm) public supportsV1Alarm: boolean; - @ccValue(NotificationCCValues.supportedNotificationTypes) public supportedNotificationTypes: number[]; public serialize(ctx: CCEncodingContext): Bytes { diff --git a/packages/cc/src/cc/ProtectionCC.ts b/packages/cc/src/cc/ProtectionCC.ts index e16671eca8cf..11e74f5deb3c 100644 --- a/packages/cc/src/cc/ProtectionCC.ts +++ b/packages/cc/src/cc/ProtectionCC.ts @@ -44,7 +44,7 @@ import { import { API, CCCommand, - ccValue, + ccValueProperty, ccValues, commandClass, expectedCCResponse, @@ -571,6 +571,8 @@ export interface ProtectionCCReportOptions { } @CCCommand(ProtectionCommand.Report) +@ccValueProperty("local", ProtectionCCValues.localProtectionState) +@ccValueProperty("rf", ProtectionCCValues.rfProtectionState) export class ProtectionCCReport extends ProtectionCC { public constructor( options: WithAddress, @@ -597,10 +599,8 @@ export class ProtectionCCReport extends ProtectionCC { }); } - @ccValue(ProtectionCCValues.localProtectionState) public readonly local: LocalProtectionState; - @ccValue(ProtectionCCValues.rfProtectionState) public readonly rf?: RFProtectionState; public toLogEntry(ctx?: GetValueDB): MessageOrCCLogEntry { @@ -630,6 +630,16 @@ export interface ProtectionCCSupportedReportOptions { } @CCCommand(ProtectionCommand.SupportedReport) +@ccValueProperty( + "supportsExclusiveControl", + ProtectionCCValues.supportsExclusiveControl, +) +@ccValueProperty("supportsTimeout", ProtectionCCValues.supportsTimeout) +@ccValueProperty( + "supportedLocalStates", + ProtectionCCValues.supportedLocalStates, +) +@ccValueProperty("supportedRFStates", ProtectionCCValues.supportedRFStates) export class ProtectionCCSupportedReport extends ProtectionCC { public constructor( options: WithAddress, @@ -693,16 +703,12 @@ export class ProtectionCCSupportedReport extends ProtectionCC { return true; } - @ccValue(ProtectionCCValues.supportsExclusiveControl) public readonly supportsExclusiveControl: boolean; - @ccValue(ProtectionCCValues.supportsTimeout) public readonly supportsTimeout: boolean; - @ccValue(ProtectionCCValues.supportedLocalStates) public readonly supportedLocalStates: LocalProtectionState[]; - @ccValue(ProtectionCCValues.supportedRFStates) public readonly supportedRFStates: RFProtectionState[]; public toLogEntry(ctx?: GetValueDB): MessageOrCCLogEntry { @@ -736,6 +742,10 @@ export interface ProtectionCCExclusiveControlReportOptions { } @CCCommand(ProtectionCommand.ExclusiveControlReport) +@ccValueProperty( + "exclusiveControlNodeId", + ProtectionCCValues.exclusiveControlNodeId, +) export class ProtectionCCExclusiveControlReport extends ProtectionCC { public constructor( options: WithAddress, @@ -759,7 +769,6 @@ export class ProtectionCCExclusiveControlReport extends ProtectionCC { }); } - @ccValue(ProtectionCCValues.exclusiveControlNodeId) public readonly exclusiveControlNodeId: number; public toLogEntry(ctx?: GetValueDB): MessageOrCCLogEntry { @@ -830,6 +839,7 @@ export interface ProtectionCCTimeoutReportOptions { } @CCCommand(ProtectionCommand.TimeoutReport) +@ccValueProperty("timeout", ProtectionCCValues.timeout) export class ProtectionCCTimeoutReport extends ProtectionCC { public constructor( options: WithAddress, @@ -853,7 +863,6 @@ export class ProtectionCCTimeoutReport extends ProtectionCC { }); } - @ccValue(ProtectionCCValues.timeout) public readonly timeout: Timeout; public toLogEntry(ctx?: GetValueDB): MessageOrCCLogEntry { diff --git a/packages/cc/src/cc/SceneActivationCC.ts b/packages/cc/src/cc/SceneActivationCC.ts index 293e2f8f6698..92225a7dda64 100644 --- a/packages/cc/src/cc/SceneActivationCC.ts +++ b/packages/cc/src/cc/SceneActivationCC.ts @@ -29,7 +29,7 @@ import { type CCRaw, CommandClass } from "../lib/CommandClass.js"; import { API, CCCommand, - ccValue, + ccValueProperty, ccValues, commandClass, implementedVersion, @@ -134,6 +134,8 @@ export interface SceneActivationCCSetOptions { @CCCommand(SceneActivationCommand.Set) @useSupervision() +@ccValueProperty("sceneId", SceneActivationCCValues.sceneId) +@ccValueProperty("dimmingDuration", SceneActivationCCValues.dimmingDuration) export class SceneActivationCCSet extends SceneActivationCC { public constructor( options: WithAddress, @@ -164,10 +166,8 @@ export class SceneActivationCCSet extends SceneActivationCC { }); } - @ccValue(SceneActivationCCValues.sceneId) public sceneId: number; - @ccValue(SceneActivationCCValues.dimmingDuration) public dimmingDuration: Duration | undefined; public serialize(ctx: CCEncodingContext): Bytes { diff --git a/packages/cc/src/cc/ScheduleEntryLockCC.ts b/packages/cc/src/cc/ScheduleEntryLockCC.ts index 83144af72add..e4abb0c48e6c 100644 --- a/packages/cc/src/cc/ScheduleEntryLockCC.ts +++ b/packages/cc/src/cc/ScheduleEntryLockCC.ts @@ -38,7 +38,7 @@ import { import { API, CCCommand, - ccValue, + ccValueProperty, ccValues, commandClass, expectedCCResponse, @@ -1026,6 +1026,12 @@ export interface ScheduleEntryLockCCSupportedReportOptions { } @CCCommand(ScheduleEntryLockCommand.SupportedReport) +@ccValueProperty("numWeekDaySlots", ScheduleEntryLockCCValues.numWeekDaySlots) +@ccValueProperty("numYearDaySlots", ScheduleEntryLockCCValues.numYearDaySlots) +@ccValueProperty( + "numDailyRepeatingSlots", + ScheduleEntryLockCCValues.numDailyRepeatingSlots, +) export class ScheduleEntryLockCCSupportedReport extends ScheduleEntryLockCC { public constructor( options: WithAddress, @@ -1056,11 +1062,10 @@ export class ScheduleEntryLockCCSupportedReport extends ScheduleEntryLockCC { }); } - @ccValue(ScheduleEntryLockCCValues.numWeekDaySlots) public numWeekDaySlots: number; - @ccValue(ScheduleEntryLockCCValues.numYearDaySlots) + public numYearDaySlots: number; - @ccValue(ScheduleEntryLockCCValues.numDailyRepeatingSlots) + public numDailyRepeatingSlots: number | undefined; public serialize(ctx: CCEncodingContext): Bytes { diff --git a/packages/cc/src/cc/SoundSwitchCC.ts b/packages/cc/src/cc/SoundSwitchCC.ts index 1c503ecac43b..2897bef83ae1 100644 --- a/packages/cc/src/cc/SoundSwitchCC.ts +++ b/packages/cc/src/cc/SoundSwitchCC.ts @@ -39,7 +39,7 @@ import { import { API, CCCommand, - ccValue, + ccValueProperty, ccValues, commandClass, expectedCCResponse, @@ -692,6 +692,8 @@ export interface SoundSwitchCCConfigurationReportOptions { } @CCCommand(SoundSwitchCommand.ConfigurationReport) +@ccValueProperty("defaultVolume", SoundSwitchCCValues.defaultVolume) +@ccValueProperty("defaultToneId", SoundSwitchCCValues.defaultToneId) export class SoundSwitchCCConfigurationReport extends SoundSwitchCC { public constructor( options: WithAddress, @@ -716,10 +718,8 @@ export class SoundSwitchCCConfigurationReport extends SoundSwitchCC { }); } - @ccValue(SoundSwitchCCValues.defaultVolume) public defaultVolume: number; - @ccValue(SoundSwitchCCValues.defaultToneId) public defaultToneId: number; public serialize(ctx: CCEncodingContext): Bytes { @@ -808,6 +808,8 @@ export interface SoundSwitchCCTonePlayReportOptions { } @CCCommand(SoundSwitchCommand.TonePlayReport) +@ccValueProperty("toneId", SoundSwitchCCValues.toneId) +@ccValueProperty("volume", SoundSwitchCCValues.volume) export class SoundSwitchCCTonePlayReport extends SoundSwitchCC { public constructor( options: WithAddress, @@ -836,10 +838,8 @@ export class SoundSwitchCCTonePlayReport extends SoundSwitchCC { }); } - @ccValue(SoundSwitchCCValues.toneId) public readonly toneId: ToneId | number; - @ccValue(SoundSwitchCCValues.volume) public volume?: number; public serialize(ctx: CCEncodingContext): Bytes { diff --git a/packages/cc/src/cc/ThermostatFanModeCC.ts b/packages/cc/src/cc/ThermostatFanModeCC.ts index 514297a4b204..859fc4da89a8 100644 --- a/packages/cc/src/cc/ThermostatFanModeCC.ts +++ b/packages/cc/src/cc/ThermostatFanModeCC.ts @@ -41,7 +41,7 @@ import { import { API, CCCommand, - ccValue, + ccValueProperty, ccValues, commandClass, expectedCCResponse, @@ -396,6 +396,8 @@ export interface ThermostatFanModeCCReportOptions { } @CCCommand(ThermostatFanModeCommand.Report) +@ccValueProperty("mode", ThermostatFanModeCCValues.fanMode) +@ccValueProperty("off", ThermostatFanModeCCValues.turnedOff) export class ThermostatFanModeCCReport extends ThermostatFanModeCC { public constructor( options: WithAddress, @@ -423,10 +425,8 @@ export class ThermostatFanModeCCReport extends ThermostatFanModeCC { }); } - @ccValue(ThermostatFanModeCCValues.fanMode) public readonly mode: ThermostatFanMode; - @ccValue(ThermostatFanModeCCValues.turnedOff) public readonly off: boolean | undefined; public toLogEntry(ctx?: GetValueDB): MessageOrCCLogEntry { @@ -453,6 +453,7 @@ export interface ThermostatFanModeCCSupportedReportOptions { } @CCCommand(ThermostatFanModeCommand.SupportedReport) +@ccValueProperty("supportedModes", ThermostatFanModeCCValues.supportedFanModes) export class ThermostatFanModeCCSupportedReport extends ThermostatFanModeCC { public constructor( options: WithAddress, @@ -494,7 +495,6 @@ export class ThermostatFanModeCCSupportedReport extends ThermostatFanModeCC { return true; } - @ccValue(ThermostatFanModeCCValues.supportedFanModes) public readonly supportedModes: ThermostatFanMode[]; public toLogEntry(ctx?: GetValueDB): MessageOrCCLogEntry { diff --git a/packages/cc/src/cc/ThermostatFanStateCC.ts b/packages/cc/src/cc/ThermostatFanStateCC.ts index ea8325577786..9b7c5b2d2a2d 100644 --- a/packages/cc/src/cc/ThermostatFanStateCC.ts +++ b/packages/cc/src/cc/ThermostatFanStateCC.ts @@ -26,7 +26,7 @@ import { import { API, CCCommand, - ccValue, + ccValueProperty, ccValues, commandClass, expectedCCResponse, @@ -159,6 +159,7 @@ export interface ThermostatFanStateCCReportOptions { } @CCCommand(ThermostatFanStateCommand.Report) +@ccValueProperty("state", ThermostatFanStateCCValues.fanState) export class ThermostatFanStateCCReport extends ThermostatFanStateCC { public constructor( options: WithAddress, @@ -182,7 +183,6 @@ export class ThermostatFanStateCCReport extends ThermostatFanStateCC { }); } - @ccValue(ThermostatFanStateCCValues.fanState) public readonly state: ThermostatFanState; public toLogEntry(ctx?: GetValueDB): MessageOrCCLogEntry { diff --git a/packages/cc/src/cc/ThermostatModeCC.ts b/packages/cc/src/cc/ThermostatModeCC.ts index efef3642a9b6..15434c2f2b2d 100644 --- a/packages/cc/src/cc/ThermostatModeCC.ts +++ b/packages/cc/src/cc/ThermostatModeCC.ts @@ -42,7 +42,7 @@ import { import { API, CCCommand, - ccValue, + ccValueProperty, ccValues, commandClass, expectedCCResponse, @@ -408,6 +408,8 @@ export type ThermostatModeCCReportOptions = }; @CCCommand(ThermostatModeCommand.Report) +@ccValueProperty("mode", ThermostatModeCCValues.thermostatMode) +@ccValueProperty("manufacturerData", ThermostatModeCCValues.manufacturerData) export class ThermostatModeCCReport extends ThermostatModeCC { public constructor( options: WithAddress, @@ -482,10 +484,8 @@ export class ThermostatModeCCReport extends ThermostatModeCC { return true; } - @ccValue(ThermostatModeCCValues.thermostatMode) public readonly mode: ThermostatMode; - @ccValue(ThermostatModeCCValues.manufacturerData) public readonly manufacturerData: Uint8Array | undefined; public serialize(ctx: CCEncodingContext): Bytes { @@ -529,6 +529,7 @@ export interface ThermostatModeCCSupportedReportOptions { } @CCCommand(ThermostatModeCommand.SupportedReport) +@ccValueProperty("supportedModes", ThermostatModeCCValues.supportedModes) export class ThermostatModeCCSupportedReport extends ThermostatModeCC { public constructor( options: WithAddress, @@ -568,7 +569,6 @@ export class ThermostatModeCCSupportedReport extends ThermostatModeCC { return true; } - @ccValue(ThermostatModeCCValues.supportedModes) public readonly supportedModes: ThermostatMode[]; public serialize(ctx: CCEncodingContext): Bytes { diff --git a/packages/cc/src/cc/ThermostatOperatingStateCC.ts b/packages/cc/src/cc/ThermostatOperatingStateCC.ts index 93a0c5f0c8ea..1d02c316b4f9 100644 --- a/packages/cc/src/cc/ThermostatOperatingStateCC.ts +++ b/packages/cc/src/cc/ThermostatOperatingStateCC.ts @@ -25,7 +25,7 @@ import { import { API, CCCommand, - ccValue, + ccValueProperty, ccValues, commandClass, expectedCCResponse, @@ -164,6 +164,7 @@ export interface ThermostatOperatingStateCCReportOptions { } @CCCommand(ThermostatOperatingStateCommand.Report) +@ccValueProperty("state", ThermostatOperatingStateCCValues.operatingState) export class ThermostatOperatingStateCCReport extends ThermostatOperatingStateCC { @@ -189,7 +190,6 @@ export class ThermostatOperatingStateCCReport }); } - @ccValue(ThermostatOperatingStateCCValues.operatingState) public readonly state: ThermostatOperatingState; public toLogEntry(ctx?: GetValueDB): MessageOrCCLogEntry { diff --git a/packages/cc/src/cc/ThermostatSetpointCC.ts b/packages/cc/src/cc/ThermostatSetpointCC.ts index d1cebcbf73f9..23ee828bc13e 100644 --- a/packages/cc/src/cc/ThermostatSetpointCC.ts +++ b/packages/cc/src/cc/ThermostatSetpointCC.ts @@ -46,7 +46,7 @@ import { import { API, CCCommand, - ccValue, + ccValueProperty, ccValues, commandClass, expectedCCResponse, @@ -927,6 +927,10 @@ export interface ThermostatSetpointCCSupportedReportOptions { } @CCCommand(ThermostatSetpointCommand.SupportedReport) +@ccValueProperty( + "supportedSetpointTypes", + ThermostatSetpointCCValues.supportedSetpointTypes, +) export class ThermostatSetpointCCSupportedReport extends ThermostatSetpointCC { public constructor( options: WithAddress, @@ -964,7 +968,6 @@ export class ThermostatSetpointCCSupportedReport extends ThermostatSetpointCC { }); } - @ccValue(ThermostatSetpointCCValues.supportedSetpointTypes) public readonly supportedSetpointTypes: readonly ThermostatSetpointType[]; public serialize(ctx: CCEncodingContext): Bytes { diff --git a/packages/cc/src/cc/TimeParametersCC.ts b/packages/cc/src/cc/TimeParametersCC.ts index 3b49f245f209..4c3309992700 100644 --- a/packages/cc/src/cc/TimeParametersCC.ts +++ b/packages/cc/src/cc/TimeParametersCC.ts @@ -40,7 +40,7 @@ import { import { API, CCCommand, - ccValue, + ccValueProperty, ccValues, commandClass, expectedCCResponse, @@ -262,6 +262,7 @@ export interface TimeParametersCCReportOptions { } @CCCommand(TimeParametersCommand.Report) +@ccValueProperty("dateAndTime", TimeParametersCCValues.dateAndTime) export class TimeParametersCCReport extends TimeParametersCC { public constructor( options: WithAddress, @@ -309,7 +310,6 @@ export class TimeParametersCCReport extends TimeParametersCC { return super.persistValues(ctx); } - @ccValue(TimeParametersCCValues.dateAndTime) public dateAndTime: Date; public toLogEntry(ctx?: GetValueDB): MessageOrCCLogEntry { diff --git a/packages/cc/src/cc/UserCodeCC.ts b/packages/cc/src/cc/UserCodeCC.ts index 0b8b5ffe5173..9764adf7e5ce 100644 --- a/packages/cc/src/cc/UserCodeCC.ts +++ b/packages/cc/src/cc/UserCodeCC.ts @@ -54,7 +54,7 @@ import { import { API, CCCommand, - ccValue, + ccValueProperty, ccValues, commandClass, expectedCCResponse, @@ -1487,6 +1487,7 @@ export interface UserCodeCCUsersNumberReportOptions { } @CCCommand(UserCodeCommand.UsersNumberReport) +@ccValueProperty("supportedUsers", UserCodeCCValues.supportedUsers) export class UserCodeCCUsersNumberReport extends UserCodeCC { public constructor( options: WithAddress, @@ -1518,7 +1519,6 @@ export class UserCodeCCUsersNumberReport extends UserCodeCC { }); } - @ccValue(UserCodeCCValues.supportedUsers) public readonly supportedUsers: number; public serialize(ctx: CCEncodingContext): Bytes { @@ -1554,6 +1554,29 @@ export interface UserCodeCCCapabilitiesReportOptions { } @CCCommand(UserCodeCommand.CapabilitiesReport) +@ccValueProperty("supportsAdminCode", UserCodeCCValues.supportsAdminCode) +@ccValueProperty( + "supportsAdminCodeDeactivation", + UserCodeCCValues.supportsAdminCodeDeactivation, +) +@ccValueProperty( + "supportsUserCodeChecksum", + UserCodeCCValues.supportsUserCodeChecksum, +) +@ccValueProperty( + "supportsMultipleUserCodeReport", + UserCodeCCValues.supportsMultipleUserCodeReport, +) +@ccValueProperty( + "supportsMultipleUserCodeSet", + UserCodeCCValues.supportsMultipleUserCodeSet, +) +@ccValueProperty( + "supportedUserIDStatuses", + UserCodeCCValues.supportedUserIDStatuses, +) +@ccValueProperty("supportedKeypadModes", UserCodeCCValues.supportedKeypadModes) +@ccValueProperty("supportedASCIIChars", UserCodeCCValues.supportedASCIIChars) export class UserCodeCCCapabilitiesReport extends UserCodeCC { public constructor( options: WithAddress, @@ -1644,28 +1667,20 @@ export class UserCodeCCCapabilitiesReport extends UserCodeCC { }); } - @ccValue(UserCodeCCValues.supportsAdminCode) public readonly supportsAdminCode: boolean; - @ccValue(UserCodeCCValues.supportsAdminCodeDeactivation) public readonly supportsAdminCodeDeactivation: boolean; - @ccValue(UserCodeCCValues.supportsUserCodeChecksum) public readonly supportsUserCodeChecksum: boolean; - @ccValue(UserCodeCCValues.supportsMultipleUserCodeReport) public readonly supportsMultipleUserCodeReport: boolean; - @ccValue(UserCodeCCValues.supportsMultipleUserCodeSet) public readonly supportsMultipleUserCodeSet: boolean; - @ccValue(UserCodeCCValues.supportedUserIDStatuses) public readonly supportedUserIDStatuses: readonly UserIDStatus[]; - @ccValue(UserCodeCCValues.supportedKeypadModes) public readonly supportedKeypadModes: readonly KeypadMode[]; - @ccValue(UserCodeCCValues.supportedASCIIChars) public readonly supportedASCIIChars: string; public serialize(ctx: CCEncodingContext): Bytes { @@ -1785,6 +1800,7 @@ export interface UserCodeCCKeypadModeReportOptions { } @CCCommand(UserCodeCommand.KeypadModeReport) +@ccValueProperty("keypadMode", UserCodeCCValues.keypadMode) export class UserCodeCCKeypadModeReport extends UserCodeCC { public constructor( options: WithAddress, @@ -1827,7 +1843,6 @@ export class UserCodeCCKeypadModeReport extends UserCodeCC { return true; } - @ccValue(UserCodeCCValues.keypadMode) public readonly keypadMode: KeypadMode; public serialize(ctx: CCEncodingContext): Bytes { @@ -1905,6 +1920,7 @@ export interface UserCodeCCAdminCodeReportOptions { } @CCCommand(UserCodeCommand.AdminCodeReport) +@ccValueProperty("adminCode", UserCodeCCValues.adminCode) export class UserCodeCCAdminCodeReport extends UserCodeCC { public constructor( options: WithAddress, @@ -1930,7 +1946,6 @@ export class UserCodeCCAdminCodeReport extends UserCodeCC { }); } - @ccValue(UserCodeCCValues.adminCode) public readonly adminCode: string; public serialize(ctx: CCEncodingContext): Bytes { @@ -1959,6 +1974,7 @@ export interface UserCodeCCUserCodeChecksumReportOptions { } @CCCommand(UserCodeCommand.UserCodeChecksumReport) +@ccValueProperty("userCodeChecksum", UserCodeCCValues.userCodeChecksum) export class UserCodeCCUserCodeChecksumReport extends UserCodeCC { public constructor( options: WithAddress, @@ -1980,7 +1996,6 @@ export class UserCodeCCUserCodeChecksumReport extends UserCodeCC { }); } - @ccValue(UserCodeCCValues.userCodeChecksum) public readonly userCodeChecksum: number; public serialize(ctx: CCEncodingContext): Bytes { diff --git a/packages/cc/src/cc/VersionCC.ts b/packages/cc/src/cc/VersionCC.ts index 4a108216c304..07a08b830854 100644 --- a/packages/cc/src/cc/VersionCC.ts +++ b/packages/cc/src/cc/VersionCC.ts @@ -33,7 +33,7 @@ import { import { API, CCCommand, - ccValue, + ccValueProperty, ccValues, commandClass, expectedCCResponse, @@ -650,6 +650,10 @@ export interface VersionCCReportOptions { } @CCCommand(VersionCommand.Report) +@ccValueProperty("libraryType", VersionCCValues.libraryType) +@ccValueProperty("protocolVersion", VersionCCValues.protocolVersion) +@ccValueProperty("firmwareVersions", VersionCCValues.firmwareVersions) +@ccValueProperty("hardwareVersion", VersionCCValues.hardwareVersion) export class VersionCCReport extends VersionCC { public constructor( options: WithAddress, @@ -711,16 +715,12 @@ export class VersionCCReport extends VersionCC { }); } - @ccValue(VersionCCValues.libraryType) public readonly libraryType: ZWaveLibraryTypes; - @ccValue(VersionCCValues.protocolVersion) public readonly protocolVersion: string; - @ccValue(VersionCCValues.firmwareVersions) public readonly firmwareVersions: string[]; - @ccValue(VersionCCValues.hardwareVersion) public readonly hardwareVersion: number | undefined; public serialize(ctx: CCEncodingContext): Bytes { @@ -888,6 +888,10 @@ export interface VersionCCCapabilitiesReportOptions { } @CCCommand(VersionCommand.CapabilitiesReport) +@ccValueProperty( + "supportsZWaveSoftwareGet", + VersionCCValues.supportsZWaveSoftwareGet, +) export class VersionCCCapabilitiesReport extends VersionCC { public constructor( options: WithAddress, @@ -911,7 +915,6 @@ export class VersionCCCapabilitiesReport extends VersionCC { }); } - @ccValue(VersionCCValues.supportsZWaveSoftwareGet) public supportsZWaveSoftwareGet: boolean; public serialize(ctx: CCEncodingContext): Bytes { @@ -950,6 +953,30 @@ export interface VersionCCZWaveSoftwareReportOptions { } @CCCommand(VersionCommand.ZWaveSoftwareReport) +@ccValueProperty("sdkVersion", VersionCCValues.sdkVersion) +@ccValueProperty( + "applicationFrameworkAPIVersion", + VersionCCValues.applicationFrameworkAPIVersion, +) +@ccValueProperty( + "applicationFrameworkBuildNumber", + VersionCCValues.applicationFrameworkBuildNumber, +) +@ccValueProperty("hostInterfaceVersion", VersionCCValues.serialAPIVersion) +@ccValueProperty( + "hostInterfaceBuildNumber", + VersionCCValues.serialAPIBuildNumber, +) +@ccValueProperty("zWaveProtocolVersion", VersionCCValues.zWaveProtocolVersion) +@ccValueProperty( + "zWaveProtocolBuildNumber", + VersionCCValues.zWaveProtocolBuildNumber, +) +@ccValueProperty("applicationVersion", VersionCCValues.applicationVersion) +@ccValueProperty( + "applicationBuildNumber", + VersionCCValues.applicationBuildNumber, +) export class VersionCCZWaveSoftwareReport extends VersionCC { public constructor( options: WithAddress, @@ -1024,31 +1051,22 @@ export class VersionCCZWaveSoftwareReport extends VersionCC { }); } - @ccValue(VersionCCValues.sdkVersion) public readonly sdkVersion: string; - @ccValue(VersionCCValues.applicationFrameworkAPIVersion) public readonly applicationFrameworkAPIVersion: string; - @ccValue(VersionCCValues.applicationFrameworkBuildNumber) public readonly applicationFrameworkBuildNumber: number; - @ccValue(VersionCCValues.serialAPIVersion) public readonly hostInterfaceVersion: string; - @ccValue(VersionCCValues.serialAPIBuildNumber) public readonly hostInterfaceBuildNumber: number; - @ccValue(VersionCCValues.zWaveProtocolVersion) public readonly zWaveProtocolVersion: string; - @ccValue(VersionCCValues.zWaveProtocolBuildNumber) public readonly zWaveProtocolBuildNumber: number; - @ccValue(VersionCCValues.applicationVersion) public readonly applicationVersion: string; - @ccValue(VersionCCValues.applicationBuildNumber) public readonly applicationBuildNumber: number; public toLogEntry(ctx?: GetValueDB): MessageOrCCLogEntry { diff --git a/packages/cc/src/cc/WakeUpCC.ts b/packages/cc/src/cc/WakeUpCC.ts index e3c6fed9544d..70d25f3c7f71 100644 --- a/packages/cc/src/cc/WakeUpCC.ts +++ b/packages/cc/src/cc/WakeUpCC.ts @@ -37,7 +37,7 @@ import { import { API, CCCommand, - ccValue, + ccValueProperty, ccValues, commandClass, expectedCCResponse, @@ -415,6 +415,8 @@ export interface WakeUpCCIntervalReportOptions { } @CCCommand(WakeUpCommand.IntervalReport) +@ccValueProperty("wakeUpInterval", WakeUpCCValues.wakeUpInterval) +@ccValueProperty("controllerNodeId", WakeUpCCValues.controllerNodeId) export class WakeUpCCIntervalReport extends WakeUpCC { public constructor( options: WithAddress, @@ -441,10 +443,8 @@ export class WakeUpCCIntervalReport extends WakeUpCC { }); } - @ccValue(WakeUpCCValues.wakeUpInterval) public readonly wakeUpInterval: number; - @ccValue(WakeUpCCValues.controllerNodeId) public readonly controllerNodeId: number; public toLogEntry(ctx?: GetValueDB): MessageOrCCLogEntry { @@ -478,6 +478,10 @@ export interface WakeUpCCIntervalCapabilitiesReportOptions { } @CCCommand(WakeUpCommand.IntervalCapabilitiesReport) +@ccValueProperty( + "wakeUpOnDemandSupported", + WakeUpCCValues.wakeUpOnDemandSupported, +) export class WakeUpCCIntervalCapabilitiesReport extends WakeUpCC { public constructor( options: WithAddress, @@ -547,7 +551,6 @@ export class WakeUpCCIntervalCapabilitiesReport extends WakeUpCC { public readonly defaultWakeUpInterval: number; public readonly wakeUpIntervalSteps: number; - @ccValue(WakeUpCCValues.wakeUpOnDemandSupported) public readonly wakeUpOnDemandSupported: boolean; public toLogEntry(ctx?: GetValueDB): MessageOrCCLogEntry { diff --git a/packages/cc/src/cc/WindowCoveringCC.ts b/packages/cc/src/cc/WindowCoveringCC.ts index 4a6e63ae1088..584b5ba7e829 100644 --- a/packages/cc/src/cc/WindowCoveringCC.ts +++ b/packages/cc/src/cc/WindowCoveringCC.ts @@ -41,7 +41,7 @@ import { import { API, CCCommand, - ccValue, + ccValueProperty, ccValues, commandClass, expectedCCResponse, @@ -686,6 +686,10 @@ export interface WindowCoveringCCSupportedReportOptions { } @CCCommand(WindowCoveringCommand.SupportedReport) +@ccValueProperty( + "supportedParameters", + WindowCoveringCCValues.supportedParameters, +) export class WindowCoveringCCSupportedReport extends WindowCoveringCC { public constructor( options: WithAddress, @@ -714,7 +718,6 @@ export class WindowCoveringCCSupportedReport extends WindowCoveringCC { }); } - @ccValue(WindowCoveringCCValues.supportedParameters) public readonly supportedParameters: readonly WindowCoveringParameter[]; public serialize(ctx: CCEncodingContext): Bytes { @@ -766,6 +769,21 @@ export interface WindowCoveringCCReportOptions { } @CCCommand(WindowCoveringCommand.Report) +@ccValueProperty( + "currentValue", + WindowCoveringCCValues.currentValue, + (self) => [self.parameter], +) +@ccValueProperty( + "targetValue", + WindowCoveringCCValues.targetValue, + (self) => [self.parameter], +) +@ccValueProperty( + "duration", + WindowCoveringCCValues.duration, + (self) => [self.parameter], +) export class WindowCoveringCCReport extends WindowCoveringCC { public constructor( options: WithAddress, @@ -801,20 +819,10 @@ export class WindowCoveringCCReport extends WindowCoveringCC { public readonly parameter: WindowCoveringParameter; - @ccValue( - WindowCoveringCCValues.currentValue, - (self: WindowCoveringCCReport) => [self.parameter] as const, - ) public readonly currentValue: number; - @ccValue( - WindowCoveringCCValues.targetValue, - (self: WindowCoveringCCReport) => [self.parameter] as const, - ) + public readonly targetValue: number; - @ccValue( - WindowCoveringCCValues.duration, - (self: WindowCoveringCCReport) => [self.parameter] as const, - ) + public readonly duration: Duration; public toLogEntry(ctx?: GetValueDB): MessageOrCCLogEntry { diff --git a/packages/cc/src/cc/ZWavePlusCC.ts b/packages/cc/src/cc/ZWavePlusCC.ts index 205d8032e67a..38b050a7e3b1 100644 --- a/packages/cc/src/cc/ZWavePlusCC.ts +++ b/packages/cc/src/cc/ZWavePlusCC.ts @@ -23,7 +23,7 @@ import { import { API, CCCommand, - ccValue, + ccValueProperty, ccValues, commandClass, expectedCCResponse, @@ -177,6 +177,11 @@ export interface ZWavePlusCCReportOptions { } @CCCommand(ZWavePlusCommand.Report) +@ccValueProperty("zwavePlusVersion", ZWavePlusCCValues.zwavePlusVersion) +@ccValueProperty("nodeType", ZWavePlusCCValues.nodeType) +@ccValueProperty("roleType", ZWavePlusCCValues.roleType) +@ccValueProperty("installerIcon", ZWavePlusCCValues.installerIcon) +@ccValueProperty("userIcon", ZWavePlusCCValues.userIcon) export class ZWavePlusCCReport extends ZWavePlusCC { public constructor( options: WithAddress, @@ -207,19 +212,14 @@ export class ZWavePlusCCReport extends ZWavePlusCC { }); } - @ccValue(ZWavePlusCCValues.zwavePlusVersion) public zwavePlusVersion: number; - @ccValue(ZWavePlusCCValues.nodeType) public nodeType: ZWavePlusNodeType; - @ccValue(ZWavePlusCCValues.roleType) public roleType: ZWavePlusRoleType; - @ccValue(ZWavePlusCCValues.installerIcon) public installerIcon: number; - @ccValue(ZWavePlusCCValues.userIcon) public userIcon: number; public serialize(ctx: CCEncodingContext): Bytes { diff --git a/packages/cc/src/cc/manufacturerProprietary/Decorators.ts b/packages/cc/src/cc/manufacturerProprietary/Decorators.ts index 7ef80eef59ad..21c7f3aa5828 100644 --- a/packages/cc/src/cc/manufacturerProprietary/Decorators.ts +++ b/packages/cc/src/cc/manufacturerProprietary/Decorators.ts @@ -15,7 +15,7 @@ import type { FibaroCC } from "./FibaroCC.js"; // === Define the manufacturer ID for a given Manufacturer Proprietary CC subclass const manufacturerIdDecorator = createSimpleReflectionDecorator< - ManufacturerProprietaryCC, + typeof ManufacturerProprietaryCC, [manufacturerId: number], ManufacturerProprietaryCCConstructor >({ @@ -60,7 +60,7 @@ export const getManufacturerProprietaryCCConstructor = manufacturerIdDecorator.lookupConstructor; const manufacturerProprietaryAPIDecorator = createSimpleReflectionDecorator< - CCAPI, + typeof CCAPI, [manufacturerId: number], APIConstructor >({ @@ -86,7 +86,7 @@ export const getManufacturerProprietaryAPI = // Decorators for easy lookup const FibaroCCAndCommandDecorator = createReflectionDecoratorPair< - FibaroCC, + typeof FibaroCC, [fibaroCCId: number], [fibaroCCCommand: number], ManufacturerProprietaryCCConstructor diff --git a/packages/cc/src/lib/CommandClassDecorators.ts b/packages/cc/src/lib/CommandClassDecorators.ts index 39bd0d340940..c0a54a090122 100644 --- a/packages/cc/src/lib/CommandClassDecorators.ts +++ b/packages/cc/src/lib/CommandClassDecorators.ts @@ -6,16 +6,13 @@ import { createReflectionDecoratorPair, createValuelessReflectionDecorator, } from "@zwave-js/core"; -import type { - TypedClassDecorator, - TypedPropertyDecorator, -} from "@zwave-js/shared"; +import type { TypedClassDecorator } from "@zwave-js/shared"; import type { APIConstructor, CCAPI } from "./API.js"; -import type { - CCConstructor, - CCResponsePredicate, - CommandClass, - DynamicCCResponse, +import { + type CCConstructor, + type CCResponsePredicate, + type CommandClass, + type DynamicCCResponse, } from "./CommandClass.js"; import type { DynamicCCValue, @@ -24,7 +21,7 @@ import type { } from "./Values.js"; const CCAndCommandDecorator = createReflectionDecoratorPair< - CommandClass, + typeof CommandClass, [ccId: CommandClasses], [ccCommand: number], CCConstructor @@ -80,7 +77,7 @@ export function getCommandClassStatic>( } const apiDecorator = createReflectionDecorator< - CCAPI, + typeof CCAPI, [cc: CommandClasses], CommandClasses, APIConstructor @@ -111,8 +108,10 @@ export function getCommandClass(cc: CommandClass | CCAPI): CommandClasses { // get the class constructor const constr = cc.constructor; // retrieve the current metadata - const ret = CCAndCommandDecorator.lookupSuperValueStatic(constr) - ?? apiDecorator.lookupValueStatic(constr); + const ret = CCAndCommandDecorator.lookupSuperValueStatic( + constr as typeof CommandClass, + ) + ?? apiDecorator.lookupValueStatic(constr as typeof CCAPI); if (ret == undefined) { throw new ZWaveError( @@ -124,7 +123,7 @@ export function getCommandClass(cc: CommandClass | CCAPI): CommandClasses { } const implementedVersionDecorator = createReflectionDecorator< - CommandClass, + typeof CommandClass, [version: number], number >({ @@ -169,7 +168,7 @@ export function getImplementedVersionStatic< } const expectedCCResponseDecorator = createReflectionDecorator< - CommandClass, + typeof CommandClass, [ cc: | CCConstructor @@ -194,12 +193,13 @@ const expectedCCResponseDecorator = createReflectionDecorator< * Defines the expected response associated with a Z-Wave message */ export function expectedCCResponse< + TTarget extends typeof CommandClass, TSent extends CommandClass, TReceived extends CommandClass, >( cc: CCConstructor | DynamicCCResponse, predicate?: CCResponsePredicate, -): TypedClassDecorator { +): TypedClassDecorator { return expectedCCResponseDecorator.decorator(cc as any, predicate as any); } @@ -224,7 +224,7 @@ export function getCCResponsePredicate( } const ccValuesDecorator = createReflectionDecorator< - CommandClass, + typeof CommandClass, [valueDefinition: Record], Record >({ @@ -260,60 +260,131 @@ export function getCCValues( const ccValue_METADATA = Symbol.for(`METADATA_ccValue`); -/** - * @publicAPI - * Defines which CC value a Z-Wave command class property belongs to - */ -export function ccValue( +// /** +// * @publicAPI +// * Defines which CC value a Z-Wave command class property belongs to +// */ +// export function ccValue( +// value: StaticCCValue, +// ): TypedPropertyDecorator; + +// export function ccValue( +// value: DynamicCCValue, +// getArgs: (self: TTarget) => Readonly, +// ): TypedPropertyDecorator; + +// // Ideally this should use the PropertyReflectionDecorator, but we cannot reuse the +// // target type in the getArgs function then. +// export function ccValue( +// ...args: +// | [value: StaticCCValue] +// | [value: DynamicCCValue, getArgs: (self: TTarget) => TArgs] +// ): TypedPropertyDecorator { +// // Normalize the arguments to the expected format +// debugger; +// let valueOrFactory: StaticCCValue | StaticCCValueFactory; +// if (args.length === 1) { +// valueOrFactory = args[0]; +// } else { +// const [value, getArgs] = args; +// valueOrFactory = (self: TTarget) => { +// const args = getArgs(self); +// const base = value(...args); +// return { +// ...base, +// is: value.is, +// options: value.options, +// }; +// }; +// } + +// return function decoratorBody_ccValue( +// target: TTarget, +// property: string | number | symbol, +// ): void { +// // get the class constructor +// const constr = target.constructor; + +// // retrieve the current metadata +// const metadata: Map< +// string | number, +// StaticCCValue | StaticCCValueFactory +// > = Reflect.getMetadata(ccValue_METADATA, constr) ?? new Map(); + +// // Add the variable +// metadata.set(property as string | number, valueOrFactory); + +// // And store it back +// Reflect.defineMetadata(ccValue_METADATA, metadata, constr); +// }; +// } + +export function ccValueProperty< + Class extends abstract new (...args: any) => any, +>( + property: keyof InstanceType, value: StaticCCValue, -): TypedPropertyDecorator; +): TypedClassDecorator; -export function ccValue( +export function ccValueProperty< + Class extends abstract new (...args: any) => any, + const TArgs extends any[], +>( + property: keyof InstanceType, value: DynamicCCValue, - getArgs: (self: TTarget) => Readonly, -): TypedPropertyDecorator; + getArgs: (self: InstanceType) => TArgs, +): TypedClassDecorator; -// Ideally this should use the PropertyReflectionDecorator, but we cannot reuse the -// target type in the getArgs function then. -export function ccValue( +/** + * @publicAPI + * Defines which CC values the properties of a Z-Wave Command Class correspond to + */ +export function ccValueProperty< + Class extends abstract new (...args: any) => any, + const TArgs extends any[], +>( + property: keyof InstanceType, ...args: | [value: StaticCCValue] - | [value: DynamicCCValue, getArgs: (self: TTarget) => TArgs] -): TypedPropertyDecorator { - // Normalize the arguments to the expected format - let valueOrFactory: StaticCCValue | StaticCCValueFactory; - if (args.length === 1) { - valueOrFactory = args[0]; - } else { - const [value, getArgs] = args; - valueOrFactory = (self: TTarget) => { - const args = getArgs(self); - const base = value(...args); - return { - ...base, - is: value.is, - options: value.options, - }; - }; - } - - return function decoratorBody_ccValue( - target: TTarget, - property: string | number | symbol, - ): void { + | [ + value: DynamicCCValue, + getArgs: (self: InstanceType) => TArgs, + ] +): TypedClassDecorator { + return function ccValues2_body(target: Class): void { // get the class constructor const constr = target.constructor; // retrieve the current metadata const metadata: Map< string | number, - StaticCCValue | StaticCCValueFactory + StaticCCValue | StaticCCValueFactory> > = Reflect.getMetadata(ccValue_METADATA, constr) ?? new Map(); + // Add the variable to the metadata + + let valueOrFactory: + | StaticCCValue + | StaticCCValueFactory>; + if (args.length === 1) { + valueOrFactory = args[0]; + } else { + const [value, getArgs] = args; + valueOrFactory = (self: InstanceType) => { + const args = getArgs(self); + const base = value(...args); + return { + ...base, + is: value.is, + options: value.options, + }; + }; + } + // Add the variable metadata.set(property as string | number, valueOrFactory); - // And store it back + // And store the metadata back Reflect.defineMetadata(ccValue_METADATA, metadata, constr); }; } @@ -351,7 +422,9 @@ export function getCCValueProperties( // */ // export const getCCValueDefinitions = ccValueDecorator.lookupValues; -const supervisionDecorator = createValuelessReflectionDecorator({ +const supervisionDecorator = createValuelessReflectionDecorator< + typeof CommandClass +>({ name: "useSupervision", }); diff --git a/packages/cc/src/lib/Security2/Extension.ts b/packages/cc/src/lib/Security2/Extension.ts index 0f077e1e300a..27f937b1e6f2 100644 --- a/packages/cc/src/lib/Security2/Extension.ts +++ b/packages/cc/src/lib/Security2/Extension.ts @@ -14,7 +14,7 @@ enum S2ExtensionType { } const extensionTypeDecorator = createSimpleReflectionDecorator< - Security2Extension, + typeof Security2Extension, [type: S2ExtensionType], Security2ExtensionConstructor >({ diff --git a/packages/core/src/util/decorators.ts b/packages/core/src/util/decorators.ts index c4a56cb9bb40..67c96a8c1dd6 100644 --- a/packages/core/src/util/decorators.ts +++ b/packages/core/src/util/decorators.ts @@ -1,23 +1,24 @@ -/* eslint-disable @typescript-eslint/no-unsafe-function-type */ import type { TypedClassDecorator } from "@zwave-js/shared"; import "reflect-metadata"; type Constructor = new (...args: any[]) => T; export interface ReflectionDecorator< - TBase extends object, + TBase extends abstract new (...args: any) => any, TArgs extends any[], TValue, - TConstructor extends Constructor = Constructor, + TConstructor extends Constructor> = Constructor< + InstanceType + >, > { /** The decorator which is used to decorate classes */ decorator: ( ...args: TArgs ) => TypedClassDecorator; /** Looks up the value which was assigned to the target class by the decorator, using a class instance */ - lookupValue: (target: TBase) => TValue | undefined; + lookupValue: (target: InstanceType) => TValue | undefined; /** Looks up the value which was assigned to the target class by the decorator, using the class itself */ - lookupValueStatic: (constr: Function) => TValue | undefined; + lookupValueStatic: (constr: TBase) => TValue | undefined; /** Looks up the class constructor for a given value. This can only be used if the value does not need to be transformed using `constructorLookupKey`. */ lookupConstructorByValue: (value: TValue) => TConstructor | undefined; /** Looks up the class constructor for a given lookup key. This MUST be used if the value needs to be transformed using `constructorLookupKey`. */ @@ -25,10 +26,12 @@ export interface ReflectionDecorator< } export interface CreateReflectionDecoratorOptions< - TBase extends object, + TBase extends abstract new (...args: any) => any, TArgs extends any[], TValue, - TConstructor extends Constructor = Constructor, + TConstructor extends Constructor> = Constructor< + InstanceType + >, > { /** The name of this decorator */ name: string; @@ -45,10 +48,12 @@ export interface CreateReflectionDecoratorOptions< /** Creates a reflection decorator and corresponding methods for reverse lookup of values and constructors */ export function createReflectionDecorator< - TBase extends object, + TBase extends abstract new (...args: any) => any, TArgs extends any[], TValue, - TConstructor extends Constructor = Constructor, + TConstructor extends Constructor> = Constructor< + InstanceType + >, >({ name, valueFromArgs, @@ -66,9 +71,12 @@ export function createReflectionDecorator< const lookupTarget = Object.create(null); const grp: ReflectionDecorator = { - decorator: (...args): TypedClassDecorator => { + decorator: (...args) => { const value = valueFromArgs(...args); - let body = (target: TConstructor) => { + function body( + target: T, + _context: ClassDecoratorContext, + ) { Reflect.defineMetadata(key, value, target); if (constructorLookupKey === false) return; @@ -80,10 +88,10 @@ export function createReflectionDecorator< Reflect.getMetadata(mapKey, lookupTarget) || new Map(); map.set(reverseLookupKey, target); Reflect.defineMetadata(mapKey, map, lookupTarget); - }; + } // Rename the decorator body so it is easier to identify in stack traces - body = Object.defineProperty(body, "name", { + Object.defineProperty(body, "name", { value: "decoratorBody_" + name, }); @@ -144,9 +152,11 @@ export function createReflectionDecorator< } export interface SimpleReflectionDecorator< - TBase extends object, + TBase extends abstract new (...args: any) => any, TArgs extends [any], - TConstructor extends Constructor = Constructor, + TConstructor extends Constructor> = Constructor< + InstanceType + >, > { /** The decorator which is used to decorate the super class */ decorator: ( @@ -154,10 +164,10 @@ export interface SimpleReflectionDecorator< ) => TypedClassDecorator; /** Looks up the value which was assigned to the target class by the decorator, using a class instance */ - lookupValue: (target: TBase) => TArgs[0] | undefined; + lookupValue: (target: InstanceType) => TArgs[0] | undefined; /** Looks up the value which was assigned to the target class by the decorator, using the class itself */ - lookupValueStatic: (constr: Function) => TArgs[0] | undefined; + lookupValueStatic: (constr: TBase) => TArgs[0] | undefined; /** Looks up the super class constructor for a given value. */ lookupConstructor: (...args: TArgs) => TConstructor | undefined; @@ -172,9 +182,11 @@ export interface CreateSimpleReflectionDecoratorOptions { * Like {@link createReflectionDecorator}, but for single-value decorators. This has the advantage that the returned functions can be reused easier with named args. */ export function createSimpleReflectionDecorator< - TBase extends object, + TBase extends abstract new (...args: any) => any, TArgs extends [any], - TConstructor extends Constructor = Constructor, + TConstructor extends Constructor> = Constructor< + InstanceType + >, >({ name, }: CreateSimpleReflectionDecoratorOptions): SimpleReflectionDecorator< @@ -203,16 +215,16 @@ export function createSimpleReflectionDecorator< } export interface ValuelessReflectionDecorator< - TBase extends object, + TBase extends abstract new (...args: any) => any, > { /** The decorator which is used to decorate the super class */ decorator: () => TypedClassDecorator; /** Checks if the target class was decorated by this decorator, using a class instance */ - isDecorated: (target: TBase) => boolean; + isDecorated: (target: InstanceType) => boolean; /** Checks if the target class was decorated by this decorator, using the class itself */ - isDecoratedStatic: (constr: Function) => boolean; + isDecoratedStatic: (constr: TBase) => boolean; } export interface CreateValuelessReflectionDecoratorOptions { @@ -224,7 +236,7 @@ export interface CreateValuelessReflectionDecoratorOptions { * Like {@link createReflectionDecorator}, but for valueless decorators. */ export function createValuelessReflectionDecorator< - TBase extends object, + TBase extends abstract new (...args: any) => any, >({ name, }: CreateValuelessReflectionDecoratorOptions): ValuelessReflectionDecorator< @@ -237,8 +249,9 @@ export function createValuelessReflectionDecorator< const ret: ValuelessReflectionDecorator = { decorator: decorator.decorator, - isDecorated: (target: TBase) => !!decorator.lookupValue(target), - isDecoratedStatic: (constr: Function) => + isDecorated: (target: InstanceType) => + !!decorator.lookupValue(target), + isDecoratedStatic: (constr: TBase) => !!decorator.lookupValueStatic(constr), }; @@ -246,10 +259,12 @@ export function createValuelessReflectionDecorator< } export interface ReflectionDecoratorPair< - TBase extends object, + TBase extends abstract new (...args: any) => any, TSuperArgs extends [any], TSubArgs extends [any], - TConstructor extends Constructor = Constructor, + TConstructor extends Constructor> = Constructor< + InstanceType + >, > { /** The decorator which is used to decorate the super class */ superDecorator: ( @@ -262,14 +277,16 @@ export interface ReflectionDecoratorPair< ) => TypedClassDecorator; /** Looks up the value which was assigned to the target super class by the decorator, using a class instance */ - lookupSuperValue: (target: TBase) => TSuperArgs[0] | undefined; + lookupSuperValue: ( + target: InstanceType, + ) => TSuperArgs[0] | undefined; /** Looks up the value which was assigned to the target sub class by the decorator, using a class instance */ - lookupSubValue: (target: TBase) => TSubArgs[0] | undefined; + lookupSubValue: (target: InstanceType) => TSubArgs[0] | undefined; /** Looks up the value which was assigned to the target super class by the decorator, using the class itself */ - lookupSuperValueStatic: (constr: Function) => TSuperArgs[0] | undefined; + lookupSuperValueStatic: (constr: TBase) => TSuperArgs[0] | undefined; /** Looks up the value which was assigned to the target sub class by the decorator, using the class itself */ - lookupSubValueStatic: (constr: Function) => TSubArgs[0] | undefined; + lookupSubValueStatic: (constr: TBase) => TSubArgs[0] | undefined; /** Looks up the super class constructor for a given value. */ lookupSuperConstructor: (...args: TSuperArgs) => TConstructor | undefined; @@ -291,10 +308,12 @@ export interface CreateReflectionDecoratorPairOptions { * This pair is meant to decorate a super class and several of its subclasses */ export function createReflectionDecoratorPair< - TBase extends object, + TBase extends abstract new (...args: any) => any, TSuperArgs extends [any], TSubArgs extends [any], - TConstructor extends Constructor = Constructor, + TConstructor extends Constructor> = Constructor< + InstanceType + >, >({ superName, subName, @@ -327,7 +346,9 @@ export function createReflectionDecoratorPair< name: subName, valueFromArgs: (arg) => arg, constructorLookupKey: (target, subArg) => { - const superArg = superDecorator.lookupValueStatic(target); + const superArg = superDecorator.lookupValueStatic( + target as unknown as TBase, + ); return getLookupKey(superArg, subArg); }, }); @@ -354,82 +375,3 @@ export function createReflectionDecoratorPair< return ret; } - -// export interface PropertyReflectionDecorator< -// // TTarget extends object, -// TArgs extends any[], -// TValue, -// > { -// /** The decorator which is used to decorate properties */ -// decorator: (...args: TArgs) => TypedPropertyDecorator; -// /** Looks up all decorated properties and the decorator arguments for a class instance */ -// lookupValues: (target: TTarget) => ReadonlyMap; -// } - -// export interface CreatePropertyReflectionDecoratorOptions< -// TArgs extends any[], -// TValue, -// > { -// /** The name of this decorator */ -// name: string; -// /** Determines the value to be stored for the given arguments */ -// valueFromArgs: (...args: TArgs) => TValue; -// } - -// /** Creates a reflection decorator for a class property and the corresponding method for reverse lookup of defined values */ -// export function createPropertyReflectionDecorator< -// // TTarget extends object, -// TArgs extends any[], -// TValue, -// >({ -// name, -// valueFromArgs, -// }: CreatePropertyReflectionDecoratorOptions< -// TArgs, -// TValue -// >): PropertyReflectionDecorator { -// const key = Symbol.for(`METADATA_${name}`); - -// const prp: PropertyReflectionDecorator = { -// decorator: (...args) => { -// const value = valueFromArgs(...args); -// let body = ( -// target: TTarget, -// property: string | number | symbol, -// ) => { -// // get the class constructor -// const constr = target.constructor; - -// // retrieve the current metadata -// const metadata: Map = -// Reflect.getMetadata(key, constr) ?? new Map(); - -// // Add the variable -// metadata.set(property as string | number, value); - -// // And store it back -// Reflect.defineMetadata(key, metadata, constr); -// }; - -// // Rename the decorator body so it is easier to identify in stack traces -// body = Object.defineProperty(body, "name", { -// value: "decoratorBody_" + name, -// }); - -// return body; -// }, - -// lookupValues: (target) => { -// return Reflect.getMetadata(key, target.constructor); -// }, -// }; - -// // Rename the decorator functions so they are easier to identify in stack traces -// for (const property of ["decorator", "lookupValues"] as const) { -// prp[property] = Object.defineProperty(prp[property], "name", { -// value: `${property}_${name}`, -// }) as any; -// } - -// return prp; -// } diff --git a/packages/maintenance/src/refactorCCValueDecorator.ts b/packages/maintenance/src/refactorCCValueDecorator.ts new file mode 100644 index 000000000000..ef92f62205d2 --- /dev/null +++ b/packages/maintenance/src/refactorCCValueDecorator.ts @@ -0,0 +1,93 @@ +import fs from "node:fs/promises"; +import { + type DecoratorStructure, + type OptionalKind, + Project, + SyntaxKind, +} from "ts-morph"; + +async function main() { + const project = new Project({ + tsConfigFilePath: "packages/cc/tsconfig.json", + }); + + const sourceFiles = project.getSourceFiles(); + for (const file of sourceFiles) { + const ccValueImport = file.getImportDeclarations().find((i) => + i.getModuleSpecifierValue().endsWith("CommandClassDecorators.js") + )?.getNamedImports().find((n) => n.getName() === "ccValue"); + if (!ccValueImport) continue; + + ccValueImport.replaceWithText("ccValueProperty"); + + const classesWithDecoratedProperties = file.getDescendantsOfKind( + SyntaxKind.ClassDeclaration, + ) + .map((c) => { + const decoratedProperties = c.getDescendantsOfKind( + SyntaxKind.PropertyDeclaration, + ) + .map((p) => { + const decorator = p.getDecorator("ccValue"); + if (!decorator) return; + + return [ + p, + decorator, + ] as const; + }) + .filter((p) => p != undefined); + + if (decoratedProperties.length === 0) return; + + return [c, decoratedProperties] as const; + }) + .filter((c) => c != undefined); + + for (const [cls, propAndDec] of classesWithDecoratedProperties) { + for (const [prop, dec] of propAndDec) { + if (dec.getArguments().length === 2) { + // The second argument can have unnecessary stuff + const secondArg = dec.getArguments()[1].asKind( + SyntaxKind.ArrowFunction, + ); + if (!secondArg) continue; + const param = secondArg.getParameters()[0]?.asKind( + SyntaxKind.Parameter, + ); + if (param) param.removeType(); + const bodyText = secondArg.getBody().getText(); + if (bodyText.includes("as const")) { + secondArg.getBody().replaceWithText( + bodyText.replace("as const", ""), + ); + } + } + + const decArgs = dec.getArguments().map((a) => a.getText()); + const newDecorator: OptionalKind = { + name: "ccValueProperty", + arguments: [ + `"${prop.getName()}"`, + ...decArgs, + ], + }; + cls.addDecorator(newDecorator); + dec.remove(); + } + } + + await file.save(); + } +} + +void main().catch(async (e) => { + debugger; + await fs.writeFile(`${e.filePath}.old`, e.oldText); + await fs.writeFile(`${e.filePath}.new`, e.newText); + console.error(`Error refactoring file ${e.filePath} + old text: ${e.filePath}.old + new text: ${e.filePath}.new`); + + process.exit(1); +}); diff --git a/packages/nvmedit/src/lib/nvm3/files/NVMFile.ts b/packages/nvmedit/src/lib/nvm3/files/NVMFile.ts index e13fa9b4387f..fea5b24f8619 100644 --- a/packages/nvmedit/src/lib/nvm3/files/NVMFile.ts +++ b/packages/nvmedit/src/lib/nvm3/files/NVMFile.ts @@ -114,9 +114,9 @@ export type NVMFileConstructor = typeof NVMFile & { /** * Defines the ID associated with a NVM file class */ -export function nvmFileID( +export function nvmFileID( id: number | ((id: number) => boolean), -): TypedClassDecorator { +): TypedClassDecorator { return (messageClass) => { Reflect.defineMetadata(METADATA_nvmFileID, id, messageClass); @@ -188,7 +188,7 @@ export function getNVMFileIDStatic>( export type NVMSection = "application" | "protocol"; const nvmSectionDecorator = createSimpleReflectionDecorator< - NVMFile, + typeof NVMFile, [section: NVMSection] >({ name: "nvmSection", diff --git a/packages/serial/src/message/Message.ts b/packages/serial/src/message/Message.ts index 7946c5dcb94d..e6cec66e8641 100644 --- a/packages/serial/src/message/Message.ts +++ b/packages/serial/src/message/Message.ts @@ -485,7 +485,7 @@ function getMessageTypeMapKey( } const messageTypesDecorator = createReflectionDecorator< - Message, + typeof Message, [messageType: MessageType, functionType: FunctionType], { messageType: MessageType; functionType: FunctionType }, MessageConstructor @@ -556,7 +556,7 @@ function getMessageConstructor( } const expectedResponseDecorator = createReflectionDecorator< - Message, + typeof Message, [typeOrPredicate: FunctionType | typeof Message | ResponsePredicate], FunctionType | typeof Message | ResponsePredicate, MessageConstructor @@ -592,7 +592,7 @@ export function getExpectedResponseStatic< } const expectedCallbackDecorator = createReflectionDecorator< - Message, + typeof Message, [typeOrPredicate: FunctionType | typeof Message | ResponsePredicate], FunctionType | typeof Message | ResponsePredicate, MessageConstructor @@ -605,9 +605,12 @@ const expectedCallbackDecorator = createReflectionDecorator< /** * Defines the expected callback function type or message class for a Z-Wave message */ -export function expectedCallback( - typeOrPredicate: FunctionType | typeof Message | ResponsePredicate, -): TypedClassDecorator { +export function expectedCallback( + typeOrPredicate: + | FunctionType + | typeof Message + | ResponsePredicate>, +): TypedClassDecorator { return expectedCallbackDecorator.decorator(typeOrPredicate as any); } @@ -632,7 +635,7 @@ export function getExpectedCallbackStatic< } const priorityDecorator = createReflectionDecorator< - Message, + typeof Message, [prio: MessagePriority], MessagePriority >({ diff --git a/packages/serial/src/serialapi/application/ApplicationUpdateRequest.ts b/packages/serial/src/serialapi/application/ApplicationUpdateRequest.ts index 466c9ae9f5f4..82abae17772c 100644 --- a/packages/serial/src/serialapi/application/ApplicationUpdateRequest.ts +++ b/packages/serial/src/serialapi/application/ApplicationUpdateRequest.ts @@ -43,7 +43,7 @@ const { lookupConstructor: getApplicationUpdateRequestConstructor, lookupValue: getApplicationUpdateType, } = createSimpleReflectionDecorator< - ApplicationUpdateRequest, + typeof ApplicationUpdateRequest, [updateType: ApplicationUpdateTypes], MessageConstructor >({ diff --git a/packages/serial/src/serialapi/capability/SerialAPISetupMessages.ts b/packages/serial/src/serialapi/capability/SerialAPISetupMessages.ts index 983d00b46249..2dbb823ac0d8 100644 --- a/packages/serial/src/serialapi/capability/SerialAPISetupMessages.ts +++ b/packages/serial/src/serialapi/capability/SerialAPISetupMessages.ts @@ -55,7 +55,7 @@ const { lookupConstructor: getSubCommandRequestConstructor, lookupValue: getSubCommandForRequest, } = createSimpleReflectionDecorator< - SerialAPISetupRequest, + typeof SerialAPISetupRequest, [command: SerialAPISetupCommand], MessageConstructor >({ @@ -67,7 +67,7 @@ const { lookupConstructor: getSubCommandResponseConstructor, lookupValue: getSubCommandForResponse, } = createSimpleReflectionDecorator< - SerialAPISetupResponse, + typeof SerialAPISetupResponse, [command: SerialAPISetupCommand], MessageConstructor >({ diff --git a/packages/serial/src/serialapi/nvm/FirmwareUpdateNVMMessages.ts b/packages/serial/src/serialapi/nvm/FirmwareUpdateNVMMessages.ts index 67b22860e0f0..95b349ac1a4a 100644 --- a/packages/serial/src/serialapi/nvm/FirmwareUpdateNVMMessages.ts +++ b/packages/serial/src/serialapi/nvm/FirmwareUpdateNVMMessages.ts @@ -37,7 +37,7 @@ const { lookupConstructor: getSubCommandRequestConstructor, lookupValue: getSubCommandForRequest, } = createSimpleReflectionDecorator< - FirmwareUpdateNVMRequest, + typeof FirmwareUpdateNVMRequest, [command: FirmwareUpdateNVMCommand], MessageConstructor >({ @@ -49,7 +49,7 @@ const { lookupConstructor: getSubCommandResponseConstructor, lookupValue: getSubCommandForResponse, } = createSimpleReflectionDecorator< - FirmwareUpdateNVMResponse, + typeof FirmwareUpdateNVMResponse, [command: FirmwareUpdateNVMCommand], MessageConstructor >({ diff --git a/packages/shared/src/types.ts b/packages/shared/src/types.ts index 4960a8cb7806..da9cdb9d0a96 100644 --- a/packages/shared/src/types.ts +++ b/packages/shared/src/types.ts @@ -9,12 +9,12 @@ export type JSONObject = Record; export type Constructor = new (...args: any[]) => T; -export type TypedClassDecorator = < - T extends TTarget, - TConstructor extends new (...args: any[]) => T, ->( - apiClass: TConstructor, -) => TConstructor | void; +export type TypedClassDecorator< + Class extends abstract new (...args: any) => any, +> = ( + target: Class, + context: ClassDecoratorContext, +) => Class | void; export type TypedPropertyDecorator = < T extends TTarget, diff --git a/packages/transformers/src/index.ts b/packages/transformers/src/index.ts index ed92683fc321..684d11e9cec4 100644 --- a/packages/transformers/src/index.ts +++ b/packages/transformers/src/index.ts @@ -58,8 +58,13 @@ export interface ValidateArgsOptions { } /** Generates code at build time which validates all arguments of this method */ -export function validateArgs(options?: ValidateArgsOptions): PropertyDecorator { - return (target: unknown, property: string | number | symbol) => { +export function validateArgs any>( + options?: ValidateArgsOptions, +) { + return function validateArgsBody( + target: T, + context: ClassMethodDecoratorContext, + ): T | void { // this is a no-op that gets replaced during the build process using the transformer below if (process.env.NODE_ENV === "test") return; if (process.execArgv.includes("--conditions=@@dev")) return; diff --git a/packages/transformers/tsconfig.json b/packages/transformers/tsconfig.json index 363dd79a39f3..323d6f158d27 100644 --- a/packages/transformers/tsconfig.json +++ b/packages/transformers/tsconfig.json @@ -3,7 +3,6 @@ "extends": "../../tsconfig.base.json", "compilerOptions": { "newLine": "lf", - "experimentalDecorators": true, "paths": { "@zwave-js/transformers": ["./src"] } diff --git a/packages/transformers/tsconfig.test.json b/packages/transformers/tsconfig.test.json index 8620bc183e3a..2281635e4fb1 100644 --- a/packages/transformers/tsconfig.test.json +++ b/packages/transformers/tsconfig.test.json @@ -8,8 +8,7 @@ "declarationMap": false, "sourceMap": false, "plugins": [{ "transform": "./build" }], - "incremental": false, - "experimentalDecorators": true + "incremental": false }, "include": ["test/fixtures/**/*.ts"] } diff --git a/test/run.cts b/test/run.ts similarity index 100% rename from test/run.cts rename to test/run.ts diff --git a/test/tsconfig.json b/test/tsconfig.json index e83bdf4cd316..217a20995603 100644 --- a/test/tsconfig.json +++ b/test/tsconfig.json @@ -1,4 +1,4 @@ { "extends": "../tsconfig.base.json", - "include": ["*.ts", "run.cts"] + "include": ["*.ts"] } diff --git a/tsconfig.base.json b/tsconfig.base.json index ff16bb6db3bb..1aac2ac6105d 100644 --- a/tsconfig.base.json +++ b/tsconfig.base.json @@ -9,8 +9,6 @@ "noEmitOnError": true, "removeComments": false, - "experimentalDecorators": true, - "emitDecoratorMetadata": false, "sourceMap": true, "inlineSourceMap": false, "stripInternal": true,