Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: migrate legacy decorators to ES decorators #7360

Merged
merged 4 commits into from
Nov 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions packages/cc/src/cc/AlarmSensorCC.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import {
import {
API,
CCCommand,
ccValue,
ccValueProperty,
ccValues,
commandClass,
expectedCCResponse,
Expand Down Expand Up @@ -474,6 +474,10 @@ export interface AlarmSensorCCSupportedReportOptions {
}

@CCCommand(AlarmSensorCommand.SupportedReport)
@ccValueProperty(
"supportedSensorTypes",
AlarmSensorCCValues.supportedSensorTypes,
)
export class AlarmSensorCCSupportedReport extends AlarmSensorCC {
public constructor(
options: WithAddress<AlarmSensorCCSupportedReportOptions>,
Expand Down Expand Up @@ -502,7 +506,6 @@ export class AlarmSensorCCSupportedReport extends AlarmSensorCC {
});
}

@ccValue(AlarmSensorCCValues.supportedSensorTypes)
public supportedSensorTypes: AlarmSensorType[];

public persistValues(ctx: PersistValuesContext): boolean {
Expand Down
22 changes: 12 additions & 10 deletions packages/cc/src/cc/AssociationCC.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import {
import {
API,
CCCommand,
ccValue,
ccValueProperty,
ccValues,
commandClass,
expectedCCResponse,
Expand Down Expand Up @@ -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<AssociationCCReportOptions>,
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -768,6 +770,7 @@ export interface AssociationCCSupportedGroupingsReportOptions {
}

@CCCommand(AssociationCommand.SupportedGroupingsReport)
@ccValueProperty("groupCount", AssociationCCValues.groupCount)
export class AssociationCCSupportedGroupingsReport extends AssociationCC {
public constructor(
options: WithAddress<AssociationCCSupportedGroupingsReportOptions>,
Expand All @@ -790,7 +793,6 @@ export class AssociationCCSupportedGroupingsReport extends AssociationCC {
});
}

@ccValue(AssociationCCValues.groupCount)
public groupCount: number;

public serialize(ctx: CCEncodingContext): Bytes {
Expand Down
14 changes: 7 additions & 7 deletions packages/cc/src/cc/AssociationGroupInfoCC.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import {
import {
API,
CCCommand,
ccValue,
ccValueProperty,
ccValues,
commandClass,
expectedCCResponse,
Expand Down Expand Up @@ -598,6 +598,7 @@ export interface AssociationGroupInfoCCInfoReportOptions {
}

@CCCommand(AssociationGroupInfoCommand.InfoReport)
@ccValueProperty("hasDynamicInfo", AssociationGroupInfoCCValues.hasDynamicInfo)
export class AssociationGroupInfoCCInfoReport extends AssociationGroupInfoCC {
public constructor(
options: WithAddress<AssociationGroupInfoCCInfoReportOptions>,
Expand Down Expand Up @@ -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[];
Expand Down Expand Up @@ -789,6 +789,11 @@ export interface AssociationGroupInfoCCCommandListReportOptions {
}

@CCCommand(AssociationGroupInfoCommand.CommandListReport)
@ccValueProperty(
"commands",
AssociationGroupInfoCCValues.commands,
(self) => [self.groupId],
)
export class AssociationGroupInfoCCCommandListReport
extends AssociationGroupInfoCC
{
Expand Down Expand Up @@ -830,11 +835,6 @@ export class AssociationGroupInfoCCCommandListReport

public readonly groupId: number;

@ccValue(
AssociationGroupInfoCCValues.commands,
(self: AssociationGroupInfoCCCommandListReport) =>
[self.groupId] as const,
)
public readonly commands: ReadonlyMap<CommandClasses, readonly number[]>;

public serialize(ctx: CCEncodingContext): Bytes {
Expand Down
11 changes: 7 additions & 4 deletions packages/cc/src/cc/BarrierOperatorCC.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ import {
import {
API,
CCCommand,
ccValue,
ccValueProperty,
ccValues,
commandClass,
expectedCCResponse,
Expand Down Expand Up @@ -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<BarrierOperatorCCReportOptions>,
Expand Down Expand Up @@ -644,10 +646,8 @@ export class BarrierOperatorCCReport extends BarrierOperatorCC {
});
}

@ccValue(BarrierOperatorCCValues.currentState)
public readonly currentState: MaybeUnknown<BarrierState>;

@ccValue(BarrierOperatorCCValues.position)
public readonly position: MaybeUnknown<number>;

public toLogEntry(ctx?: GetValueDB): MessageOrCCLogEntry {
Expand All @@ -673,6 +673,10 @@ export interface BarrierOperatorCCSignalingCapabilitiesReportOptions {
}

@CCCommand(BarrierOperatorCommand.SignalingCapabilitiesReport)
@ccValueProperty(
"supportedSubsystemTypes",
BarrierOperatorCCValues.supportedSubsystemTypes,
)
export class BarrierOperatorCCSignalingCapabilitiesReport
extends BarrierOperatorCC
{
Expand Down Expand Up @@ -702,7 +706,6 @@ export class BarrierOperatorCCSignalingCapabilitiesReport
});
}

@ccValue(BarrierOperatorCCValues.supportedSubsystemTypes)
public readonly supportedSubsystemTypes: readonly SubsystemType[];

public toLogEntry(ctx?: GetValueDB): MessageOrCCLogEntry {
Expand Down
8 changes: 4 additions & 4 deletions packages/cc/src/cc/BasicCC.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ import {
import {
API,
CCCommand,
ccValue,
ccValueProperty,
ccValues,
commandClass,
expectedCCResponse,
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -455,13 +458,10 @@ export class BasicCCReport extends BasicCC {
});
}

@ccValue(BasicCCValues.currentValue)
public currentValue: MaybeUnknown<number> | undefined;

@ccValue(BasicCCValues.targetValue)
public readonly targetValue: MaybeUnknown<number> | undefined;

@ccValue(BasicCCValues.duration)
public readonly duration: Duration | undefined;

public persistValues(ctx: PersistValuesContext): boolean {
Expand Down
26 changes: 13 additions & 13 deletions packages/cc/src/cc/BatteryCC.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ import {
import {
API,
CCCommand,
ccValue,
ccValueProperty,
ccValues,
commandClass,
expectedCCResponse,
Expand Down Expand Up @@ -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<BatteryCCReportOptions>,
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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<BatteryCCHealthReportOptions>,
Expand Down Expand Up @@ -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;
Expand Down
7 changes: 5 additions & 2 deletions packages/cc/src/cc/BinarySensorCC.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ import {
import {
API,
CCCommand,
ccValue,
ccValueProperty,
ccValues,
commandClass,
expectedCCResponse,
Expand Down Expand Up @@ -484,6 +484,10 @@ export interface BinarySensorCCSupportedReportOptions {
}

@CCCommand(BinarySensorCommand.SupportedReport)
@ccValueProperty(
"supportedSensorTypes",
BinarySensorCCValues.supportedSensorTypes,
)
export class BinarySensorCCSupportedReport extends BinarySensorCC {
public constructor(
options: WithAddress<BinarySensorCCSupportedReportOptions>,
Expand Down Expand Up @@ -514,7 +518,6 @@ export class BinarySensorCCSupportedReport extends BinarySensorCC {
});
}

@ccValue(BinarySensorCCValues.supportedSensorTypes)
public supportedSensorTypes: BinarySensorType[];

public serialize(ctx: CCEncodingContext): Bytes {
Expand Down
8 changes: 4 additions & 4 deletions packages/cc/src/cc/BinarySwitchCC.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ import {
import {
API,
CCCommand,
ccValue,
ccValueProperty,
ccValues,
commandClass,
expectedCCResponse,
Expand Down Expand Up @@ -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<BinarySwitchCCReportOptions>,
Expand Down Expand Up @@ -417,13 +420,10 @@ export class BinarySwitchCCReport extends BinarySwitchCC {
});
}

@ccValue(BinarySwitchCCValues.currentValue)
public readonly currentValue: MaybeUnknown<boolean> | undefined;

@ccValue(BinarySwitchCCValues.targetValue)
public readonly targetValue: MaybeUnknown<boolean> | undefined;

@ccValue(BinarySwitchCCValues.duration)
public readonly duration: Duration | undefined;

public serialize(ctx: CCEncodingContext): Bytes {
Expand Down
Loading
Loading