From 6437856cdc791e503118ad1a8823e8af01205502 Mon Sep 17 00:00:00 2001 From: Dominic Griesel Date: Tue, 15 Oct 2024 23:09:39 +0200 Subject: [PATCH] refactor: remove host instance from CCs --- packages/cc/src/cc/AlarmSensorCC.ts | 14 +- packages/cc/src/cc/AssociationCC.ts | 35 ++- packages/cc/src/cc/AssociationGroupInfoCC.ts | 31 +-- packages/cc/src/cc/BarrierOperatorCC.ts | 38 ++-- packages/cc/src/cc/BasicCC.ts | 11 +- packages/cc/src/cc/BatteryCC.ts | 11 +- packages/cc/src/cc/BinarySensorCC.ts | 18 +- packages/cc/src/cc/BinarySwitchCC.ts | 11 +- packages/cc/src/cc/CRC16CC.ts | 16 +- packages/cc/src/cc/CentralSceneCC.ts | 19 +- .../cc/src/cc/ClimateControlScheduleCC.ts | 34 +-- packages/cc/src/cc/ClockCC.ts | 11 +- packages/cc/src/cc/ColorSwitchCC.ts | 29 +-- packages/cc/src/cc/ConfigurationCC.ts | 94 +++----- packages/cc/src/cc/DeviceResetLocallyCC.ts | 7 +- packages/cc/src/cc/DoorLockCC.ts | 26 +-- packages/cc/src/cc/DoorLockLoggingCC.ts | 14 +- packages/cc/src/cc/EnergyProductionCC.ts | 9 +- packages/cc/src/cc/EntryControlCC.ts | 24 +- .../cc/src/cc/FirmwareUpdateMetaDataCC.ts | 41 ++-- packages/cc/src/cc/HumidityControlModeCC.ts | 16 +- .../src/cc/HumidityControlOperatingStateCC.ts | 11 +- .../cc/src/cc/HumidityControlSetpointCC.ts | 46 ++-- packages/cc/src/cc/InclusionControllerCC.ts | 12 +- packages/cc/src/cc/IndicatorCC.ts | 36 ++- packages/cc/src/cc/IrrigationCC.ts | 70 +++--- packages/cc/src/cc/LanguageCC.ts | 11 +- packages/cc/src/cc/LockCC.ts | 11 +- .../cc/src/cc/ManufacturerProprietaryCC.ts | 14 +- packages/cc/src/cc/ManufacturerSpecificCC.ts | 16 +- packages/cc/src/cc/MeterCC.ts | 23 +- .../cc/src/cc/MultiChannelAssociationCC.ts | 50 ++-- packages/cc/src/cc/MultiChannelCC.ts | 59 ++--- packages/cc/src/cc/MultiCommandCC.ts | 16 +- packages/cc/src/cc/MultilevelSensorCC.ts | 24 +- packages/cc/src/cc/MultilevelSwitchCC.ts | 23 +- packages/cc/src/cc/NoOperationCC.ts | 2 +- packages/cc/src/cc/NodeNamingCC.ts | 21 +- packages/cc/src/cc/NotificationCC.ts | 31 +-- packages/cc/src/cc/PowerlevelCC.ts | 32 +-- packages/cc/src/cc/ProtectionCC.ts | 36 ++- packages/cc/src/cc/SceneActivationCC.ts | 11 +- .../cc/src/cc/SceneActuatorConfigurationCC.ts | 16 +- .../src/cc/SceneControllerConfigurationCC.ts | 16 +- packages/cc/src/cc/ScheduleEntryLockCC.ts | 103 ++++----- packages/cc/src/cc/Security2CC.ts | 87 +++---- packages/cc/src/cc/SecurityCC.ts | 51 ++--- packages/cc/src/cc/SoundSwitchCC.ts | 36 ++- packages/cc/src/cc/SupervisionCC.ts | 14 +- packages/cc/src/cc/ThermostatFanModeCC.ts | 16 +- packages/cc/src/cc/ThermostatFanStateCC.ts | 11 +- packages/cc/src/cc/ThermostatModeCC.ts | 16 +- .../cc/src/cc/ThermostatOperatingStateCC.ts | 11 +- packages/cc/src/cc/ThermostatSetbackCC.ts | 11 +- packages/cc/src/cc/ThermostatSetpointCC.ts | 27 +-- packages/cc/src/cc/TimeCC.ts | 27 +-- packages/cc/src/cc/TimeParametersCC.ts | 11 +- packages/cc/src/cc/TransportServiceCC.ts | 23 +- packages/cc/src/cc/UserCodeCC.ts | 64 ++---- packages/cc/src/cc/VersionCC.ts | 30 +-- packages/cc/src/cc/WakeUpCC.ts | 18 +- packages/cc/src/cc/WindowCoveringCC.ts | 29 +-- packages/cc/src/cc/ZWavePlusCC.ts | 8 +- packages/cc/src/cc/ZWaveProtocolCC.ts | 83 +++---- .../cc/manufacturerProprietary/FibaroCC.ts | 36 ++- packages/cc/src/lib/CommandClass.ts | 36 +-- packages/host/src/ZWaveHost.ts | 65 +++--- packages/host/src/mocks.ts | 6 +- packages/serial/src/message/Message.test.ts | 24 +- packages/serial/src/message/Message.ts | 9 +- .../serial/src/message/ZnifferMessages.ts | 1 - packages/testing/src/MockController.ts | 24 +- packages/testing/src/MockNode.ts | 9 +- .../zwave-js/src/lib/controller/Controller.ts | 215 ++++++++---------- .../lib/controller/MockControllerBehaviors.ts | 96 ++++---- packages/zwave-js/src/lib/driver/Driver.ts | 49 ++-- .../src/lib/driver/MessageGenerators.ts | 23 +- .../src/lib/driver/Transaction.test.ts | 4 +- packages/zwave-js/src/lib/node/Endpoint.ts | 4 +- .../src/lib/node/MockNodeBehaviors.ts | 12 +- packages/zwave-js/src/lib/node/Node.ts | 6 +- .../zwave-js/src/lib/node/mixins/40_Values.ts | 1 - .../src/lib/node/mixins/70_FirmwareUpdate.ts | 16 +- .../src/lib/node/mockCCBehaviors/Basic.ts | 2 +- .../lib/node/mockCCBehaviors/BinarySensor.ts | 4 +- .../lib/node/mockCCBehaviors/BinarySwitch.ts | 2 +- .../lib/node/mockCCBehaviors/ColorSwitch.ts | 4 +- .../lib/node/mockCCBehaviors/Configuration.ts | 10 +- .../node/mockCCBehaviors/EnergyProduction.ts | 2 +- .../mockCCBehaviors/ManufacturerSpecific.ts | 2 +- .../src/lib/node/mockCCBehaviors/Meter.ts | 4 +- .../lib/node/mockCCBehaviors/MultiChannel.ts | 8 +- .../node/mockCCBehaviors/MultilevelSensor.ts | 6 +- .../node/mockCCBehaviors/MultilevelSwitch.ts | 4 +- .../lib/node/mockCCBehaviors/Notification.ts | 4 +- .../node/mockCCBehaviors/ScheduleEntryLock.ts | 23 +- .../lib/node/mockCCBehaviors/SoundSwitch.ts | 32 ++- .../node/mockCCBehaviors/ThermostatMode.ts | 4 +- .../node/mockCCBehaviors/ThermostatSetback.ts | 2 +- .../mockCCBehaviors/ThermostatSetpoint.ts | 10 +- .../src/lib/node/mockCCBehaviors/UserCode.ts | 14 +- .../node/mockCCBehaviors/WindowCovering.ts | 2 +- packages/zwave-js/src/lib/node/utils.ts | 2 - .../application/ApplicationCommandRequest.ts | 6 +- .../application/ApplicationUpdateRequest.ts | 19 +- .../BridgeApplicationCommandRequest.ts | 6 +- .../application/SerialAPIStartedRequest.ts | 4 +- .../serialapi/application/ShutdownMessages.ts | 4 +- .../GetControllerCapabilitiesMessages.ts | 4 +- .../GetControllerVersionMessages.ts | 4 +- .../capability/GetLongRangeNodesMessages.ts | 7 +- .../capability/GetProtocolVersionMessages.ts | 4 +- .../GetSerialApiCapabilitiesMessages.ts | 4 +- .../GetSerialApiInitDataMessages.ts | 4 +- .../serialapi/capability/HardResetRequest.ts | 12 +- .../capability/LongRangeChannelMessages.ts | 10 +- .../capability/SerialAPISetupMessages.ts | 111 ++++----- .../SetApplicationNodeInformationRequest.ts | 4 +- .../SetLongRangeShadowNodeIDsRequest.ts | 4 +- .../memory/GetControllerIdMessages.ts | 4 +- .../misc/GetBackgroundRSSIMessages.ts | 4 +- .../misc/SetRFReceiveModeMessages.ts | 7 +- .../misc/SetSerialApiTimeoutsMessages.ts | 7 +- .../network-mgmt/AddNodeToNetworkRequest.ts | 17 +- .../AssignPriorityReturnRouteMessages.ts | 19 +- .../AssignPrioritySUCReturnRouteMessages.ts | 15 +- .../network-mgmt/AssignReturnRouteMessages.ts | 16 +- .../AssignSUCReturnRouteMessages.ts | 21 +- .../network-mgmt/DeleteReturnRouteMessages.ts | 16 +- .../DeleteSUCReturnRouteMessages.ts | 21 +- .../GetNodeProtocolInfoMessages.ts | 7 +- .../network-mgmt/GetPriorityRouteMessages.ts | 7 +- .../network-mgmt/GetRoutingInfoMessages.ts | 8 +- .../network-mgmt/GetSUCNodeIdMessages.ts | 4 +- .../network-mgmt/IsFailedNodeMessages.ts | 8 +- .../network-mgmt/RemoveFailedNodeMessages.ts | 16 +- .../RemoveNodeFromNetworkRequest.ts | 13 +- .../network-mgmt/ReplaceFailedNodeRequest.ts | 16 +- .../network-mgmt/RequestNodeInfoMessages.ts | 7 +- .../RequestNodeNeighborUpdateMessages.ts | 13 +- .../network-mgmt/SetLearnModeMessages.ts | 16 +- .../network-mgmt/SetPriorityRouteMessages.ts | 7 +- .../network-mgmt/SetSUCNodeIDMessages.ts | 16 +- .../nvm/ExtNVMReadLongBufferMessages.ts | 7 +- .../nvm/ExtNVMReadLongByteMessages.ts | 7 +- .../nvm/ExtNVMWriteLongBufferMessages.ts | 7 +- .../nvm/ExtNVMWriteLongByteMessages.ts | 7 +- .../nvm/ExtendedNVMOperationsMessages.ts | 18 +- .../nvm/FirmwareUpdateNVMMessages.ts | 37 ++- .../src/lib/serialapi/nvm/GetNVMIdMessages.ts | 4 +- .../serialapi/nvm/NVMOperationsMessages.ts | 18 +- .../transport/SendDataBridgeMessages.ts | 35 ++- .../serialapi/transport/SendDataMessages.ts | 43 ++-- .../transport/SendTestFrameMessages.ts | 16 +- .../discardUnsupportedReports.test.ts | 12 +- .../mapNotificationDoorLock.test.ts | 4 +- .../cc-specific/notificationEnums.test.ts | 42 ++-- .../notificationIdleManually.test.ts | 8 +- .../notificationIdleRelated.test.ts | 4 +- .../cc-specific/undefinedTargetValue.test.ts | 2 +- .../cc-specific/unknownNotifications.test.ts | 2 +- packages/zwave-js/src/lib/test/cc/API.test.ts | 2 +- .../src/lib/test/cc/AssociationCC.test.ts | 16 +- .../test/cc/AssociationGroupInfoCC.test.ts | 18 +- .../zwave-js/src/lib/test/cc/BasicCC.test.ts | 32 +-- .../src/lib/test/cc/BatteryCC.test.ts | 14 +- .../src/lib/test/cc/BinarySensorCC.test.ts | 14 +- .../src/lib/test/cc/BinarySwitchCC.test.ts | 12 +- .../zwave-js/src/lib/test/cc/CRC16CC.test.ts | 12 +- .../src/lib/test/cc/CentralSceneCC.test.ts | 18 +- .../src/lib/test/cc/ColorSwitchCC.test.ts | 18 +- .../cc/CommandClass.persistValues.test.ts | 4 +- .../src/lib/test/cc/CommandClass.test.ts | 16 +- .../src/lib/test/cc/DoorLockCC.test.ts | 30 +-- .../src/lib/test/cc/DoorLockLoggingCC.test.ts | 8 +- .../src/lib/test/cc/EntryControlCC.test.ts | 16 +- .../zwave-js/src/lib/test/cc/FibaroCC.test.ts | 16 +- .../lib/test/cc/HumidityControlModeCC.test.ts | 16 +- .../HumidityControlOperatingStateCC.test.ts | 4 +- .../test/cc/HumidityControlSetpointCC.test.ts | 26 +-- .../src/lib/test/cc/IndicatorCC.test.ts | 15 +- .../src/lib/test/cc/LanguageCC.test.ts | 12 +- .../test/cc/ManufacturerSpecificCC.test.ts | 4 +- .../zwave-js/src/lib/test/cc/MeterCC.test.ts | 36 +-- .../test/cc/MultiChannelAssociationCC.test.ts | 28 +-- .../src/lib/test/cc/MultiChannelCC.test.ts | 42 ++-- .../src/lib/test/cc/MultiCommandCC.test.ts | 2 +- .../lib/test/cc/MultilevelSwitchCC.test.ts | 18 +- .../src/lib/test/cc/NoOperationCC.test.ts | 4 +- .../src/lib/test/cc/PowerlevelCC.test.ts | 14 +- .../src/lib/test/cc/SceneActivationCC.test.ts | 8 +- .../cc/SceneActuatorConfigurationCC.test.ts | 10 +- .../cc/SceneControllerConfigurationCC.test.ts | 14 +- .../src/lib/test/cc/SupervisionCC.test.ts | 10 +- .../lib/test/cc/ThermostatFanModeCC.test.ts | 8 +- .../lib/test/cc/ThermostatFanStateCC.test.ts | 6 +- .../zwave-js/src/lib/test/cc/TimeCC.test.ts | 10 +- .../zwave-js/src/lib/test/cc/WakeUpCC.test.ts | 6 +- .../src/lib/test/cc/ZWavePlusCC.test.ts | 2 +- ...rySensorReportAnyUseFirstSupported.test.ts | 2 +- .../invalidCallbackFunctionTypes.test.ts | 40 ++-- .../compat/notificationAlarmMapping.test.ts | 2 +- .../test/compat/reInterviewWakeUpNIF.test.ts | 2 +- .../test/compliance/decodeLowerS2Keys.test.ts | 10 +- .../discardInsecureCommands.test.ts | 9 +- .../encapsulationAnswerAsAsked.test.ts | 16 +- .../handleMultiCommandPayload.test.ts | 6 +- .../secureNodeSecureEndpoint.test.ts | 16 +- .../test/driver/assemblePartialCCs.test.ts | 32 +-- .../driver/computeNetCCPayloadSize.test.ts | 8 +- .../lib/test/driver/controllerJammed.test.ts | 18 +- .../createCCValuesUsingKnownVersion.test.ts | 2 +- .../driver/handleNonImplementedCCs.test.ts | 2 +- ...noreCCVersion0ForKnownSupportedCCs.test.ts | 79 +++---- .../multiStageResponseNoTimeout.test.ts | 55 ++--- .../driver/nodeAsleepBlockNonceReport.test.ts | 6 +- .../test/driver/nodeAsleepNoReject.test.ts | 4 +- .../lib/test/driver/nodeDeadReject.test.ts | 8 +- .../test/driver/notificationPushNoAGI.test.ts | 2 +- .../driver/reInterviewAssumeAwake.test.ts | 4 +- .../lib/test/driver/receiveMessages.test.ts | 2 +- .../test/driver/s0AndS2Encapsulation.test.ts | 9 +- .../lib/test/driver/s0Encapsulation.test.ts | 21 +- .../driver/s0EncapsulationTwoNodes.test.ts | 21 +- .../src/lib/test/driver/s2Collisions.test.ts | 66 ++---- .../driver/sendDataAbortAfterTimeout.test.ts | 22 +- .../lib/test/driver/sendDataFailThrow.test.ts | 4 +- .../sendDataMissingCallbackAbort.test.ts | 36 +-- .../driver/sendDataMissingResponse.test.ts | 20 +- .../setValueFailedSupervisionGet.test.ts | 4 +- .../test/driver/setValueNoSupervision.test.ts | 2 +- .../setValueSucceedAfterFailure.test.ts | 4 +- ...setValueSuccessfulSupervisionNoGet.test.ts | 2 +- .../driver/setValueSupervision255Get.test.ts | 8 +- ...ValueSupervisionSuccessMoreUpdates.test.ts | 2 +- .../driver/setValueSupervisionWorking.test.ts | 4 +- .../driver/targetValueVersionUnknown.test.ts | 4 +- .../src/lib/test/driver/unknownValues.test.ts | 12 +- .../lib/test/driver/unresponsiveStick.test.ts | 6 +- .../legacyRefreshActuatorSensorCCs.test.ts | 2 +- .../src/lib/zniffer/CCParsingContext.ts | 96 -------- packages/zwave-js/src/lib/zniffer/Zniffer.ts | 43 +++- 242 files changed, 1840 insertions(+), 2728 deletions(-) delete mode 100644 packages/zwave-js/src/lib/zniffer/CCParsingContext.ts diff --git a/packages/cc/src/cc/AlarmSensorCC.ts b/packages/cc/src/cc/AlarmSensorCC.ts index 0b5af1dfe06c..848b61fbf3fd 100644 --- a/packages/cc/src/cc/AlarmSensorCC.ts +++ b/packages/cc/src/cc/AlarmSensorCC.ts @@ -15,7 +15,6 @@ import type { CCEncodingContext, GetValueDB, ZWaveApplicationHost, - ZWaveHost, } from "@zwave-js/host/safe"; import { getEnumMemberName, isEnumMember, pick } from "@zwave-js/shared/safe"; import { validateArgs } from "@zwave-js/transformers"; @@ -131,7 +130,7 @@ export class AlarmSensorCCAPI extends PhysicalCCAPI { public async get(sensorType?: AlarmSensorType) { this.assertSupportsCommand(AlarmSensorCommand, AlarmSensorCommand.Get); - const cc = new AlarmSensorCCGet(this.applHost, { + const cc = new AlarmSensorCCGet({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, sensorType, @@ -150,7 +149,7 @@ export class AlarmSensorCCAPI extends PhysicalCCAPI { AlarmSensorCommand.SupportedGet, ); - const cc = new AlarmSensorCCSupportedGet(this.applHost, { + const cc = new AlarmSensorCCSupportedGet({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, }); @@ -324,10 +323,9 @@ duration: ${currentValue.duration}`; @CCCommand(AlarmSensorCommand.Report) export class AlarmSensorCCReport extends AlarmSensorCC { public constructor( - host: ZWaveHost, options: CommandClassDeserializationOptions, ) { - super(host, options); + super(options); validatePayload(this.payload.length >= 5, this.payload[1] !== 0xff); // Alarm Sensor reports may be forwarded by a different node, in this case // (and only then!) the payload contains the original node ID @@ -405,10 +403,9 @@ export interface AlarmSensorCCGetOptions extends CCCommandOptions { @expectedCCResponse(AlarmSensorCCReport, testResponseForAlarmSensorGet) export class AlarmSensorCCGet extends AlarmSensorCC { public constructor( - host: ZWaveHost, options: CommandClassDeserializationOptions | AlarmSensorCCGetOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { // TODO: Deserialize payload throw new ZWaveError( @@ -443,10 +440,9 @@ export class AlarmSensorCCGet extends AlarmSensorCC { @CCCommand(AlarmSensorCommand.SupportedReport) export class AlarmSensorCCSupportedReport extends AlarmSensorCC { public constructor( - host: ZWaveHost, options: CommandClassDeserializationOptions, ) { - super(host, options); + super(options); validatePayload(this.payload.length >= 1); const bitMaskLength = this.payload[0]; validatePayload(this.payload.length >= 1 + bitMaskLength); diff --git a/packages/cc/src/cc/AssociationCC.ts b/packages/cc/src/cc/AssociationCC.ts index b9b0f111f949..c7ae11f24924 100644 --- a/packages/cc/src/cc/AssociationCC.ts +++ b/packages/cc/src/cc/AssociationCC.ts @@ -18,7 +18,6 @@ import type { CCParsingContext, GetValueDB, ZWaveApplicationHost, - ZWaveHost, } from "@zwave-js/host/safe"; import { validateArgs } from "@zwave-js/transformers"; import { distinct } from "alcalzone-shared/arrays"; @@ -106,7 +105,7 @@ export class AssociationCCAPI extends PhysicalCCAPI { AssociationCommand.SupportedGroupingsGet, ); - const cc = new AssociationCCSupportedGroupingsGet(this.applHost, { + const cc = new AssociationCCSupportedGroupingsGet({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, }); @@ -126,7 +125,7 @@ export class AssociationCCAPI extends PhysicalCCAPI { AssociationCommand.SupportedGroupingsReport, ); - const cc = new AssociationCCSupportedGroupingsReport(this.applHost, { + const cc = new AssociationCCSupportedGroupingsReport({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, groupCount, @@ -142,7 +141,7 @@ export class AssociationCCAPI extends PhysicalCCAPI { public async getGroup(groupId: number) { this.assertSupportsCommand(AssociationCommand, AssociationCommand.Get); - const cc = new AssociationCCGet(this.applHost, { + const cc = new AssociationCCGet({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, groupId, @@ -168,7 +167,7 @@ export class AssociationCCAPI extends PhysicalCCAPI { AssociationCommand.Report, ); - const cc = new AssociationCCReport(this.applHost, { + const cc = new AssociationCCReport({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, ...options, @@ -186,7 +185,7 @@ export class AssociationCCAPI extends PhysicalCCAPI { ): Promise { this.assertSupportsCommand(AssociationCommand, AssociationCommand.Set); - const cc = new AssociationCCSet(this.applHost, { + const cc = new AssociationCCSet({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, groupId, @@ -222,7 +221,7 @@ export class AssociationCCAPI extends PhysicalCCAPI { ); } - const cc = new AssociationCCRemove(this.applHost, { + const cc = new AssociationCCRemove({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, ...options, @@ -269,7 +268,7 @@ export class AssociationCCAPI extends PhysicalCCAPI { AssociationCommand.SpecificGroupGet, ); - const cc = new AssociationCCSpecificGroupGet(this.applHost, { + const cc = new AssociationCCSpecificGroupGet({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, }); @@ -294,7 +293,7 @@ export class AssociationCCAPI extends PhysicalCCAPI { AssociationCommand.SpecificGroupReport, ); - const cc = new AssociationCCSpecificGroupReport(this.applHost, { + const cc = new AssociationCCSpecificGroupReport({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, group, @@ -508,10 +507,9 @@ export interface AssociationCCSetOptions extends CCCommandOptions { @useSupervision() export class AssociationCCSet extends AssociationCC { public constructor( - host: ZWaveHost, options: CommandClassDeserializationOptions | AssociationCCSetOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { validatePayload(this.payload.length >= 2); this.groupId = this.payload[0]; @@ -568,12 +566,11 @@ export interface AssociationCCRemoveOptions { @useSupervision() export class AssociationCCRemove extends AssociationCC { public constructor( - host: ZWaveHost, options: | CommandClassDeserializationOptions | (AssociationCCRemoveOptions & CCCommandOptions), ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { validatePayload(this.payload.length >= 1); if (this.payload[0] !== 0) { @@ -624,12 +621,11 @@ export interface AssociationCCReportSpecificOptions { @CCCommand(AssociationCommand.Report) export class AssociationCCReport extends AssociationCC { public constructor( - host: ZWaveHost, options: | CommandClassDeserializationOptions | (AssociationCCReportSpecificOptions & CCCommandOptions), ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { validatePayload(this.payload.length >= 3); @@ -713,10 +709,9 @@ export interface AssociationCCGetOptions extends CCCommandOptions { @expectedCCResponse(AssociationCCReport) export class AssociationCCGet extends AssociationCC { public constructor( - host: ZWaveHost, options: CommandClassDeserializationOptions | AssociationCCGetOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { validatePayload(this.payload.length >= 1); this.groupId = this.payload[0]; @@ -756,12 +751,11 @@ export interface AssociationCCSupportedGroupingsReportOptions @CCCommand(AssociationCommand.SupportedGroupingsReport) export class AssociationCCSupportedGroupingsReport extends AssociationCC { public constructor( - host: ZWaveHost, options: | CommandClassDeserializationOptions | AssociationCCSupportedGroupingsReportOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { validatePayload(this.payload.length >= 1); @@ -799,12 +793,11 @@ export interface AssociationCCSpecificGroupReportOptions { @CCCommand(AssociationCommand.SpecificGroupReport) export class AssociationCCSpecificGroupReport extends AssociationCC { public constructor( - host: ZWaveHost, options: | CommandClassDeserializationOptions | (AssociationCCSpecificGroupReportOptions & CCCommandOptions), ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { validatePayload(this.payload.length >= 1); diff --git a/packages/cc/src/cc/AssociationGroupInfoCC.ts b/packages/cc/src/cc/AssociationGroupInfoCC.ts index ba2189336a84..cff849ff794f 100644 --- a/packages/cc/src/cc/AssociationGroupInfoCC.ts +++ b/packages/cc/src/cc/AssociationGroupInfoCC.ts @@ -15,7 +15,6 @@ import type { CCEncodingContext, GetValueDB, ZWaveApplicationHost, - ZWaveHost, } from "@zwave-js/host/safe"; import { cpp2js, getEnumMemberName, num2hex } from "@zwave-js/shared/safe"; import { validateArgs } from "@zwave-js/transformers"; @@ -112,7 +111,7 @@ export class AssociationGroupInfoCCAPI extends PhysicalCCAPI { AssociationGroupInfoCommand.NameGet, ); - const cc = new AssociationGroupInfoCCNameGet(this.applHost, { + const cc = new AssociationGroupInfoCCNameGet({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, groupId, @@ -133,7 +132,7 @@ export class AssociationGroupInfoCCAPI extends PhysicalCCAPI { AssociationGroupInfoCommand.NameReport, ); - const cc = new AssociationGroupInfoCCNameReport(this.applHost, { + const cc = new AssociationGroupInfoCCNameReport({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, groupId, @@ -151,7 +150,7 @@ export class AssociationGroupInfoCCAPI extends PhysicalCCAPI { AssociationGroupInfoCommand.InfoGet, ); - const cc = new AssociationGroupInfoCCInfoGet(this.applHost, { + const cc = new AssociationGroupInfoCCInfoGet({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, groupId, @@ -184,7 +183,7 @@ export class AssociationGroupInfoCCAPI extends PhysicalCCAPI { AssociationGroupInfoCommand.InfoReport, ); - const cc = new AssociationGroupInfoCCInfoReport(this.applHost, { + const cc = new AssociationGroupInfoCCInfoReport({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, ...options, @@ -205,7 +204,7 @@ export class AssociationGroupInfoCCAPI extends PhysicalCCAPI { AssociationGroupInfoCommand.CommandListGet, ); - const cc = new AssociationGroupInfoCCCommandListGet(this.applHost, { + const cc = new AssociationGroupInfoCCCommandListGet({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, groupId, @@ -230,7 +229,7 @@ export class AssociationGroupInfoCCAPI extends PhysicalCCAPI { AssociationGroupInfoCommand.CommandListReport, ); - const cc = new AssociationGroupInfoCCCommandListReport(this.applHost, { + const cc = new AssociationGroupInfoCCCommandListReport({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, groupId, @@ -474,12 +473,11 @@ export interface AssociationGroupInfoCCNameReportOptions @CCCommand(AssociationGroupInfoCommand.NameReport) export class AssociationGroupInfoCCNameReport extends AssociationGroupInfoCC { public constructor( - host: ZWaveHost, options: | CommandClassDeserializationOptions | AssociationGroupInfoCCNameReportOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { validatePayload(this.payload.length >= 2); @@ -542,12 +540,11 @@ export interface AssociationGroupInfoCCNameGetOptions extends CCCommandOptions { @expectedCCResponse(AssociationGroupInfoCCNameReport) export class AssociationGroupInfoCCNameGet extends AssociationGroupInfoCC { public constructor( - host: ZWaveHost, options: | CommandClassDeserializationOptions | AssociationGroupInfoCCNameGetOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { validatePayload(this.payload.length >= 1); this.groupId = this.payload[0]; @@ -588,7 +585,6 @@ export interface AssociationGroupInfoCCInfoReportSpecificOptions { @CCCommand(AssociationGroupInfoCommand.InfoReport) export class AssociationGroupInfoCCInfoReport extends AssociationGroupInfoCC { public constructor( - host: ZWaveHost, options: | CommandClassDeserializationOptions | ( @@ -596,7 +592,7 @@ export class AssociationGroupInfoCCInfoReport extends AssociationGroupInfoCC { & CCCommandOptions ), ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { validatePayload(this.payload.length >= 1); @@ -708,12 +704,11 @@ export type AssociationGroupInfoCCInfoGetOptions = @expectedCCResponse(AssociationGroupInfoCCInfoReport) export class AssociationGroupInfoCCInfoGet extends AssociationGroupInfoCC { public constructor( - host: ZWaveHost, options: | CommandClassDeserializationOptions | AssociationGroupInfoCCInfoGetOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { validatePayload(this.payload.length >= 2); const optionByte = this.payload[0]; @@ -773,12 +768,11 @@ export class AssociationGroupInfoCCCommandListReport extends AssociationGroupInfoCC { public constructor( - host: ZWaveHost, options: | CommandClassDeserializationOptions | AssociationGroupInfoCCCommandListReportOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { validatePayload(this.payload.length >= 2); @@ -866,12 +860,11 @@ export class AssociationGroupInfoCCCommandListGet extends AssociationGroupInfoCC { public constructor( - host: ZWaveHost, options: | CommandClassDeserializationOptions | AssociationGroupInfoCCCommandListGetOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { validatePayload(this.payload.length >= 2); this.allowCache = !!(this.payload[0] & 0b1000_0000); diff --git a/packages/cc/src/cc/BarrierOperatorCC.ts b/packages/cc/src/cc/BarrierOperatorCC.ts index 0277aa7b0598..2ae3ace6b665 100644 --- a/packages/cc/src/cc/BarrierOperatorCC.ts +++ b/packages/cc/src/cc/BarrierOperatorCC.ts @@ -18,7 +18,6 @@ import type { CCEncodingContext, GetValueDB, ZWaveApplicationHost, - ZWaveHost, } from "@zwave-js/host/safe"; import { getEnumMemberName, @@ -148,7 +147,7 @@ export class BarrierOperatorCCAPI extends CCAPI { BarrierOperatorCommand.Get, ); - const cc = new BarrierOperatorCCGet(this.applHost, { + const cc = new BarrierOperatorCCGet({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, }); @@ -172,7 +171,7 @@ export class BarrierOperatorCCAPI extends CCAPI { BarrierOperatorCommand.Set, ); - const cc = new BarrierOperatorCCSet(this.applHost, { + const cc = new BarrierOperatorCCSet({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, targetState, @@ -189,13 +188,10 @@ export class BarrierOperatorCCAPI extends CCAPI { BarrierOperatorCommand.SignalingCapabilitiesGet, ); - const cc = new BarrierOperatorCCSignalingCapabilitiesGet( - this.applHost, - { - nodeId: this.endpoint.nodeId, - endpoint: this.endpoint.index, - }, - ); + const cc = new BarrierOperatorCCSignalingCapabilitiesGet({ + nodeId: this.endpoint.nodeId, + endpoint: this.endpoint.index, + }); const response = await this.applHost.sendCommand< BarrierOperatorCCSignalingCapabilitiesReport >( @@ -214,7 +210,7 @@ export class BarrierOperatorCCAPI extends CCAPI { BarrierOperatorCommand.EventSignalingGet, ); - const cc = new BarrierOperatorCCEventSignalingGet(this.applHost, { + const cc = new BarrierOperatorCCEventSignalingGet({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, subsystemType, @@ -238,7 +234,7 @@ export class BarrierOperatorCCAPI extends CCAPI { BarrierOperatorCommand.EventSignalingSet, ); - const cc = new BarrierOperatorCCEventSignalingSet(this.applHost, { + const cc = new BarrierOperatorCCEventSignalingSet({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, subsystemType, @@ -552,12 +548,11 @@ export interface BarrierOperatorCCSetOptions extends CCCommandOptions { @useSupervision() export class BarrierOperatorCCSet extends BarrierOperatorCC { public constructor( - host: ZWaveHost, options: | CommandClassDeserializationOptions | BarrierOperatorCCSetOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { throw new ZWaveError( `${this.constructor.name}: deserialization not implemented`, @@ -586,10 +581,9 @@ export class BarrierOperatorCCSet extends BarrierOperatorCC { @CCCommand(BarrierOperatorCommand.Report) export class BarrierOperatorCCReport extends BarrierOperatorCC { public constructor( - host: ZWaveHost, options: CommandClassDeserializationOptions, ) { - super(host, options); + super(options); validatePayload(this.payload.length >= 1); @@ -649,10 +643,9 @@ export class BarrierOperatorCCSignalingCapabilitiesReport extends BarrierOperatorCC { public constructor( - host: ZWaveHost, options: CommandClassDeserializationOptions, ) { - super(host, options); + super(options); this.supportedSubsystemTypes = parseBitMask( this.payload, @@ -693,12 +686,11 @@ export interface BarrierOperatorCCEventSignalingSetOptions @useSupervision() export class BarrierOperatorCCEventSignalingSet extends BarrierOperatorCC { public constructor( - host: ZWaveHost, options: | CommandClassDeserializationOptions | BarrierOperatorCCEventSignalingSetOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { // TODO: Deserialize payload throw new ZWaveError( @@ -738,10 +730,9 @@ export class BarrierOperatorCCEventSignalingSet extends BarrierOperatorCC { @CCCommand(BarrierOperatorCommand.EventSignalingReport) export class BarrierOperatorCCEventSignalingReport extends BarrierOperatorCC { public constructor( - host: ZWaveHost, options: CommandClassDeserializationOptions, ) { - super(host, options); + super(options); validatePayload(this.payload.length >= 2); this.subsystemType = this.payload[0]; @@ -792,12 +783,11 @@ export interface BarrierOperatorCCEventSignalingGetOptions @expectedCCResponse(BarrierOperatorCCEventSignalingReport) export class BarrierOperatorCCEventSignalingGet extends BarrierOperatorCC { public constructor( - host: ZWaveHost, options: | CommandClassDeserializationOptions | BarrierOperatorCCEventSignalingGetOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { // TODO: Deserialize payload throw new ZWaveError( diff --git a/packages/cc/src/cc/BasicCC.ts b/packages/cc/src/cc/BasicCC.ts index 6e9c7559103d..6832cd5755da 100644 --- a/packages/cc/src/cc/BasicCC.ts +++ b/packages/cc/src/cc/BasicCC.ts @@ -17,7 +17,6 @@ import type { CCEncodingContext, GetValueDB, ZWaveApplicationHost, - ZWaveHost, } from "@zwave-js/host/safe"; import { type AllOrNone, pick } from "@zwave-js/shared/safe"; import { validateArgs } from "@zwave-js/transformers"; @@ -216,7 +215,7 @@ export class BasicCCAPI extends CCAPI { public async get() { this.assertSupportsCommand(BasicCommand, BasicCommand.Get); - const cc = new BasicCCGet(this.applHost, { + const cc = new BasicCCGet({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, }); @@ -239,7 +238,7 @@ export class BasicCCAPI extends CCAPI { ): Promise { this.assertSupportsCommand(BasicCommand, BasicCommand.Set); - const cc = new BasicCCSet(this.applHost, { + const cc = new BasicCCSet({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, targetValue, @@ -364,10 +363,9 @@ export interface BasicCCSetOptions extends CCCommandOptions { @useSupervision() export class BasicCCSet extends BasicCC { public constructor( - host: ZWaveHost, options: CommandClassDeserializationOptions | BasicCCSetOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { validatePayload(this.payload.length >= 1); this.targetValue = this.payload[0]; @@ -406,10 +404,9 @@ export type BasicCCReportOptions = export class BasicCCReport extends BasicCC { // @noCCValues See comment in the constructor public constructor( - host: ZWaveHost, options: CommandClassDeserializationOptions | BasicCCReportOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { validatePayload(this.payload.length >= 1); diff --git a/packages/cc/src/cc/BatteryCC.ts b/packages/cc/src/cc/BatteryCC.ts index 06b487a35172..1858b978b92b 100644 --- a/packages/cc/src/cc/BatteryCC.ts +++ b/packages/cc/src/cc/BatteryCC.ts @@ -17,7 +17,6 @@ import type { CCEncodingContext, GetValueDB, ZWaveApplicationHost, - ZWaveHost, } from "@zwave-js/host/safe"; import { type AllOrNone, getEnumMemberName, pick } from "@zwave-js/shared/safe"; import { @@ -230,7 +229,7 @@ export class BatteryCCAPI extends PhysicalCCAPI { public async get() { this.assertSupportsCommand(BatteryCommand, BatteryCommand.Get); - const cc = new BatteryCCGet(this.applHost, { + const cc = new BatteryCCGet({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, }); @@ -258,7 +257,7 @@ export class BatteryCCAPI extends PhysicalCCAPI { public async getHealth() { this.assertSupportsCommand(BatteryCommand, BatteryCommand.HealthGet); - const cc = new BatteryCCHealthGet(this.applHost, { + const cc = new BatteryCCHealthGet({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, }); @@ -416,10 +415,9 @@ export type BatteryCCReportOptions = @CCCommand(BatteryCommand.Report) export class BatteryCCReport extends BatteryCC { public constructor( - host: ZWaveHost, options: CommandClassDeserializationOptions | BatteryCCReportOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { validatePayload(this.payload.length >= 1); @@ -602,10 +600,9 @@ export class BatteryCCGet extends BatteryCC {} @CCCommand(BatteryCommand.HealthReport) export class BatteryCCHealthReport extends BatteryCC { public constructor( - host: ZWaveHost, options: CommandClassDeserializationOptions, ) { - super(host, options); + super(options); validatePayload(this.payload.length >= 2); diff --git a/packages/cc/src/cc/BinarySensorCC.ts b/packages/cc/src/cc/BinarySensorCC.ts index 3e33164a101e..c3d4d02bc77b 100644 --- a/packages/cc/src/cc/BinarySensorCC.ts +++ b/packages/cc/src/cc/BinarySensorCC.ts @@ -14,7 +14,6 @@ import type { CCEncodingContext, GetValueDB, ZWaveApplicationHost, - ZWaveHost, } from "@zwave-js/host/safe"; import { getEnumMemberName, isEnumMember } from "@zwave-js/shared/safe"; import { validateArgs } from "@zwave-js/transformers"; @@ -113,7 +112,7 @@ export class BinarySensorCCAPI extends PhysicalCCAPI { BinarySensorCommand.Get, ); - const cc = new BinarySensorCCGet(this.applHost, { + const cc = new BinarySensorCCGet({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, sensorType, @@ -136,7 +135,7 @@ export class BinarySensorCCAPI extends PhysicalCCAPI { BinarySensorCommand.Report, ); - const cc = new BinarySensorCCReport(this.applHost, { + const cc = new BinarySensorCCReport({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, value, @@ -153,7 +152,7 @@ export class BinarySensorCCAPI extends PhysicalCCAPI { BinarySensorCommand.SupportedGet, ); - const cc = new BinarySensorCCSupportedGet(this.applHost, { + const cc = new BinarySensorCCSupportedGet({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, }); @@ -176,7 +175,7 @@ export class BinarySensorCCAPI extends PhysicalCCAPI { BinarySensorCommand.SupportedReport, ); - const cc = new BinarySensorCCSupportedReport(this.applHost, { + const cc = new BinarySensorCCSupportedReport({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, supportedSensorTypes: supported, @@ -347,12 +346,11 @@ export interface BinarySensorCCReportOptions extends CCCommandOptions { @CCCommand(BinarySensorCommand.Report) export class BinarySensorCCReport extends BinarySensorCC { public constructor( - host: ZWaveHost, options: | BinarySensorCCReportOptions | CommandClassDeserializationOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { validatePayload(this.payload.length >= 1); @@ -431,10 +429,9 @@ export interface BinarySensorCCGetOptions extends CCCommandOptions { @expectedCCResponse(BinarySensorCCReport, testResponseForBinarySensorGet) export class BinarySensorCCGet extends BinarySensorCC { public constructor( - host: ZWaveHost, options: CommandClassDeserializationOptions | BinarySensorCCGetOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { if (this.payload.length >= 1) { this.sensorType = this.payload[0]; @@ -472,12 +469,11 @@ export interface BinarySensorCCSupportedReportOptions { @CCCommand(BinarySensorCommand.SupportedReport) export class BinarySensorCCSupportedReport extends BinarySensorCC { public constructor( - host: ZWaveHost, options: | CommandClassDeserializationOptions | (BinarySensorCCSupportedReportOptions & CCCommandOptions), ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { validatePayload(this.payload.length >= 1); diff --git a/packages/cc/src/cc/BinarySwitchCC.ts b/packages/cc/src/cc/BinarySwitchCC.ts index 76dad09e80d1..9c2a132b8169 100644 --- a/packages/cc/src/cc/BinarySwitchCC.ts +++ b/packages/cc/src/cc/BinarySwitchCC.ts @@ -18,7 +18,6 @@ import type { CCEncodingContext, GetValueDB, ZWaveApplicationHost, - ZWaveHost, } from "@zwave-js/host/safe"; import type { AllOrNone } from "@zwave-js/shared"; import { validateArgs } from "@zwave-js/transformers"; @@ -103,7 +102,7 @@ export class BinarySwitchCCAPI extends CCAPI { BinarySwitchCommand.Get, ); - const cc = new BinarySwitchCCGet(this.applHost, { + const cc = new BinarySwitchCCGet({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, }); @@ -136,7 +135,7 @@ export class BinarySwitchCCAPI extends CCAPI { BinarySwitchCommand.Set, ); - const cc = new BinarySwitchCCSet(this.applHost, { + const cc = new BinarySwitchCCSet({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, targetValue, @@ -315,10 +314,9 @@ export interface BinarySwitchCCSetOptions extends CCCommandOptions { @useSupervision() export class BinarySwitchCCSet extends BinarySwitchCC { public constructor( - host: ZWaveHost, options: CommandClassDeserializationOptions | BinarySwitchCCSetOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { validatePayload(this.payload.length >= 1); this.targetValue = !!this.payload[0]; @@ -381,12 +379,11 @@ export type BinarySwitchCCReportOptions = @CCCommand(BinarySwitchCommand.Report) export class BinarySwitchCCReport extends BinarySwitchCC { public constructor( - host: ZWaveHost, options: | CommandClassDeserializationOptions | BinarySwitchCCReportOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { validatePayload(this.payload.length >= 1); diff --git a/packages/cc/src/cc/CRC16CC.ts b/packages/cc/src/cc/CRC16CC.ts index e14ebd90b301..0fe5349e4066 100644 --- a/packages/cc/src/cc/CRC16CC.ts +++ b/packages/cc/src/cc/CRC16CC.ts @@ -6,11 +6,7 @@ import { type MessageOrCCLogEntry, validatePayload, } from "@zwave-js/core/safe"; -import type { - CCEncodingContext, - GetValueDB, - ZWaveHost, -} from "@zwave-js/host/safe"; +import type { CCEncodingContext, GetValueDB } from "@zwave-js/host/safe"; import { CCAPI } from "../lib/API"; import { type CCCommandOptions, @@ -50,7 +46,7 @@ export class CRC16CCAPI extends CCAPI { CRC16Command.CommandEncapsulation, ); - const cc = new CRC16CCCommandEncapsulation(this.applHost, { + const cc = new CRC16CCCommandEncapsulation({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, encapsulated: encapsulatedCC, @@ -74,10 +70,9 @@ export class CRC16CC extends CommandClass { /** Encapsulates a command in a CRC-16 CC */ public static encapsulate( - host: ZWaveHost, cc: CommandClass, ): CRC16CCCommandEncapsulation { - const ret = new CRC16CCCommandEncapsulation(host, { + const ret = new CRC16CCCommandEncapsulation({ nodeId: cc.nodeId, encapsulated: cc, }); @@ -111,12 +106,11 @@ function getCCResponseForCommandEncapsulation( ) export class CRC16CCCommandEncapsulation extends CRC16CC { public constructor( - host: ZWaveHost, options: | CommandClassDeserializationOptions | CRC16CCCommandEncapsulationOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { validatePayload(this.payload.length >= 3); @@ -130,7 +124,7 @@ export class CRC16CCCommandEncapsulation extends CRC16CC { ); validatePayload(expectedCRC === actualCRC); - this.encapsulated = CommandClass.from(this.host, { + this.encapsulated = CommandClass.from({ data: ccBuffer, fromEncapsulation: true, encapCC: this, diff --git a/packages/cc/src/cc/CentralSceneCC.ts b/packages/cc/src/cc/CentralSceneCC.ts index 9c041550481a..d5ba86452aa8 100644 --- a/packages/cc/src/cc/CentralSceneCC.ts +++ b/packages/cc/src/cc/CentralSceneCC.ts @@ -18,7 +18,6 @@ import type { CCEncodingContext, GetValueDB, ZWaveApplicationHost, - ZWaveHost, } from "@zwave-js/host/safe"; import { getEnumMemberName, pick } from "@zwave-js/shared/safe"; import { validateArgs } from "@zwave-js/transformers"; @@ -115,7 +114,7 @@ export class CentralSceneCCAPI extends CCAPI { CentralSceneCommand.SupportedGet, ); - const cc = new CentralSceneCCSupportedGet(this.applHost, { + const cc = new CentralSceneCCSupportedGet({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, }); @@ -141,7 +140,7 @@ export class CentralSceneCCAPI extends CCAPI { CentralSceneCommand.ConfigurationGet, ); - const cc = new CentralSceneCCConfigurationGet(this.applHost, { + const cc = new CentralSceneCCConfigurationGet({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, }); @@ -165,7 +164,7 @@ export class CentralSceneCCAPI extends CCAPI { CentralSceneCommand.ConfigurationSet, ); - const cc = new CentralSceneCCConfigurationSet(this.applHost, { + const cc = new CentralSceneCCConfigurationSet({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, slowRefresh, @@ -303,10 +302,9 @@ supports slow refresh: ${ccSupported.supportsSlowRefresh}`; @CCCommand(CentralSceneCommand.Notification) export class CentralSceneCCNotification extends CentralSceneCC { public constructor( - host: ZWaveHost, options: CommandClassDeserializationOptions, ) { - super(host, options); + super(options); validatePayload(this.payload.length >= 3); this.sequenceNumber = this.payload[0]; @@ -360,10 +358,9 @@ export class CentralSceneCCNotification extends CentralSceneCC { @CCCommand(CentralSceneCommand.SupportedReport) export class CentralSceneCCSupportedReport extends CentralSceneCC { public constructor( - host: ZWaveHost, options: CommandClassDeserializationOptions, ) { - super(host, options); + super(options); validatePayload(this.payload.length >= 2); this.sceneCount = this.payload[0]; @@ -458,10 +455,9 @@ export class CentralSceneCCSupportedGet extends CentralSceneCC {} @CCCommand(CentralSceneCommand.ConfigurationReport) export class CentralSceneCCConfigurationReport extends CentralSceneCC { public constructor( - host: ZWaveHost, options: CommandClassDeserializationOptions, ) { - super(host, options); + super(options); validatePayload(this.payload.length >= 1); this.slowRefresh = !!(this.payload[0] & 0b1000_0000); @@ -493,12 +489,11 @@ export interface CentralSceneCCConfigurationSetOptions @useSupervision() export class CentralSceneCCConfigurationSet extends CentralSceneCC { public constructor( - host: ZWaveHost, options: | CommandClassDeserializationOptions | CentralSceneCCConfigurationSetOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { throw new ZWaveError( `${this.constructor.name}: deserialization not implemented`, diff --git a/packages/cc/src/cc/ClimateControlScheduleCC.ts b/packages/cc/src/cc/ClimateControlScheduleCC.ts index 85d3acb77fdf..3a94ac2a7b83 100644 --- a/packages/cc/src/cc/ClimateControlScheduleCC.ts +++ b/packages/cc/src/cc/ClimateControlScheduleCC.ts @@ -9,11 +9,7 @@ import { enumValuesToMetadataStates, validatePayload, } from "@zwave-js/core/safe"; -import type { - CCEncodingContext, - GetValueDB, - ZWaveHost, -} from "@zwave-js/host/safe"; +import type { CCEncodingContext, GetValueDB } from "@zwave-js/host/safe"; import { getEnumMemberName } from "@zwave-js/shared/safe"; import { validateArgs } from "@zwave-js/transformers"; import { padStart } from "alcalzone-shared/strings"; @@ -114,7 +110,7 @@ export class ClimateControlScheduleCCAPI extends CCAPI { ClimateControlScheduleCommand.Set, ); - const cc = new ClimateControlScheduleCCSet(this.applHost, { + const cc = new ClimateControlScheduleCCSet({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, weekday, @@ -132,7 +128,7 @@ export class ClimateControlScheduleCCAPI extends CCAPI { ClimateControlScheduleCommand.Get, ); - const cc = new ClimateControlScheduleCCGet(this.applHost, { + const cc = new ClimateControlScheduleCCGet({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, weekday, @@ -152,7 +148,7 @@ export class ClimateControlScheduleCCAPI extends CCAPI { ClimateControlScheduleCommand.ChangedGet, ); - const cc = new ClimateControlScheduleCCChangedGet(this.applHost, { + const cc = new ClimateControlScheduleCCChangedGet({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, }); @@ -172,7 +168,7 @@ export class ClimateControlScheduleCCAPI extends CCAPI { ClimateControlScheduleCommand.OverrideGet, ); - const cc = new ClimateControlScheduleCCOverrideGet(this.applHost, { + const cc = new ClimateControlScheduleCCOverrideGet({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, }); @@ -200,7 +196,7 @@ export class ClimateControlScheduleCCAPI extends CCAPI { ClimateControlScheduleCommand.OverrideSet, ); - const cc = new ClimateControlScheduleCCOverrideSet(this.applHost, { + const cc = new ClimateControlScheduleCCOverrideSet({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, overrideType: type, @@ -227,12 +223,11 @@ export interface ClimateControlScheduleCCSetOptions extends CCCommandOptions { @useSupervision() export class ClimateControlScheduleCCSet extends ClimateControlScheduleCC { public constructor( - host: ZWaveHost, options: | CommandClassDeserializationOptions | ClimateControlScheduleCCSetOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { throw new ZWaveError( `${this.constructor.name}: deserialization not implemented`, @@ -291,10 +286,9 @@ export class ClimateControlScheduleCCSet extends ClimateControlScheduleCC { @CCCommand(ClimateControlScheduleCommand.Report) export class ClimateControlScheduleCCReport extends ClimateControlScheduleCC { public constructor( - host: ZWaveHost, options: CommandClassDeserializationOptions, ) { - super(host, options); + super(options); validatePayload(this.payload.length >= 28); // 1 + 9 * 3 this.weekday = this.payload[0] & 0b111; @@ -348,12 +342,11 @@ export interface ClimateControlScheduleCCGetOptions extends CCCommandOptions { @expectedCCResponse(ClimateControlScheduleCCReport) export class ClimateControlScheduleCCGet extends ClimateControlScheduleCC { public constructor( - host: ZWaveHost, options: | CommandClassDeserializationOptions | ClimateControlScheduleCCGetOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { throw new ZWaveError( `${this.constructor.name}: deserialization not implemented`, @@ -384,10 +377,9 @@ export class ClimateControlScheduleCCChangedReport extends ClimateControlScheduleCC { public constructor( - host: ZWaveHost, options: CommandClassDeserializationOptions, ) { - super(host, options); + super(options); validatePayload(this.payload.length >= 1); this.changeCounter = this.payload[0]; @@ -414,10 +406,9 @@ export class ClimateControlScheduleCCOverrideReport extends ClimateControlScheduleCC { public constructor( - host: ZWaveHost, options: CommandClassDeserializationOptions, ) { - super(host, options); + super(options); validatePayload(this.payload.length >= 2); this.overrideType = this.payload[0] & 0b11; @@ -465,12 +456,11 @@ export class ClimateControlScheduleCCOverrideSet extends ClimateControlScheduleCC { public constructor( - host: ZWaveHost, options: | CommandClassDeserializationOptions | ClimateControlScheduleCCOverrideSetOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { throw new ZWaveError( `${this.constructor.name}: deserialization not implemented`, diff --git a/packages/cc/src/cc/ClockCC.ts b/packages/cc/src/cc/ClockCC.ts index 7357ce02538f..c7993bb071b9 100644 --- a/packages/cc/src/cc/ClockCC.ts +++ b/packages/cc/src/cc/ClockCC.ts @@ -14,7 +14,6 @@ import type { CCEncodingContext, GetValueDB, ZWaveApplicationHost, - ZWaveHost, } from "@zwave-js/host/safe"; import { getEnumMemberName, pick } from "@zwave-js/shared/safe"; import { validateArgs } from "@zwave-js/transformers"; @@ -55,7 +54,7 @@ export class ClockCCAPI extends CCAPI { public async get() { this.assertSupportsCommand(ClockCommand, ClockCommand.Get); - const cc = new ClockCCGet(this.applHost, { + const cc = new ClockCCGet({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, }); @@ -76,7 +75,7 @@ export class ClockCCAPI extends CCAPI { ): Promise { this.assertSupportsCommand(ClockCommand, ClockCommand.Set); - const cc = new ClockCCSet(this.applHost, { + const cc = new ClockCCSet({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, hour, @@ -154,10 +153,9 @@ export interface ClockCCSetOptions extends CCCommandOptions { @useSupervision() export class ClockCCSet extends ClockCC { public constructor( - host: ZWaveHost, options: CommandClassDeserializationOptions | ClockCCSetOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { // TODO: Deserialize payload throw new ZWaveError( @@ -207,10 +205,9 @@ export class ClockCCSet extends ClockCC { @CCCommand(ClockCommand.Report) export class ClockCCReport extends ClockCC { public constructor( - host: ZWaveHost, options: CommandClassDeserializationOptions, ) { - super(host, options); + super(options); validatePayload(this.payload.length >= 2); this.weekday = this.payload[0] >>> 5; diff --git a/packages/cc/src/cc/ColorSwitchCC.ts b/packages/cc/src/cc/ColorSwitchCC.ts index b61a90234f68..302060033a75 100644 --- a/packages/cc/src/cc/ColorSwitchCC.ts +++ b/packages/cc/src/cc/ColorSwitchCC.ts @@ -20,7 +20,6 @@ import type { CCEncodingContext, GetValueDB, ZWaveApplicationHost, - ZWaveHost, } from "@zwave-js/host/safe"; import { type AllOrNone, @@ -210,7 +209,7 @@ export class ColorSwitchCCAPI extends CCAPI { ColorSwitchCommand.SupportedGet, ); - const cc = new ColorSwitchCCSupportedGet(this.applHost, { + const cc = new ColorSwitchCCSupportedGet({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, }); @@ -228,7 +227,7 @@ export class ColorSwitchCCAPI extends CCAPI { public async get(component: ColorComponent) { this.assertSupportsCommand(ColorSwitchCommand, ColorSwitchCommand.Get); - const cc = new ColorSwitchCCGet(this.applHost, { + const cc = new ColorSwitchCCGet({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, colorComponent: component, @@ -248,7 +247,7 @@ export class ColorSwitchCCAPI extends CCAPI { ): Promise { this.assertSupportsCommand(ColorSwitchCommand, ColorSwitchCommand.Set); - const cc = new ColorSwitchCCSet(this.applHost, { + const cc = new ColorSwitchCCSet({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, ...options, @@ -366,7 +365,7 @@ export class ColorSwitchCCAPI extends CCAPI { ColorSwitchCommand.StartLevelChange, ); - const cc = new ColorSwitchCCStartLevelChange(this.applHost, { + const cc = new ColorSwitchCCStartLevelChange({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, ...options, @@ -384,7 +383,7 @@ export class ColorSwitchCCAPI extends CCAPI { ColorSwitchCommand.StopLevelChange, ); - const cc = new ColorSwitchCCStopLevelChange(this.applHost, { + const cc = new ColorSwitchCCStopLevelChange({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, colorComponent, @@ -687,12 +686,11 @@ export interface ColorSwitchCCSupportedReportOptions { @CCCommand(ColorSwitchCommand.SupportedReport) export class ColorSwitchCCSupportedReport extends ColorSwitchCC { public constructor( - host: ZWaveHost, options: | CommandClassDeserializationOptions | (ColorSwitchCCSupportedReportOptions & CCCommandOptions), ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { // Docs say 'variable length', but the table shows 2 bytes. @@ -749,12 +747,11 @@ export type ColorSwitchCCReportOptions = @CCCommand(ColorSwitchCommand.Report) export class ColorSwitchCCReport extends ColorSwitchCC { public constructor( - host: ZWaveHost, options: | CommandClassDeserializationOptions | (ColorSwitchCCReportOptions & CCCommandOptions), ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { validatePayload(this.payload.length >= 2); @@ -905,10 +902,9 @@ function testResponseForColorSwitchGet( @expectedCCResponse(ColorSwitchCCReport, testResponseForColorSwitchGet) export class ColorSwitchCCGet extends ColorSwitchCC { public constructor( - host: ZWaveHost, options: CommandClassDeserializationOptions | ColorSwitchCCGetOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { validatePayload(this.payload.length >= 1); this._colorComponent = this.payload[0]; @@ -958,12 +954,11 @@ export type ColorSwitchCCSetOptions = (ColorTable | { hexColor: string }) & { @useSupervision() export class ColorSwitchCCSet extends ColorSwitchCC { public constructor( - host: ZWaveHost, options: | CommandClassDeserializationOptions | (CCCommandOptions & ColorSwitchCCSetOptions), ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { validatePayload(this.payload.length >= 1); const populatedColorCount = this.payload[0] & 0b11111; @@ -1080,12 +1075,11 @@ export type ColorSwitchCCStartLevelChangeOptions = @useSupervision() export class ColorSwitchCCStartLevelChange extends ColorSwitchCC { public constructor( - host: ZWaveHost, options: | CommandClassDeserializationOptions | (CCCommandOptions & ColorSwitchCCStartLevelChangeOptions), ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { validatePayload(this.payload.length >= 3); const ignoreStartLevel = (this.payload[0] & 0b0_0_1_00000) >>> 5; @@ -1167,12 +1161,11 @@ export interface ColorSwitchCCStopLevelChangeOptions extends CCCommandOptions { @useSupervision() export class ColorSwitchCCStopLevelChange extends ColorSwitchCC { public constructor( - host: ZWaveHost, options: | CommandClassDeserializationOptions | ColorSwitchCCStopLevelChangeOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { validatePayload(this.payload.length >= 1); this.colorComponent = this.payload[0]; diff --git a/packages/cc/src/cc/ConfigurationCC.ts b/packages/cc/src/cc/ConfigurationCC.ts index fd5846dd4298..95f3099630f4 100644 --- a/packages/cc/src/cc/ConfigurationCC.ts +++ b/packages/cc/src/cc/ConfigurationCC.ts @@ -29,7 +29,6 @@ import type { CCParsingContext, GetValueDB, ZWaveApplicationHost, - ZWaveHost, } from "@zwave-js/host/safe"; import { getEnumMemberName, pick } from "@zwave-js/shared/safe"; import { validateArgs } from "@zwave-js/transformers"; @@ -147,11 +146,9 @@ type NormalizedConfigurationCCAPISetOptions = ); function createConfigurationCCInstance( - applHost: ZWaveApplicationHost, endpoint: CCAPIEndpoint, ): ConfigurationCC { return CommandClass.createInstanceUnchecked( - applHost, endpoint.virtual ? endpoint.node.physicalNodes[0] : endpoint, ConfigurationCC, )!; @@ -164,7 +161,7 @@ function normalizeConfigurationCCAPISetOptions( ): NormalizedConfigurationCCAPISetOptions { if ("bitMask" in options && options.bitMask) { // Variant 3: Partial param, look it up in the device config - const ccc = createConfigurationCCInstance(applHost, endpoint); + const ccc = createConfigurationCCInstance(endpoint); const paramInfo = ccc.getParamInformation( applHost, options.parameter, @@ -193,7 +190,7 @@ function normalizeConfigurationCCAPISetOptions( ]); } else { // Variant 1: Normal parameter, defined in a config file - const ccc = createConfigurationCCInstance(applHost, endpoint); + const ccc = createConfigurationCCInstance(endpoint); const paramInfo = ccc.getParamInformation( applHost, options.parameter, @@ -234,7 +231,7 @@ function bulkMergePartialParamValues( } // and push the merged result into the array we'll be working with if (unmergedPartials.size) { - const ccc = createConfigurationCCInstance(applHost, endpoint); + const ccc = createConfigurationCCInstance(endpoint); for (const [parameter, partials] of unmergedPartials) { allParams.push({ parameter, @@ -344,10 +341,7 @@ export class ConfigurationCCAPI extends CCAPI { const applHost = this.applHost; if (this.isSinglecast()) { - ccInstance = createConfigurationCCInstance( - this.applHost, - this.endpoint, - ); + ccInstance = createConfigurationCCInstance(this.endpoint); } else if (this.isMulticast()) { // Multicast is only possible if the parameter definition is the same on all target nodes const nodes = this.endpoint.node.physicalNodes; @@ -367,7 +361,6 @@ export class ConfigurationCCAPI extends CCAPI { const paramInfos = this.endpoint.node.physicalNodes.map( (node) => createConfigurationCCInstance( - this.applHost, node.getEndpoint(this.endpoint.index)!, ).getParamInformation( this.applHost, @@ -391,10 +384,7 @@ export class ConfigurationCCAPI extends CCAPI { ); } // If it is, just use the first node to create the CC instance - ccInstance = createConfigurationCCInstance( - this.applHost, - this.endpoint, - ); + ccInstance = createConfigurationCCInstance(this.endpoint); } else { throw new ZWaveError( `The setValue API for Configuration CC is not supported via broadcast!`, @@ -533,7 +523,7 @@ export class ConfigurationCCAPI extends CCAPI { const { valueBitMask, allowUnexpectedResponse } = options ?? {}; - const cc = new ConfigurationCCGet(this.applHost, { + const cc = new ConfigurationCCGet({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, parameter, @@ -602,7 +592,7 @@ export class ConfigurationCCAPI extends CCAPI { this.supportsCommand(ConfigurationCommand.BulkGet) && isConsecutiveArray(distinctParameters) ) { - const cc = new ConfigurationCCBulkGet(this.applHost, { + const cc = new ConfigurationCCBulkGet({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, parameters: distinctParameters, @@ -622,7 +612,7 @@ export class ConfigurationCCAPI extends CCAPI { const _values = new Map(); for (const parameter of distinctParameters) { - const cc = new ConfigurationCCGet(this.applHost, { + const cc = new ConfigurationCCGet({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, parameter, @@ -641,7 +631,7 @@ export class ConfigurationCCAPI extends CCAPI { } // Combine the returned values with the requested ones - const cc = createConfigurationCCInstance(this.applHost, this.endpoint); + const cc = createConfigurationCCInstance(this.endpoint); return options.map((o) => { let value = values?.get(o.parameter); if (typeof value === "number" && o.bitMask) { @@ -684,10 +674,7 @@ export class ConfigurationCCAPI extends CCAPI { ); let value = normalized.value; if (normalized.bitMask) { - const ccc = createConfigurationCCInstance( - this.applHost, - this.endpoint, - ); + const ccc = createConfigurationCCInstance(this.endpoint); value = ccc.composePartialParamValue( this.applHost, normalized.parameter, @@ -695,7 +682,7 @@ export class ConfigurationCCAPI extends CCAPI { normalized.value, ); } - const cc = new ConfigurationCCSet(this.applHost, { + const cc = new ConfigurationCCSet({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, resetToDefault: false, @@ -739,7 +726,7 @@ export class ConfigurationCCAPI extends CCAPI { && new Set(allParams.map((v) => v.valueSize)).size === 1; if (canUseBulkSet) { - const cc = new ConfigurationCCBulkSet(this.applHost, { + const cc = new ConfigurationCCBulkSet({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, parameters: allParams.map((v) => v.parameter), @@ -787,7 +774,7 @@ export class ConfigurationCCAPI extends CCAPI { valueFormat, } of allParams ) { - const cc = new ConfigurationCCSet(this.applHost, { + const cc = new ConfigurationCCSet({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, parameter, @@ -833,7 +820,7 @@ export class ConfigurationCCAPI extends CCAPI { ConfigurationCommand.Set, ); - const cc = new ConfigurationCCSet(this.applHost, { + const cc = new ConfigurationCCSet({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, parameter, @@ -855,7 +842,7 @@ export class ConfigurationCCAPI extends CCAPI { isConsecutiveArray(parameters) && this.supportsCommand(ConfigurationCommand.BulkSet) ) { - const cc = new ConfigurationCCBulkSet(this.applHost, { + const cc = new ConfigurationCCBulkSet({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, parameters, @@ -869,7 +856,7 @@ export class ConfigurationCCAPI extends CCAPI { ); const CCs = distinct(parameters).map( (parameter) => - new ConfigurationCCSet(this.applHost, { + new ConfigurationCCSet({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, parameter, @@ -892,7 +879,7 @@ export class ConfigurationCCAPI extends CCAPI { ConfigurationCommand.DefaultReset, ); - const cc = new ConfigurationCCDefaultReset(this.applHost, { + const cc = new ConfigurationCCDefaultReset({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, }); @@ -905,7 +892,7 @@ export class ConfigurationCCAPI extends CCAPI { // Get-type commands are only possible in singlecast this.assertPhysicalEndpoint(this.endpoint); - const cc = new ConfigurationCCPropertiesGet(this.applHost, { + const cc = new ConfigurationCCPropertiesGet({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, parameter, @@ -938,7 +925,7 @@ export class ConfigurationCCAPI extends CCAPI { // Get-type commands are only possible in singlecast this.assertPhysicalEndpoint(this.endpoint); - const cc = new ConfigurationCCNameGet(this.applHost, { + const cc = new ConfigurationCCNameGet({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, parameter, @@ -958,7 +945,7 @@ export class ConfigurationCCAPI extends CCAPI { // Get-type commands are only possible in singlecast this.assertPhysicalEndpoint(this.endpoint); - const cc = new ConfigurationCCInfoGet(this.applHost, { + const cc = new ConfigurationCCInfoGet({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, parameter, @@ -999,10 +986,7 @@ export class ConfigurationCCAPI extends CCAPI { endpoint: this.endpoint.index, message: `Scanning available parameters...`, }); - const ccInstance = createConfigurationCCInstance( - this.applHost, - this.endpoint, - ); + const ccInstance = createConfigurationCCInstance(this.endpoint); for (let param = 1; param <= 255; param++) { // Check if the parameter is readable let originalValue: ConfigValue | undefined; @@ -1614,12 +1598,11 @@ export interface ConfigurationCCReportOptions extends CCCommandOptions { @CCCommand(ConfigurationCommand.Report) export class ConfigurationCCReport extends ConfigurationCC { public constructor( - host: ZWaveHost, options: | CommandClassDeserializationOptions | ConfigurationCCReportOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { // All fields must be present @@ -1799,10 +1782,9 @@ export interface ConfigurationCCGetOptions extends CCCommandOptions { @expectedCCResponse(ConfigurationCCReport, testResponseForConfigurationGet) export class ConfigurationCCGet extends ConfigurationCC { public constructor( - host: ZWaveHost, options: CommandClassDeserializationOptions | ConfigurationCCGetOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { validatePayload(this.payload.length >= 1); this.parameter = this.payload[0]; @@ -1852,10 +1834,9 @@ export type ConfigurationCCSetOptions = @useSupervision() export class ConfigurationCCSet extends ConfigurationCC { public constructor( - host: ZWaveHost, options: CommandClassDeserializationOptions | ConfigurationCCSetOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { validatePayload(this.payload.length >= 2); this.parameter = this.payload[0]; @@ -1988,12 +1969,11 @@ function getResponseForBulkSet(cc: ConfigurationCCBulkSet) { @useSupervision() export class ConfigurationCCBulkSet extends ConfigurationCC { public constructor( - host: ZWaveHost, options: | CommandClassDeserializationOptions | ConfigurationCCBulkSetOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { // TODO: Deserialize payload throw new ZWaveError( @@ -2128,10 +2108,9 @@ export class ConfigurationCCBulkSet extends ConfigurationCC { @CCCommand(ConfigurationCommand.BulkReport) export class ConfigurationCCBulkReport extends ConfigurationCC { public constructor( - host: ZWaveHost, options: CommandClassDeserializationOptions, ) { - super(host, options); + super(options); // Ensure we received enough bytes for the preamble validatePayload(this.payload.length >= 5); @@ -2259,12 +2238,11 @@ export interface ConfigurationCCBulkGetOptions extends CCCommandOptions { @expectedCCResponse(ConfigurationCCBulkReport) export class ConfigurationCCBulkGet extends ConfigurationCC { public constructor( - host: ZWaveHost, options: | CommandClassDeserializationOptions | ConfigurationCCBulkGetOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { // TODO: Deserialize payload throw new ZWaveError( @@ -2312,12 +2290,11 @@ export interface ConfigurationCCNameReportOptions extends CCCommandOptions { @CCCommand(ConfigurationCommand.NameReport) export class ConfigurationCCNameReport extends ConfigurationCC { public constructor( - host: ZWaveHost, options: | CommandClassDeserializationOptions | ConfigurationCCNameReportOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { // Parameter and # of reports must be present @@ -2422,10 +2399,9 @@ export class ConfigurationCCNameReport extends ConfigurationCC { @expectedCCResponse(ConfigurationCCNameReport) export class ConfigurationCCNameGet extends ConfigurationCC { public constructor( - host: ZWaveHost, options: CommandClassDeserializationOptions | ConfigurationCCGetOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { validatePayload(this.payload.length >= 2); this.parameter = this.payload.readUInt16BE(0); @@ -2460,12 +2436,11 @@ export interface ConfigurationCCInfoReportOptions extends CCCommandOptions { @CCCommand(ConfigurationCommand.InfoReport) export class ConfigurationCCInfoReport extends ConfigurationCC { public constructor( - host: ZWaveHost, options: | CommandClassDeserializationOptions | ConfigurationCCInfoReportOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { // Parameter and # of reports must be present @@ -2583,10 +2558,9 @@ export class ConfigurationCCInfoReport extends ConfigurationCC { @expectedCCResponse(ConfigurationCCInfoReport) export class ConfigurationCCInfoGet extends ConfigurationCC { public constructor( - host: ZWaveHost, options: CommandClassDeserializationOptions | ConfigurationCCGetOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { validatePayload(this.payload.length >= 2); this.parameter = this.payload.readUInt16BE(0); @@ -2631,12 +2605,11 @@ export interface ConfigurationCCPropertiesReportOptions @CCCommand(ConfigurationCommand.PropertiesReport) export class ConfigurationCCPropertiesReport extends ConfigurationCC { public constructor( - host: ZWaveHost, options: | CommandClassDeserializationOptions | ConfigurationCCPropertiesReportOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { validatePayload(this.payload.length >= 3); @@ -2907,10 +2880,9 @@ export class ConfigurationCCPropertiesReport extends ConfigurationCC { @expectedCCResponse(ConfigurationCCPropertiesReport) export class ConfigurationCCPropertiesGet extends ConfigurationCC { public constructor( - host: ZWaveHost, options: CommandClassDeserializationOptions | ConfigurationCCGetOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { validatePayload(this.payload.length >= 2); this.parameter = this.payload.readUInt16BE(0); diff --git a/packages/cc/src/cc/DeviceResetLocallyCC.ts b/packages/cc/src/cc/DeviceResetLocallyCC.ts index 8a028fa9e3c7..9927ddff1922 100644 --- a/packages/cc/src/cc/DeviceResetLocallyCC.ts +++ b/packages/cc/src/cc/DeviceResetLocallyCC.ts @@ -4,7 +4,6 @@ import { TransmitOptions, validatePayload, } from "@zwave-js/core/safe"; -import type { ZWaveHost } from "@zwave-js/host/safe"; import { CCAPI } from "../lib/API"; import { CommandClass, @@ -39,7 +38,7 @@ export class DeviceResetLocallyCCAPI extends CCAPI { DeviceResetLocallyCommand.Notification, ); - const cc = new DeviceResetLocallyCCNotification(this.applHost, { + const cc = new DeviceResetLocallyCCNotification({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, }); @@ -73,8 +72,8 @@ export class DeviceResetLocallyCC extends CommandClass { @CCCommand(DeviceResetLocallyCommand.Notification) export class DeviceResetLocallyCCNotification extends DeviceResetLocallyCC { - public constructor(host: ZWaveHost, options: CommandClassOptions) { - super(host, options); + public constructor(options: CommandClassOptions) { + super(options); if (gotDeserializationOptions(options)) { // We need to make sure this doesn't get parsed accidentally, e.g. because of a bit flip diff --git a/packages/cc/src/cc/DoorLockCC.ts b/packages/cc/src/cc/DoorLockCC.ts index 218842b9b29d..90d1728687eb 100644 --- a/packages/cc/src/cc/DoorLockCC.ts +++ b/packages/cc/src/cc/DoorLockCC.ts @@ -19,7 +19,6 @@ import type { CCEncodingContext, GetValueDB, ZWaveApplicationHost, - ZWaveHost, } from "@zwave-js/host/safe"; import { getEnumMemberName, pick } from "@zwave-js/shared/safe"; import { validateArgs } from "@zwave-js/transformers"; @@ -465,7 +464,7 @@ export class DoorLockCCAPI extends PhysicalCCAPI { DoorLockCommand.CapabilitiesGet, ); - const cc = new DoorLockCCCapabilitiesGet(this.applHost, { + const cc = new DoorLockCCCapabilitiesGet({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, }); @@ -499,7 +498,7 @@ export class DoorLockCCAPI extends PhysicalCCAPI { DoorLockCommand.OperationGet, ); - const cc = new DoorLockCCOperationGet(this.applHost, { + const cc = new DoorLockCCOperationGet({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, }); @@ -533,7 +532,7 @@ export class DoorLockCCAPI extends PhysicalCCAPI { DoorLockCommand.OperationSet, ); - const cc = new DoorLockCCOperationSet(this.applHost, { + const cc = new DoorLockCCOperationSet({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, mode, @@ -550,7 +549,7 @@ export class DoorLockCCAPI extends PhysicalCCAPI { DoorLockCommand.ConfigurationSet, ); - const cc = new DoorLockCCConfigurationSet(this.applHost, { + const cc = new DoorLockCCConfigurationSet({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, ...configuration, @@ -565,7 +564,7 @@ export class DoorLockCCAPI extends PhysicalCCAPI { DoorLockCommand.ConfigurationGet, ); - const cc = new DoorLockCCConfigurationGet(this.applHost, { + const cc = new DoorLockCCConfigurationGet({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, }); @@ -829,12 +828,11 @@ export interface DoorLockCCOperationSetOptions extends CCCommandOptions { @useSupervision() export class DoorLockCCOperationSet extends DoorLockCC { public constructor( - host: ZWaveHost, options: | CommandClassDeserializationOptions | DoorLockCCOperationSetOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { // TODO: Deserialize payload throw new ZWaveError( @@ -872,10 +870,9 @@ export class DoorLockCCOperationSet extends DoorLockCC { @CCCommand(DoorLockCommand.OperationReport) export class DoorLockCCOperationReport extends DoorLockCC { public constructor( - host: ZWaveHost, options: CommandClassDeserializationOptions, ) { - super(host, options); + super(options); validatePayload(this.payload.length >= 5); this.currentMode = this.payload[0]; @@ -1015,10 +1012,9 @@ export class DoorLockCCOperationGet extends DoorLockCC {} @CCCommand(DoorLockCommand.ConfigurationReport) export class DoorLockCCConfigurationReport extends DoorLockCC { public constructor( - host: ZWaveHost, options: CommandClassDeserializationOptions, ) { - super(host, options); + super(options); validatePayload(this.payload.length >= 4); this.operationType = this.payload[0]; @@ -1190,12 +1186,11 @@ export type DoorLockCCConfigurationSetOptions = @useSupervision() export class DoorLockCCConfigurationSet extends DoorLockCC { public constructor( - host: ZWaveHost, options: | CommandClassDeserializationOptions | (CCCommandOptions & DoorLockCCConfigurationSetOptions), ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { // TODO: Deserialize payload throw new ZWaveError( @@ -1326,10 +1321,9 @@ export class DoorLockCCConfigurationSet extends DoorLockCC { @CCCommand(DoorLockCommand.CapabilitiesReport) export class DoorLockCCCapabilitiesReport extends DoorLockCC { public constructor( - host: ZWaveHost, options: CommandClassDeserializationOptions, ) { - super(host, options); + super(options); // parse variable length operation type bit mask validatePayload(this.payload.length >= 1); diff --git a/packages/cc/src/cc/DoorLockLoggingCC.ts b/packages/cc/src/cc/DoorLockLoggingCC.ts index 9272a10eca27..543bf87dc997 100644 --- a/packages/cc/src/cc/DoorLockLoggingCC.ts +++ b/packages/cc/src/cc/DoorLockLoggingCC.ts @@ -12,7 +12,6 @@ import type { CCEncodingContext, GetValueDB, ZWaveApplicationHost, - ZWaveHost, } from "@zwave-js/host/safe"; import { isPrintableASCII, num2hex } from "@zwave-js/shared/safe"; import { validateArgs } from "@zwave-js/transformers"; @@ -128,7 +127,7 @@ export class DoorLockLoggingCCAPI extends PhysicalCCAPI { DoorLockLoggingCommand.RecordsSupportedGet, ); - const cc = new DoorLockLoggingCCRecordsSupportedGet(this.applHost, { + const cc = new DoorLockLoggingCCRecordsSupportedGet({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, }); @@ -151,7 +150,7 @@ export class DoorLockLoggingCCAPI extends PhysicalCCAPI { DoorLockLoggingCommand.RecordGet, ); - const cc = new DoorLockLoggingCCRecordGet(this.applHost, { + const cc = new DoorLockLoggingCCRecordGet({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, recordNumber, @@ -233,10 +232,9 @@ export class DoorLockLoggingCC extends CommandClass { @CCCommand(DoorLockLoggingCommand.RecordsSupportedReport) export class DoorLockLoggingCCRecordsSupportedReport extends DoorLockLoggingCC { public constructor( - host: ZWaveHost, options: CommandClassDeserializationOptions, ) { - super(host, options); + super(options); validatePayload(this.payload.length >= 1); this.recordsCount = this.payload[0]; @@ -269,10 +267,9 @@ export class DoorLockLoggingCCRecordsSupportedGet extends DoorLockLoggingCC {} @CCCommand(DoorLockLoggingCommand.RecordReport) export class DoorLockLoggingCCRecordReport extends DoorLockLoggingCC { public constructor( - host: ZWaveHost, options: CommandClassDeserializationOptions, ) { - super(host, options); + super(options); validatePayload(this.payload.length >= 11); this.recordNumber = this.payload[0]; @@ -372,12 +369,11 @@ function testResponseForDoorLockLoggingRecordGet( ) export class DoorLockLoggingCCRecordGet extends DoorLockLoggingCC { public constructor( - host: ZWaveHost, options: | CommandClassDeserializationOptions | DoorLockLoggingCCRecordGetOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { throw new ZWaveError( `${this.constructor.name}: deserialization not implemented`, diff --git a/packages/cc/src/cc/EnergyProductionCC.ts b/packages/cc/src/cc/EnergyProductionCC.ts index 6a1195c1fb57..15cd08892ed0 100644 --- a/packages/cc/src/cc/EnergyProductionCC.ts +++ b/packages/cc/src/cc/EnergyProductionCC.ts @@ -12,7 +12,6 @@ import type { CCEncodingContext, GetValueDB, ZWaveApplicationHost, - ZWaveHost, } from "@zwave-js/host"; import { getEnumMemberName, pick } from "@zwave-js/shared"; import { validateArgs } from "@zwave-js/transformers"; @@ -111,7 +110,7 @@ export class EnergyProductionCCAPI extends CCAPI { EnergyProductionCommand.Get, ); - const cc = new EnergyProductionCCGet(this.applHost, { + const cc = new EnergyProductionCCGet({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, parameter, @@ -199,12 +198,11 @@ export interface EnergyProductionCCReportOptions extends CCCommandOptions { @CCCommand(EnergyProductionCommand.Report) export class EnergyProductionCCReport extends EnergyProductionCC { public constructor( - host: ZWaveHost, options: | CommandClassDeserializationOptions | EnergyProductionCCReportOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { validatePayload(this.payload.length >= 2); this.parameter = this.payload[0]; @@ -283,12 +281,11 @@ function testResponseForEnergyProductionGet( ) export class EnergyProductionCCGet extends EnergyProductionCC { public constructor( - host: ZWaveHost, options: | CommandClassDeserializationOptions | EnergyProductionCCGetOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { validatePayload(this.payload.length >= 1); this.parameter = this.payload[0]; diff --git a/packages/cc/src/cc/EntryControlCC.ts b/packages/cc/src/cc/EntryControlCC.ts index cf90c6e35908..5449503ade1e 100644 --- a/packages/cc/src/cc/EntryControlCC.ts +++ b/packages/cc/src/cc/EntryControlCC.ts @@ -17,7 +17,6 @@ import type { CCEncodingContext, GetValueDB, ZWaveApplicationHost, - ZWaveHost, } from "@zwave-js/host/safe"; import { buffer2hex, pick } from "@zwave-js/shared/safe"; import { validateArgs } from "@zwave-js/transformers"; @@ -115,7 +114,7 @@ export class EntryControlCCAPI extends CCAPI { EntryControlCommand.KeySupportedGet, ); - const cc = new EntryControlCCKeySupportedGet(this.applHost, { + const cc = new EntryControlCCKeySupportedGet({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, }); @@ -135,7 +134,7 @@ export class EntryControlCCAPI extends CCAPI { EntryControlCommand.EventSupportedGet, ); - const cc = new EntryControlCCEventSupportedGet(this.applHost, { + const cc = new EntryControlCCEventSupportedGet({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, }); @@ -164,7 +163,7 @@ export class EntryControlCCAPI extends CCAPI { EntryControlCommand.ConfigurationGet, ); - const cc = new EntryControlCCConfigurationGet(this.applHost, { + const cc = new EntryControlCCConfigurationGet({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, }); @@ -189,7 +188,7 @@ export class EntryControlCCAPI extends CCAPI { EntryControlCommand.ConfigurationGet, ); - const cc = new EntryControlCCConfigurationSet(this.applHost, { + const cc = new EntryControlCCConfigurationSet({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, keyCacheSize, @@ -397,10 +396,9 @@ key cache timeout: ${conf.keyCacheTimeout} seconds`, @CCCommand(EntryControlCommand.Notification) export class EntryControlCCNotification extends EntryControlCC { public constructor( - host: ZWaveHost, options: CommandClassDeserializationOptions, ) { - super(host, options); + super(options); validatePayload(this.payload.length >= 4); this.sequenceNumber = this.payload[0]; @@ -499,10 +497,9 @@ export class EntryControlCCNotification extends EntryControlCC { @CCCommand(EntryControlCommand.KeySupportedReport) export class EntryControlCCKeySupportedReport extends EntryControlCC { public constructor( - host: ZWaveHost, options: CommandClassDeserializationOptions, ) { - super(host, options); + super(options); validatePayload(this.payload.length >= 1); const length = this.payload[0]; @@ -531,10 +528,9 @@ export class EntryControlCCKeySupportedGet extends EntryControlCC {} @CCCommand(EntryControlCommand.EventSupportedReport) export class EntryControlCCEventSupportedReport extends EntryControlCC { public constructor( - host: ZWaveHost, options: CommandClassDeserializationOptions, ) { - super(host, options); + super(options); validatePayload(this.payload.length >= 1); const dataTypeLength = this.payload[0] & 0b11; @@ -630,10 +626,9 @@ export class EntryControlCCEventSupportedGet extends EntryControlCC {} @CCCommand(EntryControlCommand.ConfigurationReport) export class EntryControlCCConfigurationReport extends EntryControlCC { public constructor( - host: ZWaveHost, options: CommandClassDeserializationOptions, ) { - super(host, options); + super(options); validatePayload(this.payload.length >= 2); @@ -675,12 +670,11 @@ export interface EntryControlCCConfigurationSetOptions @useSupervision() export class EntryControlCCConfigurationSet extends EntryControlCC { public constructor( - host: ZWaveHost, options: | CommandClassDeserializationOptions | EntryControlCCConfigurationSetOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { // TODO: Deserialize payload throw new ZWaveError( diff --git a/packages/cc/src/cc/FirmwareUpdateMetaDataCC.ts b/packages/cc/src/cc/FirmwareUpdateMetaDataCC.ts index b19fa5814eb2..b5dbdf38ead9 100644 --- a/packages/cc/src/cc/FirmwareUpdateMetaDataCC.ts +++ b/packages/cc/src/cc/FirmwareUpdateMetaDataCC.ts @@ -13,7 +13,6 @@ import type { CCEncodingContext, GetValueDB, ZWaveApplicationHost, - ZWaveHost, } from "@zwave-js/host/safe"; import { type AllOrNone, @@ -116,7 +115,7 @@ export class FirmwareUpdateMetaDataCCAPI extends PhysicalCCAPI { FirmwareUpdateMetaDataCommand.MetaDataGet, ); - const cc = new FirmwareUpdateMetaDataCCMetaDataGet(this.applHost, { + const cc = new FirmwareUpdateMetaDataCCMetaDataGet({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, }); @@ -152,7 +151,7 @@ export class FirmwareUpdateMetaDataCCAPI extends PhysicalCCAPI { FirmwareUpdateMetaDataCommand.Report, ); - const cc = new FirmwareUpdateMetaDataCCMetaDataReport(this.applHost, { + const cc = new FirmwareUpdateMetaDataCCMetaDataReport({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, ...options, @@ -173,7 +172,7 @@ export class FirmwareUpdateMetaDataCCAPI extends PhysicalCCAPI { FirmwareUpdateMetaDataCommand.RequestGet, ); - const cc = new FirmwareUpdateMetaDataCCRequestGet(this.applHost, { + const cc = new FirmwareUpdateMetaDataCCRequestGet({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, ...options, @@ -217,7 +216,7 @@ export class FirmwareUpdateMetaDataCCAPI extends PhysicalCCAPI { FirmwareUpdateMetaDataCommand.Report, ); - const cc = new FirmwareUpdateMetaDataCCReport(this.applHost, { + const cc = new FirmwareUpdateMetaDataCCReport({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, reportNumber: fragmentNumber, @@ -241,7 +240,7 @@ export class FirmwareUpdateMetaDataCCAPI extends PhysicalCCAPI { FirmwareUpdateMetaDataCommand.ActivationSet, ); - const cc = new FirmwareUpdateMetaDataCCActivationSet(this.applHost, { + const cc = new FirmwareUpdateMetaDataCCActivationSet({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, ...options, @@ -349,7 +348,6 @@ export class FirmwareUpdateMetaDataCCMetaDataReport implements FirmwareUpdateMetaData { public constructor( - host: ZWaveHost, options: | CommandClassDeserializationOptions | ( @@ -357,7 +355,7 @@ export class FirmwareUpdateMetaDataCCMetaDataReport & CCCommandOptions ), ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { validatePayload(this.payload.length >= 6); @@ -511,10 +509,9 @@ export class FirmwareUpdateMetaDataCCRequestReport extends FirmwareUpdateMetaDataCC { public constructor( - host: ZWaveHost, options: CommandClassDeserializationOptions, ) { - super(host, options); + super(options); validatePayload(this.payload.length >= 1); this.status = this.payload[0]; if (this.payload.length >= 2) { @@ -574,12 +571,11 @@ export class FirmwareUpdateMetaDataCCRequestGet extends FirmwareUpdateMetaDataCC { public constructor( - host: ZWaveHost, options: | CommandClassDeserializationOptions | (FirmwareUpdateMetaDataCCRequestGetOptions & CCCommandOptions), ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { // TODO: Deserialize payload throw new ZWaveError( @@ -663,10 +659,9 @@ export class FirmwareUpdateMetaDataCCRequestGet // This is sent to us from the node, so we expect no response export class FirmwareUpdateMetaDataCCGet extends FirmwareUpdateMetaDataCC { public constructor( - host: ZWaveHost, options: CommandClassDeserializationOptions, ) { - super(host, options); + super(options); validatePayload(this.payload.length >= 3); this.numReports = this.payload[0]; this.reportNumber = this.payload.readUInt16BE(1) & 0x7fff; @@ -699,12 +694,11 @@ export interface FirmwareUpdateMetaDataCCReportOptions // We send this in reply to the Get command and expect no response export class FirmwareUpdateMetaDataCCReport extends FirmwareUpdateMetaDataCC { public constructor( - host: ZWaveHost, options: | CommandClassDeserializationOptions | FirmwareUpdateMetaDataCCReportOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { // TODO: Deserialize payload throw new ZWaveError( @@ -768,10 +762,9 @@ export class FirmwareUpdateMetaDataCCStatusReport extends FirmwareUpdateMetaDataCC { public constructor( - host: ZWaveHost, options: CommandClassDeserializationOptions, ) { - super(host, options); + super(options); validatePayload(this.payload.length >= 1); this.status = this.payload[0]; if (this.payload.length >= 3) { @@ -802,10 +795,9 @@ export class FirmwareUpdateMetaDataCCActivationReport extends FirmwareUpdateMetaDataCC { public constructor( - host: ZWaveHost, options: CommandClassDeserializationOptions, ) { - super(host, options); + super(options); validatePayload(this.payload.length >= 8); this.manufacturerId = this.payload.readUInt16BE(0); this.firmwareId = this.payload.readUInt16BE(2); @@ -862,12 +854,11 @@ export class FirmwareUpdateMetaDataCCActivationSet extends FirmwareUpdateMetaDataCC { public constructor( - host: ZWaveHost, options: | CommandClassDeserializationOptions | (FirmwareUpdateMetaDataCCActivationSetOptions & CCCommandOptions), ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { // TODO: Deserialize payload throw new ZWaveError( @@ -921,10 +912,9 @@ export class FirmwareUpdateMetaDataCCPrepareReport extends FirmwareUpdateMetaDataCC { public constructor( - host: ZWaveHost, options: CommandClassDeserializationOptions, ) { - super(host, options); + super(options); validatePayload(this.payload.length >= 3); this.status = this.payload[0]; this.checksum = this.payload.readUInt16BE(1); @@ -961,12 +951,11 @@ export class FirmwareUpdateMetaDataCCPrepareGet extends FirmwareUpdateMetaDataCC { public constructor( - host: ZWaveHost, options: | CommandClassDeserializationOptions | FirmwareUpdateMetaDataCCPrepareGetOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { // TODO: Deserialize payload throw new ZWaveError( diff --git a/packages/cc/src/cc/HumidityControlModeCC.ts b/packages/cc/src/cc/HumidityControlModeCC.ts index 754ef6ee0fb2..420952c27566 100644 --- a/packages/cc/src/cc/HumidityControlModeCC.ts +++ b/packages/cc/src/cc/HumidityControlModeCC.ts @@ -16,7 +16,6 @@ import type { CCEncodingContext, GetValueDB, ZWaveApplicationHost, - ZWaveHost, } from "@zwave-js/host/safe"; import { getEnumMemberName } from "@zwave-js/shared/safe"; import { validateArgs } from "@zwave-js/transformers"; @@ -127,7 +126,7 @@ export class HumidityControlModeCCAPI extends CCAPI { HumidityControlModeCommand.Get, ); - const cc = new HumidityControlModeCCGet(this.applHost, { + const cc = new HumidityControlModeCCGet({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, }); @@ -151,7 +150,7 @@ export class HumidityControlModeCCAPI extends CCAPI { HumidityControlModeCommand.Set, ); - const cc = new HumidityControlModeCCSet(this.applHost, { + const cc = new HumidityControlModeCCSet({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, mode, @@ -167,7 +166,7 @@ export class HumidityControlModeCCAPI extends CCAPI { HumidityControlModeCommand.SupportedGet, ); - const cc = new HumidityControlModeCCSupportedGet(this.applHost, { + const cc = new HumidityControlModeCCSupportedGet({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, }); @@ -286,12 +285,11 @@ export interface HumidityControlModeCCSetOptions extends CCCommandOptions { @useSupervision() export class HumidityControlModeCCSet extends HumidityControlModeCC { public constructor( - host: ZWaveHost, options: | CommandClassDeserializationOptions | HumidityControlModeCCSetOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { // TODO: Deserialize payload throw new ZWaveError( @@ -323,10 +321,9 @@ export class HumidityControlModeCCSet extends HumidityControlModeCC { @CCCommand(HumidityControlModeCommand.Report) export class HumidityControlModeCCReport extends HumidityControlModeCC { public constructor( - host: ZWaveHost, options: CommandClassDeserializationOptions, ) { - super(host, options); + super(options); validatePayload(this.payload.length >= 1); this.mode = this.payload[0] & 0b1111; @@ -354,10 +351,9 @@ export class HumidityControlModeCCSupportedReport extends HumidityControlModeCC { public constructor( - host: ZWaveHost, options: CommandClassDeserializationOptions, ) { - super(host, options); + super(options); validatePayload(this.payload.length >= 1); this._supportedModes = parseBitMask( diff --git a/packages/cc/src/cc/HumidityControlOperatingStateCC.ts b/packages/cc/src/cc/HumidityControlOperatingStateCC.ts index 9d6b9d8a26c8..c82b18931e67 100644 --- a/packages/cc/src/cc/HumidityControlOperatingStateCC.ts +++ b/packages/cc/src/cc/HumidityControlOperatingStateCC.ts @@ -7,11 +7,7 @@ import { enumValuesToMetadataStates, validatePayload, } from "@zwave-js/core/safe"; -import type { - GetValueDB, - ZWaveApplicationHost, - ZWaveHost, -} from "@zwave-js/host/safe"; +import type { GetValueDB, ZWaveApplicationHost } from "@zwave-js/host/safe"; import { getEnumMemberName } from "@zwave-js/shared/safe"; import { CCAPI, @@ -90,7 +86,7 @@ export class HumidityControlOperatingStateCCAPI extends CCAPI { HumidityControlOperatingStateCommand.Get, ); - const cc = new HumidityControlOperatingStateCCGet(this.applHost, { + const cc = new HumidityControlOperatingStateCCGet({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, }); @@ -168,10 +164,9 @@ export class HumidityControlOperatingStateCCReport extends HumidityControlOperatingStateCC { public constructor( - host: ZWaveHost, options: CommandClassDeserializationOptions, ) { - super(host, options); + super(options); validatePayload(this.payload.length >= 1); this.state = this.payload[0] & 0b1111; diff --git a/packages/cc/src/cc/HumidityControlSetpointCC.ts b/packages/cc/src/cc/HumidityControlSetpointCC.ts index 2fa2eb871178..87c5a9f13adc 100644 --- a/packages/cc/src/cc/HumidityControlSetpointCC.ts +++ b/packages/cc/src/cc/HumidityControlSetpointCC.ts @@ -21,7 +21,6 @@ import type { CCEncodingContext, GetValueDB, ZWaveApplicationHost, - ZWaveHost, } from "@zwave-js/host/safe"; import { getEnumMemberName, pick } from "@zwave-js/shared/safe"; import { validateArgs } from "@zwave-js/transformers"; @@ -208,7 +207,7 @@ export class HumidityControlSetpointCCAPI extends CCAPI { HumidityControlSetpointCommand.Get, ); - const cc = new HumidityControlSetpointCCGet(this.applHost, { + const cc = new HumidityControlSetpointCCGet({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, setpointType, @@ -241,7 +240,7 @@ export class HumidityControlSetpointCCAPI extends CCAPI { HumidityControlSetpointCommand.Set, ); - const cc = new HumidityControlSetpointCCSet(this.applHost, { + const cc = new HumidityControlSetpointCCSet({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, setpointType, @@ -260,7 +259,7 @@ export class HumidityControlSetpointCCAPI extends CCAPI { HumidityControlSetpointCommand.CapabilitiesGet, ); - const cc = new HumidityControlSetpointCCCapabilitiesGet(this.applHost, { + const cc = new HumidityControlSetpointCCCapabilitiesGet({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, setpointType, @@ -289,7 +288,7 @@ export class HumidityControlSetpointCCAPI extends CCAPI { HumidityControlSetpointCommand.SupportedGet, ); - const cc = new HumidityControlSetpointCCSupportedGet(this.applHost, { + const cc = new HumidityControlSetpointCCSupportedGet({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, }); @@ -311,14 +310,11 @@ export class HumidityControlSetpointCCAPI extends CCAPI { HumidityControlSetpointCommand.SupportedGet, ); - const cc = new HumidityControlSetpointCCScaleSupportedGet( - this.applHost, - { - nodeId: this.endpoint.nodeId, - endpoint: this.endpoint.index, - setpointType, - }, - ); + const cc = new HumidityControlSetpointCCScaleSupportedGet({ + nodeId: this.endpoint.nodeId, + endpoint: this.endpoint.index, + setpointType, + }); const response = await this.applHost.sendCommand< HumidityControlSetpointCCScaleSupportedReport >( @@ -527,12 +523,11 @@ export interface HumidityControlSetpointCCSetOptions extends CCCommandOptions { @useSupervision() export class HumidityControlSetpointCCSet extends HumidityControlSetpointCC { public constructor( - host: ZWaveHost, options: | CommandClassDeserializationOptions | HumidityControlSetpointCCSetOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { // TODO: Deserialize payload throw new ZWaveError( @@ -576,10 +571,9 @@ export class HumidityControlSetpointCCSet extends HumidityControlSetpointCC { @CCCommand(HumidityControlSetpointCommand.Report) export class HumidityControlSetpointCCReport extends HumidityControlSetpointCC { public constructor( - host: ZWaveHost, options: CommandClassDeserializationOptions, ) { - super(host, options); + super(options); validatePayload(this.payload.length >= 1); this._type = this.payload[0] & 0b1111; @@ -675,12 +669,11 @@ export interface HumidityControlSetpointCCGetOptions extends CCCommandOptions { ) export class HumidityControlSetpointCCGet extends HumidityControlSetpointCC { public constructor( - host: ZWaveHost, options: | CommandClassDeserializationOptions | HumidityControlSetpointCCGetOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { // TODO: Deserialize payload throw new ZWaveError( @@ -717,10 +710,9 @@ export class HumidityControlSetpointCCSupportedReport extends HumidityControlSetpointCC { public constructor( - host: ZWaveHost, options: CommandClassDeserializationOptions, ) { - super(host, options); + super(options); validatePayload(this.payload.length >= 1); this.supportedSetpointTypes = parseBitMask( @@ -764,10 +756,9 @@ export class HumidityControlSetpointCCScaleSupportedReport extends HumidityControlSetpointCC { public constructor( - host: ZWaveHost, options: CommandClassDeserializationOptions, ) { - super(host, options); + super(options); validatePayload(this.payload.length >= 1); @@ -807,12 +798,11 @@ export class HumidityControlSetpointCCScaleSupportedGet extends HumidityControlSetpointCC { public constructor( - host: ZWaveHost, options: | CommandClassDeserializationOptions | HumidityControlSetpointCCScaleSupportedGetOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { // TODO: Deserialize payload throw new ZWaveError( @@ -849,10 +839,9 @@ export class HumidityControlSetpointCCCapabilitiesReport extends HumidityControlSetpointCC { public constructor( - host: ZWaveHost, options: CommandClassDeserializationOptions, ) { - super(host, options); + super(options); validatePayload(this.payload.length >= 1); this._type = this.payload[0] & 0b1111; @@ -940,12 +929,11 @@ export class HumidityControlSetpointCCCapabilitiesGet extends HumidityControlSetpointCC { public constructor( - host: ZWaveHost, options: | CommandClassDeserializationOptions | HumidityControlSetpointCCCapabilitiesGetOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { // TODO: Deserialize payload throw new ZWaveError( diff --git a/packages/cc/src/cc/InclusionControllerCC.ts b/packages/cc/src/cc/InclusionControllerCC.ts index 2902bdb40f55..515b6d04fb53 100644 --- a/packages/cc/src/cc/InclusionControllerCC.ts +++ b/packages/cc/src/cc/InclusionControllerCC.ts @@ -4,7 +4,7 @@ import { validatePayload, } from "@zwave-js/core"; import { type MaybeNotKnown } from "@zwave-js/core/safe"; -import type { CCEncodingContext, GetValueDB, ZWaveHost } from "@zwave-js/host"; +import type { CCEncodingContext, GetValueDB } from "@zwave-js/host"; import { getEnumMemberName } from "@zwave-js/shared"; import { CCAPI } from "../lib/API"; import { @@ -57,7 +57,7 @@ export class InclusionControllerCCAPI extends CCAPI { InclusionControllerCommand.Initiate, ); - const cc = new InclusionControllerCCInitiate(this.applHost, { + const cc = new InclusionControllerCCInitiate({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, includedNodeId: nodeId, @@ -76,7 +76,7 @@ export class InclusionControllerCCAPI extends CCAPI { InclusionControllerCommand.Complete, ); - const cc = new InclusionControllerCCComplete(this.applHost, { + const cc = new InclusionControllerCCComplete({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, step, @@ -95,12 +95,11 @@ export interface InclusionControllerCCCompleteOptions extends CCCommandOptions { @CCCommand(InclusionControllerCommand.Complete) export class InclusionControllerCCComplete extends InclusionControllerCC { public constructor( - host: ZWaveHost, options: | CommandClassDeserializationOptions | InclusionControllerCCCompleteOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { validatePayload(this.payload.length >= 2); this.step = this.payload[0]; @@ -145,12 +144,11 @@ export interface InclusionControllerCCInitiateOptions extends CCCommandOptions { @CCCommand(InclusionControllerCommand.Initiate) export class InclusionControllerCCInitiate extends InclusionControllerCC { public constructor( - host: ZWaveHost, options: | CommandClassDeserializationOptions | InclusionControllerCCInitiateOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { validatePayload(this.payload.length >= 2); this.includedNodeId = this.payload[0]; diff --git a/packages/cc/src/cc/IndicatorCC.ts b/packages/cc/src/cc/IndicatorCC.ts index 53c33b3ab315..9f0c2a7322d1 100644 --- a/packages/cc/src/cc/IndicatorCC.ts +++ b/packages/cc/src/cc/IndicatorCC.ts @@ -19,7 +19,6 @@ import type { CCEncodingContext, GetValueDB, ZWaveApplicationHost, - ZWaveHost, } from "@zwave-js/host/safe"; import { num2hex } from "@zwave-js/shared/safe"; import { validateArgs } from "@zwave-js/transformers"; @@ -359,7 +358,7 @@ export class IndicatorCCAPI extends CCAPI { ): Promise> { this.assertSupportsCommand(IndicatorCommand, IndicatorCommand.Get); - const cc = new IndicatorCCGet(this.applHost, { + const cc = new IndicatorCCGet({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, indicatorId, @@ -396,7 +395,7 @@ export class IndicatorCCAPI extends CCAPI { ); } - const cc = new IndicatorCCSet(this.applHost, { + const cc = new IndicatorCCSet({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, ...(typeof value === "number" ? { value } : { values: value }), @@ -413,7 +412,7 @@ export class IndicatorCCAPI extends CCAPI { IndicatorCommand.Report, ); - const cc = new IndicatorCCReport(this.applHost, { + const cc = new IndicatorCCReport({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, ...options, @@ -436,7 +435,7 @@ export class IndicatorCCAPI extends CCAPI { IndicatorCommand.SupportedGet, ); - const cc = new IndicatorCCSupportedGet(this.applHost, { + const cc = new IndicatorCCSupportedGet({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, indicatorId, @@ -470,7 +469,7 @@ export class IndicatorCCAPI extends CCAPI { IndicatorCommand.SupportedReport, ); - const cc = new IndicatorCCSupportedReport(this.applHost, { + const cc = new IndicatorCCSupportedReport({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, indicatorId, @@ -491,7 +490,7 @@ export class IndicatorCCAPI extends CCAPI { IndicatorCommand.DescriptionReport, ); - const cc = new IndicatorCCDescriptionReport(this.applHost, { + const cc = new IndicatorCCDescriptionReport({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, indicatorId, @@ -671,7 +670,7 @@ export class IndicatorCCAPI extends CCAPI { IndicatorCommand.DescriptionGet, ); - const cc = new IndicatorCCDescriptionGet(this.applHost, { + const cc = new IndicatorCCDescriptionGet({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, indicatorId, @@ -902,12 +901,11 @@ export type IndicatorCCSetOptions = @useSupervision() export class IndicatorCCSet extends IndicatorCC { public constructor( - host: ZWaveHost, options: | CommandClassDeserializationOptions | (IndicatorCCSetOptions & CCCommandOptions), ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { validatePayload(this.payload.length >= 1); @@ -1002,12 +1000,11 @@ export type IndicatorCCReportSpecificOptions = @CCCommand(IndicatorCommand.Report) export class IndicatorCCReport extends IndicatorCC { public constructor( - host: ZWaveHost, options: | CommandClassDeserializationOptions | (IndicatorCCReportSpecificOptions & CCCommandOptions), ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { validatePayload(this.payload.length >= 1); @@ -1212,10 +1209,9 @@ export interface IndicatorCCGetOptions extends CCCommandOptions { @expectedCCResponse(IndicatorCCReport) export class IndicatorCCGet extends IndicatorCC { public constructor( - host: ZWaveHost, options: CommandClassDeserializationOptions | IndicatorCCGetOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { if (this.payload.length > 0) { this.indicatorId = this.payload[0]; @@ -1254,12 +1250,11 @@ export interface IndicatorCCSupportedReportOptions extends CCCommandOptions { @CCCommand(IndicatorCommand.SupportedReport) export class IndicatorCCSupportedReport extends IndicatorCC { public constructor( - host: ZWaveHost, options: | CommandClassDeserializationOptions | IndicatorCCSupportedReportOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { validatePayload(this.payload.length >= 3); @@ -1356,12 +1351,11 @@ function testResponseForIndicatorSupportedGet( ) export class IndicatorCCSupportedGet extends IndicatorCC { public constructor( - host: ZWaveHost, options: | CommandClassDeserializationOptions | IndicatorCCSupportedGetOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { validatePayload(this.payload.length >= 1); this.indicatorId = this.payload[0]; @@ -1396,12 +1390,11 @@ export interface IndicatorCCDescriptionReportOptions { @CCCommand(IndicatorCommand.DescriptionReport) export class IndicatorCCDescriptionReport extends IndicatorCC { public constructor( - host: ZWaveHost, options: | CommandClassDeserializationOptions | (IndicatorCCDescriptionReportOptions & CCCommandOptions), ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { validatePayload(this.payload.length >= 2); @@ -1473,12 +1466,11 @@ function testResponseForIndicatorDescriptionGet( ) export class IndicatorCCDescriptionGet extends IndicatorCC { public constructor( - host: ZWaveHost, options: | CommandClassDeserializationOptions | IndicatorCCDescriptionGetOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { validatePayload(this.payload.length >= 1); this.indicatorId = this.payload[0]; diff --git a/packages/cc/src/cc/IrrigationCC.ts b/packages/cc/src/cc/IrrigationCC.ts index ec06da849953..c2b09fbda68c 100644 --- a/packages/cc/src/cc/IrrigationCC.ts +++ b/packages/cc/src/cc/IrrigationCC.ts @@ -19,7 +19,6 @@ import type { CCEncodingContext, GetValueDB, ZWaveApplicationHost, - ZWaveHost, } from "@zwave-js/host/safe"; import { getEnumMemberName, pick } from "@zwave-js/shared/safe"; import { validateArgs } from "@zwave-js/transformers"; @@ -604,7 +603,7 @@ export class IrrigationCCAPI extends CCAPI { IrrigationCommand.SystemInfoGet, ); - const cc = new IrrigationCCSystemInfoGet(this.applHost, { + const cc = new IrrigationCCSystemInfoGet({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, }); @@ -631,7 +630,7 @@ export class IrrigationCCAPI extends CCAPI { IrrigationCommand.SystemStatusGet, ); - const cc = new IrrigationCCSystemStatusGet(this.applHost, { + const cc = new IrrigationCCSystemStatusGet({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, }); @@ -669,7 +668,7 @@ export class IrrigationCCAPI extends CCAPI { IrrigationCommand.SystemConfigGet, ); - const cc = new IrrigationCCSystemConfigGet(this.applHost, { + const cc = new IrrigationCCSystemConfigGet({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, }); @@ -699,7 +698,7 @@ export class IrrigationCCAPI extends CCAPI { IrrigationCommand.SystemConfigSet, ); - const cc = new IrrigationCCSystemConfigSet(this.applHost, { + const cc = new IrrigationCCSystemConfigSet({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, ...config, @@ -716,7 +715,7 @@ export class IrrigationCCAPI extends CCAPI { IrrigationCommand.ValveInfoGet, ); - const cc = new IrrigationCCValveInfoGet(this.applHost, { + const cc = new IrrigationCCValveInfoGet({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, valveId, @@ -750,7 +749,7 @@ export class IrrigationCCAPI extends CCAPI { IrrigationCommand.ValveConfigSet, ); - const cc = new IrrigationCCValveConfigSet(this.applHost, { + const cc = new IrrigationCCValveConfigSet({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, ...options, @@ -767,7 +766,7 @@ export class IrrigationCCAPI extends CCAPI { IrrigationCommand.ValveConfigGet, ); - const cc = new IrrigationCCValveConfigGet(this.applHost, { + const cc = new IrrigationCCValveConfigGet({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, valveId, @@ -801,7 +800,7 @@ export class IrrigationCCAPI extends CCAPI { IrrigationCommand.ValveRun, ); - const cc = new IrrigationCCValveRun(this.applHost, { + const cc = new IrrigationCCValveRun({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, valveId, @@ -844,7 +843,7 @@ export class IrrigationCCAPI extends CCAPI { } } - const cc = new IrrigationCCValveTableSet(this.applHost, { + const cc = new IrrigationCCValveTableSet({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, tableId, @@ -863,7 +862,7 @@ export class IrrigationCCAPI extends CCAPI { IrrigationCommand.ValveTableGet, ); - const cc = new IrrigationCCValveTableGet(this.applHost, { + const cc = new IrrigationCCValveTableGet({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, tableId, @@ -888,7 +887,7 @@ export class IrrigationCCAPI extends CCAPI { IrrigationCommand.ValveTableRun, ); - const cc = new IrrigationCCValveTableRun(this.applHost, { + const cc = new IrrigationCCValveTableRun({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, tableIDs, @@ -910,7 +909,7 @@ export class IrrigationCCAPI extends CCAPI { IrrigationCommand.SystemShutoff, ); - const cc = new IrrigationCCSystemShutoff(this.applHost, { + const cc = new IrrigationCCSystemShutoff({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, duration, @@ -1350,10 +1349,9 @@ moisture sensor polarity: ${ @CCCommand(IrrigationCommand.SystemInfoReport) export class IrrigationCCSystemInfoReport extends IrrigationCC { public constructor( - host: ZWaveHost, options: CommandClassDeserializationOptions, ) { - super(host, options); + super(options); validatePayload(this.payload.length >= 4); this.supportsMasterValve = !!(this.payload[0] & 0x01); this.numValves = this.payload[1]; @@ -1393,10 +1391,9 @@ export class IrrigationCCSystemInfoGet extends IrrigationCC {} @CCCommand(IrrigationCommand.SystemStatusReport) export class IrrigationCCSystemStatusReport extends IrrigationCC { public constructor( - host: ZWaveHost, options: CommandClassDeserializationOptions, ) { - super(host, options); + super(options); validatePayload(this.payload.length >= 2); this.systemVoltage = this.payload[0]; this.flowSensorActive = !!(this.payload[1] & 0x01); @@ -1544,12 +1541,11 @@ export type IrrigationCCSystemConfigSetOptions = { @useSupervision() export class IrrigationCCSystemConfigSet extends IrrigationCC { public constructor( - host: ZWaveHost, options: | CommandClassDeserializationOptions | (IrrigationCCSystemConfigSetOptions & CCCommandOptions), ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { // TODO: Deserialize payload throw new ZWaveError( @@ -1619,10 +1615,9 @@ export class IrrigationCCSystemConfigSet extends IrrigationCC { @CCCommand(IrrigationCommand.SystemConfigReport) export class IrrigationCCSystemConfigReport extends IrrigationCC { public constructor( - host: ZWaveHost, options: CommandClassDeserializationOptions, ) { - super(host, options); + super(options); validatePayload(this.payload.length >= 2); this.masterValveDelay = this.payload[0]; let offset = 1; @@ -1698,10 +1693,9 @@ export class IrrigationCCSystemConfigGet extends IrrigationCC {} @CCCommand(IrrigationCommand.ValveInfoReport) export class IrrigationCCValveInfoReport extends IrrigationCC { public constructor( - host: ZWaveHost, options: CommandClassDeserializationOptions, ) { - super(host, options); + super(options); validatePayload(this.payload.length >= 4); if ((this.payload[0] & 0b1) === ValveType.MasterValve) { this.valveId = "master"; @@ -1848,12 +1842,11 @@ function testResponseForIrrigationCommandWithValveId( ) export class IrrigationCCValveInfoGet extends IrrigationCC { public constructor( - host: ZWaveHost, options: | CommandClassDeserializationOptions | IrrigationCCValveInfoGetOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { // TODO: Deserialize payload throw new ZWaveError( @@ -1901,12 +1894,11 @@ export type IrrigationCCValveConfigSetOptions = { @useSupervision() export class IrrigationCCValveConfigSet extends IrrigationCC { public constructor( - host: ZWaveHost, options: | CommandClassDeserializationOptions | (IrrigationCCValveConfigSetOptions & CCCommandOptions), ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { // TODO: Deserialize payload throw new ZWaveError( @@ -1977,10 +1969,9 @@ export class IrrigationCCValveConfigSet extends IrrigationCC { @CCCommand(IrrigationCommand.ValveConfigReport) export class IrrigationCCValveConfigReport extends IrrigationCC { public constructor( - host: ZWaveHost, options: CommandClassDeserializationOptions, ) { - super(host, options); + super(options); validatePayload(this.payload.length >= 4); if ((this.payload[0] & 0b1) === ValveType.MasterValve) { this.valveId = "master"; @@ -2119,12 +2110,11 @@ export interface IrrigationCCValveConfigGetOptions extends CCCommandOptions { ) export class IrrigationCCValveConfigGet extends IrrigationCC { public constructor( - host: ZWaveHost, options: | CommandClassDeserializationOptions | IrrigationCCValveConfigGetOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { // TODO: Deserialize payload throw new ZWaveError( @@ -2166,12 +2156,11 @@ export interface IrrigationCCValveRunOptions extends CCCommandOptions { @useSupervision() export class IrrigationCCValveRun extends IrrigationCC { public constructor( - host: ZWaveHost, options: | CommandClassDeserializationOptions | IrrigationCCValveRunOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { // TODO: Deserialize payload throw new ZWaveError( @@ -2224,12 +2213,11 @@ export interface IrrigationCCValveTableSetOptions extends CCCommandOptions { @useSupervision() export class IrrigationCCValveTableSet extends IrrigationCC { public constructor( - host: ZWaveHost, options: | CommandClassDeserializationOptions | IrrigationCCValveTableSetOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { // TODO: Deserialize payload throw new ZWaveError( @@ -2280,10 +2268,9 @@ export class IrrigationCCValveTableSet extends IrrigationCC { @CCCommand(IrrigationCommand.ValveTableReport) export class IrrigationCCValveTableReport extends IrrigationCC { public constructor( - host: ZWaveHost, options: CommandClassDeserializationOptions, ) { - super(host, options); + super(options); validatePayload((this.payload.length - 1) % 3 === 0); this.tableId = this.payload[0]; this.entries = []; @@ -2337,12 +2324,11 @@ function testResponseForIrrigationValveTableGet( ) export class IrrigationCCValveTableGet extends IrrigationCC { public constructor( - host: ZWaveHost, options: | CommandClassDeserializationOptions | IrrigationCCValveTableGetOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { // TODO: Deserialize payload throw new ZWaveError( @@ -2380,12 +2366,11 @@ export interface IrrigationCCValveTableRunOptions extends CCCommandOptions { @useSupervision() export class IrrigationCCValveTableRun extends IrrigationCC { public constructor( - host: ZWaveHost, options: | CommandClassDeserializationOptions | IrrigationCCValveTableRunOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { // TODO: Deserialize payload throw new ZWaveError( @@ -2435,12 +2420,11 @@ export interface IrrigationCCSystemShutoffOptions extends CCCommandOptions { @useSupervision() export class IrrigationCCSystemShutoff extends IrrigationCC { public constructor( - host: ZWaveHost, options: | CommandClassDeserializationOptions | IrrigationCCSystemShutoffOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { // TODO: Deserialize payload throw new ZWaveError( diff --git a/packages/cc/src/cc/LanguageCC.ts b/packages/cc/src/cc/LanguageCC.ts index 47d84199c323..7cc894aacb8c 100644 --- a/packages/cc/src/cc/LanguageCC.ts +++ b/packages/cc/src/cc/LanguageCC.ts @@ -16,7 +16,6 @@ import type { CCEncodingContext, GetValueDB, ZWaveApplicationHost, - ZWaveHost, } from "@zwave-js/host/safe"; import { pick } from "@zwave-js/shared/safe"; import { validateArgs } from "@zwave-js/transformers"; @@ -79,7 +78,7 @@ export class LanguageCCAPI extends CCAPI { public async get() { this.assertSupportsCommand(LanguageCommand, LanguageCommand.Get); - const cc = new LanguageCCGet(this.applHost, { + const cc = new LanguageCCGet({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, }); @@ -99,7 +98,7 @@ export class LanguageCCAPI extends CCAPI { ): Promise { this.assertSupportsCommand(LanguageCommand, LanguageCommand.Set); - const cc = new LanguageCCSet(this.applHost, { + const cc = new LanguageCCSet({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, language, @@ -173,10 +172,9 @@ export interface LanguageCCSetOptions extends CCCommandOptions { @useSupervision() export class LanguageCCSet extends LanguageCC { public constructor( - host: ZWaveHost, options: CommandClassDeserializationOptions | LanguageCCSetOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { // TODO: Deserialize payload throw new ZWaveError( @@ -243,10 +241,9 @@ export class LanguageCCSet extends LanguageCC { @CCCommand(LanguageCommand.Report) export class LanguageCCReport extends LanguageCC { public constructor( - host: ZWaveHost, options: CommandClassDeserializationOptions, ) { - super(host, options); + super(options); // if (gotDeserializationOptions(options)) { validatePayload(this.payload.length >= 3); this.language = this.payload.toString("ascii", 0, 3); diff --git a/packages/cc/src/cc/LockCC.ts b/packages/cc/src/cc/LockCC.ts index 2850e303c2ed..97aa071a5338 100644 --- a/packages/cc/src/cc/LockCC.ts +++ b/packages/cc/src/cc/LockCC.ts @@ -14,7 +14,6 @@ import type { CCEncodingContext, GetValueDB, ZWaveApplicationHost, - ZWaveHost, } from "@zwave-js/host/safe"; import { validateArgs } from "@zwave-js/transformers"; import { @@ -74,7 +73,7 @@ export class LockCCAPI extends PhysicalCCAPI { public async get(): Promise> { this.assertSupportsCommand(LockCommand, LockCommand.Get); - const cc = new LockCCGet(this.applHost, { + const cc = new LockCCGet({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, }); @@ -93,7 +92,7 @@ export class LockCCAPI extends PhysicalCCAPI { public async set(locked: boolean): Promise { this.assertSupportsCommand(LockCommand, LockCommand.Set); - const cc = new LockCCSet(this.applHost, { + const cc = new LockCCSet({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, locked, @@ -191,10 +190,9 @@ export interface LockCCSetOptions extends CCCommandOptions { @useSupervision() export class LockCCSet extends LockCC { public constructor( - host: ZWaveHost, options: CommandClassDeserializationOptions | LockCCSetOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { // TODO: Deserialize payload throw new ZWaveError( @@ -224,10 +222,9 @@ export class LockCCSet extends LockCC { @CCCommand(LockCommand.Report) export class LockCCReport extends LockCC { public constructor( - host: ZWaveHost, options: CommandClassDeserializationOptions, ) { - super(host, options); + super(options); validatePayload(this.payload.length >= 1); this.locked = this.payload[0] === 1; } diff --git a/packages/cc/src/cc/ManufacturerProprietaryCC.ts b/packages/cc/src/cc/ManufacturerProprietaryCC.ts index b9530afba754..a6a8b80e9357 100644 --- a/packages/cc/src/cc/ManufacturerProprietaryCC.ts +++ b/packages/cc/src/cc/ManufacturerProprietaryCC.ts @@ -7,7 +7,6 @@ import { import type { CCEncodingContext, ZWaveApplicationHost, - ZWaveHost, } from "@zwave-js/host/safe"; import { staticExtends } from "@zwave-js/shared/safe"; import { validateArgs } from "@zwave-js/transformers"; @@ -37,7 +36,7 @@ export type ManufacturerProprietaryCCConstructor< typeof ManufacturerProprietaryCC, > = T & { // I don't like the any, but we need it to support half-implemented CCs (e.g. report classes) - new (host: ZWaveHost, options: any): InstanceType; + new (options: any): InstanceType; }; @API(CommandClasses["Manufacturer Proprietary"]) @@ -71,7 +70,7 @@ export class ManufacturerProprietaryCCAPI extends CCAPI { manufacturerId: number, data?: Buffer, ): Promise { - const cc = new ManufacturerProprietaryCC(this.applHost, { + const cc = new ManufacturerProprietaryCC({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, manufacturerId, @@ -84,7 +83,7 @@ export class ManufacturerProprietaryCCAPI extends CCAPI { @validateArgs() // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types public async sendAndReceiveData(manufacturerId: number, data?: Buffer) { - const cc = new ManufacturerProprietaryCC(this.applHost, { + const cc = new ManufacturerProprietaryCC({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, manufacturerId, @@ -137,12 +136,11 @@ export class ManufacturerProprietaryCC extends CommandClass { declare ccCommand: undefined; public constructor( - host: ZWaveHost, options: | CommandClassDeserializationOptions | ManufacturerProprietaryCCOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { validatePayload(this.payload.length >= 1); @@ -159,7 +157,7 @@ export class ManufacturerProprietaryCC extends CommandClass { && new.target !== PCConstructor && !staticExtends(new.target, PCConstructor) ) { - return new PCConstructor(host, options); + return new PCConstructor(options); } // If the constructor is correct, update the payload for subclass deserialization @@ -218,7 +216,7 @@ export class ManufacturerProprietaryCC extends CommandClass { this.manufacturerId, ); if (PCConstructor) { - return new PCConstructor(this.host, { + return new PCConstructor({ nodeId: this.nodeId, endpoint: this.endpointIndex, }); diff --git a/packages/cc/src/cc/ManufacturerSpecificCC.ts b/packages/cc/src/cc/ManufacturerSpecificCC.ts index 2aafb863272d..5bf1db1f1c35 100644 --- a/packages/cc/src/cc/ManufacturerSpecificCC.ts +++ b/packages/cc/src/cc/ManufacturerSpecificCC.ts @@ -12,7 +12,6 @@ import type { CCEncodingContext, GetValueDB, ZWaveApplicationHost, - ZWaveHost, } from "@zwave-js/host/safe"; import { getEnumMemberName, num2hex, pick } from "@zwave-js/shared/safe"; import { validateArgs } from "@zwave-js/transformers"; @@ -109,7 +108,7 @@ export class ManufacturerSpecificCCAPI extends PhysicalCCAPI { ManufacturerSpecificCommand.Get, ); - const cc = new ManufacturerSpecificCCGet(this.applHost, { + const cc = new ManufacturerSpecificCCGet({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, }); @@ -137,7 +136,7 @@ export class ManufacturerSpecificCCAPI extends PhysicalCCAPI { ManufacturerSpecificCommand.DeviceSpecificGet, ); - const cc = new ManufacturerSpecificCCDeviceSpecificGet(this.applHost, { + const cc = new ManufacturerSpecificCCDeviceSpecificGet({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, deviceIdType, @@ -160,7 +159,7 @@ export class ManufacturerSpecificCCAPI extends PhysicalCCAPI { ManufacturerSpecificCommand.Report, ); - const cc = new ManufacturerSpecificCCReport(this.applHost, { + const cc = new ManufacturerSpecificCCReport({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, ...options, @@ -238,12 +237,11 @@ export interface ManufacturerSpecificCCReportOptions { @CCCommand(ManufacturerSpecificCommand.Report) export class ManufacturerSpecificCCReport extends ManufacturerSpecificCC { public constructor( - host: ZWaveHost, options: | (ManufacturerSpecificCCReportOptions & CCCommandOptions) | CommandClassDeserializationOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { validatePayload(this.payload.length >= 6); @@ -295,10 +293,9 @@ export class ManufacturerSpecificCCDeviceSpecificReport extends ManufacturerSpecificCC { public constructor( - host: ZWaveHost, options: CommandClassDeserializationOptions, ) { - super(host, options); + super(options); validatePayload(this.payload.length >= 2); this.type = this.payload[0] & 0b111; @@ -345,12 +342,11 @@ export class ManufacturerSpecificCCDeviceSpecificGet extends ManufacturerSpecificCC { public constructor( - host: ZWaveHost, options: | CommandClassDeserializationOptions | ManufacturerSpecificCCDeviceSpecificGetOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { throw new ZWaveError( `${this.constructor.name}: deserialization not implemented`, diff --git a/packages/cc/src/cc/MeterCC.ts b/packages/cc/src/cc/MeterCC.ts index a3cc0ae1d8dd..23493e0de167 100644 --- a/packages/cc/src/cc/MeterCC.ts +++ b/packages/cc/src/cc/MeterCC.ts @@ -29,7 +29,6 @@ import type { CCEncodingContext, GetValueDB, ZWaveApplicationHost, - ZWaveHost, } from "@zwave-js/host/safe"; import { type AllOrNone, @@ -356,7 +355,7 @@ export class MeterCCAPI extends PhysicalCCAPI { ): Promise { this.assertSupportsCommand(MeterCommand, MeterCommand.Get); - const cc = new MeterCCGet(this.applHost, { + const cc = new MeterCCGet({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, ...options, @@ -386,7 +385,7 @@ export class MeterCCAPI extends PhysicalCCAPI { ): Promise { this.assertSupportsCommand(MeterCommand, MeterCommand.Report); - const cc = new MeterCCReport(this.applHost, { + const cc = new MeterCCReport({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, ...options, @@ -447,7 +446,7 @@ export class MeterCCAPI extends PhysicalCCAPI { public async getSupported() { this.assertSupportsCommand(MeterCommand, MeterCommand.SupportedGet); - const cc = new MeterCCSupportedGet(this.applHost, { + const cc = new MeterCCSupportedGet({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, }); @@ -473,7 +472,7 @@ export class MeterCCAPI extends PhysicalCCAPI { ): Promise { this.assertSupportsCommand(MeterCommand, MeterCommand.SupportedReport); - const cc = new MeterCCSupportedReport(this.applHost, { + const cc = new MeterCCSupportedReport({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, ...options, @@ -487,7 +486,7 @@ export class MeterCCAPI extends PhysicalCCAPI { ): Promise { this.assertSupportsCommand(MeterCommand, MeterCommand.Reset); - const cc = new MeterCCReset(this.applHost, { + const cc = new MeterCCReset({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, ...options, @@ -879,12 +878,11 @@ export interface MeterCCReportOptions { @CCCommand(MeterCommand.Report) export class MeterCCReport extends MeterCC { public constructor( - host: ZWaveHost, options: | CommandClassDeserializationOptions | (MeterCCReportOptions & CCCommandOptions), ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { const { type, rateType, scale1, value, bytesRead } = @@ -1104,12 +1102,11 @@ export interface MeterCCGetOptions { @expectedCCResponse(MeterCCReport, testResponseForMeterGet) export class MeterCCGet extends MeterCC { public constructor( - host: ZWaveHost, options: | CommandClassDeserializationOptions | (MeterCCGetOptions & CCCommandOptions), ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { if (this.payload.length >= 1) { this.rateType = (this.payload[0] & 0b11_000_000) >>> 6; @@ -1198,12 +1195,11 @@ export interface MeterCCSupportedReportOptions { @CCCommand(MeterCommand.SupportedReport) export class MeterCCSupportedReport extends MeterCC { public constructor( - host: ZWaveHost, options: | CommandClassDeserializationOptions | (MeterCCSupportedReportOptions & CCCommandOptions), ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { validatePayload(this.payload.length >= 2); @@ -1366,12 +1362,11 @@ export type MeterCCResetOptions = AllOrNone<{ @useSupervision() export class MeterCCReset extends MeterCC { public constructor( - host: ZWaveHost, options: | CommandClassDeserializationOptions | (MeterCCResetOptions & CCCommandOptions), ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { if (this.payload.length > 0) { const { diff --git a/packages/cc/src/cc/MultiChannelAssociationCC.ts b/packages/cc/src/cc/MultiChannelAssociationCC.ts index 87ece3f2d58e..fc8b61bc9e21 100644 --- a/packages/cc/src/cc/MultiChannelAssociationCC.ts +++ b/packages/cc/src/cc/MultiChannelAssociationCC.ts @@ -20,7 +20,6 @@ import type { CCParsingContext, GetValueDB, ZWaveApplicationHost, - ZWaveHost, } from "@zwave-js/host/safe"; import { pick } from "@zwave-js/shared/safe"; import { validateArgs } from "@zwave-js/transformers"; @@ -205,13 +204,10 @@ export class MultiChannelAssociationCCAPI extends PhysicalCCAPI { MultiChannelAssociationCommand.SupportedGroupingsGet, ); - const cc = new MultiChannelAssociationCCSupportedGroupingsGet( - this.applHost, - { - nodeId: this.endpoint.nodeId, - endpoint: this.endpoint.index, - }, - ); + const cc = new MultiChannelAssociationCCSupportedGroupingsGet({ + nodeId: this.endpoint.nodeId, + endpoint: this.endpoint.index, + }); const response = await this.applHost.sendCommand< MultiChannelAssociationCCSupportedGroupingsReport >( @@ -228,14 +224,11 @@ export class MultiChannelAssociationCCAPI extends PhysicalCCAPI { MultiChannelAssociationCommand.SupportedGroupingsReport, ); - const cc = new MultiChannelAssociationCCSupportedGroupingsReport( - this.applHost, - { - nodeId: this.endpoint.nodeId, - endpoint: this.endpoint.index, - groupCount, - }, - ); + const cc = new MultiChannelAssociationCCSupportedGroupingsReport({ + nodeId: this.endpoint.nodeId, + endpoint: this.endpoint.index, + groupCount, + }); await this.applHost.sendCommand(cc, this.commandOptions); } @@ -250,7 +243,7 @@ export class MultiChannelAssociationCCAPI extends PhysicalCCAPI { MultiChannelAssociationCommand.Get, ); - const cc = new MultiChannelAssociationCCGet(this.applHost, { + const cc = new MultiChannelAssociationCCGet({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, groupId, @@ -275,7 +268,7 @@ export class MultiChannelAssociationCCAPI extends PhysicalCCAPI { MultiChannelAssociationCommand.Report, ); - const cc = new MultiChannelAssociationCCReport(this.applHost, { + const cc = new MultiChannelAssociationCCReport({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, ...options, @@ -295,7 +288,7 @@ export class MultiChannelAssociationCCAPI extends PhysicalCCAPI { MultiChannelAssociationCommand.Set, ); - const cc = new MultiChannelAssociationCCSet(this.applHost, { + const cc = new MultiChannelAssociationCCSet({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, ...options, @@ -324,7 +317,7 @@ export class MultiChannelAssociationCCAPI extends PhysicalCCAPI { this.endpoint, ); for (const [group, destinations] of currentDestinations) { - const cc = new MultiChannelAssociationCCRemove(this.applHost, { + const cc = new MultiChannelAssociationCCRemove({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, groupId: group, @@ -345,7 +338,7 @@ export class MultiChannelAssociationCCAPI extends PhysicalCCAPI { ZWaveErrorCodes.Argument_Invalid, ); } else { - const cc = new MultiChannelAssociationCCRemove(this.applHost, { + const cc = new MultiChannelAssociationCCRemove({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, ...options, @@ -634,12 +627,11 @@ export type MultiChannelAssociationCCSetOptions = @useSupervision() export class MultiChannelAssociationCCSet extends MultiChannelAssociationCC { public constructor( - host: ZWaveHost, options: | CommandClassDeserializationOptions | (MultiChannelAssociationCCSetOptions & CCCommandOptions), ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { validatePayload(this.payload.length >= 1); this.groupId = this.payload[0]; @@ -708,12 +700,11 @@ export interface MultiChannelAssociationCCRemoveOptions { @useSupervision() export class MultiChannelAssociationCCRemove extends MultiChannelAssociationCC { public constructor( - host: ZWaveHost, options: | CommandClassDeserializationOptions | (MultiChannelAssociationCCRemoveOptions & CCCommandOptions), ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { validatePayload(this.payload.length >= 1); this.groupId = this.payload[0]; @@ -774,12 +765,11 @@ export interface MultiChannelAssociationCCReportOptions { @CCCommand(MultiChannelAssociationCommand.Report) export class MultiChannelAssociationCCReport extends MultiChannelAssociationCC { public constructor( - host: ZWaveHost, options: | CommandClassDeserializationOptions | (MultiChannelAssociationCCReportOptions & CCCommandOptions), ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { validatePayload(this.payload.length >= 3); @@ -883,12 +873,11 @@ export interface MultiChannelAssociationCCGetOptions extends CCCommandOptions { @expectedCCResponse(MultiChannelAssociationCCReport) export class MultiChannelAssociationCCGet extends MultiChannelAssociationCC { public constructor( - host: ZWaveHost, options: | CommandClassDeserializationOptions | MultiChannelAssociationCCGetOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { validatePayload(this.payload.length >= 1); this.groupId = this.payload[0]; @@ -930,12 +919,11 @@ export class MultiChannelAssociationCCSupportedGroupingsReport extends MultiChannelAssociationCC { public constructor( - host: ZWaveHost, options: | CommandClassDeserializationOptions | MultiChannelAssociationCCSupportedGroupingsReportOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { validatePayload(this.payload.length >= 1); diff --git a/packages/cc/src/cc/MultiChannelCC.ts b/packages/cc/src/cc/MultiChannelCC.ts index 6e63b990dd97..3c58ca9d4f3d 100644 --- a/packages/cc/src/cc/MultiChannelCC.ts +++ b/packages/cc/src/cc/MultiChannelCC.ts @@ -23,7 +23,6 @@ import type { CCParsingContext, GetValueDB, ZWaveApplicationHost, - ZWaveHost, } from "@zwave-js/host/safe"; import { validateArgs } from "@zwave-js/transformers"; import { distinct } from "alcalzone-shared/arrays"; @@ -217,7 +216,7 @@ export class MultiChannelCCAPI extends CCAPI { MultiChannelCommand.EndPointGet, ); - const cc = new MultiChannelCCEndPointGet(this.applHost, { + const cc = new MultiChannelCCEndPointGet({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, }); @@ -246,7 +245,7 @@ export class MultiChannelCCAPI extends CCAPI { MultiChannelCommand.CapabilityGet, ); - const cc = new MultiChannelCCCapabilityGet(this.applHost, { + const cc = new MultiChannelCCCapabilityGet({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, requestedEndpoint: endpoint, @@ -285,7 +284,7 @@ export class MultiChannelCCAPI extends CCAPI { MultiChannelCommand.EndPointFind, ); - const cc = new MultiChannelCCEndPointFind(this.applHost, { + const cc = new MultiChannelCCEndPointFind({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, genericClass, @@ -309,7 +308,7 @@ export class MultiChannelCCAPI extends CCAPI { MultiChannelCommand.AggregatedMembersGet, ); - const cc = new MultiChannelCCAggregatedMembersGet(this.applHost, { + const cc = new MultiChannelCCAggregatedMembersGet({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, requestedEndpoint: endpoint, @@ -337,7 +336,7 @@ export class MultiChannelCCAPI extends CCAPI { MultiChannelCommand.CommandEncapsulation, ); - const cc = new MultiChannelCCCommandEncapsulation(this.applHost, { + const cc = new MultiChannelCCCommandEncapsulation({ nodeId: this.endpoint.nodeId, ...options, }); @@ -353,7 +352,7 @@ export class MultiChannelCCAPI extends CCAPI { MultiChannelCommand.GetV1, ); - const cc = new MultiChannelCCV1Get(this.applHost, { + const cc = new MultiChannelCCV1Get({ nodeId: this.endpoint.nodeId, requestedCC: ccId, }); @@ -375,7 +374,7 @@ export class MultiChannelCCAPI extends CCAPI { MultiChannelCommand.CommandEncapsulationV1, ); - const cc = new MultiChannelCCV1CommandEncapsulation(this.applHost, { + const cc = new MultiChannelCCV1CommandEncapsulation({ nodeId: this.endpoint.nodeId, encapsulated, }); @@ -408,10 +407,9 @@ export class MultiChannelCC extends CommandClass { /** Encapsulates a command that targets a specific endpoint, with version 2+ of the Multi Channel CC */ public static encapsulate( - host: ZWaveHost, cc: CommandClass, ): MultiChannelCCCommandEncapsulation { - const ret = new MultiChannelCCCommandEncapsulation(host, { + const ret = new MultiChannelCCCommandEncapsulation({ nodeId: cc.nodeId, encapsulated: cc, destination: cc.endpointIndex, @@ -425,10 +423,9 @@ export class MultiChannelCC extends CommandClass { /** Encapsulates a command that targets a specific endpoint, with version 1 of the Multi Channel CC */ public static encapsulateV1( - host: ZWaveHost, cc: CommandClass, ): MultiChannelCCV1CommandEncapsulation { - const ret = new MultiChannelCCV1CommandEncapsulation(host, { + const ret = new MultiChannelCCV1CommandEncapsulation({ nodeId: cc.nodeId, encapsulated: cc, }); @@ -740,7 +737,6 @@ supported CCs:`; .filter( (cc) => !CommandClass.createInstanceUnchecked( - applHost, node, cc, )?.skipEndpointInterview(), @@ -824,12 +820,11 @@ export interface MultiChannelCCEndPointReportOptions extends CCCommandOptions { @CCCommand(MultiChannelCommand.EndPointReport) export class MultiChannelCCEndPointReport extends MultiChannelCC { public constructor( - host: ZWaveHost, options: | CommandClassDeserializationOptions | MultiChannelCCEndPointReportOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { validatePayload(this.payload.length >= 2); @@ -907,12 +902,11 @@ export class MultiChannelCCCapabilityReport extends MultiChannelCC implements ApplicationNodeInformation { public constructor( - host: ZWaveHost, options: | CommandClassDeserializationOptions | MultiChannelCCCapabilityReportOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { // Only validate the bytes we expect to see here @@ -1019,12 +1013,11 @@ function testResponseForMultiChannelCapabilityGet( ) export class MultiChannelCCCapabilityGet extends MultiChannelCC { public constructor( - host: ZWaveHost, options: | CommandClassDeserializationOptions | MultiChannelCCCapabilityGetOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { validatePayload(this.payload.length >= 1); this.requestedEndpoint = this.payload[0] & 0b01111111; @@ -1061,12 +1054,11 @@ export interface MultiChannelCCEndPointFindReportOptions @CCCommand(MultiChannelCommand.EndPointFindReport) export class MultiChannelCCEndPointFindReport extends MultiChannelCC { public constructor( - host: ZWaveHost, options: | CommandClassDeserializationOptions | MultiChannelCCEndPointFindReportOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { validatePayload(this.payload.length >= 3); @@ -1155,12 +1147,11 @@ export interface MultiChannelCCEndPointFindOptions extends CCCommandOptions { @expectedCCResponse(MultiChannelCCEndPointFindReport) export class MultiChannelCCEndPointFind extends MultiChannelCC { public constructor( - host: ZWaveHost, options: | CommandClassDeserializationOptions | MultiChannelCCEndPointFindOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { validatePayload(this.payload.length >= 2); this.genericClass = this.payload[0]; @@ -1197,10 +1188,9 @@ export class MultiChannelCCEndPointFind extends MultiChannelCC { @CCCommand(MultiChannelCommand.AggregatedMembersReport) export class MultiChannelCCAggregatedMembersReport extends MultiChannelCC { public constructor( - host: ZWaveHost, options: CommandClassDeserializationOptions, ) { - super(host, options); + super(options); validatePayload(this.payload.length >= 2); this.aggregatedEndpointIndex = this.payload[0] & 0b0111_1111; @@ -1241,12 +1231,11 @@ export interface MultiChannelCCAggregatedMembersGetOptions @expectedCCResponse(MultiChannelCCAggregatedMembersReport) export class MultiChannelCCAggregatedMembersGet extends MultiChannelCC { public constructor( - host: ZWaveHost, options: | CommandClassDeserializationOptions | MultiChannelCCAggregatedMembersGetOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { // TODO: Deserialize payload throw new ZWaveError( @@ -1327,12 +1316,11 @@ function testResponseForCommandEncapsulation( ) export class MultiChannelCCCommandEncapsulation extends MultiChannelCC { public constructor( - host: ZWaveHost, options: | CommandClassDeserializationOptions | MultiChannelCCCommandEncapsulationOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { validatePayload(this.payload.length >= 2); if ( @@ -1356,7 +1344,7 @@ export class MultiChannelCCCommandEncapsulation extends MultiChannelCC { } } // No need to validate further, each CC does it for itself - this.encapsulated = CommandClass.from(this.host, { + this.encapsulated = CommandClass.from({ data: this.payload.subarray(2), fromEncapsulation: true, encapCC: this, @@ -1418,10 +1406,9 @@ export class MultiChannelCCCommandEncapsulation extends MultiChannelCC { @CCCommand(MultiChannelCommand.ReportV1) export class MultiChannelCCV1Report extends MultiChannelCC { public constructor( - host: ZWaveHost, options: CommandClassDeserializationOptions, ) { - super(host, options); + super(options); // V1 won't be extended in the future, so do an exact check validatePayload(this.payload.length === 2); this.requestedCC = this.payload[0]; @@ -1458,12 +1445,11 @@ export interface MultiChannelCCV1GetOptions extends CCCommandOptions { @expectedCCResponse(MultiChannelCCV1Report, testResponseForMultiChannelV1Get) export class MultiChannelCCV1Get extends MultiChannelCC { public constructor( - host: ZWaveHost, options: | CommandClassDeserializationOptions | MultiChannelCCV1GetOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { // TODO: Deserialize payload throw new ZWaveError( @@ -1522,12 +1508,11 @@ export interface MultiChannelCCV1CommandEncapsulationOptions ) export class MultiChannelCCV1CommandEncapsulation extends MultiChannelCC { public constructor( - host: ZWaveHost, options: | CommandClassDeserializationOptions | MultiChannelCCV1CommandEncapsulationOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { validatePayload(this.payload.length >= 1); this.endpointIndex = this.payload[0]; @@ -1538,7 +1523,7 @@ export class MultiChannelCCV1CommandEncapsulation extends MultiChannelCC { && this.payload[1] === 0x00; // No need to validate further, each CC does it for itself - this.encapsulated = CommandClass.from(this.host, { + this.encapsulated = CommandClass.from({ data: this.payload.subarray(isV2withV1Header ? 2 : 1), fromEncapsulation: true, encapCC: this, diff --git a/packages/cc/src/cc/MultiCommandCC.ts b/packages/cc/src/cc/MultiCommandCC.ts index 0d4b29297848..da005011abc1 100644 --- a/packages/cc/src/cc/MultiCommandCC.ts +++ b/packages/cc/src/cc/MultiCommandCC.ts @@ -5,11 +5,7 @@ import { type MessageOrCCLogEntry, validatePayload, } from "@zwave-js/core/safe"; -import type { - CCEncodingContext, - GetValueDB, - ZWaveHost, -} from "@zwave-js/host/safe"; +import type { CCEncodingContext, GetValueDB } from "@zwave-js/host/safe"; import { validateArgs } from "@zwave-js/transformers"; import { CCAPI } from "../lib/API"; import { @@ -49,7 +45,7 @@ export class MultiCommandCCAPI extends CCAPI { ); // FIXME: This should not be on the API but rather on the applHost level - const cc = new MultiCommandCCCommandEncapsulation(this.applHost, { + const cc = new MultiCommandCCCommandEncapsulation({ nodeId: this.endpoint.nodeId, encapsulated: commands, }); @@ -72,10 +68,9 @@ export class MultiCommandCC extends CommandClass { } public static encapsulate( - host: ZWaveHost, CCs: CommandClass[], ): MultiCommandCCCommandEncapsulation { - const ret = new MultiCommandCCCommandEncapsulation(host, { + const ret = new MultiCommandCCCommandEncapsulation({ nodeId: CCs[0].nodeId, encapsulated: CCs, }); @@ -109,12 +104,11 @@ export interface MultiCommandCCCommandEncapsulationOptions // When sending commands encapsulated in this CC, responses to GET-type commands likely won't be encapsulated export class MultiCommandCCCommandEncapsulation extends MultiCommandCC { public constructor( - host: ZWaveHost, options: | CommandClassDeserializationOptions | MultiCommandCCCommandEncapsulationOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { validatePayload(this.payload.length >= 1); const numCommands = this.payload[0]; @@ -125,7 +119,7 @@ export class MultiCommandCCCommandEncapsulation extends MultiCommandCC { const cmdLength = this.payload[offset]; validatePayload(this.payload.length >= offset + 1 + cmdLength); this.encapsulated.push( - CommandClass.from(this.host, { + CommandClass.from({ data: this.payload.subarray( offset + 1, offset + 1 + cmdLength, diff --git a/packages/cc/src/cc/MultilevelSensorCC.ts b/packages/cc/src/cc/MultilevelSensorCC.ts index 8f639f30c2f2..95be6d1b8431 100644 --- a/packages/cc/src/cc/MultilevelSensorCC.ts +++ b/packages/cc/src/cc/MultilevelSensorCC.ts @@ -29,7 +29,6 @@ import type { CCEncodingContext, GetValueDB, ZWaveApplicationHost, - ZWaveHost, } from "@zwave-js/host/safe"; import { num2hex } from "@zwave-js/shared/safe"; import { validateArgs } from "@zwave-js/transformers"; @@ -278,7 +277,7 @@ export class MultilevelSensorCCAPI extends PhysicalCCAPI { ); } - const cc = new MultilevelSensorCCGet(this.applHost, { + const cc = new MultilevelSensorCCGet({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, sensorType, @@ -321,7 +320,7 @@ export class MultilevelSensorCCAPI extends PhysicalCCAPI { MultilevelSensorCommand.GetSupportedSensor, ); - const cc = new MultilevelSensorCCGetSupportedSensor(this.applHost, { + const cc = new MultilevelSensorCCGetSupportedSensor({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, }); @@ -343,7 +342,7 @@ export class MultilevelSensorCCAPI extends PhysicalCCAPI { MultilevelSensorCommand.GetSupportedScale, ); - const cc = new MultilevelSensorCCGetSupportedScale(this.applHost, { + const cc = new MultilevelSensorCCGetSupportedScale({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, sensorType, @@ -368,7 +367,7 @@ export class MultilevelSensorCCAPI extends PhysicalCCAPI { MultilevelSensorCommand.Report, ); - const cc = new MultilevelSensorCCReport(this.applHost, { + const cc = new MultilevelSensorCCReport({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, type: sensorType, @@ -629,12 +628,11 @@ export interface MultilevelSensorCCReportOptions extends CCCommandOptions { @useSupervision() export class MultilevelSensorCCReport extends MultilevelSensorCC { public constructor( - host: ZWaveHost, options: | CommandClassDeserializationOptions | MultilevelSensorCCReportOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { validatePayload(this.payload.length >= 1); @@ -776,12 +774,11 @@ export type MultilevelSensorCCGetOptions = ) export class MultilevelSensorCCGet extends MultilevelSensorCC { public constructor( - host: ZWaveHost, options: | CommandClassDeserializationOptions | MultilevelSensorCCGetOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { if (this.payload.length >= 2) { this.sensorType = this.payload[0]; @@ -846,12 +843,11 @@ export class MultilevelSensorCCSupportedSensorReport extends MultilevelSensorCC { public constructor( - host: ZWaveHost, options: | CommandClassDeserializationOptions | MultilevelSensorCCSupportedSensorReportOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { validatePayload(this.payload.length >= 1); @@ -897,12 +893,11 @@ export interface MultilevelSensorCCSupportedScaleReportOptions @CCCommand(MultilevelSensorCommand.SupportedScaleReport) export class MultilevelSensorCCSupportedScaleReport extends MultilevelSensorCC { public constructor( - host: ZWaveHost, options: | CommandClassDeserializationOptions | MultilevelSensorCCSupportedScaleReportOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { validatePayload(this.payload.length >= 2); @@ -964,12 +959,11 @@ export interface MultilevelSensorCCGetSupportedScaleOptions @expectedCCResponse(MultilevelSensorCCSupportedScaleReport) export class MultilevelSensorCCGetSupportedScale extends MultilevelSensorCC { public constructor( - host: ZWaveHost, options: | CommandClassDeserializationOptions | MultilevelSensorCCGetSupportedScaleOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { validatePayload(this.payload.length >= 1); this.sensorType = this.payload[0]; diff --git a/packages/cc/src/cc/MultilevelSwitchCC.ts b/packages/cc/src/cc/MultilevelSwitchCC.ts index 04477b5015be..7e9d996b7142 100644 --- a/packages/cc/src/cc/MultilevelSwitchCC.ts +++ b/packages/cc/src/cc/MultilevelSwitchCC.ts @@ -17,7 +17,6 @@ import type { CCEncodingContext, GetValueDB, ZWaveApplicationHost, - ZWaveHost, } from "@zwave-js/host/safe"; import { getEnumMemberName, pick } from "@zwave-js/shared/safe"; import { validateArgs } from "@zwave-js/transformers"; @@ -231,7 +230,7 @@ export class MultilevelSwitchCCAPI extends CCAPI { MultilevelSwitchCommand.Get, ); - const cc = new MultilevelSwitchCCGet(this.applHost, { + const cc = new MultilevelSwitchCCGet({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, }); @@ -262,7 +261,7 @@ export class MultilevelSwitchCCAPI extends CCAPI { MultilevelSwitchCommand.Set, ); - const cc = new MultilevelSwitchCCSet(this.applHost, { + const cc = new MultilevelSwitchCCSet({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, targetValue, @@ -280,7 +279,7 @@ export class MultilevelSwitchCCAPI extends CCAPI { MultilevelSwitchCommand.StartLevelChange, ); - const cc = new MultilevelSwitchCCStartLevelChange(this.applHost, { + const cc = new MultilevelSwitchCCStartLevelChange({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, ...options, @@ -295,7 +294,7 @@ export class MultilevelSwitchCCAPI extends CCAPI { MultilevelSwitchCommand.StopLevelChange, ); - const cc = new MultilevelSwitchCCStopLevelChange(this.applHost, { + const cc = new MultilevelSwitchCCStopLevelChange({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, }); @@ -309,7 +308,7 @@ export class MultilevelSwitchCCAPI extends CCAPI { MultilevelSwitchCommand.SupportedGet, ); - const cc = new MultilevelSwitchCCSupportedGet(this.applHost, { + const cc = new MultilevelSwitchCCSupportedGet({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, }); @@ -628,12 +627,11 @@ export interface MultilevelSwitchCCSetOptions extends CCCommandOptions { @useSupervision() export class MultilevelSwitchCCSet extends MultilevelSwitchCC { public constructor( - host: ZWaveHost, options: | CommandClassDeserializationOptions | MultilevelSwitchCCSetOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { validatePayload(this.payload.length >= 1); this.targetValue = this.payload[0]; @@ -693,12 +691,11 @@ export interface MultilevelSwitchCCReportOptions extends CCCommandOptions { @CCCommand(MultilevelSwitchCommand.Report) export class MultilevelSwitchCCReport extends MultilevelSwitchCC { public constructor( - host: ZWaveHost, options: | CommandClassDeserializationOptions | MultilevelSwitchCCReportOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { validatePayload(this.payload.length >= 1); @@ -779,12 +776,11 @@ export type MultilevelSwitchCCStartLevelChangeOptions = @useSupervision() export class MultilevelSwitchCCStartLevelChange extends MultilevelSwitchCC { public constructor( - host: ZWaveHost, options: | CommandClassDeserializationOptions | (CCCommandOptions & MultilevelSwitchCCStartLevelChangeOptions), ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { validatePayload(this.payload.length >= 2); const ignoreStartLevel = (this.payload[0] & 0b0_0_1_00000) >>> 5; @@ -861,12 +857,11 @@ export interface MultilevelSwitchCCSupportedReportOptions { @CCCommand(MultilevelSwitchCommand.SupportedReport) export class MultilevelSwitchCCSupportedReport extends MultilevelSwitchCC { public constructor( - host: ZWaveHost, options: | CommandClassDeserializationOptions | (CCCommandOptions & MultilevelSwitchCCSupportedReportOptions), ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { validatePayload(this.payload.length >= 1); diff --git a/packages/cc/src/cc/NoOperationCC.ts b/packages/cc/src/cc/NoOperationCC.ts index a83bb194e56e..79ae57ff5e9c 100644 --- a/packages/cc/src/cc/NoOperationCC.ts +++ b/packages/cc/src/cc/NoOperationCC.ts @@ -16,7 +16,7 @@ import { isCommandClassContainer } from "../lib/ICommandClassContainer"; export class NoOperationCCAPI extends PhysicalCCAPI { public async send(): Promise { await this.applHost.sendCommand( - new NoOperationCC(this.applHost, { + new NoOperationCC({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, }), diff --git a/packages/cc/src/cc/NodeNamingCC.ts b/packages/cc/src/cc/NodeNamingCC.ts index 1f866d3fcdd0..6381e23a266c 100644 --- a/packages/cc/src/cc/NodeNamingCC.ts +++ b/packages/cc/src/cc/NodeNamingCC.ts @@ -13,7 +13,6 @@ import type { CCEncodingContext, GetValueDB, ZWaveApplicationHost, - ZWaveHost, } from "@zwave-js/host/safe"; import { validateArgs } from "@zwave-js/transformers"; import { @@ -135,7 +134,7 @@ export class NodeNamingAndLocationCCAPI extends PhysicalCCAPI { NodeNamingAndLocationCommand.NameGet, ); - const cc = new NodeNamingAndLocationCCNameGet(this.applHost, { + const cc = new NodeNamingAndLocationCCNameGet({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, }); @@ -155,7 +154,7 @@ export class NodeNamingAndLocationCCAPI extends PhysicalCCAPI { NodeNamingAndLocationCommand.NameSet, ); - const cc = new NodeNamingAndLocationCCNameSet(this.applHost, { + const cc = new NodeNamingAndLocationCCNameSet({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, name, @@ -169,7 +168,7 @@ export class NodeNamingAndLocationCCAPI extends PhysicalCCAPI { NodeNamingAndLocationCommand.LocationGet, ); - const cc = new NodeNamingAndLocationCCLocationGet(this.applHost, { + const cc = new NodeNamingAndLocationCCLocationGet({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, }); @@ -191,7 +190,7 @@ export class NodeNamingAndLocationCCAPI extends PhysicalCCAPI { NodeNamingAndLocationCommand.LocationSet, ); - const cc = new NodeNamingAndLocationCCLocationSet(this.applHost, { + const cc = new NodeNamingAndLocationCCLocationSet({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, location, @@ -278,12 +277,11 @@ export interface NodeNamingAndLocationCCNameSetOptions @useSupervision() export class NodeNamingAndLocationCCNameSet extends NodeNamingAndLocationCC { public constructor( - host: ZWaveHost, options: | CommandClassDeserializationOptions | NodeNamingAndLocationCCNameSetOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { // TODO: Deserialize payload throw new ZWaveError( @@ -329,10 +327,9 @@ export class NodeNamingAndLocationCCNameSet extends NodeNamingAndLocationCC { @CCCommand(NodeNamingAndLocationCommand.NameReport) export class NodeNamingAndLocationCCNameReport extends NodeNamingAndLocationCC { public constructor( - host: ZWaveHost, options: CommandClassDeserializationOptions | CCCommandOptions, ) { - super(host, options); + super(options); const encoding = this.payload[0] === 2 ? "utf16le" : "ascii"; let nameBuffer = this.payload.subarray(1); if (encoding === "utf16le") { @@ -371,12 +368,11 @@ export class NodeNamingAndLocationCCLocationSet extends NodeNamingAndLocationCC { public constructor( - host: ZWaveHost, options: | CommandClassDeserializationOptions | NodeNamingAndLocationCCLocationSetOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { // TODO: Deserialize payload throw new ZWaveError( @@ -424,10 +420,9 @@ export class NodeNamingAndLocationCCLocationReport extends NodeNamingAndLocationCC { public constructor( - host: ZWaveHost, options: CommandClassDeserializationOptions | CCCommandOptions, ) { - super(host, options); + super(options); const encoding = this.payload[0] === 2 ? "utf16le" : "ascii"; let locationBuffer = this.payload.subarray(1); if (encoding === "utf16le") { diff --git a/packages/cc/src/cc/NotificationCC.ts b/packages/cc/src/cc/NotificationCC.ts index 014de413650a..cf7d49e947c8 100644 --- a/packages/cc/src/cc/NotificationCC.ts +++ b/packages/cc/src/cc/NotificationCC.ts @@ -35,7 +35,6 @@ import type { CCEncodingContext, GetValueDB, ZWaveApplicationHost, - ZWaveHost, } from "@zwave-js/host/safe"; import { buffer2hex, num2hex, pick } from "@zwave-js/shared/safe"; import { validateArgs } from "@zwave-js/transformers"; @@ -293,7 +292,7 @@ export class NotificationCCAPI extends PhysicalCCAPI { NotificationCommand.Get, ); - const cc = new NotificationCCGet(this.applHost, { + const cc = new NotificationCCGet({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, ...options, @@ -313,7 +312,7 @@ export class NotificationCCAPI extends PhysicalCCAPI { NotificationCommand.Report, ); - const cc = new NotificationCCReport(this.applHost, { + const cc = new NotificationCCReport({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, ...options, @@ -346,7 +345,7 @@ export class NotificationCCAPI extends PhysicalCCAPI { NotificationCommand.Set, ); - const cc = new NotificationCCSet(this.applHost, { + const cc = new NotificationCCSet({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, notificationType, @@ -362,7 +361,7 @@ export class NotificationCCAPI extends PhysicalCCAPI { NotificationCommand.SupportedGet, ); - const cc = new NotificationCCSupportedGet(this.applHost, { + const cc = new NotificationCCSupportedGet({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, }); @@ -389,7 +388,7 @@ export class NotificationCCAPI extends PhysicalCCAPI { NotificationCommand.EventSupportedGet, ); - const cc = new NotificationCCEventSupportedGet(this.applHost, { + const cc = new NotificationCCEventSupportedGet({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, notificationType, @@ -917,10 +916,9 @@ export interface NotificationCCSetOptions extends CCCommandOptions { @useSupervision() export class NotificationCCSet extends NotificationCC { public constructor( - host: ZWaveHost, options: CommandClassDeserializationOptions | NotificationCCSetOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { validatePayload(this.payload.length >= 2); this.notificationType = this.payload[0]; @@ -969,12 +967,11 @@ export type NotificationCCReportOptions = @useSupervision() export class NotificationCCReport extends NotificationCC { public constructor( - host: ZWaveHost, options: | CommandClassDeserializationOptions | (NotificationCCReportOptions & CCCommandOptions), ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { validatePayload(this.payload.length >= 2); @@ -1278,7 +1275,7 @@ export class NotificationCCReport extends NotificationCC { // Try to parse the event parameters - if this fails, we should still handle the notification report try { // Convert CommandClass instances to a standardized object representation - const cc = CommandClass.from(this.host, { + const cc = CommandClass.from({ data: this.eventParameters, fromEncapsulation: true, encapCC: this, @@ -1441,10 +1438,9 @@ export type NotificationCCGetOptions = @expectedCCResponse(NotificationCCReport) export class NotificationCCGet extends NotificationCC { public constructor( - host: ZWaveHost, options: CommandClassDeserializationOptions | NotificationCCGetOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { validatePayload(this.payload.length >= 1); this.alarmType = this.payload[0] || undefined; @@ -1514,12 +1510,11 @@ export interface NotificationCCSupportedReportOptions extends CCCommandOptions { @CCCommand(NotificationCommand.SupportedReport) export class NotificationCCSupportedReport extends NotificationCC { public constructor( - host: ZWaveHost, options: | NotificationCCSupportedReportOptions | CommandClassDeserializationOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { validatePayload(this.payload.length >= 1); @@ -1596,12 +1591,11 @@ export interface NotificationCCEventSupportedReportOptions @CCCommand(NotificationCommand.EventSupportedReport) export class NotificationCCEventSupportedReport extends NotificationCC { public constructor( - host: ZWaveHost, options: | CommandClassDeserializationOptions | NotificationCCEventSupportedReportOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { validatePayload(this.payload.length >= 1); @@ -1731,12 +1725,11 @@ export interface NotificationCCEventSupportedGetOptions @expectedCCResponse(NotificationCCEventSupportedReport) export class NotificationCCEventSupportedGet extends NotificationCC { public constructor( - host: ZWaveHost, options: | CommandClassDeserializationOptions | NotificationCCEventSupportedGetOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { validatePayload(this.payload.length >= 1); this.notificationType = this.payload[0]; diff --git a/packages/cc/src/cc/PowerlevelCC.ts b/packages/cc/src/cc/PowerlevelCC.ts index 891e4064f66c..ab8c30824532 100644 --- a/packages/cc/src/cc/PowerlevelCC.ts +++ b/packages/cc/src/cc/PowerlevelCC.ts @@ -9,11 +9,7 @@ import { ZWaveErrorCodes, validatePayload, } from "@zwave-js/core/safe"; -import type { - CCEncodingContext, - GetValueDB, - ZWaveHost, -} from "@zwave-js/host/safe"; +import type { CCEncodingContext, GetValueDB } from "@zwave-js/host/safe"; import { getEnumMemberName, pick } from "@zwave-js/shared/safe"; import { validateArgs } from "@zwave-js/transformers"; import { PhysicalCCAPI } from "../lib/API"; @@ -57,7 +53,7 @@ export class PowerlevelCCAPI extends PhysicalCCAPI { public async setNormalPowerlevel(): Promise { this.assertSupportsCommand(PowerlevelCommand, PowerlevelCommand.Set); - const cc = new PowerlevelCCSet(this.applHost, { + const cc = new PowerlevelCCSet({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, powerlevel: Powerlevel["Normal Power"], @@ -72,7 +68,7 @@ export class PowerlevelCCAPI extends PhysicalCCAPI { ): Promise { this.assertSupportsCommand(PowerlevelCommand, PowerlevelCommand.Set); - const cc = new PowerlevelCCSet(this.applHost, { + const cc = new PowerlevelCCSet({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, powerlevel, @@ -86,7 +82,7 @@ export class PowerlevelCCAPI extends PhysicalCCAPI { > { this.assertSupportsCommand(PowerlevelCommand, PowerlevelCommand.Get); - const cc = new PowerlevelCCGet(this.applHost, { + const cc = new PowerlevelCCGet({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, }); @@ -105,7 +101,7 @@ export class PowerlevelCCAPI extends PhysicalCCAPI { ): Promise { this.assertSupportsCommand(PowerlevelCommand, PowerlevelCommand.Report); - const cc = new PowerlevelCCReport(this.applHost, { + const cc = new PowerlevelCCReport({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, ...options, @@ -144,7 +140,7 @@ export class PowerlevelCCAPI extends PhysicalCCAPI { ); } - const cc = new PowerlevelCCTestNodeSet(this.applHost, { + const cc = new PowerlevelCCTestNodeSet({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, testNodeId, @@ -167,7 +163,7 @@ export class PowerlevelCCAPI extends PhysicalCCAPI { PowerlevelCommand.TestNodeGet, ); - const cc = new PowerlevelCCTestNodeGet(this.applHost, { + const cc = new PowerlevelCCTestNodeGet({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, }); @@ -195,7 +191,7 @@ export class PowerlevelCCAPI extends PhysicalCCAPI { PowerlevelCommand.TestNodeReport, ); - const cc = new PowerlevelCCTestNodeReport(this.applHost, { + const cc = new PowerlevelCCTestNodeReport({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, ...options, @@ -228,10 +224,9 @@ export type PowerlevelCCSetOptions = @useSupervision() export class PowerlevelCCSet extends PowerlevelCC { public constructor( - host: ZWaveHost, options: CommandClassDeserializationOptions | PowerlevelCCSetOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { validatePayload(this.payload.length >= 2); this.powerlevel = this.payload[0]; @@ -286,12 +281,11 @@ export type PowerlevelCCReportOptions = { @CCCommand(PowerlevelCommand.Report) export class PowerlevelCCReport extends PowerlevelCC { public constructor( - host: ZWaveHost, options: | CommandClassDeserializationOptions | (PowerlevelCCReportOptions & CCCommandOptions), ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { this.powerlevel = this.payload[0]; @@ -341,12 +335,11 @@ export interface PowerlevelCCTestNodeSetOptions extends CCCommandOptions { @useSupervision() export class PowerlevelCCTestNodeSet extends PowerlevelCC { public constructor( - host: ZWaveHost, options: | CommandClassDeserializationOptions | PowerlevelCCTestNodeSetOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { validatePayload(this.payload.length >= 4); this.testNodeId = this.payload[0]; @@ -391,12 +384,11 @@ export interface PowerlevelCCTestNodeReportOptions { @CCCommand(PowerlevelCommand.TestNodeReport) export class PowerlevelCCTestNodeReport extends PowerlevelCC { public constructor( - host: ZWaveHost, options: | CommandClassDeserializationOptions | (PowerlevelCCTestNodeReportOptions & CCCommandOptions), ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { validatePayload(this.payload.length >= 4); diff --git a/packages/cc/src/cc/ProtectionCC.ts b/packages/cc/src/cc/ProtectionCC.ts index 01863a570e92..9942c4a67fe9 100644 --- a/packages/cc/src/cc/ProtectionCC.ts +++ b/packages/cc/src/cc/ProtectionCC.ts @@ -18,7 +18,6 @@ import type { CCEncodingContext, GetValueDB, ZWaveApplicationHost, - ZWaveHost, } from "@zwave-js/host/safe"; import { getEnumMemberName, pick } from "@zwave-js/shared/safe"; import { validateArgs } from "@zwave-js/transformers"; @@ -223,7 +222,7 @@ export class ProtectionCCAPI extends CCAPI { public async get() { this.assertSupportsCommand(ProtectionCommand, ProtectionCommand.Get); - const cc = new ProtectionCCGet(this.applHost, { + const cc = new ProtectionCCGet({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, }); @@ -243,7 +242,7 @@ export class ProtectionCCAPI extends CCAPI { ): Promise { this.assertSupportsCommand(ProtectionCommand, ProtectionCommand.Set); - const cc = new ProtectionCCSet(this.applHost, { + const cc = new ProtectionCCSet({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, local, @@ -259,7 +258,7 @@ export class ProtectionCCAPI extends CCAPI { ProtectionCommand.SupportedGet, ); - const cc = new ProtectionCCSupportedGet(this.applHost, { + const cc = new ProtectionCCSupportedGet({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, }); @@ -285,7 +284,7 @@ export class ProtectionCCAPI extends CCAPI { ProtectionCommand.ExclusiveControlGet, ); - const cc = new ProtectionCCExclusiveControlGet(this.applHost, { + const cc = new ProtectionCCExclusiveControlGet({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, }); @@ -307,7 +306,7 @@ export class ProtectionCCAPI extends CCAPI { ProtectionCommand.ExclusiveControlSet, ); - const cc = new ProtectionCCExclusiveControlSet(this.applHost, { + const cc = new ProtectionCCExclusiveControlSet({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, exclusiveControlNodeId: nodeId, @@ -321,7 +320,7 @@ export class ProtectionCCAPI extends CCAPI { ProtectionCommand.TimeoutGet, ); - const cc = new ProtectionCCTimeoutGet(this.applHost, { + const cc = new ProtectionCCTimeoutGet({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, }); @@ -343,7 +342,7 @@ export class ProtectionCCAPI extends CCAPI { ProtectionCommand.TimeoutSet, ); - const cc = new ProtectionCCTimeoutSet(this.applHost, { + const cc = new ProtectionCCTimeoutSet({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, timeout, @@ -508,10 +507,9 @@ export interface ProtectionCCSetOptions extends CCCommandOptions { @useSupervision() export class ProtectionCCSet extends ProtectionCC { public constructor( - host: ZWaveHost, options: CommandClassDeserializationOptions | ProtectionCCSetOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { // TODO: Deserialize payload throw new ZWaveError( @@ -563,10 +561,9 @@ export class ProtectionCCSet extends ProtectionCC { @CCCommand(ProtectionCommand.Report) export class ProtectionCCReport extends ProtectionCC { public constructor( - host: ZWaveHost, options: CommandClassDeserializationOptions, ) { - super(host, options); + super(options); validatePayload(this.payload.length >= 1); this.local = this.payload[0] & 0b1111; if (this.payload.length >= 2) { @@ -601,10 +598,9 @@ export class ProtectionCCGet extends ProtectionCC {} @CCCommand(ProtectionCommand.SupportedReport) export class ProtectionCCSupportedReport extends ProtectionCC { public constructor( - host: ZWaveHost, options: CommandClassDeserializationOptions, ) { - super(host, options); + super(options); validatePayload(this.payload.length >= 5); this.supportsTimeout = !!(this.payload[0] & 0b1); this.supportsExclusiveControl = !!(this.payload[0] & 0b10); @@ -683,10 +679,9 @@ export class ProtectionCCSupportedGet extends ProtectionCC {} @CCCommand(ProtectionCommand.ExclusiveControlReport) export class ProtectionCCExclusiveControlReport extends ProtectionCC { public constructor( - host: ZWaveHost, options: CommandClassDeserializationOptions, ) { - super(host, options); + super(options); validatePayload(this.payload.length >= 1); this.exclusiveControlNodeId = this.payload[0]; } @@ -720,12 +715,11 @@ export interface ProtectionCCExclusiveControlSetOptions @useSupervision() export class ProtectionCCExclusiveControlSet extends ProtectionCC { public constructor( - host: ZWaveHost, options: | CommandClassDeserializationOptions | ProtectionCCExclusiveControlSetOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { // TODO: Deserialize payload throw new ZWaveError( @@ -757,10 +751,9 @@ export class ProtectionCCExclusiveControlSet extends ProtectionCC { @CCCommand(ProtectionCommand.TimeoutReport) export class ProtectionCCTimeoutReport extends ProtectionCC { public constructor( - host: ZWaveHost, options: CommandClassDeserializationOptions, ) { - super(host, options); + super(options); validatePayload(this.payload.length >= 1); this.timeout = Timeout.parse(this.payload[0]); } @@ -790,12 +783,11 @@ export interface ProtectionCCTimeoutSetOptions extends CCCommandOptions { @useSupervision() export class ProtectionCCTimeoutSet extends ProtectionCC { public constructor( - host: ZWaveHost, options: | CommandClassDeserializationOptions | ProtectionCCTimeoutSetOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { // TODO: Deserialize payload throw new ZWaveError( diff --git a/packages/cc/src/cc/SceneActivationCC.ts b/packages/cc/src/cc/SceneActivationCC.ts index 7529d2f610cf..469069b312cf 100644 --- a/packages/cc/src/cc/SceneActivationCC.ts +++ b/packages/cc/src/cc/SceneActivationCC.ts @@ -10,11 +10,7 @@ import { ValueMetadata, validatePayload, } from "@zwave-js/core/safe"; -import type { - CCEncodingContext, - GetValueDB, - ZWaveHost, -} from "@zwave-js/host/safe"; +import type { CCEncodingContext, GetValueDB } from "@zwave-js/host/safe"; import { validateArgs } from "@zwave-js/transformers"; import { CCAPI, @@ -112,7 +108,7 @@ export class SceneActivationCCAPI extends CCAPI { SceneActivationCommand.Set, ); - const cc = new SceneActivationCCSet(this.applHost, { + const cc = new SceneActivationCCSet({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, sceneId, @@ -139,12 +135,11 @@ export interface SceneActivationCCSetOptions extends CCCommandOptions { @useSupervision() export class SceneActivationCCSet extends SceneActivationCC { public constructor( - host: ZWaveHost, options: | CommandClassDeserializationOptions | SceneActivationCCSetOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { validatePayload(this.payload.length >= 1); this.sceneId = this.payload[0]; diff --git a/packages/cc/src/cc/SceneActuatorConfigurationCC.ts b/packages/cc/src/cc/SceneActuatorConfigurationCC.ts index 995eef75d8b3..ede5b7bb0db3 100644 --- a/packages/cc/src/cc/SceneActuatorConfigurationCC.ts +++ b/packages/cc/src/cc/SceneActuatorConfigurationCC.ts @@ -15,7 +15,6 @@ import type { CCEncodingContext, GetValueDB, ZWaveApplicationHost, - ZWaveHost, } from "@zwave-js/host/safe"; import { pick } from "@zwave-js/shared/safe"; import { validateArgs } from "@zwave-js/transformers"; @@ -209,7 +208,7 @@ export class SceneActuatorConfigurationCCAPI extends CCAPI { // Undefined `dimmingDuration` defaults to 0 seconds to simplify the call // for actuators that don't support non-instant `dimmingDuration` // Undefined `level` uses the actuator's current value (override = 0). - const cc = new SceneActuatorConfigurationCCSet(this.applHost, { + const cc = new SceneActuatorConfigurationCCSet({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, sceneId, @@ -234,7 +233,7 @@ export class SceneActuatorConfigurationCCAPI extends CCAPI { SceneActuatorConfigurationCommand.Get, ); - const cc = new SceneActuatorConfigurationCCGet(this.applHost, { + const cc = new SceneActuatorConfigurationCCGet({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, sceneId: 0, @@ -274,7 +273,7 @@ export class SceneActuatorConfigurationCCAPI extends CCAPI { ); } - const cc = new SceneActuatorConfigurationCCGet(this.applHost, { + const cc = new SceneActuatorConfigurationCCGet({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, sceneId: sceneId, @@ -360,12 +359,11 @@ export class SceneActuatorConfigurationCCSet extends SceneActuatorConfigurationCC { public constructor( - host: ZWaveHost, options: | CommandClassDeserializationOptions | SceneActuatorConfigurationCCSetOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { // TODO: Deserialize payload throw new ZWaveError( @@ -420,10 +418,9 @@ export class SceneActuatorConfigurationCCReport extends SceneActuatorConfigurationCC { public constructor( - host: ZWaveHost, options: CommandClassDeserializationOptions, ) { - super(host, options); + super(options); validatePayload(this.payload.length >= 3); this.sceneId = this.payload[0]; @@ -508,12 +505,11 @@ export class SceneActuatorConfigurationCCGet extends SceneActuatorConfigurationCC { public constructor( - host: ZWaveHost, options: | CommandClassDeserializationOptions | SceneActuatorConfigurationCCGetOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { // TODO: Deserialize payload throw new ZWaveError( diff --git a/packages/cc/src/cc/SceneControllerConfigurationCC.ts b/packages/cc/src/cc/SceneControllerConfigurationCC.ts index f929a99bbe7c..9e9e176bb310 100644 --- a/packages/cc/src/cc/SceneControllerConfigurationCC.ts +++ b/packages/cc/src/cc/SceneControllerConfigurationCC.ts @@ -16,7 +16,6 @@ import type { CCEncodingContext, GetValueDB, ZWaveApplicationHost, - ZWaveHost, } from "@zwave-js/host/safe"; import { pick } from "@zwave-js/shared/safe"; import { validateArgs } from "@zwave-js/transformers"; @@ -267,7 +266,7 @@ export class SceneControllerConfigurationCCAPI extends CCAPI { ); } - const cc = new SceneControllerConfigurationCCSet(this.applHost, { + const cc = new SceneControllerConfigurationCCSet({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, groupId, @@ -291,7 +290,7 @@ export class SceneControllerConfigurationCCAPI extends CCAPI { SceneControllerConfigurationCommand.Get, ); - const cc = new SceneControllerConfigurationCCGet(this.applHost, { + const cc = new SceneControllerConfigurationCCGet({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, groupId: 0, @@ -339,7 +338,7 @@ export class SceneControllerConfigurationCCAPI extends CCAPI { ); } - const cc = new SceneControllerConfigurationCCGet(this.applHost, { + const cc = new SceneControllerConfigurationCCGet({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, groupId, @@ -497,12 +496,11 @@ export class SceneControllerConfigurationCCSet extends SceneControllerConfigurationCC { public constructor( - host: ZWaveHost, options: | CommandClassDeserializationOptions | SceneControllerConfigurationCCSetOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { // TODO: Deserialize payload throw new ZWaveError( @@ -548,10 +546,9 @@ export class SceneControllerConfigurationCCReport extends SceneControllerConfigurationCC { public constructor( - host: ZWaveHost, options: CommandClassDeserializationOptions, ) { - super(host, options); + super(options); validatePayload(this.payload.length >= 3); this.groupId = this.payload[0]; this.sceneId = this.payload[1]; @@ -620,12 +617,11 @@ export class SceneControllerConfigurationCCGet extends SceneControllerConfigurationCC { public constructor( - host: ZWaveHost, options: | CommandClassDeserializationOptions | SceneControllerConfigurationCCGetOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { // TODO: Deserialize payload throw new ZWaveError( diff --git a/packages/cc/src/cc/ScheduleEntryLockCC.ts b/packages/cc/src/cc/ScheduleEntryLockCC.ts index aa97ef95d9ea..836317694bac 100644 --- a/packages/cc/src/cc/ScheduleEntryLockCC.ts +++ b/packages/cc/src/cc/ScheduleEntryLockCC.ts @@ -17,7 +17,6 @@ import type { CCEncodingContext, GetValueDB, ZWaveApplicationHost, - ZWaveHost, } from "@zwave-js/host"; import { type AllOrNone, @@ -232,7 +231,7 @@ export class ScheduleEntryLockCCAPI extends CCAPI { ScheduleEntryLockCommand.EnableSet, ); - const cc = new ScheduleEntryLockCCEnableSet(this.applHost, { + const cc = new ScheduleEntryLockCCEnableSet({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, userId, @@ -246,7 +245,7 @@ export class ScheduleEntryLockCCAPI extends CCAPI { ScheduleEntryLockCommand.EnableAllSet, ); - const cc = new ScheduleEntryLockCCEnableAllSet(this.applHost, { + const cc = new ScheduleEntryLockCCEnableAllSet({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, enabled, @@ -275,7 +274,7 @@ export class ScheduleEntryLockCCAPI extends CCAPI { ScheduleEntryLockCommand.SupportedGet, ); - const cc = new ScheduleEntryLockCCSupportedGet(this.applHost, { + const cc = new ScheduleEntryLockCCSupportedGet({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, }); @@ -333,7 +332,7 @@ export class ScheduleEntryLockCCAPI extends CCAPI { } } - const cc = new ScheduleEntryLockCCWeekDayScheduleSet(this.applHost, { + const cc = new ScheduleEntryLockCCWeekDayScheduleSet({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, ...slot, @@ -390,7 +389,7 @@ export class ScheduleEntryLockCCAPI extends CCAPI { ScheduleEntryLockCommand.WeekDayScheduleSet, ); - const cc = new ScheduleEntryLockCCWeekDayScheduleGet(this.applHost, { + const cc = new ScheduleEntryLockCCWeekDayScheduleGet({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, ...slot, @@ -460,7 +459,7 @@ export class ScheduleEntryLockCCAPI extends CCAPI { } } - const cc = new ScheduleEntryLockCCYearDayScheduleSet(this.applHost, { + const cc = new ScheduleEntryLockCCYearDayScheduleSet({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, ...slot, @@ -517,7 +516,7 @@ export class ScheduleEntryLockCCAPI extends CCAPI { ScheduleEntryLockCommand.YearDayScheduleSet, ); - const cc = new ScheduleEntryLockCCYearDayScheduleGet(this.applHost, { + const cc = new ScheduleEntryLockCCYearDayScheduleGet({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, ...slot, @@ -570,22 +569,19 @@ export class ScheduleEntryLockCCAPI extends CCAPI { } } - const cc = new ScheduleEntryLockCCDailyRepeatingScheduleSet( - this.applHost, - { - nodeId: this.endpoint.nodeId, - endpoint: this.endpoint.index, - ...slot, - ...(schedule - ? { - action: ScheduleEntryLockSetAction.Set, - ...schedule, - } - : { - action: ScheduleEntryLockSetAction.Erase, - }), - }, - ); + const cc = new ScheduleEntryLockCCDailyRepeatingScheduleSet({ + nodeId: this.endpoint.nodeId, + endpoint: this.endpoint.index, + ...slot, + ...(schedule + ? { + action: ScheduleEntryLockSetAction.Set, + ...schedule, + } + : { + action: ScheduleEntryLockSetAction.Erase, + }), + }); const result = await this.applHost.sendCommand(cc, this.commandOptions); @@ -630,14 +626,11 @@ export class ScheduleEntryLockCCAPI extends CCAPI { ScheduleEntryLockCommand.DailyRepeatingScheduleSet, ); - const cc = new ScheduleEntryLockCCDailyRepeatingScheduleGet( - this.applHost, - { - nodeId: this.endpoint.nodeId, - endpoint: this.endpoint.index, - ...slot, - }, - ); + const cc = new ScheduleEntryLockCCDailyRepeatingScheduleGet({ + nodeId: this.endpoint.nodeId, + endpoint: this.endpoint.index, + ...slot, + }); const result = await this.applHost.sendCommand< ScheduleEntryLockCCDailyRepeatingScheduleReport >( @@ -662,7 +655,7 @@ export class ScheduleEntryLockCCAPI extends CCAPI { ScheduleEntryLockCommand.TimeOffsetGet, ); - const cc = new ScheduleEntryLockCCTimeOffsetGet(this.applHost, { + const cc = new ScheduleEntryLockCCTimeOffsetGet({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, }); @@ -687,7 +680,7 @@ export class ScheduleEntryLockCCAPI extends CCAPI { ScheduleEntryLockCommand.TimeOffsetSet, ); - const cc = new ScheduleEntryLockCCTimeOffsetSet(this.applHost, { + const cc = new ScheduleEntryLockCCTimeOffsetSet({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, ...timezone, @@ -944,12 +937,11 @@ export interface ScheduleEntryLockCCEnableSetOptions extends CCCommandOptions { @useSupervision() export class ScheduleEntryLockCCEnableSet extends ScheduleEntryLockCC { public constructor( - host: ZWaveHost, options: | CommandClassDeserializationOptions | ScheduleEntryLockCCEnableSetOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { validatePayload(this.payload.length >= 2); this.userId = this.payload[0]; @@ -990,12 +982,11 @@ export interface ScheduleEntryLockCCEnableAllSetOptions @useSupervision() export class ScheduleEntryLockCCEnableAllSet extends ScheduleEntryLockCC { public constructor( - host: ZWaveHost, options: | CommandClassDeserializationOptions | ScheduleEntryLockCCEnableAllSetOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { validatePayload(this.payload.length >= 1); this.enabled = this.payload[0] === 0x01; @@ -1033,12 +1024,11 @@ export interface ScheduleEntryLockCCSupportedReportOptions @CCCommand(ScheduleEntryLockCommand.SupportedReport) export class ScheduleEntryLockCCSupportedReport extends ScheduleEntryLockCC { public constructor( - host: ZWaveHost, options: | CommandClassDeserializationOptions | ScheduleEntryLockCCSupportedReportOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { validatePayload(this.payload.length >= 2); this.numWeekDaySlots = this.payload[0]; @@ -1106,12 +1096,11 @@ export type ScheduleEntryLockCCWeekDayScheduleSetOptions = @useSupervision() export class ScheduleEntryLockCCWeekDayScheduleSet extends ScheduleEntryLockCC { public constructor( - host: ZWaveHost, options: | CommandClassDeserializationOptions | ScheduleEntryLockCCWeekDayScheduleSetOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { validatePayload(this.payload.length >= 3); this.action = this.payload[0]; @@ -1216,12 +1205,11 @@ export class ScheduleEntryLockCCWeekDayScheduleReport extends ScheduleEntryLockCC { public constructor( - host: ZWaveHost, options: | CommandClassDeserializationOptions | ScheduleEntryLockCCWeekDayScheduleReportOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { validatePayload(this.payload.length >= 2); this.userId = this.payload[0]; @@ -1340,12 +1328,11 @@ export type ScheduleEntryLockCCWeekDayScheduleGetOptions = @expectedCCResponse(ScheduleEntryLockCCWeekDayScheduleReport) export class ScheduleEntryLockCCWeekDayScheduleGet extends ScheduleEntryLockCC { public constructor( - host: ZWaveHost, options: | CommandClassDeserializationOptions | ScheduleEntryLockCCWeekDayScheduleGetOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { validatePayload(this.payload.length >= 2); this.userId = this.payload[0]; @@ -1392,12 +1379,11 @@ export type ScheduleEntryLockCCYearDayScheduleSetOptions = @useSupervision() export class ScheduleEntryLockCCYearDayScheduleSet extends ScheduleEntryLockCC { public constructor( - host: ZWaveHost, options: | CommandClassDeserializationOptions | ScheduleEntryLockCCYearDayScheduleSetOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { validatePayload(this.payload.length >= 3); this.action = this.payload[0]; @@ -1524,12 +1510,11 @@ export class ScheduleEntryLockCCYearDayScheduleReport extends ScheduleEntryLockCC { public constructor( - host: ZWaveHost, options: | CommandClassDeserializationOptions | ScheduleEntryLockCCYearDayScheduleReportOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { validatePayload(this.payload.length >= 2); this.userId = this.payload[0]; @@ -1686,12 +1671,11 @@ export type ScheduleEntryLockCCYearDayScheduleGetOptions = @expectedCCResponse(ScheduleEntryLockCCYearDayScheduleReport) export class ScheduleEntryLockCCYearDayScheduleGet extends ScheduleEntryLockCC { public constructor( - host: ZWaveHost, options: | CommandClassDeserializationOptions | ScheduleEntryLockCCYearDayScheduleGetOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { validatePayload(this.payload.length >= 2); this.userId = this.payload[0]; @@ -1733,12 +1717,11 @@ export interface ScheduleEntryLockCCTimeOffsetSetOptions @useSupervision() export class ScheduleEntryLockCCTimeOffsetSet extends ScheduleEntryLockCC { public constructor( - host: ZWaveHost, options: | CommandClassDeserializationOptions | ScheduleEntryLockCCTimeOffsetSetOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { const { standardOffset, dstOffset } = parseTimezone(this.payload); this.standardOffset = standardOffset; @@ -1782,12 +1765,11 @@ export interface ScheduleEntryLockCCTimeOffsetReportOptions @CCCommand(ScheduleEntryLockCommand.TimeOffsetReport) export class ScheduleEntryLockCCTimeOffsetReport extends ScheduleEntryLockCC { public constructor( - host: ZWaveHost, options: | CommandClassDeserializationOptions | ScheduleEntryLockCCTimeOffsetReportOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { const { standardOffset, dstOffset } = parseTimezone(this.payload); this.standardOffset = standardOffset; @@ -1843,12 +1825,11 @@ export class ScheduleEntryLockCCDailyRepeatingScheduleSet extends ScheduleEntryLockCC { public constructor( - host: ZWaveHost, options: | CommandClassDeserializationOptions | ScheduleEntryLockCCDailyRepeatingScheduleSetOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { validatePayload(this.payload.length >= 3); this.action = this.payload[0]; @@ -1962,7 +1943,6 @@ export class ScheduleEntryLockCCDailyRepeatingScheduleReport extends ScheduleEntryLockCC { public constructor( - host: ZWaveHost, options: | CommandClassDeserializationOptions | ( @@ -1970,7 +1950,7 @@ export class ScheduleEntryLockCCDailyRepeatingScheduleReport & ScheduleEntryLockCCDailyRepeatingScheduleReportOptions ), ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { validatePayload(this.payload.length >= 2); this.userId = this.payload[0]; @@ -2098,12 +2078,11 @@ export class ScheduleEntryLockCCDailyRepeatingScheduleGet extends ScheduleEntryLockCC { public constructor( - host: ZWaveHost, options: | CommandClassDeserializationOptions | ScheduleEntryLockCCDailyRepeatingScheduleGetOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { validatePayload(this.payload.length >= 2); this.userId = this.payload[0]; diff --git a/packages/cc/src/cc/Security2CC.ts b/packages/cc/src/cc/Security2CC.ts index 24fad7d6021a..4a6dfd290219 100644 --- a/packages/cc/src/cc/Security2CC.ts +++ b/packages/cc/src/cc/Security2CC.ts @@ -41,7 +41,6 @@ import type { CCParsingContext, GetValueDB, ZWaveApplicationHost, - ZWaveHost, } from "@zwave-js/host/safe"; import { buffer2hex, getEnumMemberName, pick } from "@zwave-js/shared/safe"; import { wait } from "alcalzone-shared/async"; @@ -210,7 +209,7 @@ export class Security2CCAPI extends CCAPI { this.endpoint.nodeId, ); - const cc = new Security2CCNonceReport(this.applHost, { + const cc = new Security2CCNonceReport({ nodeId: this.endpoint.nodeId, ownNodeId: this.applHost.ownNodeId, endpoint: this.endpoint.index, @@ -258,7 +257,7 @@ export class Security2CCAPI extends CCAPI { this.assertPhysicalEndpoint(this.endpoint); - const cc = new Security2CCNonceReport(this.applHost, { + const cc = new Security2CCNonceReport({ nodeId: this.endpoint.nodeId, ownNodeId: this.applHost.ownNodeId, endpoint: this.endpoint.index, @@ -303,7 +302,7 @@ export class Security2CCAPI extends CCAPI { this.assertPhysicalEndpoint(this.endpoint); - const cc = new Security2CCMessageEncapsulation(this.applHost, { + const cc = new Security2CCMessageEncapsulation({ nodeId: this.endpoint.nodeId, ownNodeId: this.applHost.ownNodeId, endpoint: this.endpoint.index, @@ -355,13 +354,10 @@ export class Security2CCAPI extends CCAPI { Security2Command.CommandsSupportedGet, ); - let cc: CommandClass = new Security2CCCommandsSupportedGet( - this.applHost, - { - nodeId: this.endpoint.nodeId, - endpoint: this.endpoint.index, - }, - ); + let cc: CommandClass = new Security2CCCommandsSupportedGet({ + nodeId: this.endpoint.nodeId, + endpoint: this.endpoint.index, + }); // Security2CCCommandsSupportedGet is special because we cannot reply on the applHost to do the automatic // encapsulation because it would use a different security class. Therefore the entire possible stack // of encapsulation needs to be done here @@ -372,11 +368,10 @@ export class Security2CCAPI extends CCAPI { ); cc = multiChannelCCVersion === 1 - ? MultiChannelCC.encapsulateV1(this.applHost, cc) - : MultiChannelCC.encapsulate(this.applHost, cc); + ? MultiChannelCC.encapsulateV1(cc) + : MultiChannelCC.encapsulate(cc); } cc = Security2CC.encapsulate( - this.applHost, cc, this.applHost.ownNodeId, this.applHost, @@ -403,7 +398,7 @@ export class Security2CCAPI extends CCAPI { Security2Command.CommandsSupportedReport, ); - const cc = new Security2CCCommandsSupportedReport(this.applHost, { + const cc = new Security2CCCommandsSupportedReport({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, supportedCCs, @@ -415,7 +410,7 @@ export class Security2CCAPI extends CCAPI { public async getKeyExchangeParameters() { this.assertSupportsCommand(Security2Command, Security2Command.KEXGet); - const cc = new Security2CCKEXGet(this.applHost, { + const cc = new Security2CCKEXGet({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, }); @@ -444,7 +439,7 @@ export class Security2CCAPI extends CCAPI { Security2Command.KEXReport, ); - const cc = new Security2CCKEXReport(this.applHost, { + const cc = new Security2CCKEXReport({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, ...params, @@ -459,7 +454,7 @@ export class Security2CCAPI extends CCAPI { ): Promise { this.assertSupportsCommand(Security2Command, Security2Command.KEXSet); - const cc = new Security2CCKEXSet(this.applHost, { + const cc = new Security2CCKEXSet({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, ...params, @@ -477,7 +472,7 @@ export class Security2CCAPI extends CCAPI { Security2Command.KEXReport, ); - const cc = new Security2CCKEXReport(this.applHost, { + const cc = new Security2CCKEXReport({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, ...params, @@ -495,7 +490,7 @@ export class Security2CCAPI extends CCAPI { Security2Command.KEXSet, ); - const cc = new Security2CCKEXSet(this.applHost, { + const cc = new Security2CCKEXSet({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, ...params, @@ -508,7 +503,7 @@ export class Security2CCAPI extends CCAPI { public async abortKeyExchange(failType: KEXFailType): Promise { this.assertSupportsCommand(Security2Command, Security2Command.KEXFail); - const cc = new Security2CCKEXFail(this.applHost, { + const cc = new Security2CCKEXFail({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, failType, @@ -525,7 +520,7 @@ export class Security2CCAPI extends CCAPI { Security2Command.PublicKeyReport, ); - const cc = new Security2CCPublicKeyReport(this.applHost, { + const cc = new Security2CCPublicKeyReport({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, includingNode, @@ -542,7 +537,7 @@ export class Security2CCAPI extends CCAPI { Security2Command.NetworkKeyGet, ); - const cc = new Security2CCNetworkKeyGet(this.applHost, { + const cc = new Security2CCNetworkKeyGet({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, requestedKey: securityClass, @@ -559,7 +554,7 @@ export class Security2CCAPI extends CCAPI { Security2Command.NetworkKeyReport, ); - const cc = new Security2CCNetworkKeyReport(this.applHost, { + const cc = new Security2CCNetworkKeyReport({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, grantedKey: securityClass, @@ -574,7 +569,7 @@ export class Security2CCAPI extends CCAPI { Security2Command.NetworkKeyVerify, ); - const cc = new Security2CCNetworkKeyVerify(this.applHost, { + const cc = new Security2CCNetworkKeyVerify({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, }); @@ -587,7 +582,7 @@ export class Security2CCAPI extends CCAPI { Security2Command.TransferEnd, ); - const cc = new Security2CCTransferEnd(this.applHost, { + const cc = new Security2CCTransferEnd({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, keyVerified: true, @@ -606,7 +601,7 @@ export class Security2CCAPI extends CCAPI { Security2Command.TransferEnd, ); - const cc = new Security2CCTransferEnd(this.applHost, { + const cc = new Security2CCTransferEnd({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, keyVerified: false, @@ -957,7 +952,6 @@ export class Security2CC extends CommandClass { /** Encapsulates a command that should be sent encrypted */ public static encapsulate( - host: ZWaveHost, cc: CommandClass, ownNodeId: number, securityManagers: SecurityManagers, @@ -992,7 +986,7 @@ export class Security2CC extends CommandClass { nodeId = cc.nodeId as number; } - const ret = new Security2CCMessageEncapsulation(host, { + const ret = new Security2CCMessageEncapsulation({ nodeId, ownNodeId, encapsulated: cc, @@ -1090,12 +1084,11 @@ export type MulticastContext = ) export class Security2CCMessageEncapsulation extends Security2CC { public constructor( - host: ZWaveHost, options: | CommandClassDeserializationOptions | Security2CCMessageEncapsulationOptions, ) { - super(host, options); + super(options); // Make sure that we can send/receive secure commands this.securityManager = this.assertSecurity(options); @@ -1408,7 +1401,7 @@ export class Security2CCMessageEncapsulation extends Security2CC { // make sure this contains a complete CC command that's worth splitting validatePayload(decryptedCCBytes.length >= 2); // and deserialize the CC - this.encapsulated = CommandClass.from(this.host, { + this.encapsulated = CommandClass.from({ data: decryptedCCBytes, fromEncapsulation: true, encapCC: this, @@ -1993,12 +1986,11 @@ export type Security2CCNonceReportOptions = @CCCommand(Security2Command.NonceReport) export class Security2CCNonceReport extends Security2CC { public constructor( - host: ZWaveHost, options: | CommandClassDeserializationOptions | (CCCommandOptions & Security2CCNonceReportOptions), ) { - super(host, options); + super(options); // Make sure that we can send/receive secure commands this.securityManager = this.assertSecurity(options); @@ -2098,12 +2090,11 @@ export class Security2CCNonceGet extends Security2CC { // 250 ms before receiving the Security 2 Nonce Report Command. public constructor( - host: ZWaveHost, options: | CommandClassDeserializationOptions | (CCCommandOptions & Security2CCNonceGetOptions), ) { - super(host, options); + super(options); // Make sure that we can send/receive secure commands this.securityManager = this.assertSecurity(options); @@ -2166,12 +2157,11 @@ export interface Security2CCKEXReportOptions { @CCCommand(Security2Command.KEXReport) export class Security2CCKEXReport extends Security2CC { public constructor( - host: ZWaveHost, options: | CommandClassDeserializationOptions | (CCCommandOptions & Security2CCKEXReportOptions), ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { validatePayload(this.payload.length >= 4); this.requestCSA = !!(this.payload[0] & 0b10); @@ -2291,12 +2281,11 @@ function testExpectedResponseForKEXSet( @expectedCCResponse(getExpectedResponseForKEXSet, testExpectedResponseForKEXSet) export class Security2CCKEXSet extends Security2CC { public constructor( - host: ZWaveHost, options: | CommandClassDeserializationOptions | (CCCommandOptions & Security2CCKEXSetOptions), ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { validatePayload(this.payload.length >= 4); this._reserved = this.payload[0] & 0b1111_1100; @@ -2391,10 +2380,9 @@ export interface Security2CCKEXFailOptions extends CCCommandOptions { @CCCommand(Security2Command.KEXFail) export class Security2CCKEXFail extends Security2CC { public constructor( - host: ZWaveHost, options: CommandClassDeserializationOptions | Security2CCKEXFailOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { validatePayload(this.payload.length >= 1); this.failType = this.payload[0]; @@ -2427,12 +2415,11 @@ export interface Security2CCPublicKeyReportOptions extends CCCommandOptions { @CCCommand(Security2Command.PublicKeyReport) export class Security2CCPublicKeyReport extends Security2CC { public constructor( - host: ZWaveHost, options: | CommandClassDeserializationOptions | Security2CCPublicKeyReportOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { validatePayload(this.payload.length >= 17); this.includingNode = !!(this.payload[0] & 0b1); @@ -2474,12 +2461,11 @@ export interface Security2CCNetworkKeyReportOptions extends CCCommandOptions { @CCCommand(Security2Command.NetworkKeyReport) export class Security2CCNetworkKeyReport extends Security2CC { public constructor( - host: ZWaveHost, options: | CommandClassDeserializationOptions | Security2CCNetworkKeyReportOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { validatePayload(this.payload.length >= 17); this.grantedKey = bitMaskToSecurityClass(this.payload, 0); @@ -2526,12 +2512,11 @@ export interface Security2CCNetworkKeyGetOptions extends CCCommandOptions { // FIXME: maybe use the dynamic @expectedCCResponse instead? export class Security2CCNetworkKeyGet extends Security2CC { public constructor( - host: ZWaveHost, options: | CommandClassDeserializationOptions | Security2CCNetworkKeyGetOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { validatePayload(this.payload.length >= 1); this.requestedKey = bitMaskToSecurityClass(this.payload, 0); @@ -2572,12 +2557,11 @@ export interface Security2CCTransferEndOptions extends CCCommandOptions { @CCCommand(Security2Command.TransferEnd) export class Security2CCTransferEnd extends Security2CC { public constructor( - host: ZWaveHost, options: | CommandClassDeserializationOptions | Security2CCTransferEndOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { validatePayload(this.payload.length >= 1); this.keyVerified = !!(this.payload[0] & 0b10); @@ -2619,12 +2603,11 @@ export interface Security2CCCommandsSupportedReportOptions @CCCommand(Security2Command.CommandsSupportedReport) export class Security2CCCommandsSupportedReport extends Security2CC { public constructor( - host: ZWaveHost, options: | CommandClassDeserializationOptions | Security2CCCommandsSupportedReportOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { const CCs = parseCCList(this.payload); // SDS13783: A sending node MAY terminate the list of supported command classes with the diff --git a/packages/cc/src/cc/SecurityCC.ts b/packages/cc/src/cc/SecurityCC.ts index 2b1d2eac4ed2..23bb7289336d 100644 --- a/packages/cc/src/cc/SecurityCC.ts +++ b/packages/cc/src/cc/SecurityCC.ts @@ -26,7 +26,6 @@ import type { CCParsingContext, GetValueDB, ZWaveApplicationHost, - ZWaveHost, } from "@zwave-js/host/safe"; import { buffer2hex, num2hex, pick } from "@zwave-js/shared/safe"; import { wait } from "alcalzone-shared/async"; @@ -115,7 +114,7 @@ export class SecurityCCAPI extends PhysicalCCAPI { requestNextNonce ? SecurityCCCommandEncapsulationNonceGet : SecurityCCCommandEncapsulation - )(this.applHost, { + )({ nodeId: this.endpoint.nodeId, ownNodeId: this.applHost.ownNodeId, securityManager: this.applHost.securityManager!, @@ -130,7 +129,7 @@ export class SecurityCCAPI extends PhysicalCCAPI { public async getNonce(): Promise { this.assertSupportsCommand(SecurityCommand, SecurityCommand.NonceGet); - const cc = new SecurityCCNonceGet(this.applHost, { + const cc = new SecurityCCNonceGet({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, }); @@ -180,7 +179,7 @@ export class SecurityCCAPI extends PhysicalCCAPI { ); const nonceId = this.applHost.securityManager.getNonceId(nonce); - const cc = new SecurityCCNonceReport(this.applHost, { + const cc = new SecurityCCNonceReport({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, nonce, @@ -215,7 +214,7 @@ export class SecurityCCAPI extends PhysicalCCAPI { public async getSecurityScheme(): Promise<[0]> { this.assertSupportsCommand(SecurityCommand, SecurityCommand.SchemeGet); - const cc = new SecurityCCSchemeGet(this.applHost, { + const cc = new SecurityCCSchemeGet({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, }); @@ -230,12 +229,12 @@ export class SecurityCCAPI extends PhysicalCCAPI { SecurityCommand.SchemeReport, ); - let cc: CommandClass = new SecurityCCSchemeReport(this.applHost, { + let cc: CommandClass = new SecurityCCSchemeReport({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, }); if (encapsulated) { - cc = new SecurityCCCommandEncapsulation(this.applHost, { + cc = new SecurityCCCommandEncapsulation({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, ownNodeId: this.applHost.ownNodeId, @@ -252,7 +251,7 @@ export class SecurityCCAPI extends PhysicalCCAPI { SecurityCommand.SchemeInherit, ); - const cc = new SecurityCCSchemeInherit(this.applHost, { + const cc = new SecurityCCSchemeInherit({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, }); @@ -266,12 +265,12 @@ export class SecurityCCAPI extends PhysicalCCAPI { SecurityCommand.NetworkKeySet, ); - const keySet = new SecurityCCNetworkKeySet(this.applHost, { + const keySet = new SecurityCCNetworkKeySet({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, networkKey, }); - const cc = new SecurityCCCommandEncapsulation(this.applHost, { + const cc = new SecurityCCCommandEncapsulation({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, ownNodeId: this.applHost.ownNodeId, @@ -288,7 +287,7 @@ export class SecurityCCAPI extends PhysicalCCAPI { SecurityCommand.NetworkKeyVerify, ); - const cc = new SecurityCCNetworkKeyVerify(this.applHost, { + const cc = new SecurityCCNetworkKeyVerify({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, }); @@ -302,7 +301,7 @@ export class SecurityCCAPI extends PhysicalCCAPI { SecurityCommand.CommandsSupportedGet, ); - const cc = new SecurityCCCommandsSupportedGet(this.applHost, { + const cc = new SecurityCCCommandsSupportedGet({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, }); @@ -326,7 +325,7 @@ export class SecurityCCAPI extends PhysicalCCAPI { SecurityCommand.CommandsSupportedReport, ); - const cc = new SecurityCCCommandsSupportedReport(this.applHost, { + const cc = new SecurityCCCommandsSupportedReport({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, supportedCCs, @@ -537,13 +536,12 @@ export class SecurityCC extends CommandClass { /** Encapsulates a command that should be sent encrypted */ public static encapsulate( - host: ZWaveHost, ownNodeId: number, securityManager: SecurityManager, cc: CommandClass, ): SecurityCCCommandEncapsulation { // TODO: When to return a SecurityCCCommandEncapsulationNonceGet? - const ret = new SecurityCCCommandEncapsulation(host, { + const ret = new SecurityCCCommandEncapsulation({ nodeId: cc.nodeId, ownNodeId, securityManager, @@ -566,12 +564,11 @@ interface SecurityCCNonceReportOptions extends CCCommandOptions { @CCCommand(SecurityCommand.NonceReport) export class SecurityCCNonceReport extends SecurityCC { constructor( - host: ZWaveHost, options: | CommandClassDeserializationOptions | SecurityCCNonceReportOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { validatePayload.withReason("Invalid nonce length")( this.payload.length === HALF_NONCE_SIZE, @@ -632,12 +629,11 @@ function getCCResponseForCommandEncapsulation( ) export class SecurityCCCommandEncapsulation extends SecurityCC { public constructor( - host: ZWaveHost, options: | CommandClassDeserializationOptions | SecurityCCCommandEncapsulationOptions, ) { - super(host, options); + super(options); this.securityManager = this.assertSecurity(options); @@ -769,7 +765,7 @@ export class SecurityCCCommandEncapsulation extends SecurityCC { // make sure this contains a complete CC command that's worth splitting validatePayload(this.decryptedCCBytes.length >= 2); // and deserialize the CC - this.encapsulated = CommandClass.from(this.host, { + this.encapsulated = CommandClass.from({ data: this.decryptedCCBytes, fromEncapsulation: true, encapCC: this, @@ -875,10 +871,9 @@ export class SecurityCCCommandEncapsulationNonceGet @CCCommand(SecurityCommand.SchemeReport) export class SecurityCCSchemeReport extends SecurityCC { public constructor( - host: ZWaveHost, options: CommandClassDeserializationOptions | CCCommandOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { validatePayload(this.payload.length >= 1); // The including controller MUST NOT perform any validation of the Supported Security Schemes byte @@ -904,10 +899,9 @@ export class SecurityCCSchemeReport extends SecurityCC { @expectedCCResponse(SecurityCCSchemeReport) export class SecurityCCSchemeGet extends SecurityCC { public constructor( - host: ZWaveHost, options: CommandClassDeserializationOptions | CCCommandOptions, ) { - super(host, options); + super(options); // Don't care, we won't get sent this and we have no options } @@ -930,10 +924,9 @@ export class SecurityCCSchemeGet extends SecurityCC { @expectedCCResponse(SecurityCCSchemeReport) export class SecurityCCSchemeInherit extends SecurityCC { public constructor( - host: ZWaveHost, options: CommandClassDeserializationOptions | CCCommandOptions, ) { - super(host, options); + super(options); // Don't care, we won't get sent this and we have no options } @@ -964,12 +957,11 @@ export interface SecurityCCNetworkKeySetOptions extends CCCommandOptions { @expectedCCResponse(SecurityCCNetworkKeyVerify) export class SecurityCCNetworkKeySet extends SecurityCC { public constructor( - host: ZWaveHost, options: | CommandClassDeserializationOptions | SecurityCCNetworkKeySetOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { validatePayload(this.payload.length >= 16); this.networkKey = this.payload.subarray(0, 16); @@ -1009,12 +1001,11 @@ export interface SecurityCCCommandsSupportedReportOptions @CCCommand(SecurityCommand.CommandsSupportedReport) export class SecurityCCCommandsSupportedReport extends SecurityCC { public constructor( - host: ZWaveHost, options: | CommandClassDeserializationOptions | SecurityCCCommandsSupportedReportOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { validatePayload(this.payload.length >= 1); diff --git a/packages/cc/src/cc/SoundSwitchCC.ts b/packages/cc/src/cc/SoundSwitchCC.ts index 316f2fae7b23..dd54f54dbf79 100644 --- a/packages/cc/src/cc/SoundSwitchCC.ts +++ b/packages/cc/src/cc/SoundSwitchCC.ts @@ -15,7 +15,6 @@ import type { CCEncodingContext, GetValueDB, ZWaveApplicationHost, - ZWaveHost, } from "@zwave-js/host/safe"; import { pick } from "@zwave-js/shared/safe"; import { validateArgs } from "@zwave-js/transformers"; @@ -121,7 +120,7 @@ export class SoundSwitchCCAPI extends CCAPI { SoundSwitchCommand.TonesNumberGet, ); - const cc = new SoundSwitchCCTonesNumberGet(this.applHost, { + const cc = new SoundSwitchCCTonesNumberGet({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, }); @@ -142,7 +141,7 @@ export class SoundSwitchCCAPI extends CCAPI { SoundSwitchCommand.ToneInfoGet, ); - const cc = new SoundSwitchCCToneInfoGet(this.applHost, { + const cc = new SoundSwitchCCToneInfoGet({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, toneId, @@ -166,7 +165,7 @@ export class SoundSwitchCCAPI extends CCAPI { SoundSwitchCommand.ConfigurationSet, ); - const cc = new SoundSwitchCCConfigurationSet(this.applHost, { + const cc = new SoundSwitchCCConfigurationSet({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, defaultToneId, @@ -182,7 +181,7 @@ export class SoundSwitchCCAPI extends CCAPI { SoundSwitchCommand.ConfigurationGet, ); - const cc = new SoundSwitchCCConfigurationGet(this.applHost, { + const cc = new SoundSwitchCCConfigurationGet({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, }); @@ -214,7 +213,7 @@ export class SoundSwitchCCAPI extends CCAPI { ); } - const cc = new SoundSwitchCCTonePlaySet(this.applHost, { + const cc = new SoundSwitchCCTonePlaySet({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, toneId, @@ -229,7 +228,7 @@ export class SoundSwitchCCAPI extends CCAPI { SoundSwitchCommand.TonePlaySet, ); - const cc = new SoundSwitchCCTonePlaySet(this.applHost, { + const cc = new SoundSwitchCCTonePlaySet({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, toneId: 0x00, @@ -245,7 +244,7 @@ export class SoundSwitchCCAPI extends CCAPI { SoundSwitchCommand.TonePlayGet, ); - const cc = new SoundSwitchCCTonePlayGet(this.applHost, { + const cc = new SoundSwitchCCTonePlayGet({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, }); @@ -481,12 +480,11 @@ export interface SoundSwitchCCTonesNumberReportOptions @CCCommand(SoundSwitchCommand.TonesNumberReport) export class SoundSwitchCCTonesNumberReport extends SoundSwitchCC { public constructor( - host: ZWaveHost, options: | CommandClassDeserializationOptions | SoundSwitchCCTonesNumberReportOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { validatePayload(this.payload.length >= 1); this.toneCount = this.payload[0]; @@ -524,12 +522,11 @@ export interface SoundSwitchCCToneInfoReportOptions extends CCCommandOptions { @CCCommand(SoundSwitchCommand.ToneInfoReport) export class SoundSwitchCCToneInfoReport extends SoundSwitchCC { public constructor( - host: ZWaveHost, options: | CommandClassDeserializationOptions | SoundSwitchCCToneInfoReportOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { validatePayload(this.payload.length >= 4); this.toneId = this.payload[0]; @@ -590,12 +587,11 @@ export interface SoundSwitchCCToneInfoGetOptions extends CCCommandOptions { ) export class SoundSwitchCCToneInfoGet extends SoundSwitchCC { public constructor( - host: ZWaveHost, options: | CommandClassDeserializationOptions | SoundSwitchCCToneInfoGetOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { validatePayload(this.payload.length >= 1); this.toneId = this.payload[0]; @@ -629,12 +625,11 @@ export interface SoundSwitchCCConfigurationSetOptions extends CCCommandOptions { @useSupervision() export class SoundSwitchCCConfigurationSet extends SoundSwitchCC { public constructor( - host: ZWaveHost, options: | CommandClassDeserializationOptions | SoundSwitchCCConfigurationSetOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { validatePayload(this.payload.length >= 2); this.defaultVolume = this.payload[0]; @@ -673,12 +668,11 @@ export interface SoundSwitchCCConfigurationReportOptions { @CCCommand(SoundSwitchCommand.ConfigurationReport) export class SoundSwitchCCConfigurationReport extends SoundSwitchCC { public constructor( - host: ZWaveHost, options: | CommandClassDeserializationOptions | (CCCommandOptions & SoundSwitchCCConfigurationReportOptions), ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { validatePayload(this.payload.length >= 2); this.defaultVolume = clamp(this.payload[0], 0, 100); @@ -726,12 +720,11 @@ export interface SoundSwitchCCTonePlaySetOptions { @useSupervision() export class SoundSwitchCCTonePlaySet extends SoundSwitchCC { public constructor( - host: ZWaveHost, options: | CommandClassDeserializationOptions | (CCCommandOptions & SoundSwitchCCTonePlaySetOptions), ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { validatePayload(this.payload.length >= 1); this.toneId = this.payload[0]; @@ -776,12 +769,11 @@ export interface SoundSwitchCCTonePlayReportOptions { @CCCommand(SoundSwitchCommand.TonePlayReport) export class SoundSwitchCCTonePlayReport extends SoundSwitchCC { public constructor( - host: ZWaveHost, options: | CommandClassDeserializationOptions | (CCCommandOptions & SoundSwitchCCTonePlayReportOptions), ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { validatePayload(this.payload.length >= 1); this.toneId = this.payload[0]; diff --git a/packages/cc/src/cc/SupervisionCC.ts b/packages/cc/src/cc/SupervisionCC.ts index 04eea4b65b64..42753c9364fa 100644 --- a/packages/cc/src/cc/SupervisionCC.ts +++ b/packages/cc/src/cc/SupervisionCC.ts @@ -23,7 +23,6 @@ import type { CCEncodingContext, GetValueDB, ZWaveApplicationHost, - ZWaveHost, } from "@zwave-js/host/safe"; import { getEnumMemberName } from "@zwave-js/shared/safe"; import { PhysicalCCAPI } from "../lib/API"; @@ -92,7 +91,7 @@ export class SupervisionCCAPI extends PhysicalCCAPI { lowPriority = false, ...cmdOptions } = options; - const cc = new SupervisionCCReport(this.applHost, { + const cc = new SupervisionCCReport({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, ...cmdOptions, @@ -144,7 +143,6 @@ export class SupervisionCC extends CommandClass { /** Encapsulates a command that targets a specific endpoint */ public static encapsulate( - host: ZWaveHost, cc: CommandClass, sessionId: number, requestStatusUpdates: boolean = true, @@ -156,7 +154,7 @@ export class SupervisionCC extends CommandClass { ); } - const ret = new SupervisionCCGet(host, { + const ret = new SupervisionCCGet({ nodeId: cc.nodeId, // Supervision CC is wrapped inside MultiChannel CCs, so the endpoint must be copied endpoint: cc.endpointIndex, @@ -291,12 +289,11 @@ export type SupervisionCCReportOptions = @CCCommand(SupervisionCommand.Report) export class SupervisionCCReport extends SupervisionCC { public constructor( - host: ZWaveHost, options: | CommandClassDeserializationOptions | (CCCommandOptions & SupervisionCCReportOptions), ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { validatePayload(this.payload.length >= 3); @@ -390,16 +387,15 @@ function testResponseForSupervisionCCGet( @expectedCCResponse(SupervisionCCReport, testResponseForSupervisionCCGet) export class SupervisionCCGet extends SupervisionCC { public constructor( - host: ZWaveHost, options: CommandClassDeserializationOptions | SupervisionCCGetOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { validatePayload(this.payload.length >= 3); this.requestStatusUpdates = !!(this.payload[0] & 0b1_0_000000); this.sessionId = this.payload[0] & 0b111111; - this.encapsulated = CommandClass.from(this.host, { + this.encapsulated = CommandClass.from({ data: this.payload.subarray(2), fromEncapsulation: true, encapCC: this, diff --git a/packages/cc/src/cc/ThermostatFanModeCC.ts b/packages/cc/src/cc/ThermostatFanModeCC.ts index ddd4753aa17c..bdb2cb881950 100644 --- a/packages/cc/src/cc/ThermostatFanModeCC.ts +++ b/packages/cc/src/cc/ThermostatFanModeCC.ts @@ -17,7 +17,6 @@ import type { CCEncodingContext, GetValueDB, ZWaveApplicationHost, - ZWaveHost, } from "@zwave-js/host/safe"; import { getEnumMemberName, pick } from "@zwave-js/shared/safe"; import { validateArgs } from "@zwave-js/transformers"; @@ -177,7 +176,7 @@ export class ThermostatFanModeCCAPI extends CCAPI { ThermostatFanModeCommand.Get, ); - const cc = new ThermostatFanModeCCGet(this.applHost, { + const cc = new ThermostatFanModeCCGet({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, }); @@ -202,7 +201,7 @@ export class ThermostatFanModeCCAPI extends CCAPI { ThermostatFanModeCommand.Set, ); - const cc = new ThermostatFanModeCCSet(this.applHost, { + const cc = new ThermostatFanModeCCSet({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, mode, @@ -219,7 +218,7 @@ export class ThermostatFanModeCCAPI extends CCAPI { ThermostatFanModeCommand.SupportedGet, ); - const cc = new ThermostatFanModeCCSupportedGet(this.applHost, { + const cc = new ThermostatFanModeCCSupportedGet({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, }); @@ -344,12 +343,11 @@ export type ThermostatFanModeCCSetOptions = CCCommandOptions & { @useSupervision() export class ThermostatFanModeCCSet extends ThermostatFanModeCC { public constructor( - host: ZWaveHost, options: | CommandClassDeserializationOptions | ThermostatFanModeCCSetOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { // TODO: Deserialize payload throw new ZWaveError( @@ -387,10 +385,9 @@ export class ThermostatFanModeCCSet extends ThermostatFanModeCC { @CCCommand(ThermostatFanModeCommand.Report) export class ThermostatFanModeCCReport extends ThermostatFanModeCC { public constructor( - host: ZWaveHost, options: CommandClassDeserializationOptions, ) { - super(host, options); + super(options); validatePayload(this.payload.length >= 1); this.mode = this.payload[0] & 0b1111; @@ -426,10 +423,9 @@ export class ThermostatFanModeCCGet extends ThermostatFanModeCC {} @CCCommand(ThermostatFanModeCommand.SupportedReport) export class ThermostatFanModeCCSupportedReport extends ThermostatFanModeCC { public constructor( - host: ZWaveHost, options: CommandClassDeserializationOptions, ) { - super(host, options); + super(options); this.supportedModes = parseBitMask( this.payload, ThermostatFanMode["Auto low"], diff --git a/packages/cc/src/cc/ThermostatFanStateCC.ts b/packages/cc/src/cc/ThermostatFanStateCC.ts index afb1ecd94ca3..e64d52b1386d 100644 --- a/packages/cc/src/cc/ThermostatFanStateCC.ts +++ b/packages/cc/src/cc/ThermostatFanStateCC.ts @@ -8,11 +8,7 @@ import { enumValuesToMetadataStates, validatePayload, } from "@zwave-js/core/safe"; -import type { - GetValueDB, - ZWaveApplicationHost, - ZWaveHost, -} from "@zwave-js/host/safe"; +import type { GetValueDB, ZWaveApplicationHost } from "@zwave-js/host/safe"; import { getEnumMemberName } from "@zwave-js/shared/safe"; import { CCAPI, @@ -82,7 +78,7 @@ export class ThermostatFanStateCCAPI extends CCAPI { ThermostatFanStateCommand.Get, ); - const cc = new ThermostatFanStateCCGet(this.applHost, { + const cc = new ThermostatFanStateCCGet({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, }); @@ -155,10 +151,9 @@ export class ThermostatFanStateCC extends CommandClass { @CCCommand(ThermostatFanStateCommand.Report) export class ThermostatFanStateCCReport extends ThermostatFanStateCC { public constructor( - host: ZWaveHost, options: CommandClassDeserializationOptions, ) { - super(host, options); + super(options); validatePayload(this.payload.length == 1); this.state = this.payload[0] & 0b1111; diff --git a/packages/cc/src/cc/ThermostatModeCC.ts b/packages/cc/src/cc/ThermostatModeCC.ts index 636d4f576122..0a3f5ac74e7d 100644 --- a/packages/cc/src/cc/ThermostatModeCC.ts +++ b/packages/cc/src/cc/ThermostatModeCC.ts @@ -18,7 +18,6 @@ import type { CCEncodingContext, GetValueDB, ZWaveApplicationHost, - ZWaveHost, } from "@zwave-js/host/safe"; import { buffer2hex, getEnumMemberName, pick } from "@zwave-js/shared/safe"; import { validateArgs } from "@zwave-js/transformers"; @@ -133,7 +132,7 @@ export class ThermostatModeCCAPI extends CCAPI { ThermostatModeCommand.Get, ); - const cc = new ThermostatModeCCGet(this.applHost, { + const cc = new ThermostatModeCCGet({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, }); @@ -183,7 +182,7 @@ export class ThermostatModeCCAPI extends CCAPI { manufacturerData = Buffer.from(manufacturerData, "hex"); } - const cc = new ThermostatModeCCSet(this.applHost, { + const cc = new ThermostatModeCCSet({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, mode, @@ -200,7 +199,7 @@ export class ThermostatModeCCAPI extends CCAPI { ThermostatModeCommand.SupportedGet, ); - const cc = new ThermostatModeCCSupportedGet(this.applHost, { + const cc = new ThermostatModeCCSupportedGet({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, }); @@ -327,12 +326,11 @@ export type ThermostatModeCCSetOptions = @useSupervision() export class ThermostatModeCCSet extends ThermostatModeCC { public constructor( - host: ZWaveHost, options: | CommandClassDeserializationOptions | ThermostatModeCCSetOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { validatePayload(this.payload.length >= 1); const manufacturerDataLength = (this.payload[0] >>> 5) & 0b111; @@ -407,12 +405,11 @@ export type ThermostatModeCCReportOptions = @CCCommand(ThermostatModeCommand.Report) export class ThermostatModeCCReport extends ThermostatModeCC { public constructor( - host: ZWaveHost, options: | CommandClassDeserializationOptions | ThermostatModeCCReportOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { validatePayload(this.payload.length >= 1); @@ -521,12 +518,11 @@ export interface ThermostatModeCCSupportedReportOptions @CCCommand(ThermostatModeCommand.SupportedReport) export class ThermostatModeCCSupportedReport extends ThermostatModeCC { public constructor( - host: ZWaveHost, options: | CommandClassDeserializationOptions | ThermostatModeCCSupportedReportOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { this.supportedModes = parseBitMask( this.payload, diff --git a/packages/cc/src/cc/ThermostatOperatingStateCC.ts b/packages/cc/src/cc/ThermostatOperatingStateCC.ts index 3f27ca9a072b..df3aaf543391 100644 --- a/packages/cc/src/cc/ThermostatOperatingStateCC.ts +++ b/packages/cc/src/cc/ThermostatOperatingStateCC.ts @@ -7,11 +7,7 @@ import { enumValuesToMetadataStates, validatePayload, } from "@zwave-js/core/safe"; -import type { - GetValueDB, - ZWaveApplicationHost, - ZWaveHost, -} from "@zwave-js/host/safe"; +import type { GetValueDB, ZWaveApplicationHost } from "@zwave-js/host/safe"; import { getEnumMemberName } from "@zwave-js/shared/safe"; import { CCAPI, @@ -88,7 +84,7 @@ export class ThermostatOperatingStateCCAPI extends PhysicalCCAPI { ThermostatOperatingStateCommand.Get, ); - const cc = new ThermostatOperatingStateCCGet(this.applHost, { + const cc = new ThermostatOperatingStateCCGet({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, }); @@ -166,10 +162,9 @@ export class ThermostatOperatingStateCCReport extends ThermostatOperatingStateCC { public constructor( - host: ZWaveHost, options: CommandClassDeserializationOptions, ) { - super(host, options); + super(options); validatePayload(this.payload.length >= 1); this.state = this.payload[0]; diff --git a/packages/cc/src/cc/ThermostatSetbackCC.ts b/packages/cc/src/cc/ThermostatSetbackCC.ts index 83aacaa08136..eb9c6251ad9f 100644 --- a/packages/cc/src/cc/ThermostatSetbackCC.ts +++ b/packages/cc/src/cc/ThermostatSetbackCC.ts @@ -10,7 +10,6 @@ import type { CCEncodingContext, GetValueDB, ZWaveApplicationHost, - ZWaveHost, } from "@zwave-js/host/safe"; import { getEnumMemberName, pick } from "@zwave-js/shared/safe"; import { validateArgs } from "@zwave-js/transformers"; @@ -79,7 +78,7 @@ export class ThermostatSetbackCCAPI extends CCAPI { ThermostatSetbackCommand.Get, ); - const cc = new ThermostatSetbackCCGet(this.applHost, { + const cc = new ThermostatSetbackCCGet({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, }); @@ -104,7 +103,7 @@ export class ThermostatSetbackCCAPI extends CCAPI { ThermostatSetbackCommand.Get, ); - const cc = new ThermostatSetbackCCSet(this.applHost, { + const cc = new ThermostatSetbackCCSet({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, setbackType, @@ -179,12 +178,11 @@ export interface ThermostatSetbackCCSetOptions extends CCCommandOptions { @useSupervision() export class ThermostatSetbackCCSet extends ThermostatSetbackCC { public constructor( - host: ZWaveHost, options: | CommandClassDeserializationOptions | ThermostatSetbackCCSetOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { validatePayload(this.payload.length >= 2); this.setbackType = this.payload[0] & 0b11; @@ -235,12 +233,11 @@ export interface ThermostatSetbackCCReportOptions { @CCCommand(ThermostatSetbackCommand.Report) export class ThermostatSetbackCCReport extends ThermostatSetbackCC { public constructor( - host: ZWaveHost, options: | CommandClassDeserializationOptions | (CCCommandOptions & ThermostatSetbackCCReportOptions), ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { validatePayload(this.payload.length >= 2); diff --git a/packages/cc/src/cc/ThermostatSetpointCC.ts b/packages/cc/src/cc/ThermostatSetpointCC.ts index 951a0399372c..025ed981942a 100644 --- a/packages/cc/src/cc/ThermostatSetpointCC.ts +++ b/packages/cc/src/cc/ThermostatSetpointCC.ts @@ -22,7 +22,6 @@ import type { CCEncodingContext, GetValueDB, ZWaveApplicationHost, - ZWaveHost, } from "@zwave-js/host/safe"; import { getEnumMemberName, pick } from "@zwave-js/shared/safe"; import { validateArgs } from "@zwave-js/transformers"; @@ -221,7 +220,7 @@ export class ThermostatSetpointCCAPI extends CCAPI { ThermostatSetpointCommand.Get, ); - const cc = new ThermostatSetpointCCGet(this.applHost, { + const cc = new ThermostatSetpointCCGet({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, setpointType, @@ -254,7 +253,7 @@ export class ThermostatSetpointCCAPI extends CCAPI { ThermostatSetpointCommand.Set, ); - const cc = new ThermostatSetpointCCSet(this.applHost, { + const cc = new ThermostatSetpointCCSet({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, setpointType, @@ -272,7 +271,7 @@ export class ThermostatSetpointCCAPI extends CCAPI { ThermostatSetpointCommand.CapabilitiesGet, ); - const cc = new ThermostatSetpointCCCapabilitiesGet(this.applHost, { + const cc = new ThermostatSetpointCCCapabilitiesGet({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, setpointType, @@ -306,7 +305,7 @@ export class ThermostatSetpointCCAPI extends CCAPI { ThermostatSetpointCommand.SupportedGet, ); - const cc = new ThermostatSetpointCCSupportedGet(this.applHost, { + const cc = new ThermostatSetpointCCSupportedGet({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, }); @@ -553,12 +552,11 @@ export interface ThermostatSetpointCCSetOptions extends CCCommandOptions { @useSupervision() export class ThermostatSetpointCCSet extends ThermostatSetpointCC { public constructor( - host: ZWaveHost, options: | CommandClassDeserializationOptions | ThermostatSetpointCCSetOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { validatePayload(this.payload.length >= 1); this.setpointType = this.payload[0] & 0b1111; @@ -615,12 +613,11 @@ export interface ThermostatSetpointCCReportOptions extends CCCommandOptions { @CCCommand(ThermostatSetpointCommand.Report) export class ThermostatSetpointCCReport extends ThermostatSetpointCC { public constructor( - host: ZWaveHost, options: | CommandClassDeserializationOptions | ThermostatSetpointCCReportOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { validatePayload(this.payload.length >= 1); @@ -721,12 +718,11 @@ export interface ThermostatSetpointCCGetOptions extends CCCommandOptions { ) export class ThermostatSetpointCCGet extends ThermostatSetpointCC { public constructor( - host: ZWaveHost, options: | CommandClassDeserializationOptions | ThermostatSetpointCCGetOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { validatePayload(this.payload.length >= 1); this.setpointType = this.payload[0] & 0b1111; @@ -771,12 +767,11 @@ export class ThermostatSetpointCCCapabilitiesReport extends ThermostatSetpointCC { public constructor( - host: ZWaveHost, options: | CommandClassDeserializationOptions | ThermostatSetpointCCCapabilitiesReportOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { validatePayload(this.payload.length >= 1); @@ -856,12 +851,11 @@ export interface ThermostatSetpointCCCapabilitiesGetOptions @expectedCCResponse(ThermostatSetpointCCCapabilitiesReport) export class ThermostatSetpointCCCapabilitiesGet extends ThermostatSetpointCC { public constructor( - host: ZWaveHost, options: | CommandClassDeserializationOptions | ThermostatSetpointCCCapabilitiesGetOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { validatePayload(this.payload.length >= 1); this.setpointType = this.payload[0] & 0b1111; @@ -900,12 +894,11 @@ export interface ThermostatSetpointCCSupportedReportOptions @CCCommand(ThermostatSetpointCommand.SupportedReport) export class ThermostatSetpointCCSupportedReport extends ThermostatSetpointCC { public constructor( - host: ZWaveHost, options: | CommandClassDeserializationOptions | ThermostatSetpointCCSupportedReportOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { validatePayload(this.payload.length >= 1); diff --git a/packages/cc/src/cc/TimeCC.ts b/packages/cc/src/cc/TimeCC.ts index 61e7e6b375eb..7ab9834abaa8 100644 --- a/packages/cc/src/cc/TimeCC.ts +++ b/packages/cc/src/cc/TimeCC.ts @@ -15,7 +15,6 @@ import type { CCEncodingContext, GetValueDB, ZWaveApplicationHost, - ZWaveHost, } from "@zwave-js/host/safe"; import { pick } from "@zwave-js/shared/safe"; import { validateArgs } from "@zwave-js/transformers"; @@ -64,7 +63,7 @@ export class TimeCCAPI extends CCAPI { public async getTime() { this.assertSupportsCommand(TimeCommand, TimeCommand.TimeGet); - const cc = new TimeCCTimeGet(this.applHost, { + const cc = new TimeCCTimeGet({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, }); @@ -85,7 +84,7 @@ export class TimeCCAPI extends CCAPI { ): Promise { this.assertSupportsCommand(TimeCommand, TimeCommand.TimeReport); - const cc = new TimeCCTimeReport(this.applHost, { + const cc = new TimeCCTimeReport({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, hour, @@ -99,7 +98,7 @@ export class TimeCCAPI extends CCAPI { public async getDate() { this.assertSupportsCommand(TimeCommand, TimeCommand.DateGet); - const cc = new TimeCCDateGet(this.applHost, { + const cc = new TimeCCDateGet({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, }); @@ -120,7 +119,7 @@ export class TimeCCAPI extends CCAPI { ): Promise { this.assertSupportsCommand(TimeCommand, TimeCommand.DateReport); - const cc = new TimeCCDateReport(this.applHost, { + const cc = new TimeCCDateReport({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, year, @@ -136,7 +135,7 @@ export class TimeCCAPI extends CCAPI { ): Promise { this.assertSupportsCommand(TimeCommand, TimeCommand.TimeOffsetSet); - const cc = new TimeCCTimeOffsetSet(this.applHost, { + const cc = new TimeCCTimeOffsetSet({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, standardOffset: timezone.standardOffset, @@ -150,7 +149,7 @@ export class TimeCCAPI extends CCAPI { public async getTimezone(): Promise> { this.assertSupportsCommand(TimeCommand, TimeCommand.TimeOffsetGet); - const cc = new TimeCCTimeOffsetGet(this.applHost, { + const cc = new TimeCCTimeOffsetGet({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, }); @@ -176,7 +175,7 @@ export class TimeCCAPI extends CCAPI { ): Promise { this.assertSupportsCommand(TimeCommand, TimeCommand.TimeOffsetReport); - const cc = new TimeCCTimeOffsetReport(this.applHost, { + const cc = new TimeCCTimeOffsetReport({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, standardOffset: timezone.standardOffset, @@ -239,10 +238,9 @@ export interface TimeCCTimeReportOptions extends CCCommandOptions { @CCCommand(TimeCommand.TimeReport) export class TimeCCTimeReport extends TimeCC { public constructor( - host: ZWaveHost, options: CommandClassDeserializationOptions | TimeCCTimeReportOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { validatePayload(this.payload.length >= 3); this.hour = this.payload[0] & 0b11111; @@ -301,10 +299,9 @@ export interface TimeCCDateReportOptions extends CCCommandOptions { @CCCommand(TimeCommand.DateReport) export class TimeCCDateReport extends TimeCC { public constructor( - host: ZWaveHost, options: CommandClassDeserializationOptions | TimeCCDateReportOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { validatePayload(this.payload.length >= 4); this.year = this.payload.readUInt16BE(0); @@ -365,12 +362,11 @@ export interface TimeCCTimeOffsetSetOptions extends CCCommandOptions { @useSupervision() export class TimeCCTimeOffsetSet extends TimeCC { public constructor( - host: ZWaveHost, options: | CommandClassDeserializationOptions | TimeCCTimeOffsetSetOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { // TODO: Deserialize payload throw new ZWaveError( @@ -432,12 +428,11 @@ export interface TimeCCTimeOffsetReportOptions extends CCCommandOptions { @CCCommand(TimeCommand.TimeOffsetReport) export class TimeCCTimeOffsetReport extends TimeCC { public constructor( - host: ZWaveHost, options: | CommandClassDeserializationOptions | TimeCCTimeOffsetReportOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { validatePayload(this.payload.length >= 9); const { standardOffset, dstOffset } = parseTimezone(this.payload); diff --git a/packages/cc/src/cc/TimeParametersCC.ts b/packages/cc/src/cc/TimeParametersCC.ts index 7b68467375c8..dbfcbe6d683f 100644 --- a/packages/cc/src/cc/TimeParametersCC.ts +++ b/packages/cc/src/cc/TimeParametersCC.ts @@ -17,7 +17,6 @@ import type { CCEncodingContext, GetValueDB, ZWaveApplicationHost, - ZWaveHost, } from "@zwave-js/host/safe"; import { validateArgs } from "@zwave-js/transformers"; import { @@ -177,7 +176,7 @@ export class TimeParametersCCAPI extends CCAPI { TimeParametersCommand.Get, ); - const cc = new TimeParametersCCGet(this.applHost, { + const cc = new TimeParametersCCGet({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, }); @@ -207,7 +206,7 @@ export class TimeParametersCCAPI extends CCAPI { const useLocalTime = shouldUseLocalTime(this.applHost, endpointToCheck); - const cc = new TimeParametersCCSet(this.applHost, { + const cc = new TimeParametersCCSet({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, dateAndTime, @@ -258,10 +257,9 @@ export class TimeParametersCC extends CommandClass { @CCCommand(TimeParametersCommand.Report) export class TimeParametersCCReport extends TimeParametersCC { public constructor( - host: ZWaveHost, options: CommandClassDeserializationOptions, ) { - super(host, options); + super(options); validatePayload(this.payload.length >= 7); const dateSegments = { year: this.payload.readUInt16BE(0), @@ -323,12 +321,11 @@ export interface TimeParametersCCSetOptions extends CCCommandOptions { @useSupervision() export class TimeParametersCCSet extends TimeParametersCC { public constructor( - host: ZWaveHost, options: | CommandClassDeserializationOptions | TimeParametersCCSetOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { validatePayload(this.payload.length >= 7); const dateSegments = { diff --git a/packages/cc/src/cc/TransportServiceCC.ts b/packages/cc/src/cc/TransportServiceCC.ts index 8c6302c47efa..ad951c0678c1 100644 --- a/packages/cc/src/cc/TransportServiceCC.ts +++ b/packages/cc/src/cc/TransportServiceCC.ts @@ -12,7 +12,6 @@ import type { CCParsingContext, GetValueDB, ZWaveApplicationHost, - ZWaveHost, } from "@zwave-js/host/safe"; import { buffer2hex } from "@zwave-js/shared/safe"; import { @@ -82,10 +81,7 @@ export class TransportServiceCC extends CommandClass } /** Encapsulates a command that should be sent in multiple segments */ - public static encapsulate( - _host: ZWaveHost, - _cc: CommandClass, - ): TransportServiceCC { + public static encapsulate(_cc: CommandClass): TransportServiceCC { throw new Error("not implemented"); } } @@ -118,12 +114,11 @@ export function isTransportServiceEncapsulation( // @expectedCCResponse(TransportServiceCCReport) export class TransportServiceCCFirstSegment extends TransportServiceCC { public constructor( - host: ZWaveHost, options: | CommandClassDeserializationOptions | TransportServiceCCFirstSegmentOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { // Deserialization has already split the datagram size from the ccCommand. // Therefore we have one more payload byte @@ -251,12 +246,11 @@ export interface TransportServiceCCSubsequentSegmentOptions // @expectedCCResponse(TransportServiceCCReport) export class TransportServiceCCSubsequentSegment extends TransportServiceCC { public constructor( - host: ZWaveHost, options: | CommandClassDeserializationOptions | TransportServiceCCSubsequentSegmentOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { // Deserialization has already split the datagram size from the ccCommand. // Therefore we have one more payload byte @@ -373,7 +367,7 @@ export class TransportServiceCCSubsequentSegment extends TransportServiceCC { } // and deserialize the CC - this._encapsulated = CommandClass.from(this.host, { + this._encapsulated = CommandClass.from({ data: datagram, fromEncapsulation: true, encapCC: this, @@ -471,12 +465,11 @@ function testResponseForSegmentRequest( @expectedCCResponse(TransportServiceCC, testResponseForSegmentRequest) export class TransportServiceCCSegmentRequest extends TransportServiceCC { public constructor( - host: ZWaveHost, options: | CommandClassDeserializationOptions | TransportServiceCCSegmentRequestOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { validatePayload(this.payload.length >= 3); this.sessionId = this.payload[1] >>> 4; @@ -521,12 +514,11 @@ export interface TransportServiceCCSegmentCompleteOptions @CCCommand(TransportServiceCommand.SegmentComplete) export class TransportServiceCCSegmentComplete extends TransportServiceCC { public constructor( - host: ZWaveHost, options: | CommandClassDeserializationOptions | TransportServiceCCSegmentCompleteOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { validatePayload(this.payload.length >= 2); this.sessionId = this.payload[1] >>> 4; @@ -558,12 +550,11 @@ export interface TransportServiceCCSegmentWaitOptions extends CCCommandOptions { @CCCommand(TransportServiceCommand.SegmentWait) export class TransportServiceCCSegmentWait extends TransportServiceCC { public constructor( - host: ZWaveHost, options: | CommandClassDeserializationOptions | TransportServiceCCSegmentWaitOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { validatePayload(this.payload.length >= 2); this.pendingSegments = this.payload[1]; diff --git a/packages/cc/src/cc/UserCodeCC.ts b/packages/cc/src/cc/UserCodeCC.ts index 82aba905eb59..22474bd99e38 100644 --- a/packages/cc/src/cc/UserCodeCC.ts +++ b/packages/cc/src/cc/UserCodeCC.ts @@ -19,7 +19,6 @@ import type { CCEncodingContext, GetValueDB, ZWaveApplicationHost, - ZWaveHost, } from "@zwave-js/host/safe"; import { getEnumMemberName, @@ -449,7 +448,7 @@ export class UserCodeCCAPI extends PhysicalCCAPI { UserCodeCommand.UsersNumberGet, ); - const cc = new UserCodeCCUsersNumberGet(this.applHost, { + const cc = new UserCodeCCUsersNumberGet({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, }); @@ -482,7 +481,7 @@ export class UserCodeCCAPI extends PhysicalCCAPI { UserCodeCommand.ExtendedUserCodeGet, ); - const cc = new UserCodeCCExtendedUserCodeGet(this.applHost, { + const cc = new UserCodeCCExtendedUserCodeGet({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, userId, @@ -507,7 +506,7 @@ export class UserCodeCCAPI extends PhysicalCCAPI { } else { this.assertSupportsCommand(UserCodeCommand, UserCodeCommand.Get); - const cc = new UserCodeCCGet(this.applHost, { + const cc = new UserCodeCCGet({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, userId, @@ -547,7 +546,7 @@ export class UserCodeCCAPI extends PhysicalCCAPI { ); } - const cc = new UserCodeCCSet(this.applHost, { + const cc = new UserCodeCCSet({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, userId, @@ -658,7 +657,7 @@ export class UserCodeCCAPI extends PhysicalCCAPI { } } } - const cc = new UserCodeCCExtendedUserCodeSet(this.applHost, { + const cc = new UserCodeCCExtendedUserCodeSet({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, userCodes: codes, @@ -692,7 +691,7 @@ export class UserCodeCCAPI extends PhysicalCCAPI { ); } - const cc = new UserCodeCCSet(this.applHost, { + const cc = new UserCodeCCSet({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, userId, @@ -709,7 +708,7 @@ export class UserCodeCCAPI extends PhysicalCCAPI { UserCodeCommand.CapabilitiesGet, ); - const cc = new UserCodeCCCapabilitiesGet(this.applHost, { + const cc = new UserCodeCCCapabilitiesGet({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, }); @@ -739,7 +738,7 @@ export class UserCodeCCAPI extends PhysicalCCAPI { UserCodeCommand.KeypadModeGet, ); - const cc = new UserCodeCCKeypadModeGet(this.applHost, { + const cc = new UserCodeCCKeypadModeGet({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, }); @@ -783,7 +782,7 @@ export class UserCodeCCAPI extends PhysicalCCAPI { ); } - const cc = new UserCodeCCKeypadModeSet(this.applHost, { + const cc = new UserCodeCCKeypadModeSet({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, keypadMode, @@ -798,7 +797,7 @@ export class UserCodeCCAPI extends PhysicalCCAPI { UserCodeCommand.AdminCodeGet, ); - const cc = new UserCodeCCAdminCodeGet(this.applHost, { + const cc = new UserCodeCCAdminCodeGet({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, }); @@ -851,7 +850,7 @@ export class UserCodeCCAPI extends PhysicalCCAPI { ); } - const cc = new UserCodeCCAdminCodeSet(this.applHost, { + const cc = new UserCodeCCAdminCodeSet({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, adminCode, @@ -866,7 +865,7 @@ export class UserCodeCCAPI extends PhysicalCCAPI { UserCodeCommand.UserCodeChecksumGet, ); - const cc = new UserCodeCCUserCodeChecksumGet(this.applHost, { + const cc = new UserCodeCCUserCodeChecksumGet({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, }); @@ -1233,12 +1232,11 @@ export type UserCodeCCSetOptions = @useSupervision() export class UserCodeCCSet extends UserCodeCC { public constructor( - host: ZWaveHost, options: | CommandClassDeserializationOptions | (CCCommandOptions & UserCodeCCSetOptions), ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { validatePayload(this.payload.length >= 2); this.userId = this.payload[0]; @@ -1326,10 +1324,9 @@ export class UserCodeCCReport extends UserCodeCC implements NotificationEventPayload { public constructor( - host: ZWaveHost, options: CommandClassDeserializationOptions | UserCodeCCReportOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { validatePayload(this.payload.length >= 2); @@ -1429,10 +1426,9 @@ export interface UserCodeCCGetOptions extends CCCommandOptions { @expectedCCResponse(UserCodeCCReport) export class UserCodeCCGet extends UserCodeCC { public constructor( - host: ZWaveHost, options: CommandClassDeserializationOptions | UserCodeCCGetOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { validatePayload(this.payload.length >= 1); this.userId = this.payload[0]; @@ -1464,12 +1460,11 @@ export interface UserCodeCCUsersNumberReportOptions extends CCCommandOptions { @CCCommand(UserCodeCommand.UsersNumberReport) export class UserCodeCCUsersNumberReport extends UserCodeCC { public constructor( - host: ZWaveHost, options: | CommandClassDeserializationOptions | UserCodeCCUsersNumberReportOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { validatePayload(this.payload.length >= 1); @@ -1523,12 +1518,11 @@ export interface UserCodeCCCapabilitiesReportOptions extends CCCommandOptions { @CCCommand(UserCodeCommand.CapabilitiesReport) export class UserCodeCCCapabilitiesReport extends UserCodeCC { public constructor( - host: ZWaveHost, options: | CommandClassDeserializationOptions | UserCodeCCCapabilitiesReportOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { let offset = 0; @@ -1700,12 +1694,11 @@ export interface UserCodeCCKeypadModeSetOptions extends CCCommandOptions { @useSupervision() export class UserCodeCCKeypadModeSet extends UserCodeCC { public constructor( - host: ZWaveHost, options: | CommandClassDeserializationOptions | UserCodeCCKeypadModeSetOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { validatePayload(this.payload.length >= 1); this.keypadMode = this.payload[0]; @@ -1737,12 +1730,11 @@ export interface UserCodeCCKeypadModeReportOptions extends CCCommandOptions { @CCCommand(UserCodeCommand.KeypadModeReport) export class UserCodeCCKeypadModeReport extends UserCodeCC { public constructor( - host: ZWaveHost, options: | CommandClassDeserializationOptions | UserCodeCCKeypadModeReportOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { validatePayload(this.payload.length >= 1); this.keypadMode = this.payload[0]; @@ -1803,12 +1795,11 @@ export interface UserCodeCCAdminCodeSetOptions extends CCCommandOptions { @useSupervision() export class UserCodeCCAdminCodeSet extends UserCodeCC { public constructor( - host: ZWaveHost, options: | CommandClassDeserializationOptions | UserCodeCCAdminCodeSetOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { validatePayload(this.payload.length >= 1); const codeLength = this.payload[0] & 0b1111; @@ -1847,12 +1838,11 @@ export interface UserCodeCCAdminCodeReportOptions extends CCCommandOptions { @CCCommand(UserCodeCommand.AdminCodeReport) export class UserCodeCCAdminCodeReport extends UserCodeCC { public constructor( - host: ZWaveHost, options: | CommandClassDeserializationOptions | UserCodeCCAdminCodeReportOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { validatePayload(this.payload.length >= 1); const codeLength = this.payload[0] & 0b1111; @@ -1898,12 +1888,11 @@ export interface UserCodeCCUserCodeChecksumReportOptions @CCCommand(UserCodeCommand.UserCodeChecksumReport) export class UserCodeCCUserCodeChecksumReport extends UserCodeCC { public constructor( - host: ZWaveHost, options: | CommandClassDeserializationOptions | UserCodeCCUserCodeChecksumReportOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { validatePayload(this.payload.length >= 2); this.userCodeChecksum = this.payload.readUInt16BE(0); @@ -1948,12 +1937,11 @@ export interface UserCode { @useSupervision() export class UserCodeCCExtendedUserCodeSet extends UserCodeCC { public constructor( - host: ZWaveHost, options: | CommandClassDeserializationOptions | UserCodeCCExtendedUserCodeSetOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { // TODO: Deserialize payload throw new ZWaveError( @@ -2009,10 +1997,9 @@ export class UserCodeCCExtendedUserCodeSet extends UserCodeCC { @CCCommand(UserCodeCommand.ExtendedUserCodeReport) export class UserCodeCCExtendedUserCodeReport extends UserCodeCC { public constructor( - host: ZWaveHost, options: CommandClassDeserializationOptions, ) { - super(host, options); + super(options); validatePayload(this.payload.length >= 1); const numCodes = this.payload[0]; let offset = 1; @@ -2076,12 +2063,11 @@ export interface UserCodeCCExtendedUserCodeGetOptions extends CCCommandOptions { @expectedCCResponse(UserCodeCCExtendedUserCodeReport) export class UserCodeCCExtendedUserCodeGet extends UserCodeCC { public constructor( - host: ZWaveHost, options: | CommandClassDeserializationOptions | UserCodeCCExtendedUserCodeGetOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { // TODO: Deserialize payload throw new ZWaveError( diff --git a/packages/cc/src/cc/VersionCC.ts b/packages/cc/src/cc/VersionCC.ts index 4ca70f989fa6..ad756b7cd467 100644 --- a/packages/cc/src/cc/VersionCC.ts +++ b/packages/cc/src/cc/VersionCC.ts @@ -19,7 +19,6 @@ import type { CCEncodingContext, GetValueDB, ZWaveApplicationHost, - ZWaveHost, } from "@zwave-js/host/safe"; import { getEnumMemberName, num2hex, pick } from "@zwave-js/shared/safe"; import { validateArgs } from "@zwave-js/transformers"; @@ -245,7 +244,7 @@ export class VersionCCAPI extends PhysicalCCAPI { public async get() { this.assertSupportsCommand(VersionCommand, VersionCommand.Get); - const cc = new VersionCCGet(this.applHost, { + const cc = new VersionCCGet({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, }); @@ -267,7 +266,7 @@ export class VersionCCAPI extends PhysicalCCAPI { public async sendReport(options: VersionCCReportOptions): Promise { this.assertSupportsCommand(VersionCommand, VersionCommand.Report); - const cc = new VersionCCReport(this.applHost, { + const cc = new VersionCCReport({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, ...options, @@ -284,7 +283,7 @@ export class VersionCCAPI extends PhysicalCCAPI { VersionCommand.CommandClassGet, ); - const cc = new VersionCCCommandClassGet(this.applHost, { + const cc = new VersionCCCommandClassGet({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, requestedCC, @@ -325,7 +324,7 @@ export class VersionCCAPI extends PhysicalCCAPI { break; } - const cc = new VersionCCCommandClassReport(this.applHost, { + const cc = new VersionCCCommandClassReport({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, requestedCC, @@ -341,7 +340,7 @@ export class VersionCCAPI extends PhysicalCCAPI { VersionCommand.CapabilitiesGet, ); - const cc = new VersionCCCapabilitiesGet(this.applHost, { + const cc = new VersionCCCapabilitiesGet({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, }); @@ -362,7 +361,7 @@ export class VersionCCAPI extends PhysicalCCAPI { VersionCommand.CapabilitiesReport, ); - const cc = new VersionCCCapabilitiesReport(this.applHost, { + const cc = new VersionCCCapabilitiesReport({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, // At this time, we do not support responding to Z-Wave Software Get @@ -378,7 +377,7 @@ export class VersionCCAPI extends PhysicalCCAPI { VersionCommand.ZWaveSoftwareGet, ); - const cc = new VersionCCZWaveSoftwareGet(this.applHost, { + const cc = new VersionCCZWaveSoftwareGet({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, }); @@ -653,12 +652,11 @@ export interface VersionCCReportOptions { @CCCommand(VersionCommand.Report) export class VersionCCReport extends VersionCC { public constructor( - host: ZWaveHost, options: | CommandClassDeserializationOptions | (VersionCCReportOptions & CCCommandOptions), ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { validatePayload(this.payload.length >= 5); @@ -783,12 +781,11 @@ export interface VersionCCCommandClassReportOptions extends CCCommandOptions { @CCCommand(VersionCommand.CommandClassReport) export class VersionCCCommandClassReport extends VersionCC { public constructor( - host: ZWaveHost, options: | VersionCCCommandClassReportOptions | CommandClassDeserializationOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { validatePayload(this.payload.length >= 2); this.requestedCC = this.payload[0]; @@ -838,12 +835,11 @@ function testResponseForVersionCommandClassGet( ) export class VersionCCCommandClassGet extends VersionCC { public constructor( - host: ZWaveHost, options: | CommandClassDeserializationOptions | VersionCCCommandClassGetOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { validatePayload(this.payload.length >= 1); this.requestedCC = this.payload[0]; @@ -875,12 +871,11 @@ export interface VersionCCCapabilitiesReportOptions { @CCCommand(VersionCommand.CapabilitiesReport) export class VersionCCCapabilitiesReport extends VersionCC { public constructor( - host: ZWaveHost, options: | CommandClassDeserializationOptions | (VersionCCCapabilitiesReportOptions & CCCommandOptions), ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { validatePayload(this.payload.length >= 1); @@ -919,10 +914,9 @@ export class VersionCCCapabilitiesGet extends VersionCC {} @CCCommand(VersionCommand.ZWaveSoftwareReport) export class VersionCCZWaveSoftwareReport extends VersionCC { public constructor( - host: ZWaveHost, options: CommandClassDeserializationOptions, ) { - super(host, options); + super(options); validatePayload(this.payload.length >= 23); this.sdkVersion = parseVersion(this.payload); diff --git a/packages/cc/src/cc/WakeUpCC.ts b/packages/cc/src/cc/WakeUpCC.ts index 76c70a0eba5b..b17942fc252a 100644 --- a/packages/cc/src/cc/WakeUpCC.ts +++ b/packages/cc/src/cc/WakeUpCC.ts @@ -13,7 +13,6 @@ import type { CCEncodingContext, GetValueDB, ZWaveApplicationHost, - ZWaveHost, } from "@zwave-js/host/safe"; import { pick } from "@zwave-js/shared/safe"; import { validateArgs } from "@zwave-js/transformers"; @@ -136,7 +135,7 @@ export class WakeUpCCAPI extends CCAPI { public async getInterval() { this.assertSupportsCommand(WakeUpCommand, WakeUpCommand.IntervalGet); - const cc = new WakeUpCCIntervalGet(this.applHost, { + const cc = new WakeUpCCIntervalGet({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, }); @@ -158,7 +157,7 @@ export class WakeUpCCAPI extends CCAPI { WakeUpCommand.IntervalCapabilitiesGet, ); - const cc = new WakeUpCCIntervalCapabilitiesGet(this.applHost, { + const cc = new WakeUpCCIntervalCapabilitiesGet({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, }); @@ -186,7 +185,7 @@ export class WakeUpCCAPI extends CCAPI { ): Promise { this.assertSupportsCommand(WakeUpCommand, WakeUpCommand.IntervalSet); - const cc = new WakeUpCCIntervalSet(this.applHost, { + const cc = new WakeUpCCIntervalSet({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, wakeUpInterval, @@ -201,7 +200,7 @@ export class WakeUpCCAPI extends CCAPI { WakeUpCommand.NoMoreInformation, ); - const cc = new WakeUpCCNoMoreInformation(this.applHost, { + const cc = new WakeUpCCNoMoreInformation({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, }); @@ -364,12 +363,11 @@ export interface WakeUpCCIntervalSetOptions extends CCCommandOptions { @useSupervision() export class WakeUpCCIntervalSet extends WakeUpCC { public constructor( - host: ZWaveHost, options: | CommandClassDeserializationOptions | WakeUpCCIntervalSetOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { validatePayload(this.payload.length >= 4); this.wakeUpInterval = this.payload.readUIntBE(0, 3); @@ -408,10 +406,9 @@ export class WakeUpCCIntervalSet extends WakeUpCC { @CCCommand(WakeUpCommand.IntervalReport) export class WakeUpCCIntervalReport extends WakeUpCC { public constructor( - host: ZWaveHost, options: CommandClassDeserializationOptions, ) { - super(host, options); + super(options); validatePayload(this.payload.length >= 4); this.wakeUpInterval = this.payload.readUIntBE(0, 3); @@ -448,10 +445,9 @@ export class WakeUpCCNoMoreInformation extends WakeUpCC {} @CCCommand(WakeUpCommand.IntervalCapabilitiesReport) export class WakeUpCCIntervalCapabilitiesReport extends WakeUpCC { public constructor( - host: ZWaveHost, options: CommandClassDeserializationOptions, ) { - super(host, options); + super(options); validatePayload(this.payload.length >= 12); this.minWakeUpInterval = this.payload.readUIntBE(0, 3); diff --git a/packages/cc/src/cc/WindowCoveringCC.ts b/packages/cc/src/cc/WindowCoveringCC.ts index 57737fb7e5fb..25a8d7c6b734 100644 --- a/packages/cc/src/cc/WindowCoveringCC.ts +++ b/packages/cc/src/cc/WindowCoveringCC.ts @@ -15,7 +15,6 @@ import type { CCEncodingContext, GetValueDB, ZWaveApplicationHost, - ZWaveHost, } from "@zwave-js/host"; import { getEnumMemberName, pick } from "@zwave-js/shared/safe"; import { validateArgs } from "@zwave-js/transformers"; @@ -475,7 +474,7 @@ export class WindowCoveringCCAPI extends CCAPI { WindowCoveringCommand.SupportedGet, ); - const cc = new WindowCoveringCCSupportedGet(this.applHost, { + const cc = new WindowCoveringCCSupportedGet({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, }); @@ -496,7 +495,7 @@ export class WindowCoveringCCAPI extends CCAPI { WindowCoveringCommand.Get, ); - const cc = new WindowCoveringCCGet(this.applHost, { + const cc = new WindowCoveringCCGet({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, parameter, @@ -525,7 +524,7 @@ export class WindowCoveringCCAPI extends CCAPI { WindowCoveringCommand.StartLevelChange, ); - const cc = new WindowCoveringCCSet(this.applHost, { + const cc = new WindowCoveringCCSet({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, targetValues, @@ -546,7 +545,7 @@ export class WindowCoveringCCAPI extends CCAPI { WindowCoveringCommand.StartLevelChange, ); - const cc = new WindowCoveringCCStartLevelChange(this.applHost, { + const cc = new WindowCoveringCCStartLevelChange({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, parameter, @@ -566,7 +565,7 @@ export class WindowCoveringCCAPI extends CCAPI { WindowCoveringCommand.StopLevelChange, ); - const cc = new WindowCoveringCCStopLevelChange(this.applHost, { + const cc = new WindowCoveringCCStopLevelChange({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, parameter, @@ -691,12 +690,11 @@ export interface WindowCoveringCCSupportedReportOptions @CCCommand(WindowCoveringCommand.SupportedReport) export class WindowCoveringCCSupportedReport extends WindowCoveringCC { public constructor( - host: ZWaveHost, options: | CommandClassDeserializationOptions | WindowCoveringCCSupportedReportOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { validatePayload(this.payload.length >= 1); @@ -759,10 +757,9 @@ export class WindowCoveringCCSupportedGet extends WindowCoveringCC {} @CCCommand(WindowCoveringCommand.Report) export class WindowCoveringCCReport extends WindowCoveringCC { public constructor( - host: ZWaveHost, options: CommandClassDeserializationOptions, ) { - super(host, options); + super(options); validatePayload(this.payload.length >= 4); this.parameter = this.payload[0]; this.currentValue = this.payload[1]; @@ -821,12 +818,11 @@ function testResponseForWindowCoveringGet( @expectedCCResponse(WindowCoveringCCReport, testResponseForWindowCoveringGet) export class WindowCoveringCCGet extends WindowCoveringCC { public constructor( - host: ZWaveHost, options: | CommandClassDeserializationOptions | WindowCoveringCCGetOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { validatePayload(this.payload.length >= 1); this.parameter = this.payload[0]; @@ -868,12 +864,11 @@ export interface WindowCoveringCCSetOptions extends CCCommandOptions { @useSupervision() export class WindowCoveringCCSet extends WindowCoveringCC { public constructor( - host: ZWaveHost, options: | CommandClassDeserializationOptions | WindowCoveringCCSetOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { validatePayload(this.payload.length >= 1); const numEntries = this.payload[0] & 0b11111; @@ -951,12 +946,11 @@ export interface WindowCoveringCCStartLevelChangeOptions @useSupervision() export class WindowCoveringCCStartLevelChange extends WindowCoveringCC { public constructor( - host: ZWaveHost, options: | CommandClassDeserializationOptions | WindowCoveringCCStartLevelChangeOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { validatePayload(this.payload.length >= 2); this.direction = !!(this.payload[0] & 0b0100_0000) ? "down" : "up"; @@ -1013,12 +1007,11 @@ export interface WindowCoveringCCStopLevelChangeOptions @useSupervision() export class WindowCoveringCCStopLevelChange extends WindowCoveringCC { public constructor( - host: ZWaveHost, options: | CommandClassDeserializationOptions | WindowCoveringCCStopLevelChangeOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { validatePayload(this.payload.length >= 1); this.parameter = this.payload[0]; diff --git a/packages/cc/src/cc/ZWavePlusCC.ts b/packages/cc/src/cc/ZWavePlusCC.ts index 941c746d8460..4c6d7284ed3c 100644 --- a/packages/cc/src/cc/ZWavePlusCC.ts +++ b/packages/cc/src/cc/ZWavePlusCC.ts @@ -9,7 +9,6 @@ import type { CCEncodingContext, GetValueDB, ZWaveApplicationHost, - ZWaveHost, } from "@zwave-js/host/safe"; import { getEnumMemberName, num2hex, pick } from "@zwave-js/shared/safe"; import { validateArgs } from "@zwave-js/transformers"; @@ -85,7 +84,7 @@ export class ZWavePlusCCAPI extends PhysicalCCAPI { public async get() { this.assertSupportsCommand(ZWavePlusCommand, ZWavePlusCommand.Get); - const cc = new ZWavePlusCCGet(this.applHost, { + const cc = new ZWavePlusCCGet({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, }); @@ -108,7 +107,7 @@ export class ZWavePlusCCAPI extends PhysicalCCAPI { public async sendReport(options: ZWavePlusCCReportOptions): Promise { this.assertSupportsCommand(ZWavePlusCommand, ZWavePlusCommand.Report); - const cc = new ZWavePlusCCReport(this.applHost, { + const cc = new ZWavePlusCCReport({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, ...options, @@ -180,12 +179,11 @@ export interface ZWavePlusCCReportOptions { @CCCommand(ZWavePlusCommand.Report) export class ZWavePlusCCReport extends ZWavePlusCC { public constructor( - host: ZWaveHost, options: | CommandClassDeserializationOptions | (CCCommandOptions & ZWavePlusCCReportOptions), ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { validatePayload(this.payload.length >= 7); this.zwavePlusVersion = this.payload[0]; diff --git a/packages/cc/src/cc/ZWaveProtocolCC.ts b/packages/cc/src/cc/ZWaveProtocolCC.ts index fd67ea05be4e..cd45e039a9ae 100644 --- a/packages/cc/src/cc/ZWaveProtocolCC.ts +++ b/packages/cc/src/cc/ZWaveProtocolCC.ts @@ -20,7 +20,7 @@ import { parseNodeProtocolInfoAndDeviceClass, validatePayload, } from "@zwave-js/core"; -import type { CCEncodingContext, ZWaveHost } from "@zwave-js/host"; +import type { CCEncodingContext } from "@zwave-js/host"; import { type CCCommandOptions, CommandClass, @@ -78,12 +78,11 @@ export class ZWaveProtocolCCNodeInformationFrame extends ZWaveProtocolCC implements NodeInformationFrame { public constructor( - host: ZWaveHost, options: | CommandClassDeserializationOptions | ZWaveProtocolCCNodeInformationFrameOptions, ) { - super(host, options); + super(options); let nif: NodeInformationFrame; if (gotDeserializationOptions(options)) { @@ -142,12 +141,11 @@ export interface ZWaveProtocolCCAssignIDsOptions extends CCCommandOptions { @CCCommand(ZWaveProtocolCommand.AssignIDs) export class ZWaveProtocolCCAssignIDs extends ZWaveProtocolCC { public constructor( - host: ZWaveHost, options: | CommandClassDeserializationOptions | ZWaveProtocolCCAssignIDsOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { validatePayload(this.payload.length >= 5); this.assignedNodeId = this.payload[0]; @@ -181,12 +179,11 @@ export interface ZWaveProtocolCCFindNodesInRangeOptions @CCCommand(ZWaveProtocolCommand.FindNodesInRange) export class ZWaveProtocolCCFindNodesInRange extends ZWaveProtocolCC { public constructor( - host: ZWaveHost, options: | CommandClassDeserializationOptions | ZWaveProtocolCCFindNodesInRangeOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { validatePayload(this.payload.length >= 1); const speedPresent = this.payload[0] & 0b1000_0000; @@ -248,12 +245,11 @@ export interface ZWaveProtocolCCRangeInfoOptions extends CCCommandOptions { @CCCommand(ZWaveProtocolCommand.RangeInfo) export class ZWaveProtocolCCRangeInfo extends ZWaveProtocolCC { public constructor( - host: ZWaveHost, options: | CommandClassDeserializationOptions | ZWaveProtocolCCRangeInfoOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { validatePayload(this.payload.length >= 1); const bitmaskLength = this.payload[0] & 0b0001_1111; @@ -303,12 +299,11 @@ export interface ZWaveProtocolCCCommandCompleteOptions @CCCommand(ZWaveProtocolCommand.CommandComplete) export class ZWaveProtocolCCCommandComplete extends ZWaveProtocolCC { public constructor( - host: ZWaveHost, options: | CommandClassDeserializationOptions | ZWaveProtocolCCCommandCompleteOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { validatePayload(this.payload.length >= 1); this.sequenceNumber = this.payload[0]; @@ -337,12 +332,11 @@ export interface ZWaveProtocolCCTransferPresentationOptions @CCCommand(ZWaveProtocolCommand.TransferPresentation) export class ZWaveProtocolCCTransferPresentation extends ZWaveProtocolCC { public constructor( - host: ZWaveHost, options: | CommandClassDeserializationOptions | ZWaveProtocolCCTransferPresentationOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { validatePayload(this.payload.length >= 1); const option = this.payload[0]; @@ -389,12 +383,11 @@ export class ZWaveProtocolCCTransferNodeInformation extends ZWaveProtocolCC implements NodeProtocolInfoAndDeviceClass { public constructor( - host: ZWaveHost, options: | CommandClassDeserializationOptions | ZWaveProtocolCCTransferNodeInformationOptions, ) { - super(host, options); + super(options); let info: NodeProtocolInfoAndDeviceClass; if (gotDeserializationOptions(options)) { @@ -460,12 +453,11 @@ export interface ZWaveProtocolCCTransferRangeInformationOptions @CCCommand(ZWaveProtocolCommand.TransferRangeInformation) export class ZWaveProtocolCCTransferRangeInformation extends ZWaveProtocolCC { public constructor( - host: ZWaveHost, options: | CommandClassDeserializationOptions | ZWaveProtocolCCTransferRangeInformationOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { validatePayload(this.payload.length >= 3); this.sequenceNumber = this.payload[0]; @@ -508,12 +500,11 @@ export interface ZWaveProtocolCCTransferEndOptions extends CCCommandOptions { @CCCommand(ZWaveProtocolCommand.TransferEnd) export class ZWaveProtocolCCTransferEnd extends ZWaveProtocolCC { public constructor( - host: ZWaveHost, options: | CommandClassDeserializationOptions | ZWaveProtocolCCTransferEndOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { validatePayload(this.payload.length >= 1); this.status = this.payload[0]; @@ -544,12 +535,11 @@ export interface ZWaveProtocolCCAssignReturnRouteOptions @CCCommand(ZWaveProtocolCommand.AssignReturnRoute) export class ZWaveProtocolCCAssignReturnRoute extends ZWaveProtocolCC { public constructor( - host: ZWaveHost, options: | CommandClassDeserializationOptions | ZWaveProtocolCCAssignReturnRouteOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { validatePayload(this.payload.length >= 7); this.destinationNodeId = this.payload[0]; @@ -609,12 +599,11 @@ export class ZWaveProtocolCCNewNodeRegistered extends ZWaveProtocolCC implements NodeInformationFrame { public constructor( - host: ZWaveHost, options: | CommandClassDeserializationOptions | ZWaveProtocolCCNewNodeRegisteredOptions, ) { - super(host, options); + super(options); let nif: NodeInformationFrame; if (gotDeserializationOptions(options)) { @@ -676,12 +665,11 @@ export interface ZWaveProtocolCCNewRangeRegisteredOptions @CCCommand(ZWaveProtocolCommand.NewRangeRegistered) export class ZWaveProtocolCCNewRangeRegistered extends ZWaveProtocolCC { public constructor( - host: ZWaveHost, options: | CommandClassDeserializationOptions | ZWaveProtocolCCNewRangeRegisteredOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { validatePayload(this.payload.length >= 2); this.testedNodeId = this.payload[0]; @@ -720,12 +708,11 @@ export class ZWaveProtocolCCTransferNewPrimaryControllerComplete extends ZWaveProtocolCC { public constructor( - host: ZWaveHost, options: | CommandClassDeserializationOptions | ZWaveProtocolCCTransferNewPrimaryControllerCompleteOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { validatePayload(this.payload.length >= 1); this.genericDeviceClass = this.payload[0]; @@ -756,12 +743,11 @@ export interface ZWaveProtocolCCSUCNodeIDOptions extends CCCommandOptions { @CCCommand(ZWaveProtocolCommand.SUCNodeID) export class ZWaveProtocolCCSUCNodeID extends ZWaveProtocolCC { public constructor( - host: ZWaveHost, options: | CommandClassDeserializationOptions | ZWaveProtocolCCSUCNodeIDOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { validatePayload(this.payload.length >= 1); this.sucNodeId = this.payload[0]; @@ -790,12 +776,11 @@ export interface ZWaveProtocolCCSetSUCOptions extends CCCommandOptions { @CCCommand(ZWaveProtocolCommand.SetSUC) export class ZWaveProtocolCCSetSUC extends ZWaveProtocolCC { public constructor( - host: ZWaveHost, options: | CommandClassDeserializationOptions | ZWaveProtocolCCSetSUCOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { validatePayload(this.payload.length >= 2); // Byte 0 must be 0x01 or ignored @@ -823,12 +808,11 @@ export interface ZWaveProtocolCCSetSUCAckOptions extends CCCommandOptions { @CCCommand(ZWaveProtocolCommand.SetSUCAck) export class ZWaveProtocolCCSetSUCAck extends ZWaveProtocolCC { public constructor( - host: ZWaveHost, options: | CommandClassDeserializationOptions | ZWaveProtocolCCSetSUCAckOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { validatePayload(this.payload.length >= 2); this.accepted = this.payload[0] === 0x01; @@ -867,12 +851,11 @@ export interface ZWaveProtocolCCStaticRouteRequestOptions @CCCommand(ZWaveProtocolCommand.StaticRouteRequest) export class ZWaveProtocolCCStaticRouteRequest extends ZWaveProtocolCC { public constructor( - host: ZWaveHost, options: | CommandClassDeserializationOptions | ZWaveProtocolCCStaticRouteRequestOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { validatePayload(this.payload.length >= 5); this.nodeIds = [...this.payload.subarray(0, 5)].filter( @@ -908,12 +891,11 @@ export interface ZWaveProtocolCCLostOptions extends CCCommandOptions { @CCCommand(ZWaveProtocolCommand.Lost) export class ZWaveProtocolCCLost extends ZWaveProtocolCC { public constructor( - host: ZWaveHost, options: | CommandClassDeserializationOptions | ZWaveProtocolCCLostOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { validatePayload(this.payload.length >= 1); this.lostNodeId = this.payload[0]; @@ -938,12 +920,11 @@ export interface ZWaveProtocolCCAcceptLostOptions extends CCCommandOptions { @CCCommand(ZWaveProtocolCommand.AcceptLost) export class ZWaveProtocolCCAcceptLost extends ZWaveProtocolCC { public constructor( - host: ZWaveHost, options: | CommandClassDeserializationOptions | ZWaveProtocolCCAcceptLostOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { validatePayload(this.payload.length >= 1); validatePayload( @@ -971,12 +952,11 @@ export interface ZWaveProtocolCCNOPPowerOptions extends CCCommandOptions { @CCCommand(ZWaveProtocolCommand.NOPPower) export class ZWaveProtocolCCNOPPower extends ZWaveProtocolCC { public constructor( - host: ZWaveHost, options: | CommandClassDeserializationOptions | ZWaveProtocolCCNOPPowerOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { if (this.payload.length >= 2) { // Ignore byte 0 @@ -1031,12 +1011,11 @@ export interface ZWaveProtocolCCReservedIDsOptions extends CCCommandOptions { @CCCommand(ZWaveProtocolCommand.ReservedIDs) export class ZWaveProtocolCCReservedIDs extends ZWaveProtocolCC { public constructor( - host: ZWaveHost, options: | CommandClassDeserializationOptions | ZWaveProtocolCCReservedIDsOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { validatePayload(this.payload.length >= 1); const numNodeIDs = this.payload[0]; @@ -1069,12 +1048,11 @@ export interface ZWaveProtocolCCReserveNodeIDsOptions extends CCCommandOptions { @expectedCCResponse(ZWaveProtocolCCReservedIDs) export class ZWaveProtocolCCReserveNodeIDs extends ZWaveProtocolCC { public constructor( - host: ZWaveHost, options: | CommandClassDeserializationOptions | ZWaveProtocolCCReserveNodeIDsOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { validatePayload(this.payload.length >= 1); this.numNodeIDs = this.payload[0]; @@ -1102,12 +1080,11 @@ export interface ZWaveProtocolCCNodesExistReplyOptions @CCCommand(ZWaveProtocolCommand.NodesExistReply) export class ZWaveProtocolCCNodesExistReply extends ZWaveProtocolCC { public constructor( - host: ZWaveHost, options: | CommandClassDeserializationOptions | ZWaveProtocolCCNodesExistReplyOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { validatePayload(this.payload.length >= 2); this.nodeMaskType = this.payload[0]; @@ -1150,12 +1127,11 @@ export interface ZWaveProtocolCCNodesExistOptions extends CCCommandOptions { ) export class ZWaveProtocolCCNodesExist extends ZWaveProtocolCC { public constructor( - host: ZWaveHost, options: | CommandClassDeserializationOptions | ZWaveProtocolCCNodesExistOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { validatePayload(this.payload.length >= 2); this.nodeMaskType = this.payload[0]; @@ -1190,12 +1166,11 @@ export interface ZWaveProtocolCCSetNWIModeOptions extends CCCommandOptions { @CCCommand(ZWaveProtocolCommand.SetNWIMode) export class ZWaveProtocolCCSetNWIMode extends ZWaveProtocolCC { public constructor( - host: ZWaveHost, options: | CommandClassDeserializationOptions | ZWaveProtocolCCSetNWIModeOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { validatePayload(this.payload.length >= 2); this.enabled = this.payload[0] === 0x01; @@ -1234,12 +1209,11 @@ export interface ZWaveProtocolCCAssignReturnRoutePriorityOptions @CCCommand(ZWaveProtocolCommand.AssignReturnRoutePriority) export class ZWaveProtocolCCAssignReturnRoutePriority extends ZWaveProtocolCC { public constructor( - host: ZWaveHost, options: | CommandClassDeserializationOptions | ZWaveProtocolCCAssignReturnRoutePriorityOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { validatePayload(this.payload.length >= 2); this.targetNodeId = this.payload[0]; @@ -1276,12 +1250,11 @@ export class ZWaveProtocolCCSmartStartIncludedNodeInformation extends ZWaveProtocolCC { public constructor( - host: ZWaveHost, options: | CommandClassDeserializationOptions | ZWaveProtocolCCSmartStartIncludedNodeInformationOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { validatePayload(this.payload.length >= 4); this.nwiHomeId = this.payload.subarray(0, 4); diff --git a/packages/cc/src/cc/manufacturerProprietary/FibaroCC.ts b/packages/cc/src/cc/manufacturerProprietary/FibaroCC.ts index e8cbf2cf788e..bf17cf524e8f 100644 --- a/packages/cc/src/cc/manufacturerProprietary/FibaroCC.ts +++ b/packages/cc/src/cc/manufacturerProprietary/FibaroCC.ts @@ -14,7 +14,6 @@ import type { CCEncodingContext, GetValueDB, ZWaveApplicationHost, - ZWaveHost, } from "@zwave-js/host/safe"; import { pick } from "@zwave-js/shared"; import { validateArgs } from "@zwave-js/transformers"; @@ -113,7 +112,7 @@ export enum FibaroCCIDs { export class FibaroCCAPI extends ManufacturerProprietaryCCAPI { // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types public async fibaroVenetianBlindsGet() { - const cc = new FibaroVenetianBlindCCGet(this.applHost, { + const cc = new FibaroVenetianBlindCCGet({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, }); @@ -130,7 +129,7 @@ export class FibaroCCAPI extends ManufacturerProprietaryCCAPI { @validateArgs() public async fibaroVenetianBlindsSetPosition(value: number): Promise { - const cc = new FibaroVenetianBlindCCSet(this.applHost, { + const cc = new FibaroVenetianBlindCCSet({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, position: value, @@ -140,7 +139,7 @@ export class FibaroCCAPI extends ManufacturerProprietaryCCAPI { @validateArgs() public async fibaroVenetianBlindsSetTilt(value: number): Promise { - const cc = new FibaroVenetianBlindCCSet(this.applHost, { + const cc = new FibaroVenetianBlindCCSet({ nodeId: this.endpoint.nodeId, endpoint: this.endpoint.index, tilt: value, @@ -217,10 +216,9 @@ export class FibaroCCAPI extends ManufacturerProprietaryCCAPI { @manufacturerId(MANUFACTURERID_FIBARO) export class FibaroCC extends ManufacturerProprietaryCC { public constructor( - host: ZWaveHost, options: CommandClassDeserializationOptions | CCCommandOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { validatePayload(this.payload.length >= 2); this.fibaroCCId = this.payload[0]; @@ -234,7 +232,7 @@ export class FibaroCC extends ManufacturerProprietaryCC { FibaroConstructor && (new.target as any) !== FibaroConstructor ) { - return new FibaroConstructor(host, options); + return new FibaroConstructor(options); } this.payload = this.payload.subarray(2); @@ -257,9 +255,7 @@ export class FibaroCC extends ManufacturerProprietaryCC { for (const ccId of supportedFibaroCCIDs) { const SubConstructor = getFibaroCCConstructor(ccId); if (SubConstructor) { - const instance = new SubConstructor(applHost, { - nodeId: node.id, - }); + const instance = new SubConstructor({ nodeId: node.id }); await instance.interview(applHost); } } @@ -275,9 +271,7 @@ export class FibaroCC extends ManufacturerProprietaryCC { for (const ccId of supportedFibaroCCIDs) { const SubConstructor = getFibaroCCConstructor(ccId); if (SubConstructor) { - const instance = new SubConstructor(applHost, { - nodeId: node.id, - }); + const instance = new SubConstructor({ nodeId: node.id }); await instance.refreshValues(applHost); } } @@ -315,10 +309,9 @@ export class FibaroVenetianBlindCC extends FibaroCC { declare fibaroCCCommand: FibaroVenetianBlindCCCommand; public constructor( - host: ZWaveHost, options: CommandClassDeserializationOptions | CCCommandOptions, ) { - super(host, options); + super(options); this.fibaroCCId = FibaroCCIDs.VenetianBlind; if (gotDeserializationOptions(options)) { @@ -326,7 +319,7 @@ export class FibaroVenetianBlindCC extends FibaroCC { this.fibaroCCCommand === FibaroVenetianBlindCCCommand.Report && (new.target as any) !== FibaroVenetianBlindCCReport ) { - return new FibaroVenetianBlindCCReport(host, options); + return new FibaroVenetianBlindCCReport(options); } } } @@ -356,7 +349,7 @@ export class FibaroVenetianBlindCC extends FibaroCC { direction: "outbound", }); const resp = await applHost.sendCommand( - new FibaroVenetianBlindCCGet(applHost, { + new FibaroVenetianBlindCCGet({ nodeId: this.nodeId, endpoint: this.endpointIndex, }), @@ -392,12 +385,11 @@ export type FibaroVenetianBlindCCSetOptions = @fibaroCCCommand(FibaroVenetianBlindCCCommand.Set) export class FibaroVenetianBlindCCSet extends FibaroVenetianBlindCC { public constructor( - host: ZWaveHost, options: | CommandClassDeserializationOptions | FibaroVenetianBlindCCSetOptions, ) { - super(host, options); + super(options); this.fibaroCCCommand = FibaroVenetianBlindCCCommand.Set; if (Buffer.isBuffer(options)) { @@ -444,10 +436,9 @@ export class FibaroVenetianBlindCCSet extends FibaroVenetianBlindCC { @fibaroCCCommand(FibaroVenetianBlindCCCommand.Report) export class FibaroVenetianBlindCCReport extends FibaroVenetianBlindCC { public constructor( - host: ZWaveHost, options: CommandClassDeserializationOptions, ) { - super(host, options); + super(options); this.fibaroCCCommand = FibaroVenetianBlindCCCommand.Report; validatePayload(this.payload.length >= 3); @@ -519,10 +510,9 @@ export class FibaroVenetianBlindCCReport extends FibaroVenetianBlindCC { @expectedCCResponse(FibaroVenetianBlindCCReport) export class FibaroVenetianBlindCCGet extends FibaroVenetianBlindCC { public constructor( - host: ZWaveHost, options: CommandClassDeserializationOptions | CCCommandOptions, ) { - super(host, options); + super(options); this.fibaroCCCommand = FibaroVenetianBlindCCCommand.Get; } } diff --git a/packages/cc/src/lib/CommandClass.ts b/packages/cc/src/lib/CommandClass.ts index 9286cbf648c8..b027147469f3 100644 --- a/packages/cc/src/lib/CommandClass.ts +++ b/packages/cc/src/lib/CommandClass.ts @@ -39,7 +39,6 @@ import type { GetSupportedCCVersion, GetValueDB, ZWaveApplicationHost, - ZWaveHost, } from "@zwave-js/host"; import { MessageOrigin } from "@zwave-js/serial"; import { @@ -160,8 +159,7 @@ export function getEffectiveCCVersion( // @publicAPI export class CommandClass implements CCId { // empty constructor to parse messages - public constructor(host: ZWaveHost, options: CommandClassOptions) { - this.host = host; + public constructor(options: CommandClassOptions) { // Default to the root endpoint - Inherited classes may override this behavior this.endpointIndex = ("endpoint" in options ? options.endpoint : undefined) ?? 0; @@ -187,7 +185,7 @@ export class CommandClass implements CCId { CommandConstructor && (new.target as any) !== CommandConstructor ) { - return new CommandConstructor(host, options); + return new CommandConstructor(options); } } @@ -225,24 +223,8 @@ export class CommandClass implements CCId { this.ccCommand = ccCommand; this.payload = payload; } - - if (this instanceof InvalidCC) return; - - if (options.origin !== MessageOrigin.Host && this.isSinglecast()) { - // Send secure commands if necessary - this.toggleEncapsulationFlag( - EncapsulationFlags.Security, - this.host.isCCSecure( - this.ccId, - this.nodeId, - this.endpointIndex, - ), - ); - } } - protected host: ZWaveHost; - /** This CC's identifier */ public ccId!: CommandClasses; public ccCommand?: number; @@ -401,7 +383,6 @@ export class CommandClass implements CCId { * Creates an instance of the CC that is serialized in the given buffer */ public static from( - host: ZWaveHost, options: CommandClassDeserializationOptions, ): CommandClass { // Fall back to unspecified command class in case we receive one that is not implemented @@ -409,7 +390,7 @@ export class CommandClass implements CCId { const Constructor = getCCConstructor(ccId) ?? CommandClass; try { - return new Constructor(host, options); + return new Constructor(options); } catch (e) { // Indicate invalid payloads with a special CC type if ( @@ -439,7 +420,7 @@ export class CommandClass implements CCId { reason = e.context; } - const ret = new InvalidCC(host, { + const ret = new InvalidCC({ nodeId, ccId, ccName, @@ -463,13 +444,12 @@ export class CommandClass implements CCId { * **INTERNAL:** Applications should not use this directly. */ public static createInstanceUnchecked( - host: ZWaveHost, endpoint: EndpointId, cc: CommandClasses | CCConstructor, ): T | undefined { const Constructor = typeof cc === "number" ? getCCConstructor(cc) : cc; if (Constructor) { - return new Constructor(host, { + return new Constructor({ nodeId: endpoint.nodeId, endpoint: endpoint.index, }) as T; @@ -1213,8 +1193,8 @@ export interface InvalidCCCreationOptions extends CommandClassCreationOptions { } export class InvalidCC extends CommandClass { - public constructor(host: ZWaveHost, options: InvalidCCCreationOptions) { - super(host, options); + public constructor(options: InvalidCCCreationOptions) { + super(options); this._ccName = options.ccName; // Numeric reasons are used internally to communicate problems with a CC // without ignoring them entirely @@ -1266,7 +1246,7 @@ export function assertValidCCs(container: ICommandClassContainer): void { export type CCConstructor = typeof CommandClass & { // I don't like the any, but we need it to support half-implemented CCs (e.g. report classes) - new (host: ZWaveHost, options: any): T; + new (options: any): T; }; /** diff --git a/packages/host/src/ZWaveHost.ts b/packages/host/src/ZWaveHost.ts index 3b4aad64d57f..17b4d78fc076 100644 --- a/packages/host/src/ZWaveHost.ts +++ b/packages/host/src/ZWaveHost.ts @@ -98,39 +98,6 @@ export interface CCEncodingContext ): void; } -/** Host application abstractions to be used in Serial API and CC implementations */ -export interface ZWaveHost { - /** - * Retrieves the maximum version of a command class that can be used to communicate with a node. - * Returns 1 if the node claims that it does not support a CC. - * Returns `undefined` for CCs that are not implemented in this library yet. - */ - getSafeCCVersion( - cc: CommandClasses, - nodeId: number, - endpointIndex?: number, - ): number | undefined; - - /** - * Retrieves the maximum version of a command class the given node/endpoint has reported support for. - * Returns 0 when the CC is not supported or that information is not known yet. - */ - getSupportedCCVersion( - cc: CommandClasses, - nodeId: number, - endpointIndex?: number, - ): number; - - /** - * Determines whether a CC must be secure for a given node and endpoint. - */ - isCCSecure( - cc: CommandClasses, - nodeId: number, - endpointIndex?: number, - ): boolean; -} - /** Host application abstractions that provide support for reading and writing values to a database */ export interface GetValueDB { /** Returns the value DB which belongs to the node with the given ID, or throws if the Value DB cannot be accessed */ @@ -151,12 +118,10 @@ export interface GetAllNodes { getAllNodes(): T[]; } -/** A more featureful version of the ZWaveHost interface, which is meant to be used on the controller application side. */ export interface ZWaveApplicationHost extends GetValueDB, HostIDs, - ZWaveHost, GetNode, GetAllNodes, SecurityManagers, @@ -190,6 +155,36 @@ export interface ZWaveApplicationHost valueId: ValueID, options: NodeSchedulePollOptions, ): boolean; + + /** + * Retrieves the maximum version of a command class that can be used to communicate with a node. + * Returns 1 if the node claims that it does not support a CC. + * Returns `undefined` for CCs that are not implemented in this library yet. + */ + getSafeCCVersion( + cc: CommandClasses, + nodeId: number, + endpointIndex?: number, + ): number | undefined; + + /** + * Retrieves the maximum version of a command class the given node/endpoint has reported support for. + * Returns 0 when the CC is not supported or that information is not known yet. + */ + getSupportedCCVersion( + cc: CommandClasses, + nodeId: number, + endpointIndex?: number, + ): number; + + /** + * Determines whether a CC must be secure for a given node and endpoint. + */ + isCCSecure( + cc: CommandClasses, + nodeId: number, + endpointIndex?: number, + ): boolean; } export interface NodeSchedulePollOptions { diff --git a/packages/host/src/mocks.ts b/packages/host/src/mocks.ts index 33732b065740..babd0e065c2e 100644 --- a/packages/host/src/mocks.ts +++ b/packages/host/src/mocks.ts @@ -13,11 +13,11 @@ import { ZWaveErrorCodes, } from "@zwave-js/core"; import { createThrowingMap } from "@zwave-js/shared"; -import type { HostIDs, ZWaveApplicationHost, ZWaveHost } from "./ZWaveHost"; +import type { HostIDs, ZWaveApplicationHost } from "./ZWaveHost"; export interface CreateTestingHostOptions extends HostIDs { - getSafeCCVersion: ZWaveHost["getSafeCCVersion"]; - getSupportedCCVersion?: ZWaveHost["getSupportedCCVersion"]; + getSafeCCVersion: ZWaveApplicationHost["getSafeCCVersion"]; + getSupportedCCVersion?: ZWaveApplicationHost["getSupportedCCVersion"]; } export type BaseTestNode = diff --git a/packages/serial/src/message/Message.test.ts b/packages/serial/src/message/Message.test.ts index 181e91f86d3a..664245187419 100644 --- a/packages/serial/src/message/Message.test.ts +++ b/packages/serial/src/message/Message.test.ts @@ -40,7 +40,7 @@ test("should deserialize and serialize correctly", (t) => { ]), ]; for (const original of okayMessages) { - const parsed = new Message(host, { data: original }); + const parsed = new Message({ data: original }); t.deepEqual(parsed.serialize(), original); } }); @@ -49,7 +49,7 @@ test("should serialize correctly when the payload is null", (t) => { const host = createTestingHost(); // synthetic message const expected = Buffer.from([0x01, 0x03, 0x00, 0xff, 0x03]); - const message = new Message(host, { + const message = new Message({ type: MessageType.Request, functionType: 0xff as any, }); @@ -92,7 +92,7 @@ test("should throw the correct error when parsing a faulty message", (t) => { ], ]; for (const [message, msg, code] of brokenMessages) { - assertZWaveError(t, () => new Message(host, { data: message }), { + assertZWaveError(t, () => new Message({ data: message }), { messageMatches: msg, errorCode: code, }); @@ -249,7 +249,7 @@ test("isComplete() should work correctly", (t) => { test("toJSON() should return a semi-readable JSON representation", (t) => { const host = createTestingHost(); - const msg1 = new Message(host, { + const msg1 = new Message({ type: MessageType.Request, functionType: FunctionType.GetControllerVersion, }); @@ -259,7 +259,7 @@ test("toJSON() should return a semi-readable JSON representation", (t) => { functionType: "GetControllerVersion", payload: "", }; - const msg2 = new Message(host, { + const msg2 = new Message({ type: MessageType.Request, functionType: FunctionType.GetControllerVersion, payload: Buffer.from("aabbcc", "hex"), @@ -270,7 +270,7 @@ test("toJSON() should return a semi-readable JSON representation", (t) => { functionType: "GetControllerVersion", payload: "aabbcc", }; - const msg3 = new Message(host, { + const msg3 = new Message({ type: MessageType.Response, functionType: FunctionType.GetControllerVersion, expectedResponse: FunctionType.GetControllerVersion, @@ -282,7 +282,7 @@ test("toJSON() should return a semi-readable JSON representation", (t) => { expectedResponse: "GetControllerVersion", payload: "", }; - const msg4 = new Message(host, { + const msg4 = new Message({ type: MessageType.Request, functionType: FunctionType.GetControllerVersion, expectedResponse: FunctionType.GetControllerVersion, @@ -311,7 +311,7 @@ test(`the constructor should throw when no message type is specified`, (t) => { const host = createTestingHost(); assertZWaveError( t, - () => new Message(host, { functionType: 0xff as any }), + () => new Message({ functionType: 0xff as any }), { errorCode: ZWaveErrorCodes.Argument_Invalid, messageMatches: /message type/i, @@ -331,7 +331,7 @@ test(`the constructor should throw when no function type is specified`, (t) => { const host = createTestingHost(); assertZWaveError( t, - () => new Message(host, { type: MessageType.Request }), + () => new Message({ type: MessageType.Request }), { errorCode: ZWaveErrorCodes.Argument_Invalid, messageMatches: /function type/i, @@ -349,7 +349,7 @@ test(`the constructor should throw when no function type is specified`, (t) => { test("getNodeUnsafe() returns undefined when the controller is not initialized yet", (t) => { const host = createTestingHost(); - const msg = new Message(host, { + const msg = new Message({ type: MessageType.Request, functionType: 0xff as any, }); @@ -358,7 +358,7 @@ test("getNodeUnsafe() returns undefined when the controller is not initialized y test("getNodeUnsafe() returns undefined when the message is no node query", (t) => { const host = createTestingHost(); - const msg = new Message(host, { + const msg = new Message({ type: MessageType.Request, functionType: 0xff as any, }); @@ -369,7 +369,7 @@ test("getNodeUnsafe() returns the associated node otherwise", (t) => { const host = createTestingHost(); host.setNode(1, {} as any); - const msg = new Message(host, { + const msg = new Message({ type: MessageType.Request, functionType: 0xff as any, }); diff --git a/packages/serial/src/message/Message.ts b/packages/serial/src/message/Message.ts index 40a0bc326d56..41d3f1304e18 100644 --- a/packages/serial/src/message/Message.ts +++ b/packages/serial/src/message/Message.ts @@ -17,7 +17,6 @@ import type { GetSupportedCCVersion, HostIDs, ZWaveApplicationHost, - ZWaveHost, } from "@zwave-js/host"; import type { JSONObject, TypedClassDecorator } from "@zwave-js/shared/safe"; import { num2hex, staticExtends } from "@zwave-js/shared/safe"; @@ -26,12 +25,10 @@ import { FunctionType, MessageType } from "./Constants"; import { isNodeQuery } from "./INodeQuery"; export type MessageConstructor = new ( - host: ZWaveHost, options?: MessageOptions, ) => T; export type DeserializingMessageConstructor = new ( - host: ZWaveHost, options: MessageDeserializationOptions, ) => T; @@ -122,8 +119,7 @@ export interface MessageEncodingContext */ export class Message { public constructor( - public readonly host: ZWaveHost, - options: MessageOptions = {}, + public readonly options: MessageOptions = {}, ) { // decide which implementation we follow if (gotDeserializationOptions(options)) { @@ -297,7 +293,6 @@ export class Message { /** Creates an instance of the message that is serialized in the given buffer */ public static from( - host: ZWaveHost, options: MessageDeserializationOptions, contextStore?: Map>, ): Message { @@ -312,7 +307,7 @@ export class Message { } } - const ret = new Constructor(host, options); + const ret = new Constructor(options); return ret; } diff --git a/packages/serial/src/message/ZnifferMessages.ts b/packages/serial/src/message/ZnifferMessages.ts index dddd22e70d9d..de4cc9ed5b49 100644 --- a/packages/serial/src/message/ZnifferMessages.ts +++ b/packages/serial/src/message/ZnifferMessages.ts @@ -59,7 +59,6 @@ export type ZnifferMessageOptions = */ export class ZnifferMessage { public constructor( - // public readonly host: ZWaveHost, options: ZnifferMessageOptions, ) { // decide which implementation we follow diff --git a/packages/testing/src/MockController.ts b/packages/testing/src/MockController.ts index 5ead88e4f3e3..030558af5013 100644 --- a/packages/testing/src/MockController.ts +++ b/packages/testing/src/MockController.ts @@ -7,7 +7,6 @@ import { type SecurityManagers, securityClassOrder, } from "@zwave-js/core"; -import type { ZWaveHost } from "@zwave-js/host"; import { Message, type MessageEncodingContext, @@ -64,19 +63,6 @@ export class MockController { this.ownNodeId = options.ownNodeId ?? 1; this.homeId = options.homeId ?? 0x7e571000; - this.host = { - getSafeCCVersion: () => 100, - getSupportedCCVersion: (cc, nodeId, endpointIndex = 0) => { - if (!this.nodes.has(nodeId)) { - return 0; - } - const node = this.nodes.get(nodeId)!; - const endpoint = node.endpoints.get(endpointIndex); - return (endpoint ?? node).implementedCCs.get(cc)?.version ?? 0; - }, - isCCSecure: () => false, - }; - this.capabilities = { ...getDefaultMockControllerCapabilities(), ...options.capabilities, @@ -184,8 +170,6 @@ export class MockController { this._nodes.delete(node.id); } - public readonly host: ZWaveHost; - public readonly capabilities: MockControllerCapabilities; /** Can be used by behaviors to store controller related state */ @@ -228,7 +212,7 @@ export class MockController { let msg: Message; try { - msg = Message.from(this.host, { + msg = Message.from({ data, origin: MessageOrigin.Host, parseCCs: false, @@ -253,7 +237,7 @@ export class MockController { handler.resolve(msg); } else { for (const behavior of this.behaviors) { - if (await behavior.onHostMessage?.(this.host, this, msg)) { + if (await behavior.onHostMessage?.(this, msg)) { return; } } @@ -443,7 +427,7 @@ export class MockController { // Then apply generic predefined behavior for (const behavior of this.behaviors) { if ( - await behavior.onNodeFrame?.(this.host, this, node, frame) + await behavior.onNodeFrame?.(this, node, frame) ) { return; } @@ -549,13 +533,11 @@ export class MockController { export interface MockControllerBehavior { /** Gets called when a message from the host is received. Return `true` to indicate that the message has been handled. */ onHostMessage?: ( - host: ZWaveHost, controller: MockController, msg: Message, ) => Promise | boolean | undefined; /** Gets called when a message from a node is received. Return `true` to indicate that the message has been handled. */ onNodeFrame?: ( - host: ZWaveHost, controller: MockController, node: MockNode, frame: MockZWaveFrame, diff --git a/packages/testing/src/MockNode.ts b/packages/testing/src/MockNode.ts index c1f3dcc92db8..8e9874ec50a5 100644 --- a/packages/testing/src/MockNode.ts +++ b/packages/testing/src/MockNode.ts @@ -8,7 +8,7 @@ import { type SecurityManagers, securityClassOrder, } from "@zwave-js/core"; -import type { CCEncodingContext, ZWaveHost } from "@zwave-js/host"; +import type { CCEncodingContext } from "@zwave-js/host"; import { TimedExpectation } from "@zwave-js/shared"; import { isDeepStrictEqual } from "node:util"; import type { CCIdToCapabilities } from "./CCSpecificCapabilities"; @@ -112,12 +112,6 @@ export class MockNode { this.id = options.id; this.controller = options.controller; - // A node's host is a bit more specialized than the controller's host. - this.host = { - ...this.controller.host, - // // Mimic the behavior of ZWaveNode, but for arbitrary node IDs - }; - const securityClasses = new Map>(); const { @@ -196,7 +190,6 @@ export class MockNode { }; } - public readonly host: ZWaveHost; public readonly id: number; public readonly controller: MockController; public readonly capabilities: MockNodeCapabilities; diff --git a/packages/zwave-js/src/lib/controller/Controller.ts b/packages/zwave-js/src/lib/controller/Controller.ts index 3b12c50f38bd..0730dc4ea047 100644 --- a/packages/zwave-js/src/lib/controller/Controller.ts +++ b/packages/zwave-js/src/lib/controller/Controller.ts @@ -1144,7 +1144,7 @@ export class ZWaveController const apiCaps = await this.driver.sendMessage< GetSerialApiCapabilitiesResponse >( - new GetSerialApiCapabilitiesRequest(this.driver), + new GetSerialApiCapabilitiesRequest(), { supportCheck: false, }, @@ -1175,7 +1175,7 @@ export class ZWaveController const version = await this.driver.sendMessage< GetControllerVersionResponse >( - new GetControllerVersionRequest(this.driver), + new GetControllerVersionRequest(), { supportCheck: false, }, @@ -1196,7 +1196,7 @@ export class ZWaveController const protocol = await this.driver.sendMessage< GetProtocolVersionResponse >( - new GetProtocolVersionRequest(this.driver), + new GetProtocolVersionRequest(), ); this._protocolVersion = protocol.protocolVersion; @@ -1236,7 +1236,7 @@ export class ZWaveController const setupCaps = await this.driver.sendMessage< SerialAPISetup_GetSupportedCommandsResponse >( - new SerialAPISetup_GetSupportedCommandsRequest(this.driver), + new SerialAPISetup_GetSupportedCommandsRequest(), ); this._supportedSerialAPISetupCommands = setupCaps.supportedCommands; this.driver.controllerLog.print( @@ -1689,7 +1689,7 @@ export class ZWaveController public async identify(): Promise { this.driver.controllerLog.print(`querying controller IDs...`); const ids = await this.driver.sendMessage( - new GetControllerIdRequest(this.driver), + new GetControllerIdRequest(), { supportCheck: false }, ); this._homeId = ids.homeId; @@ -1716,7 +1716,7 @@ export class ZWaveController const resp = await this.driver.sendMessage< SerialAPISetup_SetTXStatusReportResponse >( - new SerialAPISetup_SetTXStatusReportRequest(this.driver, { + new SerialAPISetup_SetTXStatusReportRequest({ enabled: true, }), ); @@ -1730,7 +1730,7 @@ export class ZWaveController // find the SUC this.driver.controllerLog.print(`finding SUC...`); const suc = await this.driver.sendMessage( - new GetSUCNodeIdRequest(this.driver), + new GetSUCNodeIdRequest(), { supportCheck: false }, ); this._sucNodeId = suc.sucNodeId; @@ -1792,7 +1792,7 @@ export class ZWaveController const resp = await this.driver.sendMessage< SetSerialApiTimeoutsResponse >( - new SetSerialApiTimeoutsRequest(this.driver, { + new SetSerialApiTimeoutsRequest({ ackTimeout: ack, byteTimeout: byte, }), @@ -1926,7 +1926,7 @@ export class ZWaveController const nodesResponse = await this.driver.sendMessage< GetLongRangeNodesResponse >( - new GetLongRangeNodesRequest(this.driver, { + new GetLongRangeNodesRequest({ segmentNumber: segment, }), ); @@ -1946,7 +1946,7 @@ export class ZWaveController public async setControllerNIF(): Promise { this.driver.controllerLog.print("Updating the controller NIF..."); await this.driver.sendMessage( - new SetApplicationNodeInformationRequest(this.driver, { + new SetApplicationNodeInformationRequest({ isListening: true, ...determineNIF(), }), @@ -1978,7 +1978,7 @@ export class ZWaveController } this.driver.controllerLog.print("performing hard reset..."); - await this.driver.sendMessage(new HardResetRequest(this.driver), { + await this.driver.sendMessage(new HardResetRequest(), { supportCheck: false, }); @@ -2003,7 +2003,7 @@ export class ZWaveController try { this.driver.controllerLog.print("Shutting down the Z-Wave API..."); const response = await this.driver.sendMessage( - new ShutdownRequest(this.driver), + new ShutdownRequest(), ); if (response.success) { this.driver.controllerLog.print("Z-Wave API was shut down"); @@ -2036,7 +2036,7 @@ export class ZWaveController "Starting hardware watchdog...", ); await this.driver.sendMessage( - new StartWatchdogRequest(this.driver), + new StartWatchdogRequest(), ); return true; @@ -2063,7 +2063,7 @@ export class ZWaveController "Stopping hardware watchdog...", ); await this.driver.sendMessage( - new StopWatchdogRequest(this.driver), + new StopWatchdogRequest(), ); return true; @@ -2159,7 +2159,7 @@ export class ZWaveController // kick off the inclusion process await this.driver.sendMessage( - new AddNodeToNetworkRequest(this.driver, { + new AddNodeToNetworkRequest({ addNodeType: AddNodeType.Any, highPower: true, networkWide: true, @@ -2230,7 +2230,7 @@ export class ZWaveController ); await this.driver.sendMessage( - new AddNodeDSKToNetworkRequest(this.driver, { + new AddNodeDSKToNetworkRequest({ nwiHomeId: nwiHomeIdFromDSK(dskBuffer), authHomeId: authHomeIdFromDSK(dskBuffer), protocol, @@ -2255,7 +2255,7 @@ export class ZWaveController */ public async stopInclusionNoCallback(): Promise { await this.driver.sendMessage( - new AddNodeToNetworkRequest(this.driver, { + new AddNodeToNetworkRequest({ callbackId: 0, // disable callbacks addNodeType: AddNodeType.Stop, highPower: true, @@ -2276,7 +2276,7 @@ export class ZWaveController const response = await this.driver.sendMessage< AddNodeToNetworkRequestStatusReport >( - new AddNodeToNetworkRequest(this.driver, { + new AddNodeToNetworkRequest({ addNodeType: AddNodeType.Stop, highPower: true, networkWide: true, @@ -2310,7 +2310,7 @@ export class ZWaveController try { // stop the inclusion process await this.driver.sendMessage( - new AddNodeToNetworkRequest(this.driver, { + new AddNodeToNetworkRequest({ addNodeType: AddNodeType.Stop, highPower: true, networkWide: true, @@ -2364,7 +2364,7 @@ export class ZWaveController ); try { await this.driver.sendMessage( - new EnableSmartStartListenRequest(this.driver, {}), + new EnableSmartStartListenRequest({}), ); this.driver.controllerLog.print( `Smart Start listening mode enabled`, @@ -2408,7 +2408,7 @@ export class ZWaveController ); try { await this.driver.sendMessage( - new AddNodeToNetworkRequest(this.driver, { + new AddNodeToNetworkRequest({ callbackId: 0, // disable callbacks addNodeType: AddNodeType.Stop, highPower: true, @@ -2450,7 +2450,7 @@ export class ZWaveController ); try { await this.driver.sendMessage( - new AddNodeToNetworkRequest(this.driver, { + new AddNodeToNetworkRequest({ callbackId: 0, // disable callbacks addNodeType: AddNodeType.Stop, highPower: true, @@ -2505,7 +2505,7 @@ export class ZWaveController try { // kick off the inclusion process await this.driver.sendMessage( - new RemoveNodeFromNetworkRequest(this.driver, { + new RemoveNodeFromNetworkRequest({ removeNodeType: RemoveNodeType.Any, highPower: true, networkWide: true, @@ -2542,7 +2542,7 @@ export class ZWaveController */ public async stopExclusionNoCallback(): Promise { await this.driver.sendMessage( - new RemoveNodeFromNetworkRequest(this.driver, { + new RemoveNodeFromNetworkRequest({ callbackId: 0, // disable callbacks removeNodeType: RemoveNodeType.Stop, highPower: true, @@ -2567,7 +2567,7 @@ export class ZWaveController try { // kick off the inclusion process await this.driver.sendMessage( - new RemoveNodeFromNetworkRequest(this.driver, { + new RemoveNodeFromNetworkRequest({ removeNodeType: RemoveNodeType.Stop, highPower: true, networkWide: true, @@ -5111,7 +5111,7 @@ export class ZWaveController const result = await this.driver.sendMessage< Message & SuccessIndicator >( - new SetSUCNodeIdRequest(this.driver, { + new SetSUCNodeIdRequest({ ownNodeId: this.ownNodeId!, sucNodeId: nodeId, enableSUC, @@ -5175,7 +5175,7 @@ export class ZWaveController ?.disableCallbackFunctionTypeCheck ?.includes(FunctionType.AssignSUCReturnRoute); const result = await this.driver.sendMessage( - new AssignSUCReturnRouteRequest(this.driver, { + new AssignSUCReturnRouteRequest({ nodeId, disableCallbackFunctionTypeCheck, }), @@ -5289,7 +5289,7 @@ export class ZWaveController // We are always listening const targetWakeup = false; - const cc = new ZWaveProtocolCCAssignSUCReturnRoute(this.driver, { + const cc = new ZWaveProtocolCCAssignSUCReturnRoute({ nodeId, // Empty routes are marked with a nodeId of 0 destinationNodeId: isEmpty ? 0 : this.ownNodeId ?? 1, @@ -5317,14 +5317,11 @@ export class ZWaveController // If a priority route was passed, tell the node to use it if (priorityRouteIndex >= 0) { - const cc = new ZWaveProtocolCCAssignSUCReturnRoutePriority( - this.driver, - { - nodeId, - targetNodeId: this.ownNodeId ?? 1, - routeNumber: priorityRouteIndex, - }, - ); + const cc = new ZWaveProtocolCCAssignSUCReturnRoutePriority({ + nodeId, + targetNodeId: this.ownNodeId ?? 1, + routeNumber: priorityRouteIndex, + }); try { await this.driver.sendZWaveProtocolCC(cc); } catch { @@ -5383,7 +5380,7 @@ export class ZWaveController ?.disableCallbackFunctionTypeCheck ?.includes(FunctionType.DeleteSUCReturnRoute); const result = await this.driver.sendMessage( - new DeleteSUCReturnRouteRequest(this.driver, { + new DeleteSUCReturnRouteRequest({ nodeId, disableCallbackFunctionTypeCheck, }), @@ -5496,7 +5493,7 @@ export class ZWaveController const result = await this.driver.sendMessage< AssignReturnRouteRequestTransmitReport >( - new AssignReturnRouteRequest(this.driver, { + new AssignReturnRouteRequest({ nodeId, destinationNodeId, }), @@ -5602,7 +5599,7 @@ export class ZWaveController ? this.nodes.get(destinationNodeId)?.isFrequentListening : undefined; - const cc = new ZWaveProtocolCCAssignReturnRoute(this.driver, { + const cc = new ZWaveProtocolCCAssignReturnRoute({ nodeId, // Empty routes are marked with a nodeId of 0 destinationNodeId: isEmpty ? 0 : destinationNodeId, @@ -5630,14 +5627,11 @@ export class ZWaveController // If a priority route was passed, tell the node to use it if (priorityRouteIndex >= 0) { - const cc = new ZWaveProtocolCCAssignReturnRoutePriority( - this.driver, - { - nodeId, - targetNodeId: destinationNodeId, - routeNumber: priorityRouteIndex, - }, - ); + const cc = new ZWaveProtocolCCAssignReturnRoutePriority({ + nodeId, + targetNodeId: destinationNodeId, + routeNumber: priorityRouteIndex, + }); try { await this.driver.sendZWaveProtocolCC(cc); } catch { @@ -5709,7 +5703,7 @@ export class ZWaveController const result = await this.driver.sendMessage< DeleteReturnRouteRequestTransmitReport >( - new DeleteReturnRouteRequest(this.driver, { + new DeleteReturnRouteRequest({ nodeId, }), ); @@ -5765,7 +5759,7 @@ export class ZWaveController const result = await this.driver.sendMessage< AssignReturnRouteRequestTransmitReport >( - new AssignPriorityReturnRouteRequest(this.driver, { + new AssignPriorityReturnRouteRequest({ nodeId, destinationNodeId, repeaters, @@ -5882,7 +5876,7 @@ export class ZWaveController const result = await this.driver.sendMessage< AssignPrioritySUCReturnRouteRequestTransmitReport >( - new AssignPrioritySUCReturnRouteRequest(this.driver, { + new AssignPrioritySUCReturnRouteRequest({ nodeId, repeaters, routeSpeed, @@ -5987,7 +5981,7 @@ export class ZWaveController const result = await this.driver.sendMessage< Message & SuccessIndicator >( - new SetPriorityRouteRequest(this.driver, { + new SetPriorityRouteRequest({ destinationNodeId, repeaters, routeSpeed, @@ -6024,7 +6018,7 @@ export class ZWaveController const result = await this.driver.sendMessage< Message & SuccessIndicator >( - new SetPriorityRouteRequest(this.driver, { + new SetPriorityRouteRequest({ destinationNodeId, // no repeaters = remove }), @@ -6066,7 +6060,7 @@ export class ZWaveController const result = await this.driver.sendMessage< GetPriorityRouteResponse >( - new GetPriorityRouteRequest(this.driver, { + new GetPriorityRouteRequest({ destinationNodeId, }), ); @@ -6318,7 +6312,7 @@ export class ZWaveController */ public async isFailedNode(nodeId: number): Promise { const result = await this.driver.sendMessage( - new IsFailedNodeRequest(this.driver, { failedNodeId: nodeId }), + new IsFailedNodeRequest({ failedNodeId: nodeId }), ); return result.result; } @@ -6363,7 +6357,7 @@ export class ZWaveController const result = await this.driver.sendMessage< RemoveFailedNodeRequestStatusReport | RemoveFailedNodeResponse - >(new RemoveFailedNodeRequest(this.driver, { failedNodeId: nodeId })); + >(new RemoveFailedNodeRequest({ failedNodeId: nodeId })); if (result instanceof RemoveFailedNodeResponse) { // This implicates that the process was unsuccessful. @@ -6472,7 +6466,7 @@ export class ZWaveController this._inclusionOptions = options; const result = await this.driver.sendMessage( - new ReplaceFailedNodeRequest(this.driver, { + new ReplaceFailedNodeRequest({ failedNodeId: nodeId, }), ); @@ -6545,7 +6539,7 @@ export class ZWaveController const result = await this.driver.sendMessage< | SerialAPISetup_SetRFRegionResponse | SerialAPISetup_CommandUnsupportedResponse - >(new SerialAPISetup_SetRFRegionRequest(this.driver, { region })); + >(new SerialAPISetup_SetRFRegionRequest({ region })); if (result instanceof SerialAPISetup_CommandUnsupportedResponse) { throw new ZWaveError( `Your hardware does not support setting the RF region!`, @@ -6563,7 +6557,7 @@ export class ZWaveController const result = await this.driver.sendMessage< | SerialAPISetup_GetRFRegionResponse | SerialAPISetup_CommandUnsupportedResponse - >(new SerialAPISetup_GetRFRegionRequest(this.driver)); + >(new SerialAPISetup_GetRFRegionRequest()); if (result instanceof SerialAPISetup_CommandUnsupportedResponse) { throw new ZWaveError( `Your hardware does not support getting the RF region!`, @@ -6583,7 +6577,7 @@ export class ZWaveController const result = await this.driver.sendMessage< | SerialAPISetup_GetSupportedRegionsResponse | SerialAPISetup_CommandUnsupportedResponse - >(new SerialAPISetup_GetSupportedRegionsRequest(this.driver)); + >(new SerialAPISetup_GetSupportedRegionsRequest()); if (result instanceof SerialAPISetup_CommandUnsupportedResponse) { throw new ZWaveError( `Your hardware does not support getting the supported RF regions!`, @@ -6609,7 +6603,7 @@ export class ZWaveController const result = await this.driver.sendMessage< | SerialAPISetup_GetRegionInfoResponse | SerialAPISetup_CommandUnsupportedResponse - >(new SerialAPISetup_GetRegionInfoRequest(this.driver, { region })); + >(new SerialAPISetup_GetRegionInfoRequest({ region })); if (result instanceof SerialAPISetup_CommandUnsupportedResponse) { throw new ZWaveError( `Your hardware does not support getting the RF region info!`, @@ -6699,15 +6693,12 @@ export class ZWaveController SerialAPISetupCommand.SetPowerlevel16Bit, ) ) { - request = new SerialAPISetup_SetPowerlevel16BitRequest( - this.driver, - { - powerlevel, - measured0dBm, - }, - ); + request = new SerialAPISetup_SetPowerlevel16BitRequest({ + powerlevel, + measured0dBm, + }); } else { - request = new SerialAPISetup_SetPowerlevelRequest(this.driver, { + request = new SerialAPISetup_SetPowerlevelRequest({ powerlevel, measured0dBm, }); @@ -6741,9 +6732,9 @@ export class ZWaveController SerialAPISetupCommand.GetPowerlevel16Bit, ) ) { - request = new SerialAPISetup_GetPowerlevel16BitRequest(this.driver); + request = new SerialAPISetup_GetPowerlevel16BitRequest(); } else { - request = new SerialAPISetup_GetPowerlevelRequest(this.driver); + request = new SerialAPISetup_GetPowerlevelRequest(); } const result = await this.driver.sendMessage< | SerialAPISetup_GetPowerlevelResponse @@ -6764,10 +6755,9 @@ export class ZWaveController public async setMaxLongRangePowerlevel( limit: number, ): Promise { - const request = new SerialAPISetup_SetLongRangeMaximumTxPowerRequest( - this.driver, - { limit }, - ); + const request = new SerialAPISetup_SetLongRangeMaximumTxPowerRequest({ + limit, + }); const result = await this.driver.sendMessage< | SerialAPISetup_SetLongRangeMaximumTxPowerResponse @@ -6789,9 +6779,7 @@ export class ZWaveController /** Request the maximum TX powerlevel setting for Z-Wave Long Range */ public async getMaxLongRangePowerlevel(): Promise { - const request = new SerialAPISetup_GetLongRangeMaximumTxPowerRequest( - this.driver, - ); + const request = new SerialAPISetup_GetLongRangeMaximumTxPowerRequest(); const result = await this.driver.sendMessage< | SerialAPISetup_GetLongRangeMaximumTxPowerResponse | SerialAPISetup_CommandUnsupportedResponse @@ -6830,10 +6818,7 @@ export class ZWaveController const result = await this.driver.sendMessage< SetLongRangeChannelResponse >( - new SetLongRangeChannelRequest( - this.driver, - { channel }, - ), + new SetLongRangeChannelRequest({ channel }), ); if (result.success) { @@ -6849,7 +6834,7 @@ export class ZWaveController const result = await this.driver.sendMessage< GetLongRangeChannelResponse >( - new GetLongRangeChannelRequest(this.driver), + new GetLongRangeChannelRequest(), ); const channel = result.autoChannelSelectionActive @@ -6882,7 +6867,7 @@ export class ZWaveController | SerialAPISetup_SetNodeIDTypeResponse | SerialAPISetup_CommandUnsupportedResponse >( - new SerialAPISetup_SetNodeIDTypeRequest(this.driver, { + new SerialAPISetup_SetNodeIDTypeRequest({ nodeIdType, }), ); @@ -6928,7 +6913,7 @@ export class ZWaveController const result = await this.driver.sendMessage< | SerialAPISetup_GetMaximumPayloadSizeResponse | SerialAPISetup_CommandUnsupportedResponse - >(new SerialAPISetup_GetMaximumPayloadSizeRequest(this.driver), { + >(new SerialAPISetup_GetMaximumPayloadSizeRequest(), { supportCheck: false, }); if (result instanceof SerialAPISetup_CommandUnsupportedResponse) { @@ -6949,9 +6934,7 @@ export class ZWaveController | SerialAPISetup_GetLongRangeMaximumPayloadSizeResponse | SerialAPISetup_CommandUnsupportedResponse >( - new SerialAPISetup_GetLongRangeMaximumPayloadSizeRequest( - this.driver, - ), + new SerialAPISetup_GetLongRangeMaximumPayloadSizeRequest(), ); if (result instanceof SerialAPISetup_CommandUnsupportedResponse) { throw new ZWaveError( @@ -6994,7 +6977,7 @@ export class ZWaveController const resp = await this.driver.sendMessage< RequestNodeNeighborUpdateReport >( - new RequestNodeNeighborUpdateRequest(this.driver, { + new RequestNodeNeighborUpdateRequest({ nodeId, discoveryTimeout, }), @@ -7033,7 +7016,7 @@ export class ZWaveController }); try { const resp = await this.driver.sendMessage( - new GetRoutingInfoRequest(this.driver, { + new GetRoutingInfoRequest({ nodeId, removeBadLinks: false, removeNonRepeaters: onlyRepeaters, @@ -7082,7 +7065,7 @@ export class ZWaveController const initData = await this.driver.sendMessage< GetSerialApiInitDataResponse >( - new GetSerialApiInitDataRequest(this.driver), + new GetSerialApiInitDataRequest(), ); this.driver.controllerLog.print( @@ -7138,7 +7121,7 @@ export class ZWaveController const result = await this.driver.sendMessage< GetControllerCapabilitiesResponse >( - new GetControllerCapabilitiesRequest(this.driver), + new GetControllerCapabilitiesRequest(), { supportCheck: false }, ); @@ -7200,7 +7183,7 @@ export class ZWaveController `Turning RF ${enabled ? "on" : "off"}...`, ); const ret = await this.driver.sendMessage( - new SetRFReceiveModeRequest(this.driver, { enabled }), + new SetRFReceiveModeRequest({ enabled }), ); return ret.isOK(); } catch (e) { @@ -7243,7 +7226,7 @@ export class ZWaveController const ret = await this.driver.sendMessage< FirmwareUpdateNVM_InitResponse >( - new FirmwareUpdateNVM_InitRequest(this.driver), + new FirmwareUpdateNVM_InitRequest(), ); return ret.supported; } @@ -7257,7 +7240,7 @@ export class ZWaveController value: boolean = true, ): Promise { await this.driver.sendMessage( - new FirmwareUpdateNVM_SetNewImageRequest(this.driver, { + new FirmwareUpdateNVM_SetNewImageRequest({ newImage: value, }), ); @@ -7272,7 +7255,7 @@ export class ZWaveController const ret = await this.driver.sendMessage< FirmwareUpdateNVM_GetNewImageResponse >( - new FirmwareUpdateNVM_GetNewImageRequest(this.driver), + new FirmwareUpdateNVM_GetNewImageRequest(), ); return ret.newImage; } @@ -7290,7 +7273,7 @@ export class ZWaveController const ret = await this.driver.sendMessage< FirmwareUpdateNVM_UpdateCRC16Response >( - new FirmwareUpdateNVM_UpdateCRC16Request(this.driver, { + new FirmwareUpdateNVM_UpdateCRC16Request({ offset, blockLength, crcSeed, @@ -7309,7 +7292,7 @@ export class ZWaveController buffer: Buffer, ): Promise { await this.driver.sendMessage( - new FirmwareUpdateNVM_WriteRequest(this.driver, { + new FirmwareUpdateNVM_WriteRequest({ offset, buffer, }), @@ -7325,7 +7308,7 @@ export class ZWaveController const ret = await this.driver.sendMessage< FirmwareUpdateNVM_IsValidCRC16Response >( - new FirmwareUpdateNVM_IsValidCRC16Request(this.driver), + new FirmwareUpdateNVM_IsValidCRC16Request(), ); return ret.isValid; } @@ -7337,7 +7320,7 @@ export class ZWaveController */ public async getNVMId(): Promise { const ret = await this.driver.sendMessage( - new GetNVMIdRequest(this.driver), + new GetNVMIdRequest(), ); return pick(ret, ["nvmManufacturerId", "memoryType", "memorySize"]); } @@ -7349,7 +7332,7 @@ export class ZWaveController */ public async externalNVMReadByte(offset: number): Promise { const ret = await this.driver.sendMessage( - new ExtNVMReadLongByteRequest(this.driver, { offset }), + new ExtNVMReadLongByteRequest({ offset }), ); return ret.byte; } @@ -7368,7 +7351,7 @@ export class ZWaveController data: number, ): Promise { const ret = await this.driver.sendMessage( - new ExtNVMWriteLongByteRequest(this.driver, { offset, byte: data }), + new ExtNVMWriteLongByteRequest({ offset, byte: data }), ); return ret.success; } @@ -7383,7 +7366,7 @@ export class ZWaveController length: number, ): Promise { const ret = await this.driver.sendMessage( - new ExtNVMReadLongBufferRequest(this.driver, { + new ExtNVMReadLongBufferRequest({ offset, length, }), @@ -7403,7 +7386,7 @@ export class ZWaveController length: number, ): Promise<{ buffer: Buffer; endOfFile: boolean }> { const ret = await this.driver.sendMessage( - new NVMOperationsReadRequest(this.driver, { + new NVMOperationsReadRequest({ offset, length, }), @@ -7443,7 +7426,7 @@ export class ZWaveController const ret = await this.driver.sendMessage< ExtendedNVMOperationsResponse >( - new ExtendedNVMOperationsReadRequest(this.driver, { + new ExtendedNVMOperationsReadRequest({ offset, length, }), @@ -7489,7 +7472,7 @@ export class ZWaveController const ret = await this.driver.sendMessage< ExtNVMWriteLongBufferResponse >( - new ExtNVMWriteLongBufferRequest(this.driver, { + new ExtNVMWriteLongBufferRequest({ offset, buffer, }), @@ -7512,7 +7495,7 @@ export class ZWaveController buffer: Buffer, ): Promise<{ endOfFile: boolean }> { const ret = await this.driver.sendMessage( - new NVMOperationsWriteRequest(this.driver, { + new NVMOperationsWriteRequest({ offset, buffer, }), @@ -7555,7 +7538,7 @@ export class ZWaveController const ret = await this.driver.sendMessage< ExtendedNVMOperationsResponse >( - new ExtendedNVMOperationsWriteRequest(this.driver, { + new ExtendedNVMOperationsWriteRequest({ offset, buffer, }), @@ -7599,7 +7582,7 @@ export class ZWaveController */ public async externalNVMOpen(): Promise { const ret = await this.driver.sendMessage( - new NVMOperationsOpenRequest(this.driver), + new NVMOperationsOpenRequest(), ); if (!ret.isOK()) { throw new ZWaveError( @@ -7624,7 +7607,7 @@ export class ZWaveController const ret = await this.driver.sendMessage< ExtendedNVMOperationsResponse >( - new ExtendedNVMOperationsOpenRequest(this.driver), + new ExtendedNVMOperationsOpenRequest(), ); if (!ret.isOK()) { throw new ZWaveError( @@ -7652,7 +7635,7 @@ export class ZWaveController */ public async externalNVMClose(): Promise { const ret = await this.driver.sendMessage( - new NVMOperationsCloseRequest(this.driver), + new NVMOperationsCloseRequest(), ); if (!ret.isOK()) { throw new ZWaveError( @@ -7673,7 +7656,7 @@ export class ZWaveController const ret = await this.driver.sendMessage< ExtendedNVMOperationsResponse >( - new ExtendedNVMOperationsCloseRequest(this.driver), + new ExtendedNVMOperationsCloseRequest(), ); if (!ret.isOK()) { throw new ZWaveError( @@ -8107,7 +8090,7 @@ export class ZWaveController rssiChannel3?: RSSI; }> { const ret = await this.driver.sendMessage( - new GetBackgroundRSSIRequest(this.driver), + new GetBackgroundRSSIRequest(), ); const rssi = pick(ret, [ "rssiChannel0", @@ -8827,7 +8810,7 @@ export class ZWaveController const result = await this.driver.sendMessage< Message & SuccessIndicator >( - new SetLearnModeRequest(this.driver, { + new SetLearnModeRequest({ intent: LearnModeIntent.Inclusion, }), ); @@ -8861,7 +8844,7 @@ export class ZWaveController const result = await this.driver.sendMessage< Message & SuccessIndicator >( - new SetLearnModeRequest(this.driver, { + new SetLearnModeRequest({ // TODO: We should be using .Stop here for the non-legacy // inclusion/exclusion, but that command results in a // negative response on current firmwares, even though it works. @@ -8897,7 +8880,7 @@ export class ZWaveController const result = await this.driver.sendMessage< Message & SuccessIndicator >( - new SetLearnModeRequest(this.driver, { + new SetLearnModeRequest({ intent: LearnModeIntent.NetworkWideExclusion, }), ); @@ -8933,7 +8916,7 @@ export class ZWaveController const result = await this.driver.sendMessage< Message & SuccessIndicator >( - new SetLearnModeRequest(this.driver, { + new SetLearnModeRequest({ // TODO: We should be using .Stop here for the non-legacy // inclusion/exclusion, but that command results in a // negative response on current firmwares, even though it works. diff --git a/packages/zwave-js/src/lib/controller/MockControllerBehaviors.ts b/packages/zwave-js/src/lib/controller/MockControllerBehaviors.ts index 5fea5577cd17..81c42e810498 100644 --- a/packages/zwave-js/src/lib/controller/MockControllerBehaviors.ts +++ b/packages/zwave-js/src/lib/controller/MockControllerBehaviors.ts @@ -13,7 +13,6 @@ import { ZWaveErrorCodes, isZWaveError, } from "@zwave-js/core"; -import { type ZWaveHost } from "@zwave-js/host"; import { MessageOrigin } from "@zwave-js/serial"; import { MOCK_FRAME_ACK_TIMEOUT, @@ -86,14 +85,13 @@ import { import { determineNIF } from "./NodeInformationFrame"; function createLazySendDataPayload( - host: ZWaveHost, controller: MockController, node: MockNode, msg: SendDataRequest | SendDataMulticastRequest, ): () => CommandClass { return () => { try { - const cmd = CommandClass.from(node.host, { + const cmd = CommandClass.from({ nodeId: controller.ownNodeId, data: msg.payload, origin: MessageOrigin.Host, @@ -113,7 +111,7 @@ function createLazySendDataPayload( if (e.code === ZWaveErrorCodes.CC_NotImplemented) { // The whole CC is not implemented yet. If this happens in tests, it is because we sent a raw CC. try { - const cmd = new CommandClass(host, { + const cmd = new CommandClass({ nodeId: controller.ownNodeId, ccId: msg.payload[0], ccCommand: msg.payload[1], @@ -143,9 +141,9 @@ function createLazySendDataPayload( } const respondToGetControllerId: MockControllerBehavior = { - async onHostMessage(host, controller, msg) { + async onHostMessage(controller, msg) { if (msg instanceof GetControllerIdRequest) { - const ret = new GetControllerIdResponse(host, { + const ret = new GetControllerIdResponse({ homeId: controller.homeId, ownNodeId: controller.ownNodeId, }); @@ -156,9 +154,9 @@ const respondToGetControllerId: MockControllerBehavior = { }; const respondToGetSerialApiCapabilities: MockControllerBehavior = { - async onHostMessage(host, controller, msg) { + async onHostMessage(controller, msg) { if (msg instanceof GetSerialApiCapabilitiesRequest) { - const ret = new GetSerialApiCapabilitiesResponse(host, { + const ret = new GetSerialApiCapabilitiesResponse({ ...controller.capabilities, }); await controller.sendMessageToHost(ret); @@ -168,9 +166,9 @@ const respondToGetSerialApiCapabilities: MockControllerBehavior = { }; const respondToGetControllerVersion: MockControllerBehavior = { - async onHostMessage(host, controller, msg) { + async onHostMessage(controller, msg) { if (msg instanceof GetControllerVersionRequest) { - const ret = new GetControllerVersionResponse(host, { + const ret = new GetControllerVersionResponse({ ...controller.capabilities, }); await controller.sendMessageToHost(ret); @@ -180,9 +178,9 @@ const respondToGetControllerVersion: MockControllerBehavior = { }; const respondToGetControllerCapabilities: MockControllerBehavior = { - async onHostMessage(host, controller, msg) { + async onHostMessage(controller, msg) { if (msg instanceof GetControllerCapabilitiesRequest) { - const ret = new GetControllerCapabilitiesResponse(host, { + const ret = new GetControllerCapabilitiesResponse({ ...controller.capabilities, }); await controller.sendMessageToHost(ret); @@ -192,12 +190,12 @@ const respondToGetControllerCapabilities: MockControllerBehavior = { }; const respondToGetSUCNodeId: MockControllerBehavior = { - async onHostMessage(host, controller, msg) { + async onHostMessage(controller, msg) { if (msg instanceof GetSUCNodeIdRequest) { const sucNodeId = controller.capabilities.isStaticUpdateController ? controller.ownNodeId : controller.capabilities.sucNodeId; - const ret = new GetSUCNodeIdResponse(host, { + const ret = new GetSUCNodeIdResponse({ sucNodeId, }); await controller.sendMessageToHost(ret); @@ -207,12 +205,12 @@ const respondToGetSUCNodeId: MockControllerBehavior = { }; const respondToGetSerialApiInitData: MockControllerBehavior = { - async onHostMessage(host, controller, msg) { + async onHostMessage(controller, msg) { if (msg instanceof GetSerialApiInitDataRequest) { const nodeIds = new Set(controller.nodes.keys()); nodeIds.add(controller.ownNodeId); - const ret = new GetSerialApiInitDataResponse(host, { + const ret = new GetSerialApiInitDataResponse({ zwaveApiVersion: controller.capabilities.zwaveApiVersion, isPrimary: !controller.capabilities.isSecondary, nodeType: NodeType.Controller, @@ -229,9 +227,9 @@ const respondToGetSerialApiInitData: MockControllerBehavior = { }; const respondToSoftReset: MockControllerBehavior = { - onHostMessage(host, controller, msg) { + onHostMessage(controller, msg) { if (msg instanceof SoftResetRequest) { - const ret = new SerialAPIStartedRequest(host, { + const ret = new SerialAPIStartedRequest({ wakeUpReason: SerialAPIWakeUpReason.SoftwareReset, watchdogEnabled: controller.capabilities.watchdogEnabled, isListening: true, @@ -247,10 +245,10 @@ const respondToSoftReset: MockControllerBehavior = { }; const respondToGetNodeProtocolInfo: MockControllerBehavior = { - async onHostMessage(host, controller, msg) { + async onHostMessage(controller, msg) { if (msg instanceof GetNodeProtocolInfoRequest) { if (msg.requestedNodeId === controller.ownNodeId) { - const ret = new GetNodeProtocolInfoResponse(host, { + const ret = new GetNodeProtocolInfoResponse({ ...determineNIF(), nodeType: NodeType.Controller, isListening: true, @@ -268,7 +266,7 @@ const respondToGetNodeProtocolInfo: MockControllerBehavior = { const nodeCaps = controller.nodes.get( msg.requestedNodeId, )!.capabilities; - const ret = new GetNodeProtocolInfoResponse(host, { + const ret = new GetNodeProtocolInfoResponse({ ...nodeCaps, }); await controller.sendMessageToHost(ret); @@ -279,7 +277,7 @@ const respondToGetNodeProtocolInfo: MockControllerBehavior = { }; const handleSendData: MockControllerBehavior = { - async onHostMessage(host, controller, msg) { + async onHostMessage(controller, msg) { if (msg instanceof SendDataRequest) { // Check if this command is legal right now const state = controller.state.get( @@ -299,7 +297,7 @@ const handleSendData: MockControllerBehavior = { ); // Notify the host that the message was sent - const res = new SendDataResponse(host, { + const res = new SendDataResponse({ wasSent: true, }); await controller.sendMessageToHost(res); @@ -310,7 +308,6 @@ const handleSendData: MockControllerBehavior = { const node = controller.nodes.get(msg.getNodeId()!)!; // Create a lazy frame, so it can be deserialized on the node after a short delay to simulate radio transmission const lazyPayload = createLazySendDataPayload( - host, controller, node, msg, @@ -350,7 +347,7 @@ const handleSendData: MockControllerBehavior = { MockControllerCommunicationState.Idle, ); - const cb = new SendDataRequestTransmitReport(host, { + const cb = new SendDataRequestTransmitReport({ callbackId: msg.callbackId!, transmitStatus: ack ? TransmitStatus.OK @@ -371,7 +368,7 @@ const handleSendData: MockControllerBehavior = { }; const handleSendDataMulticast: MockControllerBehavior = { - async onHostMessage(host, controller, msg) { + async onHostMessage(controller, msg) { if (msg instanceof SendDataMulticastRequest) { // Check if this command is legal right now const state = controller.state.get( @@ -393,7 +390,7 @@ const handleSendDataMulticast: MockControllerBehavior = { ); // Notify the host that the message was sent - const res = new SendDataMulticastResponse(host, { + const res = new SendDataMulticastResponse({ wasSent: true, }); await controller.sendMessageToHost(res); @@ -407,7 +404,6 @@ const handleSendDataMulticast: MockControllerBehavior = { const node = controller.nodes.get(nodeId)!; // Create a lazy frame, so it can be deserialized on the node after a short delay to simulate radio transmission const lazyPayload = createLazySendDataPayload( - host, controller, node, msg, @@ -449,7 +445,7 @@ const handleSendDataMulticast: MockControllerBehavior = { MockControllerCommunicationState.Idle, ); - const cb = new SendDataMulticastRequestTransmitReport(host, { + const cb = new SendDataMulticastRequestTransmitReport({ callbackId: msg.callbackId!, transmitStatus: ack ? TransmitStatus.OK @@ -470,7 +466,7 @@ const handleSendDataMulticast: MockControllerBehavior = { }; const handleRequestNodeInfo: MockControllerBehavior = { - async onHostMessage(host, controller, msg) { + async onHostMessage(controller, msg) { if (msg instanceof RequestNodeInfoRequest) { // Check if this command is legal right now const state = controller.state.get( @@ -493,10 +489,9 @@ const handleRequestNodeInfo: MockControllerBehavior = { // Send the data to the node const node = controller.nodes.get(msg.getNodeId()!)!; - const command = new ZWaveProtocolCCRequestNodeInformationFrame( - node.host, - { nodeId: controller.ownNodeId }, - ); + const command = new ZWaveProtocolCCRequestNodeInformationFrame({ + nodeId: controller.ownNodeId, + }); const frame = createMockZWaveRequestFrame(command, { ackRequested: false, }); @@ -508,7 +503,7 @@ const handleRequestNodeInfo: MockControllerBehavior = { ); // Notify the host that the message was sent - const res = new RequestNodeInfoResponse(host, { + const res = new RequestNodeInfoResponse({ wasSent: true, }); await controller.sendMessageToHost(res); @@ -523,14 +518,14 @@ const handleRequestNodeInfo: MockControllerBehavior = { let cb: ApplicationUpdateRequest; try { const nodeInfo = await nodeInfoPromise; - cb = new ApplicationUpdateRequestNodeInfoReceived(host, { + cb = new ApplicationUpdateRequestNodeInfoReceived({ nodeInformation: { ...nodeInfo, nodeId: nodeInfo.nodeId as number, }, }); } catch { - cb = new ApplicationUpdateRequestNodeInfoRequestFailed(host); + cb = new ApplicationUpdateRequestNodeInfoRequestFailed(); } controller.state.set( MockControllerStateKeys.CommunicationState, @@ -544,7 +539,7 @@ const handleRequestNodeInfo: MockControllerBehavior = { }; const handleAssignSUCReturnRoute: MockControllerBehavior = { - async onHostMessage(host, controller, msg) { + async onHostMessage(controller, msg) { if (msg instanceof AssignSUCReturnRouteRequest) { // Check if this command is legal right now const state = controller.state.get( @@ -569,7 +564,7 @@ const handleAssignSUCReturnRoute: MockControllerBehavior = { // Send the command to the node const node = controller.nodes.get(msg.getNodeId()!)!; - const command = new ZWaveProtocolCCAssignSUCReturnRoute(host, { + const command = new ZWaveProtocolCCAssignSUCReturnRoute({ nodeId: node.id, destinationNodeId: controller.ownNodeId, repeaters: [], // don't care @@ -583,7 +578,7 @@ const handleAssignSUCReturnRoute: MockControllerBehavior = { const ackPromise = controller.sendToNode(node, frame); // Notify the host that the message was sent - const res = new AssignSUCReturnRouteResponse(host, { + const res = new AssignSUCReturnRouteResponse({ wasExecuted: true, }); await controller.sendMessageToHost(res); @@ -610,7 +605,7 @@ const handleAssignSUCReturnRoute: MockControllerBehavior = { ); if (expectCallback) { - const cb = new AssignSUCReturnRouteRequestTransmitReport(host, { + const cb = new AssignSUCReturnRouteRequestTransmitReport({ callbackId: msg.callbackId!, transmitStatus: ack ? TransmitStatus.OK @@ -625,14 +620,14 @@ const handleAssignSUCReturnRoute: MockControllerBehavior = { }; const forwardCommandClassesToHost: MockControllerBehavior = { - async onNodeFrame(host, controller, node, frame) { + async onNodeFrame(controller, node, frame) { if ( frame.type === MockZWaveFrameType.Request && frame.payload instanceof CommandClass && !(frame.payload instanceof ZWaveProtocolCC) ) { // This is a CC that is meant for the host application - const msg = new ApplicationCommandRequest(host, { + const msg = new ApplicationCommandRequest({ command: frame.payload, }); // Nodes send commands TO the controller, so we need to fix the node ID before forwarding @@ -645,20 +640,17 @@ const forwardCommandClassesToHost: MockControllerBehavior = { }; const forwardUnsolicitedNIF: MockControllerBehavior = { - async onNodeFrame(host, controller, node, frame) { + async onNodeFrame(controller, node, frame) { if ( frame.type === MockZWaveFrameType.Request && frame.payload instanceof ZWaveProtocolCCNodeInformationFrame ) { - const updateRequest = new ApplicationUpdateRequestNodeInfoReceived( - host, - { - nodeInformation: { - ...frame.payload, - nodeId: frame.payload.nodeId as number, - }, + const updateRequest = new ApplicationUpdateRequestNodeInfoReceived({ + nodeInformation: { + ...frame.payload, + nodeId: frame.payload.nodeId as number, }, - ); + }); // Simulate a serialized frame being transmitted via radio before receiving it await controller.sendMessageToHost( updateRequest, diff --git a/packages/zwave-js/src/lib/driver/Driver.ts b/packages/zwave-js/src/lib/driver/Driver.ts index e5c929167040..1477004adc88 100644 --- a/packages/zwave-js/src/lib/driver/Driver.ts +++ b/packages/zwave-js/src/lib/driver/Driver.ts @@ -3007,7 +3007,7 @@ export class Driver extends TypedEventEmitter try { this.isSoftResetting = true; - await this.sendMessage(new SoftResetRequest(this), { + await this.sendMessage(new SoftResetRequest(), { supportCheck: false, pauseSendThread: true, }); @@ -3067,7 +3067,7 @@ export class Driver extends TypedEventEmitter try { this.isSoftResetting = true; - await this.sendMessage(new SoftResetRequest(this), { + await this.sendMessage(new SoftResetRequest(), { supportCheck: false, pauseSendThread: true, }); @@ -3159,7 +3159,7 @@ export class Driver extends TypedEventEmitter try { // And resume sending - this requires us to unpause the send thread this.unpauseSendQueue(); - await this.sendMessage(new GetControllerVersionRequest(this), { + await this.sendMessage(new GetControllerVersionRequest(), { supportCheck: false, priority: MessagePriority.ControllerImmediate, }); @@ -3468,7 +3468,7 @@ export class Driver extends TypedEventEmitter try { // Parse the message while remembering potential decoding errors in embedded CCs // This way we can log the invalid CC contents - msg = Message.from(this, { + msg = Message.from({ data, sdkVersion: this._controller?.sdkVersion, ctx: this.getCCParsingContext(), @@ -4526,7 +4526,7 @@ export class Driver extends TypedEventEmitter level: "debug", direction: "outbound", }); - const cc = new TransportServiceCCSegmentRequest(this, { + const cc = new TransportServiceCCSegmentRequest({ nodeId: command.nodeId, sessionId: command.sessionId, datagramOffset: offset, @@ -4543,7 +4543,7 @@ export class Driver extends TypedEventEmitter level: "debug", direction: "outbound", }); - const cc = new TransportServiceCCSegmentComplete(this, { + const cc = new TransportServiceCCSegmentComplete({ nodeId: command.nodeId, sessionId: command.sessionId, }); @@ -4591,7 +4591,7 @@ export class Driver extends TypedEventEmitter }); } else { // This belongs to a session we don't know... tell the sending node to try again - const cc = new TransportServiceCCSegmentWait(this, { + const cc = new TransportServiceCCSegmentWait({ nodeId: command.nodeId, pendingSegments: 0, }); @@ -5240,7 +5240,6 @@ ${handlers.length} left`, // 3. if (SupervisionCC.requiresEncapsulation(cmd)) { cmd = SupervisionCC.encapsulate( - this, cmd, this.getNextSupervisionSessionId(cmd.nodeId as number), ); @@ -5254,13 +5253,13 @@ ${handlers.length} left`, ); cmd = multiChannelCCVersion === 1 - ? MultiChannelCC.encapsulateV1(this, cmd) - : MultiChannelCC.encapsulate(this, cmd); + ? MultiChannelCC.encapsulateV1(cmd) + : MultiChannelCC.encapsulate(cmd); } // 5. if (CRC16CC.requiresEncapsulation(cmd)) { - cmd = CRC16CC.encapsulate(this, cmd); + cmd = CRC16CC.encapsulate(cmd); } else { // The command must be S2-encapsulated, if ... let maybeS2 = false; @@ -5277,7 +5276,6 @@ ${handlers.length} left`, } if (maybeS2 && Security2CC.requiresEncapsulation(cmd)) { cmd = Security2CC.encapsulate( - this, cmd, this.ownNodeId, this, @@ -5293,7 +5291,6 @@ ${handlers.length} left`, // This check will return false for S2-encapsulated commands if (SecurityCC.requiresEncapsulation(cmd)) { cmd = SecurityCC.encapsulate( - this, this.ownNodeId, this.securityManager!, cmd, @@ -6119,13 +6116,13 @@ ${handlers.length} left`, this.controller.isFunctionSupported(FunctionType.SendDataBridge) ) { // Prioritize Bridge commands when they are supported - msg = new SendDataBridgeRequest(this, { + msg = new SendDataBridgeRequest({ sourceNodeId: this.ownNodeId, command, maxSendAttempts: this._options.attempts.sendData, }); } else { - msg = new SendDataRequest(this, { + msg = new SendDataRequest({ command, maxSendAttempts: this._options.attempts.sendData, }); @@ -6137,13 +6134,13 @@ ${handlers.length} left`, ) ) { // Prioritize Bridge commands when they are supported - msg = new SendDataMulticastBridgeRequest(this, { + msg = new SendDataMulticastBridgeRequest({ sourceNodeId: this.ownNodeId, command, maxSendAttempts: this._options.attempts.sendData, }); } else { - msg = new SendDataMulticastRequest(this, { + msg = new SendDataMulticastRequest({ command, maxSendAttempts: this._options.attempts.sendData, }); @@ -6233,7 +6230,6 @@ ${handlers.length} left`, // Create the encapsulating CC so we have a session ID const sessionId = this.getNextSupervisionSessionId(command.nodeId); command = SupervisionCC.encapsulate( - this, command, sessionId, options.requestStatusUpdates, @@ -6275,8 +6271,15 @@ ${handlers.length} left`, command.encapsulationFlags = options.encapsulationFlags; } - // For S2 multicast, the Security encapsulation flag does not get set automatically by the CC constructor - if (options?.s2MulticastGroupId != undefined) { + // Use security encapsulation for CCs that are only supported securely, and multicast commands + if ( + this.isCCSecure( + command.ccId, + command.nodeId as number, + command.endpointIndex, + ) + || options?.s2MulticastGroupId != undefined + ) { command.toggleEncapsulationFlag(EncapsulationFlags.Security, true); } @@ -6344,7 +6347,7 @@ ${handlers.length} left`, private async abortSendData(): Promise { try { - const abort = new SendDataAbort(this); + const abort = new SendDataAbort(); await this.writeSerial( abort.serialize(this.getCCEncodingContext()), ); @@ -6981,7 +6984,7 @@ ${handlers.length} left`, msg = commandOrMsg; } else { const SendDataConstructor = this.getSendDataSinglecastConstructor(); - msg = new SendDataConstructor(this, { + msg = new SendDataConstructor({ sourceNodeId: this.ownNodeId, command: commandOrMsg, }); @@ -7456,7 +7459,7 @@ ${handlers.length} left`, const result = await this.sendMessage< Message & SuccessIndicator >( - new SendTestFrameRequest(this, { + new SendTestFrameRequest({ testNodeId: nodeId, powerlevel, }), diff --git a/packages/zwave-js/src/lib/driver/MessageGenerators.ts b/packages/zwave-js/src/lib/driver/MessageGenerators.ts index 26c6c3762ad9..15b8ee124bde 100644 --- a/packages/zwave-js/src/lib/driver/MessageGenerators.ts +++ b/packages/zwave-js/src/lib/driver/MessageGenerators.ts @@ -340,14 +340,14 @@ export const maybeTransportServiceGenerator: MessageGeneratorImplementation = ); let cc: TransportServiceCC; if (segment === 0) { - cc = new TransportServiceCCFirstSegment(driver, { + cc = new TransportServiceCCFirstSegment({ nodeId, sessionId, datagramSize: payload.length, partialDatagram: chunk, }); } else { - cc = new TransportServiceCCSubsequentSegment(driver, { + cc = new TransportServiceCCSubsequentSegment({ nodeId, sessionId, datagramSize: payload.length, @@ -524,7 +524,7 @@ export const secureMessageGeneratorS0: MessageGeneratorImplementation = let nonce: Buffer | undefined = secMan.getFreeNonce(nodeId); if (!nonce) { // No free nonce, request a new one - const cc = new SecurityCCNonceGet(driver, { + const cc = new SecurityCCNonceGet({ nodeId: nodeId, endpoint: msg.command.endpointIndex, }); @@ -603,7 +603,7 @@ export const secureMessageGeneratorS2: MessageGeneratorImplementation = // Request a new nonce // No free nonce, request a new one - const cc = new Security2CCNonceGet(driver, { + const cc = new Security2CCNonceGet({ nodeId: nodeId, ownNodeId: driver.ownNodeId, endpoint: msg.command.endpointIndex, @@ -834,7 +834,7 @@ export const secureMessageGeneratorS2Multicast: MessageGeneratorImplementation = const innerMPANState = secMan.getInnerMPANState(groupId); // This should always be defined, but better not throw unnecessarily here if (innerMPANState) { - const cc = new Security2CCMessageEncapsulation(driver, { + const cc = new Security2CCMessageEncapsulation({ nodeId, ownNodeId: driver.ownNodeId, securityManagers: driver, @@ -896,19 +896,16 @@ export const secureMessageGeneratorS2Multicast: MessageGeneratorImplementation = if (finalSupervisionResult) { // We can return return information about the success of this multicast - so we should // TODO: Not sure if we need to "wrap" the response for something. For now, try faking it - const cc = new SupervisionCCReport(driver, { + const cc = new SupervisionCCReport({ nodeId: NODE_ID_BROADCAST, sessionId: 0, // fake moreUpdatesFollow: false, // fake ...(finalSupervisionResult as any), }); - const ret = new (driver.getSendDataSinglecastConstructor())( - driver, - { - sourceNodeId: driver.ownNodeId, - command: cc, - }, - ); + const ret = new (driver.getSendDataSinglecastConstructor())({ + sourceNodeId: driver.ownNodeId, + command: cc, + }); return ret; } else { return response; diff --git a/packages/zwave-js/src/lib/driver/Transaction.test.ts b/packages/zwave-js/src/lib/driver/Transaction.test.ts index b564e5ad7a8d..fa2081225a7e 100644 --- a/packages/zwave-js/src/lib/driver/Transaction.test.ts +++ b/packages/zwave-js/src/lib/driver/Transaction.test.ts @@ -165,7 +165,7 @@ test("NodeQuery comparisons should prioritize listening nodes", (t) => { const driver = driverMock as any as Driver; const msg = nodeId != undefined ? new SendDataRequest(driver, { - command: new NoOperationCC(driver, { + command: new NoOperationCC({ nodeId, }), }) @@ -274,7 +274,7 @@ test("Messages in the wakeup queue should be preferred over lesser priorities on function createTransaction(nodeId: number, priority: MessagePriority) { const driver = driverMock as any as Driver; const msg = new SendDataRequest(driver, { - command: new NoOperationCC(driver, { nodeId }), + command: new NoOperationCC({ nodeId }), }); const ret = createDummyTransaction(driverMock, { priority, diff --git a/packages/zwave-js/src/lib/node/Endpoint.ts b/packages/zwave-js/src/lib/node/Endpoint.ts index 2e84cff4d0d4..c9a052c7eb25 100644 --- a/packages/zwave-js/src/lib/node/Endpoint.ts +++ b/packages/zwave-js/src/lib/node/Endpoint.ts @@ -271,7 +271,7 @@ export class Endpoint ZWaveErrorCodes.CC_NotSupported, ); } - return CommandClass.createInstanceUnchecked(this.driver, this, cc); + return CommandClass.createInstanceUnchecked(this, cc); } /** @@ -283,7 +283,7 @@ export class Endpoint ): T | undefined { const ccId = typeof cc === "number" ? cc : getCommandClassStatic(cc); if (this.supportsCC(ccId) || this.controlsCC(ccId)) { - return CommandClass.createInstanceUnchecked(this.driver, this, cc); + return CommandClass.createInstanceUnchecked(this, cc); } } diff --git a/packages/zwave-js/src/lib/node/MockNodeBehaviors.ts b/packages/zwave-js/src/lib/node/MockNodeBehaviors.ts index 42e73826a39b..3639dd80f3f0 100644 --- a/packages/zwave-js/src/lib/node/MockNodeBehaviors.ts +++ b/packages/zwave-js/src/lib/node/MockNodeBehaviors.ts @@ -46,7 +46,7 @@ const respondToRequestNodeInfo: MockNodeBehavior = { receivedCC instanceof ZWaveProtocolCCRequestNodeInformationFrame ) { - const cc = new ZWaveProtocolCCNodeInformationFrame(self.host, { + const cc = new ZWaveProtocolCCNodeInformationFrame({ nodeId: self.id, ...self.capabilities, supportedCCs: [...self.implementedCCs] @@ -85,7 +85,7 @@ const respondToVersionCCCommandClassGet: MockNodeBehavior = { version = 1; } - const cc = new VersionCCCommandClassReport(self.host, { + const cc = new VersionCCCommandClassReport({ nodeId: self.id, endpoint: "index" in endpoint ? endpoint.index : undefined, requestedCC: receivedCC.requestedCC, @@ -99,7 +99,7 @@ const respondToVersionCCCommandClassGet: MockNodeBehavior = { const respondToZWavePlusCCGet: MockNodeBehavior = { handleCC(controller, self, receivedCC) { if (receivedCC instanceof ZWavePlusCCGet) { - const cc = new ZWavePlusCCReport(self.host, { + const cc = new ZWavePlusCCReport({ nodeId: controller.ownNodeId, zwavePlusVersion: 2, nodeType: ZWavePlusNodeType.Node, @@ -123,7 +123,7 @@ const respondToS0ZWavePlusCCGet: MockNodeBehavior = { receivedCC instanceof SecurityCCCommandEncapsulation && receivedCC.encapsulated instanceof ZWavePlusCCGet ) { - let cc: CommandClass = new ZWavePlusCCReport(self.host, { + let cc: CommandClass = new ZWavePlusCCReport({ nodeId: controller.ownNodeId, zwavePlusVersion: 2, nodeType: ZWavePlusNodeType.Node, @@ -136,7 +136,6 @@ const respondToS0ZWavePlusCCGet: MockNodeBehavior = { userIcon: 0x0000, }); cc = SecurityCC.encapsulate( - self.host, self.id, self.securityManagers.securityManager!, cc, @@ -152,7 +151,7 @@ const respondToS2ZWavePlusCCGet: MockNodeBehavior = { receivedCC instanceof Security2CCMessageEncapsulation && receivedCC.encapsulated instanceof ZWavePlusCCGet ) { - let cc: CommandClass = new ZWavePlusCCReport(self.host, { + let cc: CommandClass = new ZWavePlusCCReport({ nodeId: controller.ownNodeId, zwavePlusVersion: 2, nodeType: ZWavePlusNodeType.Node, @@ -165,7 +164,6 @@ const respondToS2ZWavePlusCCGet: MockNodeBehavior = { userIcon: 0x0000, }); cc = Security2CC.encapsulate( - self.host, cc, self.id, self.securityManagers, diff --git a/packages/zwave-js/src/lib/node/Node.ts b/packages/zwave-js/src/lib/node/Node.ts index be8f30e2e661..c57a36aa8609 100644 --- a/packages/zwave-js/src/lib/node/Node.ts +++ b/packages/zwave-js/src/lib/node/Node.ts @@ -1140,7 +1140,7 @@ export class ZWaveNode extends ZWaveNodeMixins nodeId: this.id, }); const resp = await this.driver.sendMessage( - new GetNodeProtocolInfoRequest(this.driver, { + new GetNodeProtocolInfoRequest({ requestedNodeId: this.id, }), ); @@ -1300,7 +1300,7 @@ protocol version: ${this.protocolVersion}`; public async requestNodeInfo(): Promise { const resp = await this.driver.sendMessage< RequestNodeInfoResponse | ApplicationUpdateRequest - >(new RequestNodeInfoRequest(this.driver, { nodeId: this.id })); + >(new RequestNodeInfoRequest({ nodeId: this.id })); if (resp instanceof RequestNodeInfoResponse && !resp.wasSent) { // TODO: handle this in SendThreadMachine throw new ZWaveError( @@ -1393,7 +1393,6 @@ protocol version: ${this.protocolVersion}`; try { if (force) { instance = CommandClass.createInstanceUnchecked( - this.driver, endpoint, cc, )!; @@ -6368,7 +6367,6 @@ ${formatRouteHealthCheckSummary(this.id, otherNode.id, summary)}`, : undefined; const ccInstance = CommandClass.createInstanceUnchecked( - this.driver, this, valueId.commandClass, ); diff --git a/packages/zwave-js/src/lib/node/mixins/40_Values.ts b/packages/zwave-js/src/lib/node/mixins/40_Values.ts index d6737aa484df..0171d8525aca 100644 --- a/packages/zwave-js/src/lib/node/mixins/40_Values.ts +++ b/packages/zwave-js/src/lib/node/mixins/40_Values.ts @@ -139,7 +139,6 @@ export abstract class NodeValuesMixin extends NodeWakeupMixin } const ccInstance = CommandClass.createInstanceUnchecked( - this.driver, this, arg.commandClass, ); diff --git a/packages/zwave-js/src/lib/node/mixins/70_FirmwareUpdate.ts b/packages/zwave-js/src/lib/node/mixins/70_FirmwareUpdate.ts index 4c6745096c76..7a049b6ffd8f 100644 --- a/packages/zwave-js/src/lib/node/mixins/70_FirmwareUpdate.ts +++ b/packages/zwave-js/src/lib/node/mixins/70_FirmwareUpdate.ts @@ -555,9 +555,11 @@ export abstract class FirmwareUpdateMixin extends SchedulePollMixin // ================================ // STEP 2: // Determine the fragment size - const fcc = new FirmwareUpdateMetaDataCC(this.driver, { - nodeId: this.id, - }); + const fcc = new FirmwareUpdateMetaDataCC({ nodeId: this.id }); + fcc.toggleEncapsulationFlag( + EncapsulationFlags.Security, + this.driver.isCCSecure(fcc.ccId, this.id), + ); const maxGrossPayloadSizeSecure = this.driver .computeNetCCPayloadSize( fcc, @@ -613,9 +615,11 @@ export abstract class FirmwareUpdateMixin extends SchedulePollMixin }); // Since no update is in progress, we need to determine the fragment size again - const fcc = new FirmwareUpdateMetaDataCC(this.driver, { - nodeId: this.id, - }); + const fcc = new FirmwareUpdateMetaDataCC({ nodeId: this.id }); + fcc.toggleEncapsulationFlag( + EncapsulationFlags.Security, + !!(command.encapsulationFlags & EncapsulationFlags.Security), + ); const ccVersion = getEffectiveCCVersion(this.driver, fcc); const fragmentSize = this.driver.computeNetCCPayloadSize(fcc) - 2 // report number diff --git a/packages/zwave-js/src/lib/node/mockCCBehaviors/Basic.ts b/packages/zwave-js/src/lib/node/mockCCBehaviors/Basic.ts index 0f5ab952e176..4a4dc48c3467 100644 --- a/packages/zwave-js/src/lib/node/mockCCBehaviors/Basic.ts +++ b/packages/zwave-js/src/lib/node/mockCCBehaviors/Basic.ts @@ -15,7 +15,7 @@ const respondToBasicGet: MockNodeBehavior = { return; } - const cc = new BasicCCReport(self.host, { + const cc = new BasicCCReport({ nodeId: controller.ownNodeId, currentValue: (self.state.get(StateKeys.currentValue) ?? 0) as number, diff --git a/packages/zwave-js/src/lib/node/mockCCBehaviors/BinarySensor.ts b/packages/zwave-js/src/lib/node/mockCCBehaviors/BinarySensor.ts index 751d08b98a87..9fb8c0d4a1b0 100644 --- a/packages/zwave-js/src/lib/node/mockCCBehaviors/BinarySensor.ts +++ b/packages/zwave-js/src/lib/node/mockCCBehaviors/BinarySensor.ts @@ -23,7 +23,7 @@ const respondToBinarySensorSupportedGet: MockNodeBehavior = { receivedCC.endpointIndex, ), }; - const cc = new BinarySensorCCSupportedReport(self.host, { + const cc = new BinarySensorCCSupportedReport({ nodeId: controller.ownNodeId, supportedSensorTypes: capabilities.supportedSensorTypes, }); @@ -56,7 +56,7 @@ const respondToBinarySensorGet: MockNodeBehavior = { if (sensorType != undefined) { const value = capabilities.getValue?.(sensorType) ?? false; - const cc = new BinarySensorCCReport(self.host, { + const cc = new BinarySensorCCReport({ nodeId: controller.ownNodeId, type: sensorType, value, diff --git a/packages/zwave-js/src/lib/node/mockCCBehaviors/BinarySwitch.ts b/packages/zwave-js/src/lib/node/mockCCBehaviors/BinarySwitch.ts index a431d87ceab1..49b649f8f937 100644 --- a/packages/zwave-js/src/lib/node/mockCCBehaviors/BinarySwitch.ts +++ b/packages/zwave-js/src/lib/node/mockCCBehaviors/BinarySwitch.ts @@ -32,7 +32,7 @@ const respondToBinarySwitchGet: MockNodeBehavior = { receivedCC.endpointIndex, ), }; - const cc = new BinarySwitchCCReport(self.host, { + const cc = new BinarySwitchCCReport({ nodeId: controller.ownNodeId, currentValue: ( self.state.get(StateKeys.currentValue) diff --git a/packages/zwave-js/src/lib/node/mockCCBehaviors/ColorSwitch.ts b/packages/zwave-js/src/lib/node/mockCCBehaviors/ColorSwitch.ts index 04ab347da8d2..ec0f63565677 100644 --- a/packages/zwave-js/src/lib/node/mockCCBehaviors/ColorSwitch.ts +++ b/packages/zwave-js/src/lib/node/mockCCBehaviors/ColorSwitch.ts @@ -35,7 +35,7 @@ const respondToColorSwitchSupportedGet: MockNodeBehavior = { receivedCC.endpointIndex, ), }; - const cc = new ColorSwitchCCSupportedReport(self.host, { + const cc = new ColorSwitchCCSupportedReport({ nodeId: controller.ownNodeId, supportedColorComponents: Object.keys( capabilities.colorComponents, @@ -74,7 +74,7 @@ const respondToColorSwitchGet: MockNodeBehavior = { }; const component = receivedCC.colorComponent; if (component in capabilities.colorComponents) { - const cc = new ColorSwitchCCReport(self.host, { + const cc = new ColorSwitchCCReport({ nodeId: controller.ownNodeId, colorComponent: component, currentValue: diff --git a/packages/zwave-js/src/lib/node/mockCCBehaviors/Configuration.ts b/packages/zwave-js/src/lib/node/mockCCBehaviors/Configuration.ts index 4a5f0a2665a1..7eb5ce3ede84 100644 --- a/packages/zwave-js/src/lib/node/mockCCBehaviors/Configuration.ts +++ b/packages/zwave-js/src/lib/node/mockCCBehaviors/Configuration.ts @@ -50,7 +50,7 @@ const respondToConfigurationGet: MockNodeBehavior = { ?? paramInfo.defaultValue ?? 0; - const cc = new ConfigurationCCReport(self.host, { + const cc = new ConfigurationCCReport({ nodeId: controller.ownNodeId, parameter, value, @@ -137,7 +137,7 @@ const respondToConfigurationNameGet: MockNodeBehavior = { // Do nothing if the parameter is not supported if (!paramInfo) return { action: "fail" }; - const cc = new ConfigurationCCNameReport(self.host, { + const cc = new ConfigurationCCNameReport({ nodeId: controller.ownNodeId, parameter, name: paramInfo.name ?? "", @@ -165,7 +165,7 @@ const respondToConfigurationInfoGet: MockNodeBehavior = { // Do nothing if the parameter is not supported if (!paramInfo) return { action: "fail" }; - const cc = new ConfigurationCCInfoReport(self.host, { + const cc = new ConfigurationCCInfoReport({ nodeId: controller.ownNodeId, parameter, info: paramInfo.info ?? "", @@ -197,7 +197,7 @@ const respondToConfigurationPropertiesGet: MockNodeBehavior = { // If the parameter is not supported, respond with the first supported parameter if (!paramInfo) { - cc = new ConfigurationCCPropertiesReport(self.host, { + cc = new ConfigurationCCPropertiesReport({ nodeId: controller.ownNodeId, parameter, valueFormat: 0, @@ -205,7 +205,7 @@ const respondToConfigurationPropertiesGet: MockNodeBehavior = { nextParameter: nextParameter?.["#"] ?? 0, }); } else { - cc = new ConfigurationCCPropertiesReport(self.host, { + cc = new ConfigurationCCPropertiesReport({ nodeId: controller.ownNodeId, parameter, valueSize: paramInfo.valueSize, diff --git a/packages/zwave-js/src/lib/node/mockCCBehaviors/EnergyProduction.ts b/packages/zwave-js/src/lib/node/mockCCBehaviors/EnergyProduction.ts index acfc5ad840e5..fcf27572380c 100644 --- a/packages/zwave-js/src/lib/node/mockCCBehaviors/EnergyProduction.ts +++ b/packages/zwave-js/src/lib/node/mockCCBehaviors/EnergyProduction.ts @@ -52,7 +52,7 @@ const respondToEnergyProductionGet: MockNodeBehavior = { ) as unknown as keyof typeof capabilities.values ]; - const cc = new EnergyProductionCCReport(self.host, { + const cc = new EnergyProductionCCReport({ nodeId: controller.ownNodeId, parameter: receivedCC.parameter, value: result?.value ?? 0, diff --git a/packages/zwave-js/src/lib/node/mockCCBehaviors/ManufacturerSpecific.ts b/packages/zwave-js/src/lib/node/mockCCBehaviors/ManufacturerSpecific.ts index 1ca966debef4..ad537d1ceed9 100644 --- a/packages/zwave-js/src/lib/node/mockCCBehaviors/ManufacturerSpecific.ts +++ b/packages/zwave-js/src/lib/node/mockCCBehaviors/ManufacturerSpecific.ts @@ -7,7 +7,7 @@ import { type MockNodeBehavior } from "@zwave-js/testing"; const respondToManufacturerSpecificGet: MockNodeBehavior = { handleCC(controller, self, receivedCC) { if (receivedCC instanceof ManufacturerSpecificCCGet) { - const cc = new ManufacturerSpecificCCReport(self.host, { + const cc = new ManufacturerSpecificCCReport({ nodeId: self.id, manufacturerId: self.capabilities.manufacturerId, productType: self.capabilities.productType, diff --git a/packages/zwave-js/src/lib/node/mockCCBehaviors/Meter.ts b/packages/zwave-js/src/lib/node/mockCCBehaviors/Meter.ts index 281a2638fb97..81424ce67ff2 100644 --- a/packages/zwave-js/src/lib/node/mockCCBehaviors/Meter.ts +++ b/packages/zwave-js/src/lib/node/mockCCBehaviors/Meter.ts @@ -29,7 +29,7 @@ const respondToMeterSupportedGet: MockNodeBehavior = { receivedCC.endpointIndex, ), }; - const cc = new MeterCCSupportedReport(self.host, { + const cc = new MeterCCSupportedReport({ nodeId: controller.ownNodeId, type: capabilities.meterType, supportedScales: capabilities.supportedScales, @@ -68,7 +68,7 @@ const respondToMeterGet: MockNodeBehavior = { } : value; - const cc = new MeterCCReport(self.host, { + const cc = new MeterCCReport({ nodeId: controller.ownNodeId, type: capabilities.meterType, scale, diff --git a/packages/zwave-js/src/lib/node/mockCCBehaviors/MultiChannel.ts b/packages/zwave-js/src/lib/node/mockCCBehaviors/MultiChannel.ts index fc6132e65fab..f968c22693aa 100644 --- a/packages/zwave-js/src/lib/node/mockCCBehaviors/MultiChannel.ts +++ b/packages/zwave-js/src/lib/node/mockCCBehaviors/MultiChannel.ts @@ -44,7 +44,7 @@ const encapsulateMultiChannelCC: MockNodeBehavior = { (multiChannelEncap as MultiChannelCCCommandEncapsulation) .destination as number; - response.cc = new MultiChannelCCCommandEncapsulation(self.host, { + response.cc = new MultiChannelCCCommandEncapsulation({ nodeId: response.cc.nodeId, encapsulated: response.cc, endpoint: source, @@ -59,7 +59,7 @@ const encapsulateMultiChannelCC: MockNodeBehavior = { const respondToMultiChannelCCEndPointGet: MockNodeBehavior = { handleCC(controller, self, receivedCC) { if (receivedCC instanceof MultiChannelCCEndPointGet) { - const cc = new MultiChannelCCEndPointReport(self.host, { + const cc = new MultiChannelCCEndPointReport({ nodeId: controller.ownNodeId, countIsDynamic: false, identicalCapabilities: false, @@ -74,7 +74,7 @@ const respondToMultiChannelCCEndPointFind: MockNodeBehavior = { handleCC(controller, self, receivedCC) { if (receivedCC instanceof MultiChannelCCEndPointFind) { const request = receivedCC; - const cc = new MultiChannelCCEndPointFindReport(self.host, { + const cc = new MultiChannelCCEndPointFindReport({ nodeId: controller.ownNodeId, genericClass: request.genericClass, specificClass: request.specificClass, @@ -92,7 +92,7 @@ const respondToMultiChannelCCCapabilityGet: MockNodeBehavior = { const endpoint = self.endpoints.get( receivedCC.requestedEndpoint, )!; - const cc = new MultiChannelCCCapabilityReport(self.host, { + const cc = new MultiChannelCCCapabilityReport({ nodeId: controller.ownNodeId, endpointIndex: endpoint.index, genericDeviceClass: endpoint?.capabilities.genericDeviceClass diff --git a/packages/zwave-js/src/lib/node/mockCCBehaviors/MultilevelSensor.ts b/packages/zwave-js/src/lib/node/mockCCBehaviors/MultilevelSensor.ts index 8a1157757b13..ab824a4bd05a 100644 --- a/packages/zwave-js/src/lib/node/mockCCBehaviors/MultilevelSensor.ts +++ b/packages/zwave-js/src/lib/node/mockCCBehaviors/MultilevelSensor.ts @@ -24,7 +24,7 @@ const respondToMultilevelSensorGetSupportedSensor: MockNodeBehavior = { receivedCC.endpointIndex, ), }; - const cc = new MultilevelSensorCCSupportedSensorReport(self.host, { + const cc = new MultilevelSensorCCSupportedSensorReport({ nodeId: controller.ownNodeId, supportedSensorTypes: Object.keys( capabilities.sensors, @@ -48,7 +48,7 @@ const respondToMultilevelSensorGetSupportedScale: MockNodeBehavior = { const sensorType = receivedCC.sensorType; const supportedScales = capabilities.sensors[sensorType]?.supportedScales ?? []; - const cc = new MultilevelSensorCCSupportedScaleReport(self.host, { + const cc = new MultilevelSensorCCSupportedScaleReport({ nodeId: controller.ownNodeId, sensorType, supportedScales, @@ -79,7 +79,7 @@ const respondToMultilevelSensorGet: MockNodeBehavior = { ?? capabilities.sensors[sensorType].supportedScales[0] ?? 0; const value = capabilities.getValue?.(sensorType, scale) ?? 0; - const cc = new MultilevelSensorCCReport(self.host, { + const cc = new MultilevelSensorCCReport({ nodeId: controller.ownNodeId, type: sensorType, scale, diff --git a/packages/zwave-js/src/lib/node/mockCCBehaviors/MultilevelSwitch.ts b/packages/zwave-js/src/lib/node/mockCCBehaviors/MultilevelSwitch.ts index 075f33238104..83784ebd9b9a 100644 --- a/packages/zwave-js/src/lib/node/mockCCBehaviors/MultilevelSwitch.ts +++ b/packages/zwave-js/src/lib/node/mockCCBehaviors/MultilevelSwitch.ts @@ -43,7 +43,7 @@ const respondToMultilevelSwitchGet: MockNodeBehavior = { ?? capabilities.defaultValue ?? UNKNOWN_STATE ) as MaybeUnknown; - const cc = new MultilevelSwitchCCReport(self.host, { + const cc = new MultilevelSwitchCCReport({ nodeId: controller.ownNodeId, currentValue, // We don't support transitioning yet @@ -73,7 +73,7 @@ const respondToMultilevelSwitchSupportedGet: MockNodeBehavior = { receivedCC.endpointIndex, ), }; - const cc = new MultilevelSwitchCCSupportedReport(self.host, { + const cc = new MultilevelSwitchCCSupportedReport({ nodeId: controller.ownNodeId, switchType: capabilities.primarySwitchType, }); diff --git a/packages/zwave-js/src/lib/node/mockCCBehaviors/Notification.ts b/packages/zwave-js/src/lib/node/mockCCBehaviors/Notification.ts index 561697580ea0..bed6319a0433 100644 --- a/packages/zwave-js/src/lib/node/mockCCBehaviors/Notification.ts +++ b/packages/zwave-js/src/lib/node/mockCCBehaviors/Notification.ts @@ -23,7 +23,7 @@ const respondToNotificationSupportedGet: MockNodeBehavior = { receivedCC.endpointIndex, ), }; - const cc = new NotificationCCSupportedReport(self.host, { + const cc = new NotificationCCSupportedReport({ nodeId: controller.ownNodeId, supportsV1Alarm: capabilities.supportsV1Alarm, supportedNotificationTypes: Object.keys( @@ -49,7 +49,7 @@ const respondToNotificationEventSupportedGet: MockNodeBehavior = { receivedCC.notificationType in capabilities.notificationTypesAndEvents ) { - const cc = new NotificationCCEventSupportedReport(self.host, { + const cc = new NotificationCCEventSupportedReport({ nodeId: controller.ownNodeId, notificationType: receivedCC.notificationType, supportedEvents: capabilities.notificationTypesAndEvents[ diff --git a/packages/zwave-js/src/lib/node/mockCCBehaviors/ScheduleEntryLock.ts b/packages/zwave-js/src/lib/node/mockCCBehaviors/ScheduleEntryLock.ts index 8995a3788bea..d539f2a3e2ac 100644 --- a/packages/zwave-js/src/lib/node/mockCCBehaviors/ScheduleEntryLock.ts +++ b/packages/zwave-js/src/lib/node/mockCCBehaviors/ScheduleEntryLock.ts @@ -58,7 +58,7 @@ const respondToScheduleEntryLockSupportedGet: MockNodeBehavior = { receivedCC.endpointIndex, ), }; - const cc = new ScheduleEntryLockCCSupportedReport(self.host, { + const cc = new ScheduleEntryLockCCSupportedReport({ nodeId: controller.ownNodeId, ...capabilities, }); @@ -83,7 +83,7 @@ const respondToScheduleEntryLockTimeOffsetSet: MockNodeBehavior = { const respondToScheduleEntryLockTimeOffsetGet: MockNodeBehavior = { handleCC(controller, self, receivedCC) { if (receivedCC instanceof ScheduleEntryLockCCTimeOffsetGet) { - const cc = new ScheduleEntryLockCCTimeOffsetReport(self.host, { + const cc = new ScheduleEntryLockCCTimeOffsetReport({ nodeId: controller.ownNodeId, standardOffset: (self.state.get(StateKeys.standardOffset) ?? 0) as number, @@ -195,7 +195,7 @@ const respondToScheduleEntryLockWeekDayScheduleGet: MockNodeBehavior = { StateKeys.schedule(userId, slotId, kind), ) ?? {}) as AllOrNone; - const cc = new ScheduleEntryLockCCWeekDayScheduleReport(self.host, { + const cc = new ScheduleEntryLockCCWeekDayScheduleReport({ nodeId: controller.ownNodeId, userId, slotId, @@ -294,7 +294,7 @@ const respondToScheduleEntryLockYearDayScheduleGet: MockNodeBehavior = { StateKeys.schedule(userId, slotId, kind), ) ?? {}) as AllOrNone; - const cc = new ScheduleEntryLockCCYearDayScheduleReport(self.host, { + const cc = new ScheduleEntryLockCCYearDayScheduleReport({ nodeId: controller.ownNodeId, userId, slotId, @@ -394,15 +394,12 @@ const respondToScheduleEntryLockDailyRepeatingScheduleGet: MockNodeBehavior = { StateKeys.schedule(userId, slotId, kind), ) ?? {}) as AllOrNone; - const cc = new ScheduleEntryLockCCDailyRepeatingScheduleReport( - self.host, - { - nodeId: controller.ownNodeId, - userId, - slotId, - ...schedule, - }, - ); + const cc = new ScheduleEntryLockCCDailyRepeatingScheduleReport({ + nodeId: controller.ownNodeId, + userId, + slotId, + ...schedule, + }); return { action: "sendCC", cc }; } }, diff --git a/packages/zwave-js/src/lib/node/mockCCBehaviors/SoundSwitch.ts b/packages/zwave-js/src/lib/node/mockCCBehaviors/SoundSwitch.ts index 1ffce5eef991..876e4e708506 100644 --- a/packages/zwave-js/src/lib/node/mockCCBehaviors/SoundSwitch.ts +++ b/packages/zwave-js/src/lib/node/mockCCBehaviors/SoundSwitch.ts @@ -47,7 +47,7 @@ const respondToSoundSwitchConfigurationGet: MockNodeBehavior = { receivedCC.endpointIndex, ), }; - const cc = new SoundSwitchCCConfigurationReport(self.host, { + const cc = new SoundSwitchCCConfigurationReport({ nodeId: controller.ownNodeId, defaultToneId: (self.state.get(StateKeys.defaultToneId) as number) @@ -87,7 +87,7 @@ const respondToSoundSwitchToneNumberGet: MockNodeBehavior = { receivedCC.endpointIndex, ), }; - const cc = new SoundSwitchCCTonesNumberReport(self.host, { + const cc = new SoundSwitchCCTonesNumberReport({ nodeId: controller.ownNodeId, toneCount: capabilities.tones.length, }); @@ -108,7 +108,7 @@ const respondToSoundSwitchToneInfoGet: MockNodeBehavior = { }; const tone = capabilities.tones[receivedCC.toneId - 1]; if (tone) { - const cc = new SoundSwitchCCToneInfoReport(self.host, { + const cc = new SoundSwitchCCToneInfoReport({ nodeId: controller.ownNodeId, toneId: receivedCC.toneId, ...tone, @@ -176,14 +176,11 @@ const respondToSoundSwitchTonePlaySet: MockNodeBehavior = { self.state.delete(StateKeys.state); // Tell the controller that we're done playing - const cc = new SoundSwitchCCTonePlayReport( - self.host, - { - nodeId: controller.ownNodeId, - toneId: 0, - volume: 0, - }, - ); + const cc = new SoundSwitchCCTonePlayReport({ + nodeId: controller.ownNodeId, + toneId: 0, + volume: 0, + }); await self.sendToController( createMockZWaveRequestFrame(cc, { ackRequested: false, @@ -207,14 +204,11 @@ const respondToSoundSwitchTonePlayGet: MockNodeBehavior = { StateKeys.state, ) as SoundSwitchState | undefined; - const cc = new SoundSwitchCCTonePlayReport( - self.host, - { - nodeId: controller.ownNodeId, - toneId: currentState?.toneId ?? 0, - volume: currentState?.volume ?? 0, - }, - ); + const cc = new SoundSwitchCCTonePlayReport({ + nodeId: controller.ownNodeId, + toneId: currentState?.toneId ?? 0, + volume: currentState?.volume ?? 0, + }); return { action: "sendCC", cc }; } diff --git a/packages/zwave-js/src/lib/node/mockCCBehaviors/ThermostatMode.ts b/packages/zwave-js/src/lib/node/mockCCBehaviors/ThermostatMode.ts index bac3e9bfb740..32c9c58e8d89 100644 --- a/packages/zwave-js/src/lib/node/mockCCBehaviors/ThermostatMode.ts +++ b/packages/zwave-js/src/lib/node/mockCCBehaviors/ThermostatMode.ts @@ -45,7 +45,7 @@ const respondToThermostatModeGet: MockNodeBehavior = { ? self.state.get(StateKeys.manufacturerData) : undefined; - const cc = new ThermostatModeCCReport(self.host, { + const cc = new ThermostatModeCCReport({ nodeId: controller.ownNodeId, mode, // @ts-expect-error I know... @@ -67,7 +67,7 @@ const respondToThermostatModeSupportedGet: MockNodeBehavior = { ), }; - const cc = new ThermostatModeCCSupportedReport(self.host, { + const cc = new ThermostatModeCCSupportedReport({ nodeId: controller.ownNodeId, supportedModes: capabilities.supportedModes, }); diff --git a/packages/zwave-js/src/lib/node/mockCCBehaviors/ThermostatSetback.ts b/packages/zwave-js/src/lib/node/mockCCBehaviors/ThermostatSetback.ts index 1831e75f3c4a..794a3e1bab1c 100644 --- a/packages/zwave-js/src/lib/node/mockCCBehaviors/ThermostatSetback.ts +++ b/packages/zwave-js/src/lib/node/mockCCBehaviors/ThermostatSetback.ts @@ -34,7 +34,7 @@ const respondToThermostatSetbackGet: MockNodeBehavior = { ?? "Unused" ) as SetbackState; - const cc = new ThermostatSetbackCCReport(self.host, { + const cc = new ThermostatSetbackCCReport({ nodeId: controller.ownNodeId, setbackType, setbackState, diff --git a/packages/zwave-js/src/lib/node/mockCCBehaviors/ThermostatSetpoint.ts b/packages/zwave-js/src/lib/node/mockCCBehaviors/ThermostatSetpoint.ts index 36809cef47df..dac9ba334d58 100644 --- a/packages/zwave-js/src/lib/node/mockCCBehaviors/ThermostatSetpoint.ts +++ b/packages/zwave-js/src/lib/node/mockCCBehaviors/ThermostatSetpoint.ts @@ -98,14 +98,14 @@ const respondToThermostatSetpointGet: MockNodeBehavior = { let cc: ThermostatSetpointCCReport; if (value !== undefined) { - cc = new ThermostatSetpointCCReport(self.host, { + cc = new ThermostatSetpointCCReport({ nodeId: controller.ownNodeId, type: setpointType, value, scale: scale ?? 0, }); } else { - cc = new ThermostatSetpointCCReport(self.host, { + cc = new ThermostatSetpointCCReport({ nodeId: controller.ownNodeId, type: ThermostatSetpointType["N/A"], scale: 0, @@ -128,7 +128,7 @@ const respondToThermostatSetpointSupportedGet: MockNodeBehavior = { ), }; - const cc = new ThermostatSetpointCCSupportedReport(self.host, { + const cc = new ThermostatSetpointCCSupportedReport({ nodeId: controller.ownNodeId, supportedSetpointTypes: Object.keys(capabilities.setpoints).map( (k) => parseInt(k), @@ -155,7 +155,7 @@ const respondToThermostatSetpointCapabilitiesGet: MockNodeBehavior = { let cc: ThermostatSetpointCCCapabilitiesReport; if (setpointCaps) { - cc = new ThermostatSetpointCCCapabilitiesReport(self.host, { + cc = new ThermostatSetpointCCCapabilitiesReport({ nodeId: controller.ownNodeId, type: setpointType, minValue: setpointCaps.minValue, @@ -164,7 +164,7 @@ const respondToThermostatSetpointCapabilitiesGet: MockNodeBehavior = { maxValueScale: setpointCaps.scale === "°C" ? 0 : 1, }); } else { - cc = new ThermostatSetpointCCCapabilitiesReport(self.host, { + cc = new ThermostatSetpointCCCapabilitiesReport({ nodeId: controller.ownNodeId, type: ThermostatSetpointType["N/A"], minValue: 0, diff --git a/packages/zwave-js/src/lib/node/mockCCBehaviors/UserCode.ts b/packages/zwave-js/src/lib/node/mockCCBehaviors/UserCode.ts index f12c9537aec6..c72a8369a610 100644 --- a/packages/zwave-js/src/lib/node/mockCCBehaviors/UserCode.ts +++ b/packages/zwave-js/src/lib/node/mockCCBehaviors/UserCode.ts @@ -55,7 +55,7 @@ const respondToUsersNumberGet: MockNodeBehavior = { receivedCC.endpointIndex, ), }; - const cc = new UserCodeCCUsersNumberReport(self.host, { + const cc = new UserCodeCCUsersNumberReport({ nodeId: controller.ownNodeId, supportedUsers: capabilities.numUsers ?? 1, }); @@ -77,7 +77,7 @@ const respondToUserGet: MockNodeBehavior = { const userId = receivedCC.userId; let cc: UserCodeCCReport; if (capabilities.numUsers >= userId) { - cc = new UserCodeCCReport(self.host, { + cc = new UserCodeCCReport({ nodeId: controller.ownNodeId, userId, userIdStatus: (self.state.get( @@ -88,7 +88,7 @@ const respondToUserGet: MockNodeBehavior = { ) as string, }); } else { - cc = new UserCodeCCReport(self.host, { + cc = new UserCodeCCReport({ nodeId: controller.ownNodeId, userId, userIdStatus: UserIDStatus.StatusNotAvailable, @@ -137,7 +137,7 @@ const respondToUserCodeCapabilitiesGet: MockNodeBehavior = { receivedCC.endpointIndex, ), }; - const cc = new UserCodeCCCapabilitiesReport(self.host, { + const cc = new UserCodeCCCapabilitiesReport({ nodeId: controller.ownNodeId, supportsAdminCode: capabilities.supportsAdminCode!, supportsAdminCodeDeactivation: capabilities @@ -165,7 +165,7 @@ const respondToUserCodeKeypadModeGet: MockNodeBehavior = { receivedCC.endpointIndex, ), }; - const cc = new UserCodeCCKeypadModeReport(self.host, { + const cc = new UserCodeCCKeypadModeReport({ nodeId: controller.ownNodeId, keypadMode: (self.state.get(StateKeys.keypadMode) ?? capabilities.supportedKeypadModes?.[0] @@ -242,7 +242,7 @@ const respondToUserCodeAdminCodeGet: MockNodeBehavior = { adminCode = self.state.get(StateKeys.adminCode) as string; } - const cc = new UserCodeCCAdminCodeReport(self.host, { + const cc = new UserCodeCCAdminCodeReport({ nodeId: controller.ownNodeId, adminCode: adminCode ?? "", }); @@ -289,7 +289,7 @@ const respondToUserCodeUserCodeChecksumGet: MockNodeBehavior = { const checksum = data.length > 0 ? CRC16_CCITT(data) : 0x0000; - const cc = new UserCodeCCUserCodeChecksumReport(self.host, { + const cc = new UserCodeCCUserCodeChecksumReport({ nodeId: controller.ownNodeId, userCodeChecksum: checksum, }); diff --git a/packages/zwave-js/src/lib/node/mockCCBehaviors/WindowCovering.ts b/packages/zwave-js/src/lib/node/mockCCBehaviors/WindowCovering.ts index e58846dc4fff..1ac1647d50ff 100644 --- a/packages/zwave-js/src/lib/node/mockCCBehaviors/WindowCovering.ts +++ b/packages/zwave-js/src/lib/node/mockCCBehaviors/WindowCovering.ts @@ -22,7 +22,7 @@ const respondToWindowCoveringSupportedGet: MockNodeBehavior = { receivedCC.endpointIndex, ), }; - const cc = new WindowCoveringCCSupportedReport(self.host, { + const cc = new WindowCoveringCCSupportedReport({ nodeId: controller.ownNodeId, supportedParameters: capabilities.supportedParameters, }); diff --git a/packages/zwave-js/src/lib/node/utils.ts b/packages/zwave-js/src/lib/node/utils.ts index 6c8e14e56443..dd98b3252e41 100644 --- a/packages/zwave-js/src/lib/node/utils.ts +++ b/packages/zwave-js/src/lib/node/utils.ts @@ -235,7 +235,6 @@ export function translateValueID( ...valueId, }; const ccInstance = CommandClass.createInstanceUnchecked( - applHost, endpoint, valueId.commandClass, ); @@ -351,7 +350,6 @@ export function getDefinedValueIDsInternal( || cc === CommandClasses.Basic ) { const ccInstance = CommandClass.createInstanceUnchecked( - applHost, endpoint, cc, ); diff --git a/packages/zwave-js/src/lib/serialapi/application/ApplicationCommandRequest.ts b/packages/zwave-js/src/lib/serialapi/application/ApplicationCommandRequest.ts index a958a04ac16f..be1f8c2cf027 100644 --- a/packages/zwave-js/src/lib/serialapi/application/ApplicationCommandRequest.ts +++ b/packages/zwave-js/src/lib/serialapi/application/ApplicationCommandRequest.ts @@ -10,7 +10,6 @@ import { encodeNodeID, parseNodeID, } from "@zwave-js/core"; -import type { ZWaveHost } from "@zwave-js/host"; import { FunctionType, Message, @@ -51,12 +50,11 @@ export class ApplicationCommandRequest extends Message implements ICommandClassContainer { public constructor( - host: ZWaveHost, options: | MessageDeserializationOptions | ApplicationCommandRequestOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { // first byte is a status flag const status = this.payload[0]; @@ -92,7 +90,7 @@ export class ApplicationCommandRequest extends Message offset += nodeIdBytes; // and a command class const commandLength = this.payload[offset++]; - this.command = CommandClass.from(this.host, { + this.command = CommandClass.from({ data: this.payload.subarray(offset, offset + commandLength), nodeId, origin: options.origin, diff --git a/packages/zwave-js/src/lib/serialapi/application/ApplicationUpdateRequest.ts b/packages/zwave-js/src/lib/serialapi/application/ApplicationUpdateRequest.ts index 7facc83d7aea..11d61cd26831 100644 --- a/packages/zwave-js/src/lib/serialapi/application/ApplicationUpdateRequest.ts +++ b/packages/zwave-js/src/lib/serialapi/application/ApplicationUpdateRequest.ts @@ -11,7 +11,6 @@ import { parseNodeID, parseNodeUpdatePayload, } from "@zwave-js/core"; -import type { ZWaveHost } from "@zwave-js/host"; import { type DeserializingMessageConstructor, FunctionType, @@ -55,8 +54,8 @@ const { @messageTypes(MessageType.Request, FunctionType.ApplicationUpdateRequest) // this is only received, not sent! export class ApplicationUpdateRequest extends Message { - public constructor(host: ZWaveHost, options?: MessageOptions) { - super(host, options); + public constructor(options?: MessageOptions) { + super(options); if (gotDeserializationOptions(options)) { this.updateType = this.payload[0]; @@ -68,7 +67,7 @@ export class ApplicationUpdateRequest extends Message { CommandConstructor && (new.target as any) !== CommandConstructor ) { - return new CommandConstructor(host, options); + return new CommandConstructor(options); } this.payload = this.payload.subarray(1); @@ -98,12 +97,11 @@ export class ApplicationUpdateRequestWithNodeInfo extends ApplicationUpdateRequest { public constructor( - host: ZWaveHost, options: | MessageDeserializationOptions | ApplicationUpdateRequestWithNodeInfoOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { this.nodeInformation = parseNodeUpdatePayload( @@ -154,10 +152,9 @@ export class ApplicationUpdateRequestNodeRemoved extends ApplicationUpdateRequest { public constructor( - host: ZWaveHost, options: MessageDeserializationOptions, ) { - super(host, options); + super(options); const { nodeId } = parseNodeID(this.payload, options.ctx.nodeIdType, 0); this.nodeId = nodeId; @@ -171,10 +168,9 @@ class ApplicationUpdateRequestSmartStartHomeIDReceivedBase extends ApplicationUpdateRequest { public constructor( - host: ZWaveHost, options: MessageDeserializationOptions, ) { - super(host, options); + super(options); let offset = 0; const { nodeId, bytesRead: nodeIdBytes } = parseNodeID( this.payload, @@ -246,10 +242,9 @@ export class ApplicationUpdateRequestSUCIdChanged extends ApplicationUpdateRequest { public constructor( - host: ZWaveHost, options: MessageDeserializationOptions, ) { - super(host, options); + super(options); const { nodeId } = parseNodeID(this.payload, options.ctx.nodeIdType, 0); this.sucNodeID = nodeId; diff --git a/packages/zwave-js/src/lib/serialapi/application/BridgeApplicationCommandRequest.ts b/packages/zwave-js/src/lib/serialapi/application/BridgeApplicationCommandRequest.ts index 2b11230284e6..73baeb18babf 100644 --- a/packages/zwave-js/src/lib/serialapi/application/BridgeApplicationCommandRequest.ts +++ b/packages/zwave-js/src/lib/serialapi/application/BridgeApplicationCommandRequest.ts @@ -13,7 +13,6 @@ import { parseNodeBitMask, parseNodeID, } from "@zwave-js/core"; -import type { ZWaveHost } from "@zwave-js/host"; import { FunctionType, Message, @@ -33,10 +32,9 @@ export class BridgeApplicationCommandRequest extends Message implements ICommandClassContainer { public constructor( - host: ZWaveHost, options: MessageDeserializationOptions, ) { - super(host, options); + super(options); this._ownNodeId = options.ctx.ownNodeId; // if (gotDeserializationOptions(options)) { @@ -74,7 +72,7 @@ export class BridgeApplicationCommandRequest extends Message offset += srcNodeIdBytes; // Parse the CC const commandLength = this.payload[offset++]; - this.command = CommandClass.from(this.host, { + this.command = CommandClass.from({ data: this.payload.subarray(offset, offset + commandLength), nodeId: sourceNodeId, origin: options.origin, diff --git a/packages/zwave-js/src/lib/serialapi/application/SerialAPIStartedRequest.ts b/packages/zwave-js/src/lib/serialapi/application/SerialAPIStartedRequest.ts index 028f0782a53a..10adc96cf2be 100644 --- a/packages/zwave-js/src/lib/serialapi/application/SerialAPIStartedRequest.ts +++ b/packages/zwave-js/src/lib/serialapi/application/SerialAPIStartedRequest.ts @@ -5,7 +5,6 @@ import { encodeCCList, parseCCList, } from "@zwave-js/core"; -import type { ZWaveHost } from "@zwave-js/host"; import { FunctionType, Message, @@ -60,10 +59,9 @@ export interface SerialAPIStartedRequestOptions extends MessageBaseOptions { @priority(MessagePriority.Normal) export class SerialAPIStartedRequest extends Message { public constructor( - host: ZWaveHost, options: MessageDeserializationOptions | SerialAPIStartedRequestOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { this.wakeUpReason = this.payload[0]; diff --git a/packages/zwave-js/src/lib/serialapi/application/ShutdownMessages.ts b/packages/zwave-js/src/lib/serialapi/application/ShutdownMessages.ts index ee6fd3212a26..e2f58de80106 100644 --- a/packages/zwave-js/src/lib/serialapi/application/ShutdownMessages.ts +++ b/packages/zwave-js/src/lib/serialapi/application/ShutdownMessages.ts @@ -1,5 +1,4 @@ import { type MessageOrCCLogEntry, MessagePriority } from "@zwave-js/core"; -import type { ZWaveHost } from "@zwave-js/host"; import { FunctionType, Message, @@ -23,10 +22,9 @@ export class ShutdownRequest extends Message {} @messageTypes(MessageType.Response, FunctionType.Shutdown) export class ShutdownResponse extends Message { public constructor( - host: ZWaveHost, options: MessageDeserializationOptions, ) { - super(host, options); + super(options); this.success = this.payload[0] !== 0; } diff --git a/packages/zwave-js/src/lib/serialapi/capability/GetControllerCapabilitiesMessages.ts b/packages/zwave-js/src/lib/serialapi/capability/GetControllerCapabilitiesMessages.ts index 15b08a5a3be3..b3cfe7bcdb9a 100644 --- a/packages/zwave-js/src/lib/serialapi/capability/GetControllerCapabilitiesMessages.ts +++ b/packages/zwave-js/src/lib/serialapi/capability/GetControllerCapabilitiesMessages.ts @@ -1,5 +1,4 @@ import { ControllerCapabilityFlags, MessagePriority } from "@zwave-js/core"; -import type { ZWaveHost } from "@zwave-js/host"; import { FunctionType, Message, @@ -32,12 +31,11 @@ export interface GetControllerCapabilitiesResponseOptions @messageTypes(MessageType.Response, FunctionType.GetControllerCapabilities) export class GetControllerCapabilitiesResponse extends Message { public constructor( - host: ZWaveHost, options: | MessageDeserializationOptions | GetControllerCapabilitiesResponseOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { const capabilityFlags = this.payload[0]; diff --git a/packages/zwave-js/src/lib/serialapi/capability/GetControllerVersionMessages.ts b/packages/zwave-js/src/lib/serialapi/capability/GetControllerVersionMessages.ts index d642a83493e2..78a34fe8aecf 100644 --- a/packages/zwave-js/src/lib/serialapi/capability/GetControllerVersionMessages.ts +++ b/packages/zwave-js/src/lib/serialapi/capability/GetControllerVersionMessages.ts @@ -1,5 +1,4 @@ import { MessagePriority } from "@zwave-js/core"; -import type { ZWaveHost } from "@zwave-js/host"; import { FunctionType, Message, @@ -30,12 +29,11 @@ export interface GetControllerVersionResponseOptions @messageTypes(MessageType.Response, FunctionType.GetControllerVersion) export class GetControllerVersionResponse extends Message { public constructor( - host: ZWaveHost, options: | MessageDeserializationOptions | GetControllerVersionResponseOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { // The payload consists of a zero-terminated string and a uint8 for the controller type diff --git a/packages/zwave-js/src/lib/serialapi/capability/GetLongRangeNodesMessages.ts b/packages/zwave-js/src/lib/serialapi/capability/GetLongRangeNodesMessages.ts index f92b098ffc3e..e16ed603837c 100644 --- a/packages/zwave-js/src/lib/serialapi/capability/GetLongRangeNodesMessages.ts +++ b/packages/zwave-js/src/lib/serialapi/capability/GetLongRangeNodesMessages.ts @@ -5,7 +5,6 @@ import { encodeLongRangeNodeBitMask, parseLongRangeNodeBitMask, } from "@zwave-js/core"; -import type { ZWaveHost } from "@zwave-js/host"; import { FunctionType, Message, @@ -28,12 +27,11 @@ export interface GetLongRangeNodesRequestOptions extends MessageBaseOptions { @priority(MessagePriority.Controller) export class GetLongRangeNodesRequest extends Message { public constructor( - host: ZWaveHost, options: | MessageDeserializationOptions | GetLongRangeNodesRequestOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { this.segmentNumber = this.payload[0]; @@ -59,12 +57,11 @@ export interface GetLongRangeNodesResponseOptions extends MessageBaseOptions { @messageTypes(MessageType.Response, FunctionType.GetLongRangeNodes) export class GetLongRangeNodesResponse extends Message { public constructor( - host: ZWaveHost, options: | MessageDeserializationOptions | GetLongRangeNodesResponseOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { this.moreNodes = this.payload[0] != 0; diff --git a/packages/zwave-js/src/lib/serialapi/capability/GetProtocolVersionMessages.ts b/packages/zwave-js/src/lib/serialapi/capability/GetProtocolVersionMessages.ts index 8bd2d83b8630..dbb5c5a54d3f 100644 --- a/packages/zwave-js/src/lib/serialapi/capability/GetProtocolVersionMessages.ts +++ b/packages/zwave-js/src/lib/serialapi/capability/GetProtocolVersionMessages.ts @@ -1,6 +1,5 @@ import type { ProtocolType } from "@zwave-js/core"; import { MessagePriority } from "@zwave-js/core"; -import type { ZWaveHost } from "@zwave-js/host"; import { FunctionType, Message, @@ -19,10 +18,9 @@ export class GetProtocolVersionRequest extends Message {} @messageTypes(MessageType.Response, FunctionType.GetProtocolVersion) export class GetProtocolVersionResponse extends Message { public constructor( - host: ZWaveHost, options: MessageDeserializationOptions, ) { - super(host, options); + super(options); this.protocolType = this.payload[0]; this.protocolVersion = [ this.payload[1], diff --git a/packages/zwave-js/src/lib/serialapi/capability/GetSerialApiCapabilitiesMessages.ts b/packages/zwave-js/src/lib/serialapi/capability/GetSerialApiCapabilitiesMessages.ts index 032a2b2ec4dc..7cfca7b6d858 100644 --- a/packages/zwave-js/src/lib/serialapi/capability/GetSerialApiCapabilitiesMessages.ts +++ b/packages/zwave-js/src/lib/serialapi/capability/GetSerialApiCapabilitiesMessages.ts @@ -1,5 +1,4 @@ import { MessagePriority, encodeBitMask, parseBitMask } from "@zwave-js/core"; -import type { ZWaveHost } from "@zwave-js/host"; import { FunctionType, Message, @@ -34,12 +33,11 @@ export interface GetSerialApiCapabilitiesResponseOptions @messageTypes(MessageType.Response, FunctionType.GetSerialApiCapabilities) export class GetSerialApiCapabilitiesResponse extends Message { public constructor( - host: ZWaveHost, options: | MessageDeserializationOptions | GetSerialApiCapabilitiesResponseOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { // The first 8 bytes are the api version, manufacturer id, product type and product id diff --git a/packages/zwave-js/src/lib/serialapi/capability/GetSerialApiInitDataMessages.ts b/packages/zwave-js/src/lib/serialapi/capability/GetSerialApiInitDataMessages.ts index 9059e4cdaca2..aa57539c5d26 100644 --- a/packages/zwave-js/src/lib/serialapi/capability/GetSerialApiInitDataMessages.ts +++ b/packages/zwave-js/src/lib/serialapi/capability/GetSerialApiInitDataMessages.ts @@ -12,7 +12,6 @@ import { getChipTypeAndVersion, getZWaveChipType, } from "@zwave-js/core"; -import type { ZWaveHost } from "@zwave-js/host"; import { FunctionType, Message, @@ -39,12 +38,11 @@ export interface GetSerialApiInitDataResponseOptions @messageTypes(MessageType.Response, FunctionType.GetSerialApiInitData) export class GetSerialApiInitDataResponse extends Message { public constructor( - host: ZWaveHost, options: | MessageDeserializationOptions | GetSerialApiInitDataResponseOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { const apiVersion = this.payload[0]; diff --git a/packages/zwave-js/src/lib/serialapi/capability/HardResetRequest.ts b/packages/zwave-js/src/lib/serialapi/capability/HardResetRequest.ts index ab84895c044f..cf7e121a4bc0 100644 --- a/packages/zwave-js/src/lib/serialapi/capability/HardResetRequest.ts +++ b/packages/zwave-js/src/lib/serialapi/capability/HardResetRequest.ts @@ -1,6 +1,5 @@ import type { MessageOrCCLogEntry } from "@zwave-js/core"; import { MessagePriority } from "@zwave-js/core"; -import type { ZWaveHost } from "@zwave-js/host"; import { FunctionType, Message, @@ -18,21 +17,21 @@ import { @messageTypes(MessageType.Request, FunctionType.HardReset) @priority(MessagePriority.Controller) export class HardResetRequestBase extends Message { - public constructor(host: ZWaveHost, options?: MessageOptions) { + public constructor(options?: MessageOptions) { if (gotDeserializationOptions(options)) { if ( options.origin === MessageOrigin.Host && (new.target as any) !== HardResetRequest ) { - return new HardResetRequest(host, options); + return new HardResetRequest(options); } else if ( options.origin !== MessageOrigin.Host && (new.target as any) !== HardResetCallback ) { - return new HardResetCallback(host, options); + return new HardResetCallback(options); } } - super(host, options); + super(options); } } @@ -56,10 +55,9 @@ export class HardResetRequest extends HardResetRequestBase { export class HardResetCallback extends HardResetRequestBase { public constructor( - host: ZWaveHost, options: MessageDeserializationOptions, ) { - super(host, options); + super(options); this.callbackId = this.payload[0]; } diff --git a/packages/zwave-js/src/lib/serialapi/capability/LongRangeChannelMessages.ts b/packages/zwave-js/src/lib/serialapi/capability/LongRangeChannelMessages.ts index d21ba28d63cb..d77d783a9b92 100644 --- a/packages/zwave-js/src/lib/serialapi/capability/LongRangeChannelMessages.ts +++ b/packages/zwave-js/src/lib/serialapi/capability/LongRangeChannelMessages.ts @@ -5,7 +5,6 @@ import { ZWaveErrorCodes, } from "@zwave-js/core"; import { LongRangeChannel } from "@zwave-js/core"; -import type { ZWaveHost } from "@zwave-js/host"; import { FunctionType, Message, @@ -30,10 +29,9 @@ export class GetLongRangeChannelRequest extends Message {} @priority(MessagePriority.Controller) export class GetLongRangeChannelResponse extends Message { public constructor( - host: ZWaveHost, options: MessageDeserializationOptions, ) { - super(host, options); + super(options); this.channel = this.payload[0]; if (this.payload.length >= 2) { @@ -63,12 +61,11 @@ export interface SetLongRangeChannelRequestOptions extends MessageBaseOptions { @expectedResponse(FunctionType.SetLongRangeChannel) export class SetLongRangeChannelRequest extends Message { public constructor( - host: ZWaveHost, options: | MessageDeserializationOptions | SetLongRangeChannelRequestOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { throw new ZWaveError( `${this.constructor.name}: deserialization not implemented`, @@ -101,10 +98,9 @@ export class SetLongRangeChannelResponse extends Message implements SuccessIndicator { public constructor( - host: ZWaveHost, options: MessageDeserializationOptions, ) { - super(host, options); + super(options); this.success = this.payload[0] !== 0; } diff --git a/packages/zwave-js/src/lib/serialapi/capability/SerialAPISetupMessages.ts b/packages/zwave-js/src/lib/serialapi/capability/SerialAPISetupMessages.ts index 45cc16b23240..1e048bcc3919 100644 --- a/packages/zwave-js/src/lib/serialapi/capability/SerialAPISetupMessages.ts +++ b/packages/zwave-js/src/lib/serialapi/capability/SerialAPISetupMessages.ts @@ -10,7 +10,6 @@ import { parseBitMask, validatePayload, } from "@zwave-js/core"; -import type { ZWaveHost } from "@zwave-js/host"; import type { DeserializingMessageConstructor, MessageEncodingContext, @@ -87,8 +86,8 @@ function testResponseForSerialAPISetupRequest( @priority(MessagePriority.Controller) @expectedResponse(testResponseForSerialAPISetupRequest) export class SerialAPISetupRequest extends Message { - public constructor(host: ZWaveHost, options: MessageOptions = {}) { - super(host, options); + public constructor(options: MessageOptions = {}) { + super(options); if (gotDeserializationOptions(options)) { throw new ZWaveError( `${this.constructor.name}: deserialization not implemented`, @@ -127,17 +126,16 @@ export class SerialAPISetupRequest extends Message { @messageTypes(MessageType.Response, FunctionType.SerialAPISetup) export class SerialAPISetupResponse extends Message { public constructor( - host: ZWaveHost, options: MessageDeserializationOptions, ) { - super(host, options); + super(options); this.command = this.payload[0]; const CommandConstructor = getSubCommandResponseConstructor( this.command, ); if (CommandConstructor && (new.target as any) !== CommandConstructor) { - return new CommandConstructor(host, options); + return new CommandConstructor(options); } this.payload = this.payload.subarray(1); @@ -164,10 +162,9 @@ export class SerialAPISetup_CommandUnsupportedResponse extends SerialAPISetupResponse { public constructor( - host: ZWaveHost, options: MessageDeserializationOptions, ) { - super(host, options); + super(options); // The payload contains which command is unsupported this.command = this.payload[0]; } @@ -191,8 +188,8 @@ export class SerialAPISetup_CommandUnsupportedResponse export class SerialAPISetup_GetSupportedCommandsRequest extends SerialAPISetupRequest { - public constructor(host: ZWaveHost, options?: MessageOptions) { - super(host, options); + public constructor(options?: MessageOptions) { + super(options); this.command = SerialAPISetupCommand.GetSupportedCommands; } } @@ -202,10 +199,9 @@ export class SerialAPISetup_GetSupportedCommandsResponse extends SerialAPISetupResponse { public constructor( - host: ZWaveHost, options: MessageDeserializationOptions, ) { - super(host, options); + super(options); validatePayload(this.payload.length >= 1); if (this.payload.length > 1) { @@ -267,12 +263,11 @@ export class SerialAPISetup_SetTXStatusReportRequest extends SerialAPISetupRequest { public constructor( - host: ZWaveHost, options: | MessageDeserializationOptions | SerialAPISetup_SetTXStatusReportOptions, ) { - super(host, options); + super(options); this.command = SerialAPISetupCommand.SetTxStatusReport; if (gotDeserializationOptions(options)) { @@ -308,10 +303,9 @@ export class SerialAPISetup_SetTXStatusReportResponse implements SuccessIndicator { public constructor( - host: ZWaveHost, options: MessageDeserializationOptions, ) { - super(host, options); + super(options); this.success = this.payload[0] !== 0; } @@ -341,12 +335,11 @@ export interface SerialAPISetup_SetNodeIDTypeOptions @subCommandRequest(SerialAPISetupCommand.SetNodeIDType) export class SerialAPISetup_SetNodeIDTypeRequest extends SerialAPISetupRequest { public constructor( - host: ZWaveHost, options: | MessageDeserializationOptions | SerialAPISetup_SetNodeIDTypeOptions, ) { - super(host, options); + super(options); this.command = SerialAPISetupCommand.SetNodeIDType; if (gotDeserializationOptions(options)) { @@ -383,10 +376,9 @@ export class SerialAPISetup_SetNodeIDTypeResponse extends SerialAPISetupResponse implements SuccessIndicator { public constructor( - host: ZWaveHost, options: MessageDeserializationOptions, ) { - super(host, options); + super(options); this.success = this.payload[0] !== 0; } @@ -409,8 +401,8 @@ export class SerialAPISetup_SetNodeIDTypeResponse extends SerialAPISetupResponse @subCommandRequest(SerialAPISetupCommand.GetRFRegion) export class SerialAPISetup_GetRFRegionRequest extends SerialAPISetupRequest { - public constructor(host: ZWaveHost, options?: MessageOptions) { - super(host, options); + public constructor(options?: MessageOptions) { + super(options); this.command = SerialAPISetupCommand.GetRFRegion; } } @@ -418,10 +410,9 @@ export class SerialAPISetup_GetRFRegionRequest extends SerialAPISetupRequest { @subCommandResponse(SerialAPISetupCommand.GetRFRegion) export class SerialAPISetup_GetRFRegionResponse extends SerialAPISetupResponse { public constructor( - host: ZWaveHost, options: MessageDeserializationOptions, ) { - super(host, options); + super(options); this.region = this.payload[0]; } @@ -445,12 +436,11 @@ export interface SerialAPISetup_SetRFRegionOptions extends MessageBaseOptions { @subCommandRequest(SerialAPISetupCommand.SetRFRegion) export class SerialAPISetup_SetRFRegionRequest extends SerialAPISetupRequest { public constructor( - host: ZWaveHost, options: | MessageDeserializationOptions | SerialAPISetup_SetRFRegionOptions, ) { - super(host, options); + super(options); this.command = SerialAPISetupCommand.SetRFRegion; if (gotDeserializationOptions(options)) { @@ -484,10 +474,9 @@ export class SerialAPISetup_SetRFRegionResponse extends SerialAPISetupResponse implements SuccessIndicator { public constructor( - host: ZWaveHost, options: MessageDeserializationOptions, ) { - super(host, options); + super(options); this.success = this.payload[0] !== 0; } @@ -510,8 +499,8 @@ export class SerialAPISetup_SetRFRegionResponse extends SerialAPISetupResponse @subCommandRequest(SerialAPISetupCommand.GetPowerlevel) export class SerialAPISetup_GetPowerlevelRequest extends SerialAPISetupRequest { - public constructor(host: ZWaveHost, options?: MessageOptions) { - super(host, options); + public constructor(options?: MessageOptions) { + super(options); this.command = SerialAPISetupCommand.GetPowerlevel; } } @@ -521,10 +510,9 @@ export class SerialAPISetup_GetPowerlevelResponse extends SerialAPISetupResponse { public constructor( - host: ZWaveHost, options: MessageDeserializationOptions, ) { - super(host, options); + super(options); validatePayload(this.payload.length >= 2); // The values are in 0.1 dBm, signed this.powerlevel = this.payload.readInt8(0) / 10; @@ -561,12 +549,11 @@ export interface SerialAPISetup_SetPowerlevelOptions @subCommandRequest(SerialAPISetupCommand.SetPowerlevel) export class SerialAPISetup_SetPowerlevelRequest extends SerialAPISetupRequest { public constructor( - host: ZWaveHost, options: | MessageDeserializationOptions | SerialAPISetup_SetPowerlevelOptions, ) { - super(host, options); + super(options); this.command = SerialAPISetupCommand.SetPowerlevel; if (gotDeserializationOptions(options)) { @@ -622,10 +609,9 @@ export class SerialAPISetup_SetPowerlevelResponse extends SerialAPISetupResponse implements SuccessIndicator { public constructor( - host: ZWaveHost, options: MessageDeserializationOptions, ) { - super(host, options); + super(options); this.success = this.payload[0] !== 0; } @@ -650,8 +636,8 @@ export class SerialAPISetup_SetPowerlevelResponse extends SerialAPISetupResponse export class SerialAPISetup_GetPowerlevel16BitRequest extends SerialAPISetupRequest { - public constructor(host: ZWaveHost, options?: MessageOptions) { - super(host, options); + public constructor(options?: MessageOptions) { + super(options); this.command = SerialAPISetupCommand.GetPowerlevel16Bit; } } @@ -661,10 +647,9 @@ export class SerialAPISetup_GetPowerlevel16BitResponse extends SerialAPISetupResponse { public constructor( - host: ZWaveHost, options: MessageDeserializationOptions, ) { - super(host, options); + super(options); validatePayload(this.payload.length >= 4); // The values are in 0.1 dBm, signed this.powerlevel = this.payload.readInt16BE(0) / 10; @@ -703,12 +688,11 @@ export class SerialAPISetup_SetPowerlevel16BitRequest extends SerialAPISetupRequest { public constructor( - host: ZWaveHost, options: | MessageDeserializationOptions | SerialAPISetup_SetPowerlevel16BitOptions, ) { - super(host, options); + super(options); this.command = SerialAPISetupCommand.SetPowerlevel16Bit; if (gotDeserializationOptions(options)) { @@ -765,10 +749,9 @@ export class SerialAPISetup_SetPowerlevel16BitResponse implements SuccessIndicator { public constructor( - host: ZWaveHost, options: MessageDeserializationOptions, ) { - super(host, options); + super(options); this.success = this.payload[0] !== 0; } @@ -793,8 +776,8 @@ export class SerialAPISetup_SetPowerlevel16BitResponse export class SerialAPISetup_GetLongRangeMaximumTxPowerRequest extends SerialAPISetupRequest { - public constructor(host: ZWaveHost, options?: MessageOptions) { - super(host, options); + public constructor(options?: MessageOptions) { + super(options); this.command = SerialAPISetupCommand.GetLongRangeMaximumTxPower; } } @@ -804,10 +787,9 @@ export class SerialAPISetup_GetLongRangeMaximumTxPowerResponse extends SerialAPISetupResponse { public constructor( - host: ZWaveHost, options: MessageDeserializationOptions, ) { - super(host, options); + super(options); validatePayload(this.payload.length >= 2); // The values are in 0.1 dBm, signed this.limit = this.payload.readInt16BE(0) / 10; @@ -841,12 +823,11 @@ export class SerialAPISetup_SetLongRangeMaximumTxPowerRequest extends SerialAPISetupRequest { public constructor( - host: ZWaveHost, options: | MessageDeserializationOptions | SerialAPISetup_SetLongRangeMaximumTxPowerOptions, ) { - super(host, options); + super(options); this.command = SerialAPISetupCommand.SetLongRangeMaximumTxPower; if (gotDeserializationOptions(options)) { @@ -895,10 +876,9 @@ export class SerialAPISetup_SetLongRangeMaximumTxPowerResponse implements SuccessIndicator { public constructor( - host: ZWaveHost, options: MessageDeserializationOptions, ) { - super(host, options); + super(options); this.success = this.payload[0] !== 0; } @@ -923,8 +903,8 @@ export class SerialAPISetup_SetLongRangeMaximumTxPowerResponse export class SerialAPISetup_GetMaximumPayloadSizeRequest extends SerialAPISetupRequest { - public constructor(host: ZWaveHost, options?: MessageOptions) { - super(host, options); + public constructor(options?: MessageOptions) { + super(options); this.command = SerialAPISetupCommand.GetMaximumPayloadSize; } } @@ -934,10 +914,9 @@ export class SerialAPISetup_GetMaximumPayloadSizeResponse extends SerialAPISetupResponse { public constructor( - host: ZWaveHost, options: MessageDeserializationOptions, ) { - super(host, options); + super(options); this.maxPayloadSize = this.payload[0]; } @@ -958,8 +937,8 @@ export class SerialAPISetup_GetMaximumPayloadSizeResponse export class SerialAPISetup_GetLongRangeMaximumPayloadSizeRequest extends SerialAPISetupRequest { - public constructor(host: ZWaveHost, options?: MessageOptions) { - super(host, options); + public constructor(options?: MessageOptions) { + super(options); this.command = SerialAPISetupCommand.GetLongRangeMaximumPayloadSize; } } @@ -969,10 +948,9 @@ export class SerialAPISetup_GetLongRangeMaximumPayloadSizeResponse extends SerialAPISetupResponse { public constructor( - host: ZWaveHost, options: MessageDeserializationOptions, ) { - super(host, options); + super(options); this.maxPayloadSize = this.payload[0]; } @@ -993,8 +971,8 @@ export class SerialAPISetup_GetLongRangeMaximumPayloadSizeResponse export class SerialAPISetup_GetSupportedRegionsRequest extends SerialAPISetupRequest { - public constructor(host: ZWaveHost, options?: MessageOptions) { - super(host, options); + public constructor(options?: MessageOptions) { + super(options); this.command = SerialAPISetupCommand.GetSupportedRegions; } } @@ -1004,10 +982,9 @@ export class SerialAPISetup_GetSupportedRegionsResponse extends SerialAPISetupResponse { public constructor( - host: ZWaveHost, options: MessageDeserializationOptions, ) { - super(host, options); + super(options); validatePayload(this.payload.length >= 1); const numRegions = this.payload[0]; @@ -1030,12 +1007,11 @@ export interface SerialAPISetup_GetRegionInfoOptions @subCommandRequest(SerialAPISetupCommand.GetRegionInfo) export class SerialAPISetup_GetRegionInfoRequest extends SerialAPISetupRequest { public constructor( - host: ZWaveHost, options: | MessageDeserializationOptions | SerialAPISetup_GetRegionInfoOptions, ) { - super(host, options); + super(options); this.command = SerialAPISetupCommand.GetRegionInfo; if (gotDeserializationOptions(options)) { @@ -1072,10 +1048,9 @@ export class SerialAPISetup_GetRegionInfoResponse extends SerialAPISetupResponse { public constructor( - host: ZWaveHost, options: MessageDeserializationOptions, ) { - super(host, options); + super(options); this.region = this.payload[0]; this.supportsZWave = !!(this.payload[1] & 0b1); this.supportsLongRange = !!(this.payload[1] & 0b10); diff --git a/packages/zwave-js/src/lib/serialapi/capability/SetApplicationNodeInformationRequest.ts b/packages/zwave-js/src/lib/serialapi/capability/SetApplicationNodeInformationRequest.ts index 5ea1fed5107b..2fc8f9c42bba 100644 --- a/packages/zwave-js/src/lib/serialapi/capability/SetApplicationNodeInformationRequest.ts +++ b/packages/zwave-js/src/lib/serialapi/capability/SetApplicationNodeInformationRequest.ts @@ -5,7 +5,6 @@ import { encodeCCList, getCCName, } from "@zwave-js/core"; -import type { ZWaveHost } from "@zwave-js/host"; import { FunctionType, Message, @@ -31,10 +30,9 @@ export interface SetApplicationNodeInformationRequestOptions @priority(MessagePriority.Controller) export class SetApplicationNodeInformationRequest extends Message { public constructor( - host: ZWaveHost, options: SetApplicationNodeInformationRequestOptions, ) { - super(host, options); + super(options); this.isListening = options.isListening; this.genericDeviceClass = options.genericDeviceClass; this.specificDeviceClass = options.specificDeviceClass; diff --git a/packages/zwave-js/src/lib/serialapi/capability/SetLongRangeShadowNodeIDsRequest.ts b/packages/zwave-js/src/lib/serialapi/capability/SetLongRangeShadowNodeIDsRequest.ts index c20cdc92cfb0..079df6cfc39b 100644 --- a/packages/zwave-js/src/lib/serialapi/capability/SetLongRangeShadowNodeIDsRequest.ts +++ b/packages/zwave-js/src/lib/serialapi/capability/SetLongRangeShadowNodeIDsRequest.ts @@ -1,5 +1,4 @@ import { MessagePriority, encodeBitMask, parseBitMask } from "@zwave-js/core"; -import type { ZWaveHost } from "@zwave-js/host"; import { FunctionType, Message, @@ -25,12 +24,11 @@ const NUM_LONG_RANGE_SHADOW_NODE_IDS = 4; @priority(MessagePriority.Controller) export class SetLongRangeShadowNodeIDsRequest extends Message { public constructor( - host: ZWaveHost, options: | MessageDeserializationOptions | LongRangeShadowNodeIDsRequestOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { this.shadowNodeIds = parseBitMask( diff --git a/packages/zwave-js/src/lib/serialapi/memory/GetControllerIdMessages.ts b/packages/zwave-js/src/lib/serialapi/memory/GetControllerIdMessages.ts index 608cc7577b5f..75126f6c84f7 100644 --- a/packages/zwave-js/src/lib/serialapi/memory/GetControllerIdMessages.ts +++ b/packages/zwave-js/src/lib/serialapi/memory/GetControllerIdMessages.ts @@ -1,6 +1,5 @@ import type { MessageOrCCLogEntry } from "@zwave-js/core"; import { MessagePriority, encodeNodeID, parseNodeID } from "@zwave-js/core"; -import type { ZWaveHost } from "@zwave-js/host"; import { FunctionType, Message, @@ -28,10 +27,9 @@ export interface GetControllerIdResponseOptions extends MessageBaseOptions { @messageTypes(MessageType.Response, FunctionType.GetControllerId) export class GetControllerIdResponse extends Message { public constructor( - host: ZWaveHost, options: MessageDeserializationOptions | GetControllerIdResponseOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { // The payload is 4 bytes home id, followed by the controller node id this.homeId = this.payload.readUInt32BE(0); diff --git a/packages/zwave-js/src/lib/serialapi/misc/GetBackgroundRSSIMessages.ts b/packages/zwave-js/src/lib/serialapi/misc/GetBackgroundRSSIMessages.ts index 3a112049ea14..62cc328bc90b 100644 --- a/packages/zwave-js/src/lib/serialapi/misc/GetBackgroundRSSIMessages.ts +++ b/packages/zwave-js/src/lib/serialapi/misc/GetBackgroundRSSIMessages.ts @@ -5,7 +5,6 @@ import { type RSSI, rssiToString, } from "@zwave-js/core"; -import type { ZWaveHost } from "@zwave-js/host"; import { FunctionType, Message, @@ -25,10 +24,9 @@ export class GetBackgroundRSSIRequest extends Message {} @messageTypes(MessageType.Response, FunctionType.GetBackgroundRSSI) export class GetBackgroundRSSIResponse extends Message { public constructor( - host: ZWaveHost, options: MessageDeserializationOptions, ) { - super(host, options); + super(options); this.rssiChannel0 = parseRSSI(this.payload, 0); this.rssiChannel1 = parseRSSI(this.payload, 1); this.rssiChannel2 = tryParseRSSI(this.payload, 2); diff --git a/packages/zwave-js/src/lib/serialapi/misc/SetRFReceiveModeMessages.ts b/packages/zwave-js/src/lib/serialapi/misc/SetRFReceiveModeMessages.ts index fa739bca700e..502f3b30a1c1 100644 --- a/packages/zwave-js/src/lib/serialapi/misc/SetRFReceiveModeMessages.ts +++ b/packages/zwave-js/src/lib/serialapi/misc/SetRFReceiveModeMessages.ts @@ -4,7 +4,6 @@ import { ZWaveError, ZWaveErrorCodes, } from "@zwave-js/core"; -import type { ZWaveHost } from "@zwave-js/host"; import type { MessageEncodingContext, SuccessIndicator, @@ -31,10 +30,9 @@ export interface SetRFReceiveModeRequestOptions extends MessageBaseOptions { @expectedResponse(FunctionType.SetRFReceiveMode) export class SetRFReceiveModeRequest extends Message { public constructor( - host: ZWaveHost, options: MessageDeserializationOptions | SetRFReceiveModeRequestOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { throw new ZWaveError( `${this.constructor.name}: deserialization not implemented`, @@ -68,10 +66,9 @@ export class SetRFReceiveModeResponse extends Message implements SuccessIndicator { public constructor( - host: ZWaveHost, options: MessageDeserializationOptions, ) { - super(host, options); + super(options); this.success = this.payload[0] !== 0; } diff --git a/packages/zwave-js/src/lib/serialapi/misc/SetSerialApiTimeoutsMessages.ts b/packages/zwave-js/src/lib/serialapi/misc/SetSerialApiTimeoutsMessages.ts index d404f2c4df34..97ca50aaae70 100644 --- a/packages/zwave-js/src/lib/serialapi/misc/SetSerialApiTimeoutsMessages.ts +++ b/packages/zwave-js/src/lib/serialapi/misc/SetSerialApiTimeoutsMessages.ts @@ -1,5 +1,4 @@ import { MessagePriority } from "@zwave-js/core"; -import type { ZWaveHost } from "@zwave-js/host"; import { FunctionType, Message, @@ -22,10 +21,9 @@ interface SetSerialApiTimeoutsRequestOptions extends MessageBaseOptions { @priority(MessagePriority.Controller) export class SetSerialApiTimeoutsRequest extends Message { public constructor( - host: ZWaveHost, options: SetSerialApiTimeoutsRequestOptions, ) { - super(host, options); + super(options); this.ackTimeout = options.ackTimeout; this.byteTimeout = options.byteTimeout; } @@ -45,10 +43,9 @@ export class SetSerialApiTimeoutsRequest extends Message { @messageTypes(MessageType.Response, FunctionType.SetSerialApiTimeouts) export class SetSerialApiTimeoutsResponse extends Message { public constructor( - host: ZWaveHost, options: MessageDeserializationOptions, ) { - super(host, options); + super(options); this._oldAckTimeout = this.payload[0] * 10; this._oldByteTimeout = this.payload[1] * 10; } diff --git a/packages/zwave-js/src/lib/serialapi/network-mgmt/AddNodeToNetworkRequest.ts b/packages/zwave-js/src/lib/serialapi/network-mgmt/AddNodeToNetworkRequest.ts index 1dd0ddf9ca03..59609fb46c88 100644 --- a/packages/zwave-js/src/lib/serialapi/network-mgmt/AddNodeToNetworkRequest.ts +++ b/packages/zwave-js/src/lib/serialapi/network-mgmt/AddNodeToNetworkRequest.ts @@ -11,7 +11,7 @@ import { parseNodeID, parseNodeUpdatePayload, } from "@zwave-js/core"; -import type { GetAllNodes, ZWaveHost } from "@zwave-js/host"; +import type { GetAllNodes } from "@zwave-js/host"; import type { MessageEncodingContext, SuccessIndicator, @@ -94,14 +94,14 @@ export function computeNeighborDiscoveryTimeout( // no expected response, the controller will respond with multiple AddNodeToNetworkRequests @priority(MessagePriority.Controller) export class AddNodeToNetworkRequestBase extends Message { - public constructor(host: ZWaveHost, options: MessageOptions) { + public constructor(options: MessageOptions) { if ( gotDeserializationOptions(options) && (new.target as any) !== AddNodeToNetworkRequestStatusReport ) { - return new AddNodeToNetworkRequestStatusReport(host, options); + return new AddNodeToNetworkRequestStatusReport(options); } - super(host, options); + super(options); } } @@ -135,10 +135,9 @@ function testCallbackForAddNodeRequest( @expectedCallback(testCallbackForAddNodeRequest) export class AddNodeToNetworkRequest extends AddNodeToNetworkRequestBase { public constructor( - host: ZWaveHost, options: AddNodeToNetworkRequestOptions = {}, ) { - super(host, options); + super(options); this.addNodeType = options.addNodeType; this.highPower = !!options.highPower; @@ -211,10 +210,9 @@ export class EnableSmartStartListenRequest extends AddNodeToNetworkRequestBase { export class AddNodeDSKToNetworkRequest extends AddNodeToNetworkRequestBase { public constructor( - host: ZWaveHost, options: AddNodeDSKToNetworkRequestOptions, ) { - super(host, options); + super(options); this.nwiHomeId = options.nwiHomeId; this.authHomeId = options.authHomeId; @@ -277,10 +275,9 @@ export class AddNodeToNetworkRequestStatusReport implements SuccessIndicator { public constructor( - host: ZWaveHost, options: MessageDeserializationOptions, ) { - super(host, options); + super(options); this.callbackId = this.payload[0]; this.status = this.payload[1]; switch (this.status) { diff --git a/packages/zwave-js/src/lib/serialapi/network-mgmt/AssignPriorityReturnRouteMessages.ts b/packages/zwave-js/src/lib/serialapi/network-mgmt/AssignPriorityReturnRouteMessages.ts index f7c84a4c0fbc..3ad9ff228202 100644 --- a/packages/zwave-js/src/lib/serialapi/network-mgmt/AssignPriorityReturnRouteMessages.ts +++ b/packages/zwave-js/src/lib/serialapi/network-mgmt/AssignPriorityReturnRouteMessages.ts @@ -9,7 +9,6 @@ import { ZWaveErrorCodes, encodeNodeID, } from "@zwave-js/core"; -import type { ZWaveHost } from "@zwave-js/host"; import { FunctionType, Message, @@ -30,18 +29,15 @@ import { getEnumMemberName } from "@zwave-js/shared"; @messageTypes(MessageType.Request, FunctionType.AssignPriorityReturnRoute) @priority(MessagePriority.Normal) export class AssignPriorityReturnRouteRequestBase extends Message { - public constructor(host: ZWaveHost, options: MessageOptions) { + public constructor(options: MessageOptions) { if ( gotDeserializationOptions(options) && (new.target as any) !== AssignPriorityReturnRouteRequestTransmitReport ) { - return new AssignPriorityReturnRouteRequestTransmitReport( - host, - options, - ); + return new AssignPriorityReturnRouteRequestTransmitReport(options); } - super(host, options); + super(options); } } @@ -60,12 +56,11 @@ export class AssignPriorityReturnRouteRequest extends AssignPriorityReturnRouteRequestBase { public constructor( - host: ZWaveHost, options: | MessageDeserializationOptions | AssignPriorityReturnRouteRequestOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { throw new ZWaveError( `${this.constructor.name}: deserialization not implemented`, @@ -147,10 +142,9 @@ export class AssignPriorityReturnRouteResponse extends Message implements SuccessIndicator { public constructor( - host: ZWaveHost, options: MessageDeserializationOptions, ) { - super(host, options); + super(options); this.hasStarted = this.payload[0] !== 0; } @@ -173,10 +167,9 @@ export class AssignPriorityReturnRouteRequestTransmitReport implements SuccessIndicator { public constructor( - host: ZWaveHost, options: MessageDeserializationOptions, ) { - super(host, options); + super(options); this.callbackId = this.payload[0]; this.transmitStatus = this.payload[1]; diff --git a/packages/zwave-js/src/lib/serialapi/network-mgmt/AssignPrioritySUCReturnRouteMessages.ts b/packages/zwave-js/src/lib/serialapi/network-mgmt/AssignPrioritySUCReturnRouteMessages.ts index 07e27523a566..4fee6d7b593e 100644 --- a/packages/zwave-js/src/lib/serialapi/network-mgmt/AssignPrioritySUCReturnRouteMessages.ts +++ b/packages/zwave-js/src/lib/serialapi/network-mgmt/AssignPrioritySUCReturnRouteMessages.ts @@ -9,7 +9,6 @@ import { ZWaveErrorCodes, encodeNodeID, } from "@zwave-js/core"; -import type { ZWaveHost } from "@zwave-js/host"; import { FunctionType, Message, @@ -30,18 +29,17 @@ import { getEnumMemberName } from "@zwave-js/shared"; @messageTypes(MessageType.Request, FunctionType.AssignPrioritySUCReturnRoute) @priority(MessagePriority.Normal) export class AssignPrioritySUCReturnRouteRequestBase extends Message { - public constructor(host: ZWaveHost, options: MessageOptions) { + public constructor(options: MessageOptions) { if ( gotDeserializationOptions(options) && (new.target as any) !== AssignPrioritySUCReturnRouteRequestTransmitReport ) { return new AssignPrioritySUCReturnRouteRequestTransmitReport( - host, options, ); } - super(host, options); + super(options); } } @@ -59,12 +57,11 @@ export class AssignPrioritySUCReturnRouteRequest extends AssignPrioritySUCReturnRouteRequestBase { public constructor( - host: ZWaveHost, options: | MessageDeserializationOptions | AssignPrioritySUCReturnRouteRequestOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { throw new ZWaveError( `${this.constructor.name}: deserialization not implemented`, @@ -132,10 +129,9 @@ export class AssignPrioritySUCReturnRouteResponse extends Message implements SuccessIndicator { public constructor( - host: ZWaveHost, options: MessageDeserializationOptions, ) { - super(host, options); + super(options); this.hasStarted = this.payload[0] !== 0; } @@ -158,10 +154,9 @@ export class AssignPrioritySUCReturnRouteRequestTransmitReport implements SuccessIndicator { public constructor( - host: ZWaveHost, options: MessageDeserializationOptions, ) { - super(host, options); + super(options); this.callbackId = this.payload[0]; this.transmitStatus = this.payload[1]; diff --git a/packages/zwave-js/src/lib/serialapi/network-mgmt/AssignReturnRouteMessages.ts b/packages/zwave-js/src/lib/serialapi/network-mgmt/AssignReturnRouteMessages.ts index f3e010e22141..256326a5250c 100644 --- a/packages/zwave-js/src/lib/serialapi/network-mgmt/AssignReturnRouteMessages.ts +++ b/packages/zwave-js/src/lib/serialapi/network-mgmt/AssignReturnRouteMessages.ts @@ -6,7 +6,6 @@ import { ZWaveErrorCodes, encodeNodeID, } from "@zwave-js/core"; -import type { ZWaveHost } from "@zwave-js/host"; import type { INodeQuery, MessageEncodingContext, @@ -30,14 +29,14 @@ import { getEnumMemberName } from "@zwave-js/shared"; @messageTypes(MessageType.Request, FunctionType.AssignReturnRoute) @priority(MessagePriority.Normal) export class AssignReturnRouteRequestBase extends Message { - public constructor(host: ZWaveHost, options: MessageOptions) { + public constructor(options: MessageOptions) { if ( gotDeserializationOptions(options) && (new.target as any) !== AssignReturnRouteRequestTransmitReport ) { - return new AssignReturnRouteRequestTransmitReport(host, options); + return new AssignReturnRouteRequestTransmitReport(options); } - super(host, options); + super(options); } } @@ -52,12 +51,11 @@ export class AssignReturnRouteRequest extends AssignReturnRouteRequestBase implements INodeQuery { public constructor( - host: ZWaveHost, options: | MessageDeserializationOptions | AssignReturnRouteRequestOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { throw new ZWaveError( `${this.constructor.name}: deserialization not implemented`, @@ -101,10 +99,9 @@ export class AssignReturnRouteResponse extends Message implements SuccessIndicator { public constructor( - host: ZWaveHost, options: MessageDeserializationOptions, ) { - super(host, options); + super(options); this.hasStarted = this.payload[0] !== 0; } @@ -127,10 +124,9 @@ export class AssignReturnRouteRequestTransmitReport implements SuccessIndicator { public constructor( - host: ZWaveHost, options: MessageDeserializationOptions, ) { - super(host, options); + super(options); this.callbackId = this.payload[0]; this.transmitStatus = this.payload[1]; diff --git a/packages/zwave-js/src/lib/serialapi/network-mgmt/AssignSUCReturnRouteMessages.ts b/packages/zwave-js/src/lib/serialapi/network-mgmt/AssignSUCReturnRouteMessages.ts index fea2b809285d..7b3ceda16802 100644 --- a/packages/zwave-js/src/lib/serialapi/network-mgmt/AssignSUCReturnRouteMessages.ts +++ b/packages/zwave-js/src/lib/serialapi/network-mgmt/AssignSUCReturnRouteMessages.ts @@ -4,7 +4,6 @@ import { TransmitStatus, encodeNodeID, } from "@zwave-js/core"; -import type { ZWaveHost } from "@zwave-js/host"; import { FunctionType, type INodeQuery, @@ -27,26 +26,23 @@ import { getEnumMemberName } from "@zwave-js/shared"; @messageTypes(MessageType.Request, FunctionType.AssignSUCReturnRoute) @priority(MessagePriority.Normal) export class AssignSUCReturnRouteRequestBase extends Message { - public constructor(host: ZWaveHost, options: MessageOptions) { + public constructor(options: MessageOptions) { if (gotDeserializationOptions(options)) { if ( options.origin === MessageOrigin.Host && (new.target as any) !== AssignSUCReturnRouteRequest ) { - return new AssignSUCReturnRouteRequest(host, options); + return new AssignSUCReturnRouteRequest(options); } else if ( options.origin !== MessageOrigin.Host && (new.target as any) !== AssignSUCReturnRouteRequestTransmitReport ) { - return new AssignSUCReturnRouteRequestTransmitReport( - host, - options, - ); + return new AssignSUCReturnRouteRequestTransmitReport(options); } } - super(host, options); + super(options); } } @@ -72,12 +68,11 @@ export class AssignSUCReturnRouteRequest extends AssignSUCReturnRouteRequestBase implements INodeQuery { public constructor( - host: ZWaveHost, options: | MessageDeserializationOptions | AssignSUCReturnRouteRequestOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { this.nodeId = this.payload[0]; this.callbackId = this.payload[1]; @@ -109,12 +104,11 @@ export class AssignSUCReturnRouteResponse extends Message implements SuccessIndicator { public constructor( - host: ZWaveHost, options: | MessageDeserializationOptions | AssignSUCReturnRouteResponseOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { this.wasExecuted = this.payload[0] !== 0; } else { @@ -153,12 +147,11 @@ export class AssignSUCReturnRouteRequestTransmitReport implements SuccessIndicator { public constructor( - host: ZWaveHost, options: | MessageDeserializationOptions | AssignSUCReturnRouteRequestTransmitReportOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { this.callbackId = this.payload[0]; diff --git a/packages/zwave-js/src/lib/serialapi/network-mgmt/DeleteReturnRouteMessages.ts b/packages/zwave-js/src/lib/serialapi/network-mgmt/DeleteReturnRouteMessages.ts index 60ce6618ab9b..0dc86ed5a5dd 100644 --- a/packages/zwave-js/src/lib/serialapi/network-mgmt/DeleteReturnRouteMessages.ts +++ b/packages/zwave-js/src/lib/serialapi/network-mgmt/DeleteReturnRouteMessages.ts @@ -6,7 +6,6 @@ import { ZWaveErrorCodes, encodeNodeID, } from "@zwave-js/core"; -import type { ZWaveHost } from "@zwave-js/host"; import type { INodeQuery, MessageEncodingContext, @@ -30,14 +29,14 @@ import { getEnumMemberName } from "@zwave-js/shared"; @messageTypes(MessageType.Request, FunctionType.DeleteReturnRoute) @priority(MessagePriority.Normal) export class DeleteReturnRouteRequestBase extends Message { - public constructor(host: ZWaveHost, options: MessageOptions) { + public constructor(options: MessageOptions) { if ( gotDeserializationOptions(options) && (new.target as any) !== DeleteReturnRouteRequestTransmitReport ) { - return new DeleteReturnRouteRequestTransmitReport(host, options); + return new DeleteReturnRouteRequestTransmitReport(options); } - super(host, options); + super(options); } } @@ -51,12 +50,11 @@ export class DeleteReturnRouteRequest extends DeleteReturnRouteRequestBase implements INodeQuery { public constructor( - host: ZWaveHost, options: | MessageDeserializationOptions | DeleteReturnRouteRequestOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { throw new ZWaveError( `${this.constructor.name}: deserialization not implemented`, @@ -83,10 +81,9 @@ export class DeleteReturnRouteResponse extends Message implements SuccessIndicator { public constructor( - host: ZWaveHost, options: MessageDeserializationOptions, ) { - super(host, options); + super(options); this.hasStarted = this.payload[0] !== 0; } @@ -109,10 +106,9 @@ export class DeleteReturnRouteRequestTransmitReport implements SuccessIndicator { public constructor( - host: ZWaveHost, options: MessageDeserializationOptions, ) { - super(host, options); + super(options); this.callbackId = this.payload[0]; this.transmitStatus = this.payload[1]; diff --git a/packages/zwave-js/src/lib/serialapi/network-mgmt/DeleteSUCReturnRouteMessages.ts b/packages/zwave-js/src/lib/serialapi/network-mgmt/DeleteSUCReturnRouteMessages.ts index fb0a761e61da..10ed44691215 100644 --- a/packages/zwave-js/src/lib/serialapi/network-mgmt/DeleteSUCReturnRouteMessages.ts +++ b/packages/zwave-js/src/lib/serialapi/network-mgmt/DeleteSUCReturnRouteMessages.ts @@ -4,7 +4,6 @@ import { TransmitStatus, encodeNodeID, } from "@zwave-js/core"; -import type { ZWaveHost } from "@zwave-js/host"; import type { INodeQuery, MessageEncodingContext, @@ -29,26 +28,23 @@ import { getEnumMemberName } from "@zwave-js/shared"; @messageTypes(MessageType.Request, FunctionType.DeleteSUCReturnRoute) @priority(MessagePriority.Normal) export class DeleteSUCReturnRouteRequestBase extends Message { - public constructor(host: ZWaveHost, options: MessageOptions) { + public constructor(options: MessageOptions) { if (gotDeserializationOptions(options)) { if ( options.origin === MessageOrigin.Host && (new.target as any) !== DeleteSUCReturnRouteRequest ) { - return new DeleteSUCReturnRouteRequest(host, options); + return new DeleteSUCReturnRouteRequest(options); } else if ( options.origin !== MessageOrigin.Host && (new.target as any) !== DeleteSUCReturnRouteRequestTransmitReport ) { - return new DeleteSUCReturnRouteRequestTransmitReport( - host, - options, - ); + return new DeleteSUCReturnRouteRequestTransmitReport(options); } } - super(host, options); + super(options); } } @@ -74,12 +70,11 @@ export class DeleteSUCReturnRouteRequest extends DeleteSUCReturnRouteRequestBase implements INodeQuery { public constructor( - host: ZWaveHost, options: | MessageDeserializationOptions | DeleteSUCReturnRouteRequestOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { this.nodeId = this.payload[0]; this.callbackId = this.payload[1]; @@ -111,12 +106,11 @@ export class DeleteSUCReturnRouteResponse extends Message implements SuccessIndicator { public constructor( - host: ZWaveHost, options: | MessageDeserializationOptions | DeleteSUCReturnRouteResponseOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { this.wasExecuted = this.payload[0] !== 0; } else { @@ -155,12 +149,11 @@ export class DeleteSUCReturnRouteRequestTransmitReport implements SuccessIndicator { public constructor( - host: ZWaveHost, options: | MessageDeserializationOptions | DeleteSUCReturnRouteRequestTransmitReportOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { this.callbackId = this.payload[0]; diff --git a/packages/zwave-js/src/lib/serialapi/network-mgmt/GetNodeProtocolInfoMessages.ts b/packages/zwave-js/src/lib/serialapi/network-mgmt/GetNodeProtocolInfoMessages.ts index 4a475bee26d4..fccd3b49b5ad 100644 --- a/packages/zwave-js/src/lib/serialapi/network-mgmt/GetNodeProtocolInfoMessages.ts +++ b/packages/zwave-js/src/lib/serialapi/network-mgmt/GetNodeProtocolInfoMessages.ts @@ -12,7 +12,6 @@ import { parseNodeID, parseNodeProtocolInfo, } from "@zwave-js/core"; -import type { ZWaveHost } from "@zwave-js/host"; import { FunctionType, Message, @@ -36,12 +35,11 @@ interface GetNodeProtocolInfoRequestOptions extends MessageBaseOptions { @priority(MessagePriority.Controller) export class GetNodeProtocolInfoRequest extends Message { public constructor( - host: ZWaveHost, options: | MessageDeserializationOptions | GetNodeProtocolInfoRequestOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { this.requestedNodeId = parseNodeID(this.payload, options.ctx.nodeIdType, 0).nodeId; @@ -67,12 +65,11 @@ interface GetNodeProtocolInfoResponseOptions @messageTypes(MessageType.Response, FunctionType.GetNodeProtocolInfo) export class GetNodeProtocolInfoResponse extends Message { public constructor( - host: ZWaveHost, options: | MessageDeserializationOptions | GetNodeProtocolInfoResponseOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { // The context should contain the node ID the protocol info was requested for. diff --git a/packages/zwave-js/src/lib/serialapi/network-mgmt/GetPriorityRouteMessages.ts b/packages/zwave-js/src/lib/serialapi/network-mgmt/GetPriorityRouteMessages.ts index 56213ede4090..4558515637cb 100644 --- a/packages/zwave-js/src/lib/serialapi/network-mgmt/GetPriorityRouteMessages.ts +++ b/packages/zwave-js/src/lib/serialapi/network-mgmt/GetPriorityRouteMessages.ts @@ -10,7 +10,6 @@ import { encodeNodeID, parseNodeID, } from "@zwave-js/core"; -import type { ZWaveHost } from "@zwave-js/host"; import { FunctionType, Message, @@ -34,10 +33,9 @@ export interface GetPriorityRouteRequestOptions extends MessageBaseOptions { @expectedResponse(FunctionType.GetPriorityRoute) export class GetPriorityRouteRequest extends Message { public constructor( - host: ZWaveHost, options: MessageDeserializationOptions | GetPriorityRouteRequestOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { throw new ZWaveError( `${this.constructor.name}: deserialization not implemented`, @@ -72,10 +70,9 @@ export class GetPriorityRouteRequest extends Message { @messageTypes(MessageType.Response, FunctionType.GetPriorityRoute) export class GetPriorityRouteResponse extends Message { public constructor( - host: ZWaveHost, options: MessageDeserializationOptions, ) { - super(host, options); + super(options); let offset = 0; const { nodeId, bytesRead: nodeIdBytes } = parseNodeID( this.payload, diff --git a/packages/zwave-js/src/lib/serialapi/network-mgmt/GetRoutingInfoMessages.ts b/packages/zwave-js/src/lib/serialapi/network-mgmt/GetRoutingInfoMessages.ts index c53adb6ce37e..8da062d7f431 100644 --- a/packages/zwave-js/src/lib/serialapi/network-mgmt/GetRoutingInfoMessages.ts +++ b/packages/zwave-js/src/lib/serialapi/network-mgmt/GetRoutingInfoMessages.ts @@ -5,7 +5,6 @@ import { encodeNodeID, parseNodeBitMask, } from "@zwave-js/core"; -import type { ZWaveHost } from "@zwave-js/host"; import { FunctionType, Message, @@ -28,8 +27,8 @@ interface GetRoutingInfoRequestOptions extends MessageBaseOptions { @expectedResponse(FunctionType.GetRoutingInfo) @priority(MessagePriority.Controller) export class GetRoutingInfoRequest extends Message { - public constructor(host: ZWaveHost, options: GetRoutingInfoRequestOptions) { - super(host, options); + public constructor(options: GetRoutingInfoRequestOptions) { + super(options); this.sourceNodeId = options.nodeId; this.removeNonRepeaters = !!options.removeNonRepeaters; this.removeBadLinks = !!options.removeBadLinks; @@ -67,10 +66,9 @@ export class GetRoutingInfoRequest extends Message { @messageTypes(MessageType.Response, FunctionType.GetRoutingInfo) export class GetRoutingInfoResponse extends Message { public constructor( - host: ZWaveHost, options: MessageDeserializationOptions, ) { - super(host, options); + super(options); if (this.payload.length === NUM_NODEMASK_BYTES) { // the payload contains a bit mask of all neighbor nodes diff --git a/packages/zwave-js/src/lib/serialapi/network-mgmt/GetSUCNodeIdMessages.ts b/packages/zwave-js/src/lib/serialapi/network-mgmt/GetSUCNodeIdMessages.ts index e76621862fe5..351262ea3f73 100644 --- a/packages/zwave-js/src/lib/serialapi/network-mgmt/GetSUCNodeIdMessages.ts +++ b/packages/zwave-js/src/lib/serialapi/network-mgmt/GetSUCNodeIdMessages.ts @@ -1,5 +1,4 @@ import { MessagePriority, encodeNodeID, parseNodeID } from "@zwave-js/core"; -import type { ZWaveHost } from "@zwave-js/host"; import { FunctionType, Message, @@ -25,10 +24,9 @@ export interface GetSUCNodeIdResponseOptions extends MessageBaseOptions { @messageTypes(MessageType.Response, FunctionType.GetSUCNodeId) export class GetSUCNodeIdResponse extends Message { public constructor( - host: ZWaveHost, options: MessageDeserializationOptions | GetSUCNodeIdResponseOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { this.sucNodeId = parseNodeID( diff --git a/packages/zwave-js/src/lib/serialapi/network-mgmt/IsFailedNodeMessages.ts b/packages/zwave-js/src/lib/serialapi/network-mgmt/IsFailedNodeMessages.ts index 27d2333e32d9..ab7f7dc71c53 100644 --- a/packages/zwave-js/src/lib/serialapi/network-mgmt/IsFailedNodeMessages.ts +++ b/packages/zwave-js/src/lib/serialapi/network-mgmt/IsFailedNodeMessages.ts @@ -1,5 +1,4 @@ import { MessagePriority, encodeNodeID } from "@zwave-js/core"; -import type { ZWaveHost } from "@zwave-js/host"; import { FunctionType, Message, @@ -21,8 +20,8 @@ export interface IsFailedNodeRequestOptions extends MessageBaseOptions { @expectedResponse(FunctionType.IsFailedNode) @priority(MessagePriority.Controller) export class IsFailedNodeRequest extends Message { - public constructor(host: ZWaveHost, options: IsFailedNodeRequestOptions) { - super(host, options); + public constructor(options: IsFailedNodeRequestOptions) { + super(options); this.failedNodeId = options.failedNodeId; } @@ -38,10 +37,9 @@ export class IsFailedNodeRequest extends Message { @messageTypes(MessageType.Response, FunctionType.IsFailedNode) export class IsFailedNodeResponse extends Message { public constructor( - host: ZWaveHost, options: MessageDeserializationOptions, ) { - super(host, options); + super(options); this.result = !!this.payload[0]; } diff --git a/packages/zwave-js/src/lib/serialapi/network-mgmt/RemoveFailedNodeMessages.ts b/packages/zwave-js/src/lib/serialapi/network-mgmt/RemoveFailedNodeMessages.ts index 0919273eed6d..172a1abaab10 100644 --- a/packages/zwave-js/src/lib/serialapi/network-mgmt/RemoveFailedNodeMessages.ts +++ b/packages/zwave-js/src/lib/serialapi/network-mgmt/RemoveFailedNodeMessages.ts @@ -1,5 +1,4 @@ import { MessagePriority, encodeNodeID } from "@zwave-js/core"; -import type { ZWaveHost } from "@zwave-js/host"; import type { MessageEncodingContext, SuccessIndicator, @@ -47,14 +46,14 @@ export enum RemoveFailedNodeStatus { @messageTypes(MessageType.Request, FunctionType.RemoveFailedNode) @priority(MessagePriority.Controller) export class RemoveFailedNodeRequestBase extends Message { - public constructor(host: ZWaveHost, options: MessageOptions) { + public constructor(options: MessageOptions) { if ( gotDeserializationOptions(options) && (new.target as any) !== RemoveFailedNodeRequestStatusReport ) { - return new RemoveFailedNodeRequestStatusReport(host, options); + return new RemoveFailedNodeRequestStatusReport(options); } - super(host, options); + super(options); } } @@ -67,10 +66,9 @@ interface RemoveFailedNodeRequestOptions extends MessageBaseOptions { @expectedCallback(FunctionType.RemoveFailedNode) export class RemoveFailedNodeRequest extends RemoveFailedNodeRequestBase { public constructor( - host: ZWaveHost, options: RemoveFailedNodeRequestOptions, ) { - super(host, options); + super(options); this.failedNodeId = options.failedNodeId; } @@ -91,10 +89,9 @@ export class RemoveFailedNodeRequestStatusReport implements SuccessIndicator { public constructor( - host: ZWaveHost, options: MessageDeserializationOptions, ) { - super(host, options); + super(options); this.callbackId = this.payload[0]; this._removeStatus = this.payload[1]; @@ -115,10 +112,9 @@ export class RemoveFailedNodeResponse extends Message implements SuccessIndicator { public constructor( - host: ZWaveHost, options: MessageDeserializationOptions, ) { - super(host, options); + super(options); this._removeStatus = this.payload[0]; } diff --git a/packages/zwave-js/src/lib/serialapi/network-mgmt/RemoveNodeFromNetworkRequest.ts b/packages/zwave-js/src/lib/serialapi/network-mgmt/RemoveNodeFromNetworkRequest.ts index 5f79092ea3ac..cf62859b1074 100644 --- a/packages/zwave-js/src/lib/serialapi/network-mgmt/RemoveNodeFromNetworkRequest.ts +++ b/packages/zwave-js/src/lib/serialapi/network-mgmt/RemoveNodeFromNetworkRequest.ts @@ -3,7 +3,6 @@ import { MessagePriority, parseNodeID, } from "@zwave-js/core"; -import type { ZWaveHost } from "@zwave-js/host"; import type { MessageEncodingContext, SuccessIndicator, @@ -54,14 +53,14 @@ interface RemoveNodeFromNetworkRequestOptions extends MessageBaseOptions { // no expected response, the controller will respond with multiple RemoveNodeFromNetworkRequests @priority(MessagePriority.Controller) export class RemoveNodeFromNetworkRequestBase extends Message { - public constructor(host: ZWaveHost, options: MessageOptions) { + public constructor(options: MessageOptions) { if ( gotDeserializationOptions(options) && (new.target as any) !== RemoveNodeFromNetworkRequestStatusReport ) { - return new RemoveNodeFromNetworkRequestStatusReport(host, options); + return new RemoveNodeFromNetworkRequestStatusReport(options); } - super(host, options); + super(options); } } @@ -97,10 +96,9 @@ export class RemoveNodeFromNetworkRequest extends RemoveNodeFromNetworkRequestBase { public constructor( - host: ZWaveHost, options: RemoveNodeFromNetworkRequestOptions = {}, ) { - super(host, options); + super(options); this.removeNodeType = options.removeNodeType; this.highPower = !!options.highPower; @@ -131,10 +129,9 @@ export class RemoveNodeFromNetworkRequestStatusReport implements SuccessIndicator { public constructor( - host: ZWaveHost, options: MessageDeserializationOptions, ) { - super(host, options); + super(options); this.callbackId = this.payload[0]; this.status = this.payload[1]; switch (this.status) { diff --git a/packages/zwave-js/src/lib/serialapi/network-mgmt/ReplaceFailedNodeRequest.ts b/packages/zwave-js/src/lib/serialapi/network-mgmt/ReplaceFailedNodeRequest.ts index de05d1f742e1..2514eaafa4f6 100644 --- a/packages/zwave-js/src/lib/serialapi/network-mgmt/ReplaceFailedNodeRequest.ts +++ b/packages/zwave-js/src/lib/serialapi/network-mgmt/ReplaceFailedNodeRequest.ts @@ -1,5 +1,4 @@ import { MessagePriority, encodeNodeID } from "@zwave-js/core"; -import type { ZWaveHost } from "@zwave-js/host"; import type { MessageEncodingContext, SuccessIndicator, @@ -47,14 +46,14 @@ export enum ReplaceFailedNodeStatus { @messageTypes(MessageType.Request, FunctionType.ReplaceFailedNode) @priority(MessagePriority.Controller) export class ReplaceFailedNodeRequestBase extends Message { - public constructor(host: ZWaveHost, options: MessageOptions) { + public constructor(options: MessageOptions) { if ( gotDeserializationOptions(options) && (new.target as any) !== ReplaceFailedNodeRequestStatusReport ) { - return new ReplaceFailedNodeRequestStatusReport(host, options); + return new ReplaceFailedNodeRequestStatusReport(options); } - super(host, options); + super(options); } } @@ -66,10 +65,9 @@ interface ReplaceFailedNodeRequestOptions extends MessageBaseOptions { @expectedResponse(FunctionType.ReplaceFailedNode) export class ReplaceFailedNodeRequest extends ReplaceFailedNodeRequestBase { public constructor( - host: ZWaveHost, options: ReplaceFailedNodeRequestOptions, ) { - super(host, options); + super(options); this.failedNodeId = options.failedNodeId; } @@ -90,10 +88,9 @@ export class ReplaceFailedNodeResponse extends Message implements SuccessIndicator { public constructor( - host: ZWaveHost, options: MessageDeserializationOptions, ) { - super(host, options); + super(options); this._replaceStatus = this.payload[0]; } @@ -112,10 +109,9 @@ export class ReplaceFailedNodeRequestStatusReport implements SuccessIndicator { public constructor( - host: ZWaveHost, options: MessageDeserializationOptions, ) { - super(host, options); + super(options); this.callbackId = this.payload[0]; this._replaceStatus = this.payload[1]; diff --git a/packages/zwave-js/src/lib/serialapi/network-mgmt/RequestNodeInfoMessages.ts b/packages/zwave-js/src/lib/serialapi/network-mgmt/RequestNodeInfoMessages.ts index ced2a7d7c954..5a058a6619fe 100644 --- a/packages/zwave-js/src/lib/serialapi/network-mgmt/RequestNodeInfoMessages.ts +++ b/packages/zwave-js/src/lib/serialapi/network-mgmt/RequestNodeInfoMessages.ts @@ -4,7 +4,6 @@ import { encodeNodeID, parseNodeID, } from "@zwave-js/core"; -import type { ZWaveHost } from "@zwave-js/host"; import { FunctionType, type INodeQuery, @@ -34,10 +33,9 @@ export class RequestNodeInfoResponse extends Message implements SuccessIndicator { public constructor( - host: ZWaveHost, options: MessageDeserializationOptions | RequestNodeInfoResponseOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { this.wasSent = this.payload[0] !== 0; } else { @@ -85,10 +83,9 @@ function testCallbackForRequestNodeInfoRequest( @priority(MessagePriority.NodeQuery) export class RequestNodeInfoRequest extends Message implements INodeQuery { public constructor( - host: ZWaveHost, options: RequestNodeInfoRequestOptions | MessageDeserializationOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { this.nodeId = parseNodeID( this.payload, diff --git a/packages/zwave-js/src/lib/serialapi/network-mgmt/RequestNodeNeighborUpdateMessages.ts b/packages/zwave-js/src/lib/serialapi/network-mgmt/RequestNodeNeighborUpdateMessages.ts index 5c861605a824..93f95cdcb764 100644 --- a/packages/zwave-js/src/lib/serialapi/network-mgmt/RequestNodeNeighborUpdateMessages.ts +++ b/packages/zwave-js/src/lib/serialapi/network-mgmt/RequestNodeNeighborUpdateMessages.ts @@ -1,6 +1,5 @@ import type { MessageOrCCLogEntry } from "@zwave-js/core"; import { MessagePriority, encodeNodeID } from "@zwave-js/core"; -import type { ZWaveHost } from "@zwave-js/host"; import type { MessageEncodingContext, MultiStageCallback, @@ -37,14 +36,14 @@ export interface RequestNodeNeighborUpdateRequestOptions @messageTypes(MessageType.Request, FunctionType.RequestNodeNeighborUpdate) @priority(MessagePriority.Controller) export class RequestNodeNeighborUpdateRequestBase extends Message { - public constructor(host: ZWaveHost, options: MessageOptions) { + public constructor(options: MessageOptions) { if ( gotDeserializationOptions(options) && (new.target as any) !== RequestNodeNeighborUpdateReport ) { - return new RequestNodeNeighborUpdateReport(host, options); + return new RequestNodeNeighborUpdateReport(options); } - super(host, options); + super(options); } } @@ -53,10 +52,9 @@ export class RequestNodeNeighborUpdateRequest extends RequestNodeNeighborUpdateRequestBase { public constructor( - host: ZWaveHost, options: RequestNodeNeighborUpdateRequestOptions, ) { - super(host, options); + super(options); this.nodeId = options.nodeId; this.discoveryTimeout = options.discoveryTimeout; } @@ -90,10 +88,9 @@ export class RequestNodeNeighborUpdateReport implements SuccessIndicator, MultiStageCallback { public constructor( - host: ZWaveHost, options: MessageDeserializationOptions, ) { - super(host, options); + super(options); this.callbackId = this.payload[0]; this._updateStatus = this.payload[1]; diff --git a/packages/zwave-js/src/lib/serialapi/network-mgmt/SetLearnModeMessages.ts b/packages/zwave-js/src/lib/serialapi/network-mgmt/SetLearnModeMessages.ts index 29bfc735bc75..849c484748cc 100644 --- a/packages/zwave-js/src/lib/serialapi/network-mgmt/SetLearnModeMessages.ts +++ b/packages/zwave-js/src/lib/serialapi/network-mgmt/SetLearnModeMessages.ts @@ -5,7 +5,6 @@ import { ZWaveError, ZWaveErrorCodes, } from "@zwave-js/core"; -import type { ZWaveHost } from "@zwave-js/host"; import { FunctionType, Message, @@ -48,14 +47,14 @@ export enum LearnModeStatus { @messageTypes(MessageType.Request, FunctionType.SetLearnMode) @priority(MessagePriority.Controller) export class SetLearnModeRequestBase extends Message { - public constructor(host: ZWaveHost, options: MessageOptions) { + public constructor(options: MessageOptions) { if ( gotDeserializationOptions(options) && (new.target as any) !== SetLearnModeCallback ) { - return new SetLearnModeCallback(host, options); + return new SetLearnModeCallback(options); } - super(host, options); + super(options); } } @@ -67,10 +66,9 @@ export interface SetLearnModeRequestOptions extends MessageBaseOptions { // The callback may come much (30+ seconds), so we wait for it outside of the queue export class SetLearnModeRequest extends SetLearnModeRequestBase { public constructor( - host: ZWaveHost, options: MessageDeserializationOptions | SetLearnModeRequestOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { throw new ZWaveError( `${this.constructor.name}: deserialization not implemented`, @@ -107,10 +105,9 @@ export class SetLearnModeRequest extends SetLearnModeRequestBase { @messageTypes(MessageType.Response, FunctionType.SetLearnMode) export class SetLearnModeResponse extends Message implements SuccessIndicator { public constructor( - host: ZWaveHost, options: MessageDeserializationOptions, ) { - super(host, options); + super(options); this.success = this.payload[0] !== 0; } @@ -132,10 +129,9 @@ export class SetLearnModeCallback extends SetLearnModeRequestBase implements SuccessIndicator { public constructor( - host: ZWaveHost, options: MessageDeserializationOptions, ) { - super(host, options); + super(options); this.callbackId = this.payload[0]; this.status = this.payload[1]; diff --git a/packages/zwave-js/src/lib/serialapi/network-mgmt/SetPriorityRouteMessages.ts b/packages/zwave-js/src/lib/serialapi/network-mgmt/SetPriorityRouteMessages.ts index f168d53ecb4b..555a632091bd 100644 --- a/packages/zwave-js/src/lib/serialapi/network-mgmt/SetPriorityRouteMessages.ts +++ b/packages/zwave-js/src/lib/serialapi/network-mgmt/SetPriorityRouteMessages.ts @@ -10,7 +10,6 @@ import { encodeNodeID, parseNodeID, } from "@zwave-js/core"; -import type { ZWaveHost } from "@zwave-js/host"; import { FunctionType, Message, @@ -40,12 +39,11 @@ export type SetPriorityRouteRequestOptions = @expectedResponse(FunctionType.SetPriorityRoute) export class SetPriorityRouteRequest extends Message { public constructor( - host: ZWaveHost, options: | MessageDeserializationOptions | (MessageBaseOptions & SetPriorityRouteRequestOptions), ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { throw new ZWaveError( `${this.constructor.name}: deserialization not implemented`, @@ -133,10 +131,9 @@ export class SetPriorityRouteResponse extends Message implements SuccessIndicator { public constructor( - host: ZWaveHost, options: MessageDeserializationOptions, ) { - super(host, options); + super(options); // Byte(s) 0/1 are the node ID - this is missing from the Host API specs const { /* nodeId, */ bytesRead } = parseNodeID( this.payload, diff --git a/packages/zwave-js/src/lib/serialapi/network-mgmt/SetSUCNodeIDMessages.ts b/packages/zwave-js/src/lib/serialapi/network-mgmt/SetSUCNodeIDMessages.ts index 20d6e581873b..e4bb2c02473d 100644 --- a/packages/zwave-js/src/lib/serialapi/network-mgmt/SetSUCNodeIDMessages.ts +++ b/packages/zwave-js/src/lib/serialapi/network-mgmt/SetSUCNodeIDMessages.ts @@ -6,7 +6,6 @@ import { ZWaveErrorCodes, encodeNodeID, } from "@zwave-js/core"; -import type { ZWaveHost } from "@zwave-js/host"; import type { MessageEncodingContext, SuccessIndicator, @@ -41,14 +40,14 @@ export interface SetSUCNodeIdRequestOptions extends MessageBaseOptions { @messageTypes(MessageType.Request, FunctionType.SetSUCNodeId) @priority(MessagePriority.Controller) export class SetSUCNodeIdRequestBase extends Message { - public constructor(host: ZWaveHost, options: MessageOptions) { + public constructor(options: MessageOptions) { if ( gotDeserializationOptions(options) && (new.target as any) !== SetSUCNodeIdRequestStatusReport ) { - return new SetSUCNodeIdRequestStatusReport(host, options); + return new SetSUCNodeIdRequestStatusReport(options); } - super(host, options); + super(options); } } @@ -56,10 +55,9 @@ export class SetSUCNodeIdRequestBase extends Message { @expectedCallback(FunctionType.SetSUCNodeId) export class SetSUCNodeIdRequest extends SetSUCNodeIdRequestBase { public constructor( - host: ZWaveHost, options: MessageDeserializationOptions | SetSUCNodeIdRequestOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { throw new ZWaveError( `${this.constructor.name}: deserialization not implemented`, @@ -107,10 +105,9 @@ export class SetSUCNodeIdRequest extends SetSUCNodeIdRequestBase { @messageTypes(MessageType.Response, FunctionType.SetSUCNodeId) export class SetSUCNodeIdResponse extends Message implements SuccessIndicator { public constructor( - host: ZWaveHost, options: MessageDeserializationOptions, ) { - super(host, options); + super(options); this._wasExecuted = this.payload[0] !== 0; } @@ -135,10 +132,9 @@ export class SetSUCNodeIdRequestStatusReport extends SetSUCNodeIdRequestBase implements SuccessIndicator { public constructor( - host: ZWaveHost, options: MessageDeserializationOptions, ) { - super(host, options); + super(options); this.callbackId = this.payload[0]; this._status = this.payload[1]; diff --git a/packages/zwave-js/src/lib/serialapi/nvm/ExtNVMReadLongBufferMessages.ts b/packages/zwave-js/src/lib/serialapi/nvm/ExtNVMReadLongBufferMessages.ts index c4c84b3d0721..750daeb548e9 100644 --- a/packages/zwave-js/src/lib/serialapi/nvm/ExtNVMReadLongBufferMessages.ts +++ b/packages/zwave-js/src/lib/serialapi/nvm/ExtNVMReadLongBufferMessages.ts @@ -4,7 +4,6 @@ import { ZWaveError, ZWaveErrorCodes, } from "@zwave-js/core"; -import type { ZWaveHost } from "@zwave-js/host"; import { FunctionType, Message, @@ -29,12 +28,11 @@ export interface ExtNVMReadLongBufferRequestOptions extends MessageBaseOptions { @expectedResponse(FunctionType.ExtNVMReadLongBuffer) export class ExtNVMReadLongBufferRequest extends Message { public constructor( - host: ZWaveHost, options: | MessageDeserializationOptions | ExtNVMReadLongBufferRequestOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { throw new ZWaveError( `${this.constructor.name}: deserialization not implemented`, @@ -83,10 +81,9 @@ export class ExtNVMReadLongBufferRequest extends Message { @messageTypes(MessageType.Response, FunctionType.ExtNVMReadLongBuffer) export class ExtNVMReadLongBufferResponse extends Message { public constructor( - host: ZWaveHost, options: MessageDeserializationOptions, ) { - super(host, options); + super(options); this.buffer = this.payload; } diff --git a/packages/zwave-js/src/lib/serialapi/nvm/ExtNVMReadLongByteMessages.ts b/packages/zwave-js/src/lib/serialapi/nvm/ExtNVMReadLongByteMessages.ts index cd748277f557..30ed8ca21abd 100644 --- a/packages/zwave-js/src/lib/serialapi/nvm/ExtNVMReadLongByteMessages.ts +++ b/packages/zwave-js/src/lib/serialapi/nvm/ExtNVMReadLongByteMessages.ts @@ -4,7 +4,6 @@ import { ZWaveError, ZWaveErrorCodes, } from "@zwave-js/core"; -import type { ZWaveHost } from "@zwave-js/host"; import { FunctionType, Message, @@ -28,12 +27,11 @@ export interface ExtNVMReadLongByteRequestOptions extends MessageBaseOptions { @expectedResponse(FunctionType.ExtNVMReadLongByte) export class ExtNVMReadLongByteRequest extends Message { public constructor( - host: ZWaveHost, options: | MessageDeserializationOptions | ExtNVMReadLongByteRequestOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { throw new ZWaveError( `${this.constructor.name}: deserialization not implemented`, @@ -69,10 +67,9 @@ export class ExtNVMReadLongByteRequest extends Message { @messageTypes(MessageType.Response, FunctionType.ExtNVMReadLongByte) export class ExtNVMReadLongByteResponse extends Message { public constructor( - host: ZWaveHost, options: MessageDeserializationOptions, ) { - super(host, options); + super(options); this.byte = this.payload[0]; } diff --git a/packages/zwave-js/src/lib/serialapi/nvm/ExtNVMWriteLongBufferMessages.ts b/packages/zwave-js/src/lib/serialapi/nvm/ExtNVMWriteLongBufferMessages.ts index 280acbee33d6..8b27db4fe920 100644 --- a/packages/zwave-js/src/lib/serialapi/nvm/ExtNVMWriteLongBufferMessages.ts +++ b/packages/zwave-js/src/lib/serialapi/nvm/ExtNVMWriteLongBufferMessages.ts @@ -4,7 +4,6 @@ import { ZWaveError, ZWaveErrorCodes, } from "@zwave-js/core"; -import type { ZWaveHost } from "@zwave-js/host"; import { FunctionType, Message, @@ -31,12 +30,11 @@ export interface ExtNVMWriteLongBufferRequestOptions @expectedResponse(FunctionType.ExtNVMWriteLongBuffer) export class ExtNVMWriteLongBufferRequest extends Message { public constructor( - host: ZWaveHost, options: | MessageDeserializationOptions | ExtNVMWriteLongBufferRequestOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { throw new ZWaveError( `${this.constructor.name}: deserialization not implemented`, @@ -87,10 +85,9 @@ export class ExtNVMWriteLongBufferRequest extends Message { @messageTypes(MessageType.Response, FunctionType.ExtNVMWriteLongBuffer) export class ExtNVMWriteLongBufferResponse extends Message { public constructor( - host: ZWaveHost, options: MessageDeserializationOptions, ) { - super(host, options); + super(options); this.success = this.payload[0] !== 0; } diff --git a/packages/zwave-js/src/lib/serialapi/nvm/ExtNVMWriteLongByteMessages.ts b/packages/zwave-js/src/lib/serialapi/nvm/ExtNVMWriteLongByteMessages.ts index a8919c8aaa48..b645d01ecefb 100644 --- a/packages/zwave-js/src/lib/serialapi/nvm/ExtNVMWriteLongByteMessages.ts +++ b/packages/zwave-js/src/lib/serialapi/nvm/ExtNVMWriteLongByteMessages.ts @@ -4,7 +4,6 @@ import { ZWaveError, ZWaveErrorCodes, } from "@zwave-js/core"; -import type { ZWaveHost } from "@zwave-js/host"; import { FunctionType, Message, @@ -29,12 +28,11 @@ export interface ExtNVMWriteLongByteRequestOptions extends MessageBaseOptions { @expectedResponse(FunctionType.ExtExtWriteLongByte) export class ExtNVMWriteLongByteRequest extends Message { public constructor( - host: ZWaveHost, options: | MessageDeserializationOptions | ExtNVMWriteLongByteRequestOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { throw new ZWaveError( `${this.constructor.name}: deserialization not implemented`, @@ -82,10 +80,9 @@ export class ExtNVMWriteLongByteRequest extends Message { @messageTypes(MessageType.Response, FunctionType.ExtExtWriteLongByte) export class ExtNVMWriteLongByteResponse extends Message { public constructor( - host: ZWaveHost, options: MessageDeserializationOptions, ) { - super(host, options); + super(options); this.success = this.payload[0] !== 0; } diff --git a/packages/zwave-js/src/lib/serialapi/nvm/ExtendedNVMOperationsMessages.ts b/packages/zwave-js/src/lib/serialapi/nvm/ExtendedNVMOperationsMessages.ts index 9f51e2e18408..4bfd2177595b 100644 --- a/packages/zwave-js/src/lib/serialapi/nvm/ExtendedNVMOperationsMessages.ts +++ b/packages/zwave-js/src/lib/serialapi/nvm/ExtendedNVMOperationsMessages.ts @@ -6,7 +6,6 @@ import { ZWaveErrorCodes, validatePayload, } from "@zwave-js/core"; -import type { ZWaveHost } from "@zwave-js/host"; import type { MessageEncodingContext, SuccessIndicator, @@ -76,8 +75,8 @@ export class ExtendedNVMOperationsRequest extends Message { export class ExtendedNVMOperationsOpenRequest extends ExtendedNVMOperationsRequest { - public constructor(host: ZWaveHost, options?: MessageOptions) { - super(host, options); + public constructor(options?: MessageOptions) { + super(options); this.command = ExtendedNVMOperationsCommand.Open; } } @@ -87,8 +86,8 @@ export class ExtendedNVMOperationsOpenRequest export class ExtendedNVMOperationsCloseRequest extends ExtendedNVMOperationsRequest { - public constructor(host: ZWaveHost, options?: MessageOptions) { - super(host, options); + public constructor(options?: MessageOptions) { + super(options); this.command = ExtendedNVMOperationsCommand.Close; } } @@ -106,12 +105,11 @@ export class ExtendedNVMOperationsReadRequest extends ExtendedNVMOperationsRequest { public constructor( - host: ZWaveHost, options: | MessageDeserializationOptions | ExtendedNVMOperationsReadRequestOptions, ) { - super(host, options); + super(options); this.command = ExtendedNVMOperationsCommand.Read; if (gotDeserializationOptions(options)) { @@ -175,12 +173,11 @@ export class ExtendedNVMOperationsWriteRequest extends ExtendedNVMOperationsRequest { public constructor( - host: ZWaveHost, options: | MessageDeserializationOptions | ExtendedNVMOperationsWriteRequestOptions, ) { - super(host, options); + super(options); this.command = ExtendedNVMOperationsCommand.Write; if (gotDeserializationOptions(options)) { @@ -240,10 +237,9 @@ export class ExtendedNVMOperationsResponse extends Message implements SuccessIndicator { public constructor( - host: ZWaveHost, options: MessageDeserializationOptions, ) { - super(host, options); + super(options); validatePayload(this.payload.length >= 2); this.status = this.payload[0]; diff --git a/packages/zwave-js/src/lib/serialapi/nvm/FirmwareUpdateNVMMessages.ts b/packages/zwave-js/src/lib/serialapi/nvm/FirmwareUpdateNVMMessages.ts index 53b257187d2d..874d40ce710d 100644 --- a/packages/zwave-js/src/lib/serialapi/nvm/FirmwareUpdateNVMMessages.ts +++ b/packages/zwave-js/src/lib/serialapi/nvm/FirmwareUpdateNVMMessages.ts @@ -7,7 +7,6 @@ import { createSimpleReflectionDecorator, validatePayload, } from "@zwave-js/core"; -import type { ZWaveHost } from "@zwave-js/host"; import type { DeserializingMessageConstructor, MessageBaseOptions, @@ -71,8 +70,8 @@ function testResponseForFirmwareUpdateNVMRequest( @priority(MessagePriority.Controller) @expectedResponse(testResponseForFirmwareUpdateNVMRequest) export class FirmwareUpdateNVMRequest extends Message { - public constructor(host: ZWaveHost, options: MessageOptions = {}) { - super(host, options); + public constructor(options: MessageOptions = {}) { + super(options); if (gotDeserializationOptions(options)) { throw new ZWaveError( `${this.constructor.name}: deserialization not implemented`, @@ -111,17 +110,16 @@ export class FirmwareUpdateNVMRequest extends Message { @messageTypes(MessageType.Response, FunctionType.FirmwareUpdateNVM) export class FirmwareUpdateNVMResponse extends Message { public constructor( - host: ZWaveHost, options: MessageDeserializationOptions, ) { - super(host, options); + super(options); this.command = this.payload[0]; const CommandConstructor = getSubCommandResponseConstructor( this.command, ); if (CommandConstructor && (new.target as any) !== CommandConstructor) { - return new CommandConstructor(host, options); + return new CommandConstructor(options); } this.payload = this.payload.subarray(1); @@ -151,10 +149,9 @@ export class FirmwareUpdateNVM_InitRequest extends FirmwareUpdateNVMRequest {} @subCommandResponse(FirmwareUpdateNVMCommand.Init) export class FirmwareUpdateNVM_InitResponse extends FirmwareUpdateNVMResponse { public constructor( - host: ZWaveHost, options: MessageDeserializationOptions, ) { - super(host, options); + super(options); this.supported = this.payload[0] !== 0; } @@ -182,12 +179,11 @@ export class FirmwareUpdateNVM_SetNewImageRequest extends FirmwareUpdateNVMRequest { public constructor( - host: ZWaveHost, options: | MessageDeserializationOptions | FirmwareUpdateNVM_SetNewImageRequestOptions, ) { - super(host, options); + super(options); this.command = FirmwareUpdateNVMCommand.SetNewImage; if (gotDeserializationOptions(options)) { @@ -222,10 +218,9 @@ export class FirmwareUpdateNVM_SetNewImageResponse extends FirmwareUpdateNVMResponse { public constructor( - host: ZWaveHost, options: MessageDeserializationOptions, ) { - super(host, options); + super(options); this.changed = this.payload[0] !== 0; } @@ -252,10 +247,9 @@ export class FirmwareUpdateNVM_GetNewImageResponse extends FirmwareUpdateNVMResponse { public constructor( - host: ZWaveHost, options: MessageDeserializationOptions, ) { - super(host, options); + super(options); this.newImage = this.payload[0] !== 0; } @@ -285,12 +279,11 @@ export class FirmwareUpdateNVM_UpdateCRC16Request extends FirmwareUpdateNVMRequest { public constructor( - host: ZWaveHost, options: | MessageDeserializationOptions | FirmwareUpdateNVM_UpdateCRC16RequestOptions, ) { - super(host, options); + super(options); this.command = FirmwareUpdateNVMCommand.UpdateCRC16; if (gotDeserializationOptions(options)) { @@ -339,10 +332,9 @@ export class FirmwareUpdateNVM_UpdateCRC16Response extends FirmwareUpdateNVMResponse { public constructor( - host: ZWaveHost, options: MessageDeserializationOptions, ) { - super(host, options); + super(options); validatePayload(this.payload.length >= 2); this.crc16 = this.payload.readUint16BE(0); } @@ -375,10 +367,9 @@ export class FirmwareUpdateNVM_IsValidCRC16Response extends FirmwareUpdateNVMResponse { public constructor( - host: ZWaveHost, options: MessageDeserializationOptions, ) { - super(host, options); + super(options); this.isValid = this.payload[0] !== 0; // There are two more bytes containing the CRC result, but we don't care about that } @@ -406,12 +397,11 @@ export interface FirmwareUpdateNVM_WriteRequestOptions @subCommandRequest(FirmwareUpdateNVMCommand.Write) export class FirmwareUpdateNVM_WriteRequest extends FirmwareUpdateNVMRequest { public constructor( - host: ZWaveHost, options: | MessageDeserializationOptions | FirmwareUpdateNVM_WriteRequestOptions, ) { - super(host, options); + super(options); this.command = FirmwareUpdateNVMCommand.Write; if (gotDeserializationOptions(options)) { @@ -453,10 +443,9 @@ export class FirmwareUpdateNVM_WriteRequest extends FirmwareUpdateNVMRequest { @subCommandResponse(FirmwareUpdateNVMCommand.Write) export class FirmwareUpdateNVM_WriteResponse extends FirmwareUpdateNVMResponse { public constructor( - host: ZWaveHost, options: MessageDeserializationOptions, ) { - super(host, options); + super(options); this.overwritten = this.payload[0] !== 0; } diff --git a/packages/zwave-js/src/lib/serialapi/nvm/GetNVMIdMessages.ts b/packages/zwave-js/src/lib/serialapi/nvm/GetNVMIdMessages.ts index 8dfa52d06847..32fbe189dd50 100644 --- a/packages/zwave-js/src/lib/serialapi/nvm/GetNVMIdMessages.ts +++ b/packages/zwave-js/src/lib/serialapi/nvm/GetNVMIdMessages.ts @@ -1,5 +1,4 @@ import { type MessageOrCCLogEntry, MessagePriority } from "@zwave-js/core"; -import type { ZWaveHost } from "@zwave-js/host"; import { FunctionType, Message, @@ -74,10 +73,9 @@ export class GetNVMIdRequest extends Message {} @messageTypes(MessageType.Response, FunctionType.GetNVMId) export class GetNVMIdResponse extends Message { public constructor( - host: ZWaveHost, options: MessageDeserializationOptions, ) { - super(host, options); + super(options); this.nvmManufacturerId = this.payload[1]; this.memoryType = this.payload[2]; this.memorySize = this.payload[3]; diff --git a/packages/zwave-js/src/lib/serialapi/nvm/NVMOperationsMessages.ts b/packages/zwave-js/src/lib/serialapi/nvm/NVMOperationsMessages.ts index 08d3f3a95f11..0b8854f803aa 100644 --- a/packages/zwave-js/src/lib/serialapi/nvm/NVMOperationsMessages.ts +++ b/packages/zwave-js/src/lib/serialapi/nvm/NVMOperationsMessages.ts @@ -6,7 +6,6 @@ import { ZWaveErrorCodes, validatePayload, } from "@zwave-js/core"; -import type { ZWaveHost } from "@zwave-js/host"; import { FunctionType, Message, @@ -68,8 +67,8 @@ export class NVMOperationsRequest extends Message { // ============================================================================= export class NVMOperationsOpenRequest extends NVMOperationsRequest { - public constructor(host: ZWaveHost, options?: MessageOptions) { - super(host, options); + public constructor(options?: MessageOptions) { + super(options); this.command = NVMOperationsCommand.Open; } } @@ -77,8 +76,8 @@ export class NVMOperationsOpenRequest extends NVMOperationsRequest { // ============================================================================= export class NVMOperationsCloseRequest extends NVMOperationsRequest { - public constructor(host: ZWaveHost, options?: MessageOptions) { - super(host, options); + public constructor(options?: MessageOptions) { + super(options); this.command = NVMOperationsCommand.Close; } } @@ -92,12 +91,11 @@ export interface NVMOperationsReadRequestOptions extends MessageBaseOptions { export class NVMOperationsReadRequest extends NVMOperationsRequest { public constructor( - host: ZWaveHost, options: | MessageDeserializationOptions | NVMOperationsReadRequestOptions, ) { - super(host, options); + super(options); this.command = NVMOperationsCommand.Read; if (gotDeserializationOptions(options)) { @@ -157,12 +155,11 @@ export interface NVMOperationsWriteRequestOptions extends MessageBaseOptions { export class NVMOperationsWriteRequest extends NVMOperationsRequest { public constructor( - host: ZWaveHost, options: | MessageDeserializationOptions | NVMOperationsWriteRequestOptions, ) { - super(host, options); + super(options); this.command = NVMOperationsCommand.Write; if (gotDeserializationOptions(options)) { @@ -220,10 +217,9 @@ export class NVMOperationsWriteRequest extends NVMOperationsRequest { @messageTypes(MessageType.Response, FunctionType.NVMOperations) export class NVMOperationsResponse extends Message implements SuccessIndicator { public constructor( - host: ZWaveHost, options: MessageDeserializationOptions, ) { - super(host, options); + super(options); validatePayload(this.payload.length >= 2); this.status = this.payload[0]; diff --git a/packages/zwave-js/src/lib/serialapi/transport/SendDataBridgeMessages.ts b/packages/zwave-js/src/lib/serialapi/transport/SendDataBridgeMessages.ts index c52dd4b459ab..d26e049f9cc1 100644 --- a/packages/zwave-js/src/lib/serialapi/transport/SendDataBridgeMessages.ts +++ b/packages/zwave-js/src/lib/serialapi/transport/SendDataBridgeMessages.ts @@ -12,7 +12,7 @@ import { ZWaveErrorCodes, encodeNodeID, } from "@zwave-js/core"; -import type { CCEncodingContext, ZWaveHost } from "@zwave-js/host"; +import type { CCEncodingContext } from "@zwave-js/host"; import type { MessageEncodingContext, SuccessIndicator, @@ -40,14 +40,14 @@ import { parseTXReport, txReportToMessageRecord } from "./SendDataShared"; @messageTypes(MessageType.Request, FunctionType.SendDataBridge) @priority(MessagePriority.Normal) export class SendDataBridgeRequestBase extends Message { - public constructor(host: ZWaveHost, options: MessageOptions) { + public constructor(options: MessageOptions) { if ( gotDeserializationOptions(options) && (new.target as any) !== SendDataBridgeRequestTransmitReport ) { - return new SendDataBridgeRequestTransmitReport(host, options); + return new SendDataBridgeRequestTransmitReport(options); } - super(host, options); + super(options); } } @@ -67,10 +67,9 @@ export class SendDataBridgeRequest implements ICommandClassContainer { public constructor( - host: ZWaveHost, options: SendDataBridgeRequestOptions, ) { - super(host, options); + super(options); if (!options.command.isSinglecast() && !options.command.isBroadcast()) { throw new ZWaveError( @@ -190,12 +189,11 @@ export class SendDataBridgeRequestTransmitReport implements SuccessIndicator { public constructor( - host: ZWaveHost, options: | MessageDeserializationOptions | SendDataBridgeRequestTransmitReportOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { this.callbackId = this.payload[0]; @@ -241,10 +239,9 @@ export class SendDataBridgeResponse extends Message implements SuccessIndicator { public constructor( - host: ZWaveHost, options: MessageDeserializationOptions, ) { - super(host, options); + super(options); this._wasSent = this.payload[0] !== 0; } @@ -268,18 +265,15 @@ export class SendDataBridgeResponse extends Message @messageTypes(MessageType.Request, FunctionType.SendDataMulticastBridge) @priority(MessagePriority.Normal) export class SendDataMulticastBridgeRequestBase extends Message { - public constructor(host: ZWaveHost, options: MessageOptions) { + public constructor(options: MessageOptions) { if ( gotDeserializationOptions(options) && (new.target as any) !== SendDataMulticastBridgeRequestTransmitReport ) { - return new SendDataMulticastBridgeRequestTransmitReport( - host, - options, - ); + return new SendDataMulticastBridgeRequestTransmitReport(options); } - super(host, options); + super(options); } } @@ -298,10 +292,9 @@ export class SendDataMulticastBridgeRequest< CCType extends CommandClass = CommandClass, > extends SendDataMulticastBridgeRequestBase implements ICommandClassContainer { public constructor( - host: ZWaveHost, options: SendDataMulticastBridgeRequestOptions, ) { - super(host, options); + super(options); if (!options.command.isMulticast()) { throw new ZWaveError( @@ -417,12 +410,11 @@ export class SendDataMulticastBridgeRequestTransmitReport implements SuccessIndicator { public constructor( - host: ZWaveHost, options: | MessageDeserializationOptions | SendDataMulticastBridgeRequestTransmitReportOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { this.callbackId = this.payload[0]; @@ -461,10 +453,9 @@ export class SendDataMulticastBridgeResponse extends Message implements SuccessIndicator { public constructor( - host: ZWaveHost, options: MessageDeserializationOptions, ) { - super(host, options); + super(options); this._wasSent = this.payload[0] !== 0; } diff --git a/packages/zwave-js/src/lib/serialapi/transport/SendDataMessages.ts b/packages/zwave-js/src/lib/serialapi/transport/SendDataMessages.ts index 33bd3cf5f5e5..7023067ab38f 100644 --- a/packages/zwave-js/src/lib/serialapi/transport/SendDataMessages.ts +++ b/packages/zwave-js/src/lib/serialapi/transport/SendDataMessages.ts @@ -16,7 +16,7 @@ import { encodeNodeID, parseNodeID, } from "@zwave-js/core"; -import type { CCEncodingContext, ZWaveHost } from "@zwave-js/host"; +import type { CCEncodingContext } from "@zwave-js/host"; import { FunctionType, Message, @@ -48,21 +48,21 @@ export const MAX_SEND_ATTEMPTS = 5; @messageTypes(MessageType.Request, FunctionType.SendData) @priority(MessagePriority.Normal) export class SendDataRequestBase extends Message { - public constructor(host: ZWaveHost, options: MessageOptions) { + public constructor(options: MessageOptions) { if (gotDeserializationOptions(options)) { if ( options.origin === MessageOrigin.Host && (new.target as any) !== SendDataRequest ) { - return new SendDataRequest(host, options); + return new SendDataRequest(options); } else if ( options.origin !== MessageOrigin.Host && (new.target as any) !== SendDataRequestTransmitReport ) { - return new SendDataRequestTransmitReport(host, options); + return new SendDataRequestTransmitReport(options); } } - super(host, options); + super(options); } } @@ -81,10 +81,9 @@ export class SendDataRequest implements ICommandClassContainer { public constructor( - host: ZWaveHost, options: MessageDeserializationOptions | SendDataRequestOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { let offset = 0; @@ -105,7 +104,7 @@ export class SendDataRequest ); if (options.parseCCs !== false) { - this.command = CommandClass.from(host, { + this.command = CommandClass.from({ nodeId, data: this.payload, origin: options.origin, @@ -226,12 +225,11 @@ export class SendDataRequestTransmitReport extends SendDataRequestBase implements SuccessIndicator { public constructor( - host: ZWaveHost, options: | MessageDeserializationOptions | SendDataRequestTransmitReportOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { this.callbackId = this.payload[0]; @@ -297,10 +295,9 @@ export interface SendDataResponseOptions extends MessageBaseOptions { @messageTypes(MessageType.Response, FunctionType.SendData) export class SendDataResponse extends Message implements SuccessIndicator { public constructor( - host: ZWaveHost, options: MessageDeserializationOptions | SendDataResponseOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { this.wasSent = this.payload[0] !== 0; } else { @@ -330,26 +327,23 @@ export class SendDataResponse extends Message implements SuccessIndicator { @messageTypes(MessageType.Request, FunctionType.SendDataMulticast) @priority(MessagePriority.Normal) export class SendDataMulticastRequestBase extends Message { - public constructor(host: ZWaveHost, options: MessageOptions) { + public constructor(options: MessageOptions) { if (gotDeserializationOptions(options)) { if ( options.origin === MessageOrigin.Host && (new.target as any) !== SendDataMulticastRequest ) { - return new SendDataMulticastRequest(host, options); + return new SendDataMulticastRequest(options); } else if ( options.origin !== MessageOrigin.Host && (new.target as any) !== SendDataMulticastRequestTransmitReport ) { - return new SendDataMulticastRequestTransmitReport( - host, - options, - ); + return new SendDataMulticastRequestTransmitReport(options); } } - super(host, options); + super(options); } } @@ -367,12 +361,11 @@ export class SendDataMulticastRequest< CCType extends CommandClass = CommandClass, > extends SendDataMulticastRequestBase implements ICommandClassContainer { public constructor( - host: ZWaveHost, options: | MessageDeserializationOptions | SendDataMulticastRequestOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { const numNodeIDs = this.payload[0]; @@ -403,7 +396,7 @@ export class SendDataMulticastRequest< this.payload = serializedCC; if (options.parseCCs !== false) { - this.command = CommandClass.from(host, { + this.command = CommandClass.from({ nodeId: this._nodeIds[0], data: this.payload, origin: options.origin, @@ -525,12 +518,11 @@ export class SendDataMulticastRequestTransmitReport implements SuccessIndicator { public constructor( - host: ZWaveHost, options: | MessageDeserializationOptions | SendDataMulticastRequestTransmitReportOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { this.callbackId = this.payload[0]; @@ -580,12 +572,11 @@ export class SendDataMulticastResponse extends Message implements SuccessIndicator { public constructor( - host: ZWaveHost, options: | MessageDeserializationOptions | SendDataMulticastResponseOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { this.wasSent = this.payload[0] !== 0; } else { diff --git a/packages/zwave-js/src/lib/serialapi/transport/SendTestFrameMessages.ts b/packages/zwave-js/src/lib/serialapi/transport/SendTestFrameMessages.ts index 484a2d106c50..9224515076ea 100644 --- a/packages/zwave-js/src/lib/serialapi/transport/SendTestFrameMessages.ts +++ b/packages/zwave-js/src/lib/serialapi/transport/SendTestFrameMessages.ts @@ -6,7 +6,6 @@ import { encodeNodeID, parseNodeID, } from "@zwave-js/core"; -import type { ZWaveHost } from "@zwave-js/host"; import { FunctionType, Message, @@ -27,14 +26,14 @@ import { getEnumMemberName } from "@zwave-js/shared"; @messageTypes(MessageType.Request, FunctionType.SendTestFrame) @priority(MessagePriority.Normal) export class SendTestFrameRequestBase extends Message { - public constructor(host: ZWaveHost, options: MessageOptions) { + public constructor(options: MessageOptions) { if ( gotDeserializationOptions(options) && (new.target as any) !== SendTestFrameTransmitReport ) { - return new SendTestFrameTransmitReport(host, options); + return new SendTestFrameTransmitReport(options); } - super(host, options); + super(options); } } @@ -47,10 +46,9 @@ export interface SendTestFrameRequestOptions extends MessageBaseOptions { @expectedCallback(FunctionType.SendTestFrame) export class SendTestFrameRequest extends SendTestFrameRequestBase { public constructor( - host: ZWaveHost, options: MessageDeserializationOptions | SendTestFrameRequestOptions, ) { - super(host, options); + super(options); if (gotDeserializationOptions(options)) { let offset = 0; const { nodeId, bytesRead: nodeIdBytes } = parseNodeID( @@ -101,10 +99,9 @@ export class SendTestFrameRequest extends SendTestFrameRequestBase { @messageTypes(MessageType.Response, FunctionType.SendTestFrame) export class SendTestFrameResponse extends Message { public constructor( - host: ZWaveHost, options: MessageDeserializationOptions, ) { - super(host, options); + super(options); this.wasSent = this.payload[0] !== 0; } @@ -122,10 +119,9 @@ export class SendTestFrameTransmitReport extends SendTestFrameRequestBase implements SuccessIndicator { public constructor( - host: ZWaveHost, options: MessageDeserializationOptions, ) { - super(host, options); + super(options); this.callbackId = this.payload[0]; this.transmitStatus = this.payload[1]; diff --git a/packages/zwave-js/src/lib/test/cc-specific/discardUnsupportedReports.test.ts b/packages/zwave-js/src/lib/test/cc-specific/discardUnsupportedReports.test.ts index d67a0d433b97..cbd179e574c3 100644 --- a/packages/zwave-js/src/lib/test/cc-specific/discardUnsupportedReports.test.ts +++ b/packages/zwave-js/src/lib/test/cc-specific/discardUnsupportedReports.test.ts @@ -24,7 +24,7 @@ integrationTest( testBody: async (t, driver, node, mockController, mockNode) => { // Unsupported report from root endpoint - let cc: CommandClass = new MultilevelSensorCCReport(mockNode.host, { + let cc: CommandClass = new MultilevelSensorCCReport({ nodeId: mockController.ownNodeId, type: 0x01, // Temperature scale: 0x00, // Celsius @@ -37,13 +37,13 @@ integrationTest( ); // Report from endpoint 1, unsupported on root - cc = new MultilevelSensorCCReport(mockNode.host, { + cc = new MultilevelSensorCCReport({ nodeId: mockController.ownNodeId, type: 0x01, // Temperature scale: 0x00, // Celsius value: 25.12, }); - cc = new MultiChannelCCCommandEncapsulation(mockNode.host, { + cc = new MultiChannelCCCommandEncapsulation({ nodeId: mockController.ownNodeId, endpoint: 1, destination: 0, @@ -56,13 +56,13 @@ integrationTest( ); // Unsupported Report from endpoint 1, supported on root - cc = new MeterCCReport(mockNode.host, { + cc = new MeterCCReport({ nodeId: mockController.ownNodeId, type: 0x01, // Electric scale: 0x00, // kWh value: 1.234, }); - cc = new MultiChannelCCCommandEncapsulation(mockNode.host, { + cc = new MultiChannelCCCommandEncapsulation({ nodeId: mockController.ownNodeId, endpoint: 1, destination: 0, @@ -75,7 +75,7 @@ integrationTest( ); // Supported report from root endpoint - cc = new MeterCCReport(mockNode.host, { + cc = new MeterCCReport({ nodeId: mockController.ownNodeId, type: 0x01, // Electric scale: 0x00, // kWh diff --git a/packages/zwave-js/src/lib/test/cc-specific/mapNotificationDoorLock.test.ts b/packages/zwave-js/src/lib/test/cc-specific/mapNotificationDoorLock.test.ts index f8d7f3320652..b99c1977ba42 100644 --- a/packages/zwave-js/src/lib/test/cc-specific/mapNotificationDoorLock.test.ts +++ b/packages/zwave-js/src/lib/test/cc-specific/mapNotificationDoorLock.test.ts @@ -18,7 +18,7 @@ integrationTest( testBody: async (t, driver, node, mockController, mockNode) => { const valueId = DoorLockCCValues.currentMode.id; - let cc = new NotificationCCReport(mockNode.host, { + let cc = new NotificationCCReport({ nodeId: mockController.ownNodeId, notificationType: 0x06, // Access Control, notificationEvent: 0x01, // Manual Lock Operation @@ -33,7 +33,7 @@ integrationTest( t.is(node.getValue(valueId), DoorLockMode.Secured); - cc = new NotificationCCReport(mockNode.host, { + cc = new NotificationCCReport({ nodeId: mockController.ownNodeId, notificationType: 0x06, // Access Control, notificationEvent: 0x06, // Keypad Unlock Operation diff --git a/packages/zwave-js/src/lib/test/cc-specific/notificationEnums.test.ts b/packages/zwave-js/src/lib/test/cc-specific/notificationEnums.test.ts index f78f514a8311..3c935c56b20a 100644 --- a/packages/zwave-js/src/lib/test/cc-specific/notificationEnums.test.ts +++ b/packages/zwave-js/src/lib/test/cc-specific/notificationEnums.test.ts @@ -49,7 +49,7 @@ integrationTest( }); // Send notifications to the node - let cc = new NotificationCCReport(mockNode.host, { + let cc = new NotificationCCReport({ nodeId: mockController.ownNodeId, notificationType: 0x0f, notificationEvent: 0x01, @@ -66,7 +66,7 @@ integrationTest( let value = node.getValue(valveOperationStatusId); t.is(value, 0x00); - cc = new NotificationCCReport(mockNode.host, { + cc = new NotificationCCReport({ nodeId: mockController.ownNodeId, notificationType: 0x0f, notificationEvent: 0x01, @@ -124,7 +124,7 @@ integrationTest( }); // Send notifications to the node - let cc = new NotificationCCReport(mockNode.host, { + let cc = new NotificationCCReport({ nodeId: mockController.ownNodeId, notificationType: 0x06, notificationEvent: 0x16, @@ -141,7 +141,7 @@ integrationTest( let value = node.getValue(doorStateValueId); t.is(value, 0x1600); - cc = new NotificationCCReport(mockNode.host, { + cc = new NotificationCCReport({ nodeId: mockController.ownNodeId, notificationType: 0x06, notificationEvent: 0x16, @@ -157,7 +157,7 @@ integrationTest( value = node.getValue(doorStateValueId); t.is(value, 0x1601); - cc = new NotificationCCReport(mockNode.host, { + cc = new NotificationCCReport({ nodeId: mockController.ownNodeId, notificationType: 0x06, notificationEvent: 0x16, // open @@ -172,7 +172,7 @@ integrationTest( value = node.getValue(doorStateValueId); t.is(value, 0x16); - cc = new NotificationCCReport(mockNode.host, { + cc = new NotificationCCReport({ nodeId: mockController.ownNodeId, notificationType: 0x06, notificationEvent: 0x17, // closed @@ -240,7 +240,7 @@ integrationTest("The 'simple' Door state value works correctly", { ); const valueSimple = NotificationCCValues.doorStateSimple; - let cc = new NotificationCCReport(mockNode.host, { + let cc = new NotificationCCReport({ nodeId: mockController.ownNodeId, notificationType: 0x06, notificationEvent: 0x16, // Window/door is open @@ -259,7 +259,7 @@ integrationTest("The 'simple' Door state value works correctly", { // === - cc = new NotificationCCReport(mockNode.host, { + cc = new NotificationCCReport({ nodeId: mockController.ownNodeId, notificationType: 0x06, notificationEvent: 0x16, // Window/door is open @@ -278,7 +278,7 @@ integrationTest("The 'simple' Door state value works correctly", { // === - cc = new NotificationCCReport(mockNode.host, { + cc = new NotificationCCReport({ nodeId: mockController.ownNodeId, notificationType: 0x06, notificationEvent: 0x16, // Window/door is open @@ -296,7 +296,7 @@ integrationTest("The 'simple' Door state value works correctly", { // === - cc = new NotificationCCReport(mockNode.host, { + cc = new NotificationCCReport({ nodeId: mockController.ownNodeId, notificationType: 0x06, notificationEvent: 0x17, // Window/door is closed @@ -346,7 +346,7 @@ integrationTest("The synthetic 'Door tilt state' value works correctly", { t.false(hasTiltVID()); // Send a notification to the node where the window is not tilted - let cc = new NotificationCCReport(mockNode.host, { + let cc = new NotificationCCReport({ nodeId: mockController.ownNodeId, notificationType: 0x06, notificationEvent: 0x16, // Window/door is open @@ -366,7 +366,7 @@ integrationTest("The synthetic 'Door tilt state' value works correctly", { // === // Again with tilt - cc = new NotificationCCReport(mockNode.host, { + cc = new NotificationCCReport({ nodeId: mockController.ownNodeId, notificationType: 0x06, notificationEvent: 0x16, // Window/door is open @@ -387,7 +387,7 @@ integrationTest("The synthetic 'Door tilt state' value works correctly", { // === // Again without tilt - cc = new NotificationCCReport(mockNode.host, { + cc = new NotificationCCReport({ nodeId: mockController.ownNodeId, notificationType: 0x06, notificationEvent: 0x16, // Window/door is open @@ -406,7 +406,7 @@ integrationTest("The synthetic 'Door tilt state' value works correctly", { // === // Again with tilt to be able to detect changes - cc = new NotificationCCReport(mockNode.host, { + cc = new NotificationCCReport({ nodeId: mockController.ownNodeId, notificationType: 0x06, notificationEvent: 0x16, // Window/door is open @@ -425,7 +425,7 @@ integrationTest("The synthetic 'Door tilt state' value works correctly", { // === // And now without the enum - cc = new NotificationCCReport(mockNode.host, { + cc = new NotificationCCReport({ nodeId: mockController.ownNodeId, notificationType: 0x06, notificationEvent: 0x17, // Window/door is closed @@ -443,7 +443,7 @@ integrationTest("The synthetic 'Door tilt state' value works correctly", { // === // Again with tilt to be able to detect changes - cc = new NotificationCCReport(mockNode.host, { + cc = new NotificationCCReport({ nodeId: mockController.ownNodeId, notificationType: 0x06, notificationEvent: 0x16, // Window/door is open @@ -462,7 +462,7 @@ integrationTest("The synthetic 'Door tilt state' value works correctly", { // === // And again without the enum - cc = new NotificationCCReport(mockNode.host, { + cc = new NotificationCCReport({ nodeId: mockController.ownNodeId, notificationType: 0x06, notificationEvent: 0x16, // Window/door is open @@ -520,7 +520,7 @@ integrationTest( }); // Send notifications to the node - let cc = new NotificationCCReport(mockNode.host, { + let cc = new NotificationCCReport({ nodeId: mockController.ownNodeId, notificationType: 0x05, notificationEvent: 0x07, @@ -538,7 +538,7 @@ integrationTest( t.is(value, 0x02); // Now send one without an event parameter - cc = new NotificationCCReport(mockNode.host, { + cc = new NotificationCCReport({ nodeId: mockController.ownNodeId, notificationType: 0x05, notificationEvent: 0x07, @@ -553,7 +553,7 @@ integrationTest( value = node.getValue(waterPressureAlarmValueId); t.is(value, 0x01); - // cc = new NotificationCCReport(mockNode.host, { + // cc = new NotificationCCReport({ // nodeId: mockController.ownNodeId, // notificationType: 0x06, // notificationEvent: 0x16, // open @@ -568,7 +568,7 @@ integrationTest( // value = node.getValue(waterPressureAlarmValueId); // t.is(value, 0x16); - // cc = new NotificationCCReport(mockNode.host, { + // cc = new NotificationCCReport({ // nodeId: mockController.ownNodeId, // notificationType: 0x06, // notificationEvent: 0x17, // closed diff --git a/packages/zwave-js/src/lib/test/cc-specific/notificationIdleManually.test.ts b/packages/zwave-js/src/lib/test/cc-specific/notificationIdleManually.test.ts index 35f73d45cfa8..736216c9a9c3 100644 --- a/packages/zwave-js/src/lib/test/cc-specific/notificationIdleManually.test.ts +++ b/packages/zwave-js/src/lib/test/cc-specific/notificationIdleManually.test.ts @@ -17,7 +17,7 @@ integrationTest("Notification values can get idled manually", { "Alarm status", ).id; - let cc = new NotificationCCReport(mockNode.host, { + let cc = new NotificationCCReport({ nodeId: mockController.ownNodeId, notificationType: 0x01, // Smoke Alarm notificationEvent: 0x03, // Smoke alarm test @@ -46,7 +46,7 @@ integrationTest("Notification values can get idled manually", { "Door state", ).id; - cc = new NotificationCCReport(mockNode.host, { + cc = new NotificationCCReport({ nodeId: mockController.ownNodeId, notificationType: 0x06, // Access Control notificationEvent: 0x16, // Door state @@ -80,7 +80,7 @@ integrationTest( "Alarm status", ).id; - let cc = new NotificationCCReport(mockNode.host, { + let cc = new NotificationCCReport({ nodeId: mockController.ownNodeId, notificationType: 0x01, // Smoke Alarm notificationEvent: 0x03, // Smoke alarm test @@ -108,7 +108,7 @@ integrationTest( "Door state", ).id; - cc = new NotificationCCReport(mockNode.host, { + cc = new NotificationCCReport({ nodeId: mockController.ownNodeId, notificationType: 0x06, // Access Control notificationEvent: 0x16, // Door state diff --git a/packages/zwave-js/src/lib/test/cc-specific/notificationIdleRelated.test.ts b/packages/zwave-js/src/lib/test/cc-specific/notificationIdleRelated.test.ts index 3b5c77ffc139..ddc52c574833 100644 --- a/packages/zwave-js/src/lib/test/cc-specific/notificationIdleRelated.test.ts +++ b/packages/zwave-js/src/lib/test/cc-specific/notificationIdleRelated.test.ts @@ -22,7 +22,7 @@ integrationTest( "Lock state", ).id; - let cc = new NotificationCCReport(mockNode.host, { + let cc = new NotificationCCReport({ nodeId: mockController.ownNodeId, notificationType: 0x06, // Access Control, notificationEvent: 0x0b, // Lock jammed @@ -37,7 +37,7 @@ integrationTest( t.is(node.getValue(lockStateValueId), 0x0b /* Lock jammed */); - cc = new NotificationCCReport(mockNode.host, { + cc = new NotificationCCReport({ nodeId: mockController.ownNodeId, notificationType: 0x06, // Access Control, notificationEvent: 0x06, // Keypad Unlock Operation diff --git a/packages/zwave-js/src/lib/test/cc-specific/undefinedTargetValue.test.ts b/packages/zwave-js/src/lib/test/cc-specific/undefinedTargetValue.test.ts index 9077749337ad..e1ed5ddb699f 100644 --- a/packages/zwave-js/src/lib/test/cc-specific/undefinedTargetValue.test.ts +++ b/packages/zwave-js/src/lib/test/cc-specific/undefinedTargetValue.test.ts @@ -18,7 +18,7 @@ integrationTest( const targetValueValueID = BinarySwitchCCValues.targetValue.id; node.valueDB.setValue(targetValueValueID, false); - const cc = new BinarySwitchCCReport(mockNode.host, { + const cc = new BinarySwitchCCReport({ nodeId: mockController.ownNodeId, currentValue: true, }); diff --git a/packages/zwave-js/src/lib/test/cc-specific/unknownNotifications.test.ts b/packages/zwave-js/src/lib/test/cc-specific/unknownNotifications.test.ts index 4926670410fc..0cc050765dc9 100644 --- a/packages/zwave-js/src/lib/test/cc-specific/unknownNotifications.test.ts +++ b/packages/zwave-js/src/lib/test/cc-specific/unknownNotifications.test.ts @@ -18,7 +18,7 @@ integrationTest( ), testBody: async (t, driver, node, mockController, mockNode) => { - const cc = new NotificationCCReport(mockNode.host, { + const cc = new NotificationCCReport({ nodeId: mockController.ownNodeId, notificationType: 0x06, // Access Control, notificationEvent: 0xfd, // Manual Lock Operation diff --git a/packages/zwave-js/src/lib/test/cc/API.test.ts b/packages/zwave-js/src/lib/test/cc/API.test.ts index 97762861ac6e..5770a3b76845 100644 --- a/packages/zwave-js/src/lib/test/cc/API.test.ts +++ b/packages/zwave-js/src/lib/test/cc/API.test.ts @@ -51,6 +51,6 @@ test.after.always(async (t) => { test.serial(`supportsCommand() returns NOT_KNOWN by default`, (t) => { const { node2, driver } = t.context; - const API = new DummyCCAPI(driver, node2); + const API = new DummyCCAPI(node2); t.is(API.supportsCommand(null as any), NOT_KNOWN); }); diff --git a/packages/zwave-js/src/lib/test/cc/AssociationCC.test.ts b/packages/zwave-js/src/lib/test/cc/AssociationCC.test.ts index c983331c5a5e..2ea9287042b8 100644 --- a/packages/zwave-js/src/lib/test/cc/AssociationCC.test.ts +++ b/packages/zwave-js/src/lib/test/cc/AssociationCC.test.ts @@ -23,7 +23,7 @@ function buildCCBuffer(payload: Buffer): Buffer { } test("the SupportedGroupingsGet command should serialize correctly", (t) => { - const cc = new AssociationCCSupportedGroupingsGet(host, { + const cc = new AssociationCCSupportedGroupingsGet({ nodeId: 1, }); const expected = buildCCBuffer( @@ -41,7 +41,7 @@ test("the SupportedGroupingsReport command should be deserialized correctly", (t 7, // # of groups ]), ); - const cc = new AssociationCCSupportedGroupingsReport(host, { + const cc = new AssociationCCSupportedGroupingsReport({ nodeId: 2, data: ccData, context: {} as any, @@ -51,7 +51,7 @@ test("the SupportedGroupingsReport command should be deserialized correctly", (t }); test("the Set command should serialize correctly", (t) => { - const cc = new AssociationCCSet(host, { + const cc = new AssociationCCSet({ nodeId: 2, groupId: 5, nodeIds: [1, 2, 5], @@ -69,7 +69,7 @@ test("the Set command should serialize correctly", (t) => { t.deepEqual(cc.serialize({} as any), expected); }); test("the Get command should serialize correctly", (t) => { - const cc = new AssociationCCGet(host, { + const cc = new AssociationCCGet({ nodeId: 1, groupId: 9, }); @@ -95,7 +95,7 @@ test("the Report command should be deserialized correctly", (t) => { 5, ]), ); - const cc = new AssociationCCReport(host, { + const cc = new AssociationCCReport({ nodeId: 1, data: ccData, context: {} as any, @@ -108,7 +108,7 @@ test("the Report command should be deserialized correctly", (t) => { }); test("the Remove command should serialize correctly", (t) => { - const cc = new AssociationCCRemove(host, { + const cc = new AssociationCCRemove({ nodeId: 2, groupId: 5, nodeIds: [1, 2, 5], @@ -127,7 +127,7 @@ test("the Remove command should serialize correctly", (t) => { }); test("the Remove command should serialize correctly (empty node list)", (t) => { - const cc = new AssociationCCRemove(host, { + const cc = new AssociationCCRemove({ nodeId: 2, groupId: 5, }); @@ -145,7 +145,7 @@ test("the Remove command should serialize correctly (empty node list)", (t) => { // 1, // Buffer.from([255]), // not a valid command // ); -// const cc: any = new AssociationCC(host, { +// const cc: any = new AssociationCC({ // data: serializedCC, // }); // t.is(cc.constructor, AssociationCC); diff --git a/packages/zwave-js/src/lib/test/cc/AssociationGroupInfoCC.test.ts b/packages/zwave-js/src/lib/test/cc/AssociationGroupInfoCC.test.ts index 901f4419d375..dd9b5bb70c26 100644 --- a/packages/zwave-js/src/lib/test/cc/AssociationGroupInfoCC.test.ts +++ b/packages/zwave-js/src/lib/test/cc/AssociationGroupInfoCC.test.ts @@ -26,7 +26,7 @@ function buildCCBuffer(payload: Buffer): Buffer { } test("the NameGet command should serialize correctly", (t) => { - const cc = new AssociationGroupInfoCCNameGet(host, { + const cc = new AssociationGroupInfoCCNameGet({ nodeId: 1, groupId: 7, }); @@ -54,7 +54,7 @@ test("the NameReport command should be deserialized correctly", (t) => { 0x72, ]), ); - const cc = new AssociationGroupInfoCCNameReport(host, { + const cc = new AssociationGroupInfoCCNameReport({ nodeId: 1, data: ccData, context: {} as any, @@ -65,7 +65,7 @@ test("the NameReport command should be deserialized correctly", (t) => { }); test("the InfoGet command should serialize correctly (no flag set)", (t) => { - const cc = new AssociationGroupInfoCCInfoGet(host, { + const cc = new AssociationGroupInfoCCInfoGet({ nodeId: 1, groupId: 7, listMode: false, @@ -82,7 +82,7 @@ test("the InfoGet command should serialize correctly (no flag set)", (t) => { }); test("the InfoGet command should serialize correctly (refresh cache flag set)", (t) => { - const cc = new AssociationGroupInfoCCInfoGet(host, { + const cc = new AssociationGroupInfoCCInfoGet({ nodeId: 1, groupId: 7, listMode: false, @@ -99,7 +99,7 @@ test("the InfoGet command should serialize correctly (refresh cache flag set)", }); test("the InfoGet command should serialize correctly (list mode flag set)", (t) => { - const cc = new AssociationGroupInfoCCInfoGet(host, { + const cc = new AssociationGroupInfoCCInfoGet({ nodeId: 1, groupId: 7, listMode: true, @@ -141,7 +141,7 @@ test("the Info Report command should be deserialized correctly", (t) => { 0, ]), ); - const cc = new AssociationGroupInfoCCInfoReport(host, { + const cc = new AssociationGroupInfoCCInfoReport({ nodeId: 1, data: ccData, context: {} as any, @@ -158,7 +158,7 @@ test("the Info Report command should be deserialized correctly", (t) => { }); test("the CommandListGet command should serialize correctly", (t) => { - const cc = new AssociationGroupInfoCCCommandListGet(host, { + const cc = new AssociationGroupInfoCCCommandListGet({ nodeId: 1, groupId: 6, allowCache: true, @@ -187,7 +187,7 @@ test("the CommandListReport command should be deserialized correctly", (t) => { 0x05, ]), ); - const cc = new AssociationGroupInfoCCCommandListReport(host, { + const cc = new AssociationGroupInfoCCCommandListReport({ nodeId: 1, data: ccData, context: {} as any, @@ -206,7 +206,7 @@ test("deserializing an unsupported command should return an unspecified version const serializedCC = buildCCBuffer( Buffer.from([255]), // not a valid command ); - const cc: any = new AssociationGroupInfoCC(host, { + const cc: any = new AssociationGroupInfoCC({ nodeId: 1, data: serializedCC, context: {} as any, diff --git a/packages/zwave-js/src/lib/test/cc/BasicCC.test.ts b/packages/zwave-js/src/lib/test/cc/BasicCC.test.ts index 9d89bb144a52..f7080e9f28ff 100644 --- a/packages/zwave-js/src/lib/test/cc/BasicCC.test.ts +++ b/packages/zwave-js/src/lib/test/cc/BasicCC.test.ts @@ -25,7 +25,7 @@ function buildCCBuffer(payload: Buffer): Buffer { } test("the Get command should serialize correctly", (t) => { - const basicCC = new BasicCCGet(host, { nodeId: 1 }); + const basicCC = new BasicCCGet({ nodeId: 1 }); const expected = buildCCBuffer( Buffer.from([ BasicCommand.Get, // CC Command @@ -35,7 +35,7 @@ test("the Get command should serialize correctly", (t) => { }); test("the Set command should serialize correctly", (t) => { - const basicCC = new BasicCCSet(host, { + const basicCC = new BasicCCSet({ nodeId: 2, targetValue: 55, }); @@ -55,7 +55,7 @@ test("the Report command (v1) should be deserialized correctly", (t) => { 55, // current value ]), ); - const basicCC = new BasicCCReport(host, { + const basicCC = new BasicCCReport({ nodeId: 2, data: ccData, context: {} as any, @@ -75,7 +75,7 @@ test("the Report command (v2) should be deserialized correctly", (t) => { 1, // duration ]), ); - const basicCC = new BasicCCReport(host, { + const basicCC = new BasicCCReport({ nodeId: 2, data: ccData, context: {} as any, @@ -91,7 +91,7 @@ test("deserializing an unsupported command should return an unspecified version const serializedCC = buildCCBuffer( Buffer.from([255]), // not a valid command ); - const basicCC: any = new BasicCC(host, { + const basicCC: any = new BasicCC({ nodeId: 2, data: serializedCC, context: {} as any, @@ -137,7 +137,7 @@ test("getDefinedValueIDs() should include the target value for all endpoints exc }); test("BasicCCSet should expect no response", (t) => { - const cc = new BasicCCSet(host, { + const cc = new BasicCCSet({ nodeId: 2, endpoint: 2, targetValue: 7, @@ -146,12 +146,12 @@ test("BasicCCSet should expect no response", (t) => { }); test("BasicCCSet => BasicCCReport = unexpected", (t) => { - const ccRequest = new BasicCCSet(host, { + const ccRequest = new BasicCCSet({ nodeId: 2, endpoint: 2, targetValue: 7, }); - const ccResponse = new BasicCCReport(host, { + const ccResponse = new BasicCCReport({ nodeId: ccRequest.nodeId, currentValue: 7, }); @@ -160,17 +160,17 @@ test("BasicCCSet => BasicCCReport = unexpected", (t) => { }); test("BasicCCGet should expect a response", (t) => { - const cc = new BasicCCGet(host, { + const cc = new BasicCCGet({ nodeId: 2, }); t.true(cc.expectsCCResponse()); }); test("BasicCCGet => BasicCCReport = expected", (t) => { - const ccRequest = new BasicCCGet(host, { + const ccRequest = new BasicCCGet({ nodeId: 2, }); - const ccResponse = new BasicCCReport(host, { + const ccResponse = new BasicCCReport({ nodeId: ccRequest.nodeId, currentValue: 7, }); @@ -179,10 +179,10 @@ test("BasicCCGet => BasicCCReport = expected", (t) => { }); test("BasicCCGet => BasicCCReport (wrong node) = unexpected", (t) => { - const ccRequest = new BasicCCGet(host, { + const ccRequest = new BasicCCGet({ nodeId: 2, }); - const ccResponse = new BasicCCReport(host, { + const ccResponse = new BasicCCReport({ nodeId: (ccRequest.nodeId as number) + 1, currentValue: 7, }); @@ -191,10 +191,10 @@ test("BasicCCGet => BasicCCReport (wrong node) = unexpected", (t) => { }); test("BasicCCGet => BasicCCSet = unexpected", (t) => { - const ccRequest = new BasicCCGet(host, { + const ccRequest = new BasicCCGet({ nodeId: 2, }); - const ccResponse = new BasicCCSet(host, { + const ccResponse = new BasicCCSet({ nodeId: ccRequest.nodeId, targetValue: 7, }); @@ -203,7 +203,7 @@ test("BasicCCGet => BasicCCSet = unexpected", (t) => { }); test("Looking up CC values for a CC instance should work", (t) => { - const cc = new BasicCCGet(host, { + const cc = new BasicCCGet({ nodeId: 2, }); const values = getCCValues(cc) as typeof BasicCCValues; diff --git a/packages/zwave-js/src/lib/test/cc/BatteryCC.test.ts b/packages/zwave-js/src/lib/test/cc/BatteryCC.test.ts index 7a52ff0a36f5..d54671ffc6c9 100644 --- a/packages/zwave-js/src/lib/test/cc/BatteryCC.test.ts +++ b/packages/zwave-js/src/lib/test/cc/BatteryCC.test.ts @@ -13,7 +13,7 @@ import test from "ava"; const host = createTestingHost(); test("the Get command should serialize correctly", (t) => { - const batteryCC = new BatteryCCGet(host, { nodeId: 1 }); + const batteryCC = new BatteryCCGet({ nodeId: 1 }); const expected = Buffer.from([ CommandClasses.Battery, // CC BatteryCommand.Get, // CC Command @@ -27,7 +27,7 @@ test("the Report command (v1) should be deserialized correctly: when the battery BatteryCommand.Report, // CC Command 55, // current value ]); - const batteryCC = new BatteryCC(host, { + const batteryCC = new BatteryCC({ nodeId: 7, data: ccData, context: {} as any, @@ -43,7 +43,7 @@ test("the Report command (v1) should be deserialized correctly: when the battery BatteryCommand.Report, // CC Command 0xff, // current value ]); - const batteryCC = new BatteryCC(host, { + const batteryCC = new BatteryCC({ nodeId: 7, data: ccData, context: {} as any, @@ -61,7 +61,7 @@ test("the Report command (v2) should be deserialized correctly: all flags set", 0b00_1111_00, 1, // disconnected ]); - const batteryCC = new BatteryCC(host, { + const batteryCC = new BatteryCC({ nodeId: 7, data: ccData, context: {} as any, @@ -82,7 +82,7 @@ test("the Report command (v2) should be deserialized correctly: charging status" 0b10_000000, // Maintaining 0, ]); - const batteryCC = new BatteryCC(host, { + const batteryCC = new BatteryCC({ nodeId: 7, data: ccData, context: {} as any, @@ -99,7 +99,7 @@ test("the Report command (v2) should be deserialized correctly: recharge or repl 0b11, // Maintaining 0, ]); - const batteryCC = new BatteryCC(host, { + const batteryCC = new BatteryCC({ nodeId: 7, data: ccData, context: {} as any, @@ -113,7 +113,7 @@ test("deserializing an unsupported command should return an unspecified version CommandClasses.Battery, // CC 255, // not a valid command ]); - const basicCC: any = new BatteryCC(host, { + const basicCC: any = new BatteryCC({ nodeId: 7, data: serializedCC, context: {} as any, diff --git a/packages/zwave-js/src/lib/test/cc/BinarySensorCC.test.ts b/packages/zwave-js/src/lib/test/cc/BinarySensorCC.test.ts index 073cf4ec7f4d..31d5251a1dca 100644 --- a/packages/zwave-js/src/lib/test/cc/BinarySensorCC.test.ts +++ b/packages/zwave-js/src/lib/test/cc/BinarySensorCC.test.ts @@ -23,7 +23,7 @@ function buildCCBuffer(payload: Buffer): Buffer { } test("the Get command should serialize correctly (no sensor type)", (t) => { - const cc = new BinarySensorCCGet(host, { nodeId: 1 }); + const cc = new BinarySensorCCGet({ nodeId: 1 }); const expected = buildCCBuffer( Buffer.from([ BinarySensorCommand.Get, // CC Command @@ -34,7 +34,7 @@ test("the Get command should serialize correctly (no sensor type)", (t) => { }); test("the Get command should serialize correctly", (t) => { - const cc = new BinarySensorCCGet(host, { + const cc = new BinarySensorCCGet({ nodeId: 1, sensorType: BinarySensorType.CO, }); @@ -51,7 +51,7 @@ test("the Report command (v1) should be deserialized correctly", (t) => { 0xff, // current value ]), ); - const cc = new BinarySensorCCReport(host, { + const cc = new BinarySensorCCReport({ nodeId: 1, data: ccData, context: {} as any, @@ -68,7 +68,7 @@ test("the Report command (v2) should be deserialized correctly", (t) => { BinarySensorType.CO2, ]), ); - const cc = new BinarySensorCCReport(host, { + const cc = new BinarySensorCCReport({ nodeId: 1, data: ccData, context: {} as any, @@ -79,7 +79,7 @@ test("the Report command (v2) should be deserialized correctly", (t) => { }); test("the SupportedGet command should serialize correctly", (t) => { - const cc = new BinarySensorCCSupportedGet(host, { nodeId: 1 }); + const cc = new BinarySensorCCSupportedGet({ nodeId: 1 }); const expected = buildCCBuffer( Buffer.from([ BinarySensorCommand.SupportedGet, // CC Command @@ -96,7 +96,7 @@ test("the SupportedReport command should be deserialized correctly", (t) => { 0b10, ]), ); - const cc = new BinarySensorCCSupportedReport(host, { + const cc = new BinarySensorCCSupportedReport({ nodeId: 1, data: ccData, context: {} as any, @@ -115,7 +115,7 @@ test("deserializing an unsupported command should return an unspecified version const serializedCC = buildCCBuffer( Buffer.from([255]), // not a valid command ); - const cc: any = new BinarySensorCC(host, { + const cc: any = new BinarySensorCC({ nodeId: 1, data: serializedCC, context: {} as any, diff --git a/packages/zwave-js/src/lib/test/cc/BinarySwitchCC.test.ts b/packages/zwave-js/src/lib/test/cc/BinarySwitchCC.test.ts index 77bae2a99407..3e6495c77ff5 100644 --- a/packages/zwave-js/src/lib/test/cc/BinarySwitchCC.test.ts +++ b/packages/zwave-js/src/lib/test/cc/BinarySwitchCC.test.ts @@ -21,7 +21,7 @@ function buildCCBuffer(payload: Buffer): Buffer { } test("the Get command should serialize correctly", (t) => { - const cc = new BinarySwitchCCGet(host, { nodeId: 1 }); + const cc = new BinarySwitchCCGet({ nodeId: 1 }); const expected = buildCCBuffer( Buffer.from([ BinarySwitchCommand.Get, // CC Command @@ -31,7 +31,7 @@ test("the Get command should serialize correctly", (t) => { }); test("the Set command should serialize correctly (no duration)", (t) => { - const cc = new BinarySwitchCCSet(host, { + const cc = new BinarySwitchCCSet({ nodeId: 2, targetValue: false, }); @@ -53,7 +53,7 @@ test("the Set command should serialize correctly (no duration)", (t) => { test("the Set command should serialize correctly", (t) => { const duration = new Duration(2, "minutes"); - const cc = new BinarySwitchCCSet(host, { + const cc = new BinarySwitchCCSet({ nodeId: 2, targetValue: true, duration, @@ -81,7 +81,7 @@ test("the Report command (v1) should be deserialized correctly", (t) => { 0xff, // current value ]), ); - const cc = new BinarySwitchCCReport(host, { + const cc = new BinarySwitchCCReport({ nodeId: 2, data: ccData, context: {} as any, @@ -101,7 +101,7 @@ test("the Report command (v2) should be deserialized correctly", (t) => { 1, // duration ]), ); - const cc = new BinarySwitchCCReport(host, { + const cc = new BinarySwitchCCReport({ nodeId: 2, data: ccData, context: {} as any, @@ -117,7 +117,7 @@ test("deserializing an unsupported command should return an unspecified version const serializedCC = buildCCBuffer( Buffer.from([255]), // not a valid command ); - const cc: any = new BinarySwitchCC(host, { + const cc: any = new BinarySwitchCC({ nodeId: 2, data: serializedCC, context: {} as any, diff --git a/packages/zwave-js/src/lib/test/cc/CRC16CC.test.ts b/packages/zwave-js/src/lib/test/cc/CRC16CC.test.ts index 4a48f506f282..75904afa7c30 100644 --- a/packages/zwave-js/src/lib/test/cc/CRC16CC.test.ts +++ b/packages/zwave-js/src/lib/test/cc/CRC16CC.test.ts @@ -13,7 +13,7 @@ import test from "ava"; const host = createTestingHost(); test("should be detected as an encapsulating CC", (t) => { - const basicCCSet = new BasicCCSet(host, { + const basicCCSet = new BasicCCSet({ nodeId: 3, targetValue: 89, }); @@ -23,7 +23,7 @@ test("should be detected as an encapsulating CC", (t) => { test("should match the specs", (t) => { // SDS13783 contains the following sample encapsulated command: - const basicCCGet = new BasicCCGet(host, { nodeId: 1 }); + const basicCCGet = new BasicCCGet({ nodeId: 1 }); const crc16 = CRC16CC.encapsulate(host, basicCCGet); const serialized = crc16.serialize({} as any); const expected = Buffer.from("560120024d26", "hex"); @@ -31,7 +31,7 @@ test("should match the specs", (t) => { }); test("serialization and deserialization should be compatible", (t) => { - const basicCCSet = new BasicCCSet(host, { + const basicCCSet = new BasicCCSet({ nodeId: 3, targetValue: 89, }); @@ -40,7 +40,7 @@ test("serialization and deserialization should be compatible", (t) => { t.is(crc16.encapsulated, basicCCSet); const serialized = crc16.serialize({} as any); - const deserialized = CommandClass.from(host, { + const deserialized = CommandClass.from({ nodeId: basicCCSet.nodeId as number, data: serialized, context: {} as any, @@ -54,7 +54,7 @@ test("serialization and deserialization should be compatible", (t) => { }); test("deserializing a CC with a wrong checksum should result in an invalid CC", (t) => { - const basicCCSet = new BasicCCSet(host, { + const basicCCSet = new BasicCCSet({ nodeId: 3, targetValue: 89, }); @@ -64,7 +64,7 @@ test("deserializing a CC with a wrong checksum should result in an invalid CC", const serialized = crc16.serialize({} as any); serialized[serialized.length - 1] ^= 0xff; - const decoded = CommandClass.from(host, { + const decoded = CommandClass.from({ nodeId: basicCCSet.nodeId as number, data: serialized, context: {} as any, diff --git a/packages/zwave-js/src/lib/test/cc/CentralSceneCC.test.ts b/packages/zwave-js/src/lib/test/cc/CentralSceneCC.test.ts index 0df8766b8eba..0121b582754a 100644 --- a/packages/zwave-js/src/lib/test/cc/CentralSceneCC.test.ts +++ b/packages/zwave-js/src/lib/test/cc/CentralSceneCC.test.ts @@ -25,7 +25,7 @@ function buildCCBuffer(payload: Buffer): Buffer { } test("the ConfigurationGet command should serialize correctly", (t) => { - const cc = new CentralSceneCCConfigurationGet(host, { + const cc = new CentralSceneCCConfigurationGet({ nodeId: 1, }); const expected = buildCCBuffer( @@ -37,7 +37,7 @@ test("the ConfigurationGet command should serialize correctly", (t) => { }); test("the ConfigurationSet command should serialize correctly (flags set)", (t) => { - const cc = new CentralSceneCCConfigurationSet(host, { + const cc = new CentralSceneCCConfigurationSet({ nodeId: 2, slowRefresh: true, }); @@ -51,7 +51,7 @@ test("the ConfigurationSet command should serialize correctly (flags set)", (t) }); test("the ConfigurationSet command should serialize correctly (flags not set)", (t) => { - const cc = new CentralSceneCCConfigurationSet(host, { + const cc = new CentralSceneCCConfigurationSet({ nodeId: 2, slowRefresh: false, }); @@ -71,7 +71,7 @@ test("the ConfigurationReport command should be deserialized correctly", (t) => 0b1000_0000, ]), ); - const cc = new CentralSceneCCConfigurationReport(host, { + const cc = new CentralSceneCCConfigurationReport({ nodeId: 1, data: ccData, context: {} as any, @@ -81,7 +81,7 @@ test("the ConfigurationReport command should be deserialized correctly", (t) => }); test("the SupportedGet command should serialize correctly", (t) => { - const cc = new CentralSceneCCSupportedGet(host, { + const cc = new CentralSceneCCSupportedGet({ nodeId: 1, }); const expected = buildCCBuffer( @@ -104,7 +104,7 @@ test("the SupportedReport command should be deserialized correctly", (t) => { 0, ]), ); - const cc = new CentralSceneCCSupportedReport(host, { + const cc = new CentralSceneCCSupportedReport({ nodeId: 1, data: ccData, context: {} as any, @@ -127,7 +127,7 @@ test("the Notification command should be deserialized correctly", (t) => { 8, // scene number ]), ); - const cc = new CentralSceneCCNotification(host, { + const cc = new CentralSceneCCNotification({ nodeId: 1, data: ccData, context: {} as any, @@ -149,7 +149,7 @@ test("the Notification command should be deserialized correctly (KeyHeldDown)", 8, // scene number ]), ); - const cc = new CentralSceneCCNotification(host, { + const cc = new CentralSceneCCNotification({ nodeId: 1, data: ccData, context: {} as any, @@ -165,7 +165,7 @@ test("deserializing an unsupported command should return an unspecified version const serializedCC = buildCCBuffer( Buffer.from([255]), // not a valid command ); - const cc: any = new CentralSceneCC(host, { + const cc: any = new CentralSceneCC({ nodeId: 1, data: serializedCC, context: {} as any, diff --git a/packages/zwave-js/src/lib/test/cc/ColorSwitchCC.test.ts b/packages/zwave-js/src/lib/test/cc/ColorSwitchCC.test.ts index 8381339036f5..e0ed797ac7f2 100644 --- a/packages/zwave-js/src/lib/test/cc/ColorSwitchCC.test.ts +++ b/packages/zwave-js/src/lib/test/cc/ColorSwitchCC.test.ts @@ -31,7 +31,7 @@ function buildCCBuffer(payload: Buffer): Buffer { } test("the SupportedGet command should serialize correctly", (t) => { - const cc = new ColorSwitchCCSupportedGet(host, { + const cc = new ColorSwitchCCSupportedGet({ nodeId: 1, }); const expected = buildCCBuffer( @@ -50,7 +50,7 @@ test("the SupportedReport command should deserialize correctly", (t) => { 0b0000_0001, ]), ); - const cc = new ColorSwitchCCSupportedReport(host, { + const cc = new ColorSwitchCCSupportedReport({ nodeId: 1, data: ccData, context: {} as any, @@ -72,7 +72,7 @@ test("the SupportedReport command should deserialize correctly", (t) => { }); test("the Get command should serialize correctly", (t) => { - const cc = new ColorSwitchCCGet(host, { + const cc = new ColorSwitchCCGet({ nodeId: 1, colorComponent: ColorComponent.Red, }); @@ -93,7 +93,7 @@ test("the Report command should deserialize correctly (version 1)", (t) => { 0b1111_1111, // value: 255 ]), ); - const cc = new ColorSwitchCCReport(host, { + const cc = new ColorSwitchCCReport({ nodeId: 1, data: ccData, context: {} as any, @@ -115,7 +115,7 @@ test("the Report command should deserialize correctly (version 3)", (t) => { 0b0000_0001, // duration: 1 ]), ); - const cc = new ColorSwitchCCReport(host, { + const cc = new ColorSwitchCCReport({ nodeId: 1, data: ccData, context: {} as any, @@ -129,7 +129,7 @@ test("the Report command should deserialize correctly (version 3)", (t) => { }); test("the Set command should serialize correctly (without duration)", (t) => { - const cc = new ColorSwitchCCSet(host, { + const cc = new ColorSwitchCCSet({ nodeId: 1, red: 128, green: 255, @@ -158,7 +158,7 @@ test("the Set command should serialize correctly (without duration)", (t) => { }); test("the Set command should serialize correctly (version 2)", (t) => { - const cc = new ColorSwitchCCSet(host, { + const cc = new ColorSwitchCCSet({ nodeId: 1, red: 128, green: 255, @@ -187,7 +187,7 @@ test("the Set command should serialize correctly (version 2)", (t) => { }); test("the StartLevelChange command should serialize correctly", (t) => { - const cc = new ColorSwitchCCStartLevelChange(host, { + const cc = new ColorSwitchCCStartLevelChange({ nodeId: 1, startLevel: 5, ignoreStartLevel: true, @@ -214,7 +214,7 @@ test("the StartLevelChange command should serialize correctly", (t) => { }); test("the StopLevelChange command should serialize correctly", (t) => { - const cc = new ColorSwitchCCStopLevelChange(host, { + const cc = new ColorSwitchCCStopLevelChange({ nodeId: 1, colorComponent: ColorComponent.Red, }); diff --git a/packages/zwave-js/src/lib/test/cc/CommandClass.persistValues.test.ts b/packages/zwave-js/src/lib/test/cc/CommandClass.persistValues.test.ts index 2e22d9589137..83a03979d623 100644 --- a/packages/zwave-js/src/lib/test/cc/CommandClass.persistValues.test.ts +++ b/packages/zwave-js/src/lib/test/cc/CommandClass.persistValues.test.ts @@ -71,7 +71,7 @@ test(`persistValues() should not update "interviewComplete" in the value DB`, (t const { node2, driver } = t.context; // Repro for #383 - const cc = new BasicCCSet(driver, { + const cc = new BasicCCSet({ nodeId: node2.id, targetValue: 55, }); @@ -91,7 +91,7 @@ test(`persistValues() should not update "interviewComplete" in the value DB`, (t test(`persistValues() should not store values marked as "events" (non-stateful)`, async (t) => { const { node2, driver } = t.context; - const cc = new CentralSceneCCNotification(driver, { + const cc = new CentralSceneCCNotification({ nodeId: node2.id, data: Buffer.from([ CommandClasses["Central Scene"], diff --git a/packages/zwave-js/src/lib/test/cc/CommandClass.test.ts b/packages/zwave-js/src/lib/test/cc/CommandClass.test.ts index b15ad4d12f21..eb17d9ecc98b 100644 --- a/packages/zwave-js/src/lib/test/cc/CommandClass.test.ts +++ b/packages/zwave-js/src/lib/test/cc/CommandClass.test.ts @@ -29,13 +29,13 @@ class DummyCCSubClass2 extends DummyCC { test(`creating and serializing should work for unspecified commands`, (t) => { // Repro for #1219 - const cc = new CommandClass(host, { + const cc = new CommandClass({ nodeId: 2, ccId: 0x5d, ccCommand: 0x02, payload: Buffer.from([1, 2, 3]), }); - const msg = new SendDataRequest(host, { + const msg = new SendDataRequest({ command: cc, callbackId: 0xfe, }); @@ -47,7 +47,7 @@ test(`creating and serializing should work for unspecified commands`, (t) => { test("from() returns an un-specialized instance when receiving a non-implemented CC", (t) => { // This is a Node Provisioning CC. Change it when that CC is implemented - const cc = CommandClass.from(host, { + const cc = CommandClass.from({ data: Buffer.from("78030100", "hex"), nodeId: 5, context: {} as any, @@ -61,7 +61,7 @@ test("from() returns an un-specialized instance when receiving a non-implemented test("from() does not throw when the CC is implemented", (t) => { t.notThrows(() => - CommandClass.from(host, { + CommandClass.from({ // CRC-16 with BasicCC data: Buffer.from("560120024d26", "hex"), nodeId: 5, @@ -71,7 +71,7 @@ test("from() does not throw when the CC is implemented", (t) => { }); test("getImplementedVersion() should return the implemented version for a CommandClass instance", (t) => { - const cc = new BasicCC(host, { nodeId: 1 }); + const cc = new BasicCC({ nodeId: 1 }); t.is(getImplementedVersion(cc), 2); }); @@ -86,7 +86,7 @@ test("getImplementedVersion() should return 0 for a non-existing CC", (t) => { }); test("getImplementedVersion() should work with inheritance", (t) => { - const cc = new BasicCCGet(host, { nodeId: 1 }); + const cc = new BasicCCGet({ nodeId: 1 }); t.is(getImplementedVersion(cc), 2); }); @@ -99,12 +99,12 @@ test("getImplementedVersionStatic() should work on inherited classes", (t) => { }); test("expectMoreMessages() returns false by default", (t) => { - const cc = new DummyCC(host, { nodeId: 1 }); + const cc = new DummyCC({ nodeId: 1 }); t.false(cc.expectMoreMessages([])); }); test("getExpectedCCResponse() returns the expected CC response like it was defined", (t) => { - const cc = new DummyCCSubClass2(host, { nodeId: 1 }); + const cc = new DummyCCSubClass2({ nodeId: 1 }); const actual = getExpectedCCResponse(cc); t.is(actual, DummyCCSubClass1); }); diff --git a/packages/zwave-js/src/lib/test/cc/DoorLockCC.test.ts b/packages/zwave-js/src/lib/test/cc/DoorLockCC.test.ts index 702bb1a61f9c..ac5bf54758d2 100644 --- a/packages/zwave-js/src/lib/test/cc/DoorLockCC.test.ts +++ b/packages/zwave-js/src/lib/test/cc/DoorLockCC.test.ts @@ -40,7 +40,7 @@ valueDB2.setValue(DoorLockCCValues.boltSupported.id, true); valueDB2.setValue(DoorLockCCValues.latchSupported.id, true); test("the OperationGet command should serialize correctly", (t) => { - const cc = new DoorLockCCOperationGet(host, { nodeId: 1 }); + const cc = new DoorLockCCOperationGet({ nodeId: 1 }); const expected = buildCCBuffer( Buffer.from([ DoorLockCommand.OperationGet, // CC Command @@ -50,7 +50,7 @@ test("the OperationGet command should serialize correctly", (t) => { }); test("the OperationSet command should serialize correctly", (t) => { - const cc = new DoorLockCCOperationSet(host, { + const cc = new DoorLockCCOperationSet({ nodeId: 2, mode: DoorLockMode.OutsideUnsecured, }); @@ -74,7 +74,7 @@ test("the OperationReport command (v1-v3) should be deserialized correctly", (t) 20, // timeout seconds ]), ); - const cc = new DoorLockCCOperationReport(host, { + const cc = new DoorLockCCOperationReport({ nodeId: 1, data: ccData, context: {} as any, @@ -104,7 +104,7 @@ test("the OperationReport command (v4) should be deserialized correctly", (t) => 0x01, // 1 second left ]), ); - const cc = new DoorLockCCOperationReport(host, { + const cc = new DoorLockCCOperationReport({ nodeId: 2, data: ccData, context: {} as any, @@ -130,7 +130,7 @@ test("the OperationReport command (v4) should be deserialized correctly", (t) => }); test("the ConfigurationGet command should serialize correctly", (t) => { - const cc = new DoorLockCCConfigurationGet(host, { nodeId: 1 }); + const cc = new DoorLockCCConfigurationGet({ nodeId: 1 }); const expected = buildCCBuffer( Buffer.from([ DoorLockCommand.ConfigurationGet, // CC Command @@ -149,7 +149,7 @@ test("the ConfigurationReport command (v1-v3) should be deserialized correctly", 20, // timeout seconds ]), ); - const cc = new DoorLockCCConfigurationReport(host, { + const cc = new DoorLockCCConfigurationReport({ nodeId: 1, data: ccData, context: {} as any, @@ -185,7 +185,7 @@ test("the ConfigurationReport command must ignore invalid timeouts (constant)", 20, // timeout seconds ]), ); - const cc = new DoorLockCCConfigurationReport(host, { + const cc = new DoorLockCCConfigurationReport({ nodeId: 1, data: ccData, context: {} as any, @@ -204,7 +204,7 @@ test("the ConfigurationReport command must ignore invalid timeouts (invalid minu 20, // timeout seconds ]), ); - const cc = new DoorLockCCConfigurationReport(host, { + const cc = new DoorLockCCConfigurationReport({ nodeId: 1, data: ccData, context: {} as any, @@ -223,7 +223,7 @@ test("the ConfigurationReport command must ignore invalid timeouts (invalid seco 0xff, // timeout seconds ]), ); - const cc = new DoorLockCCConfigurationReport(host, { + const cc = new DoorLockCCConfigurationReport({ nodeId: 1, data: ccData, context: {} as any, @@ -248,7 +248,7 @@ test("the ConfigurationReport command (v4) should be deserialized correctly", (t 0b01, // flags ]), ); - const cc = new DoorLockCCConfigurationReport(host, { + const cc = new DoorLockCCConfigurationReport({ nodeId: 1, data: ccData, context: {} as any, @@ -261,7 +261,7 @@ test("the ConfigurationReport command (v4) should be deserialized correctly", (t }); test("the ConfigurationSet command (v4) should serialize correctly", (t) => { - const cc = new DoorLockCCConfigurationSet(host, { + const cc = new DoorLockCCConfigurationSet({ nodeId: 2, operationType: DoorLockOperationType.Timed, outsideHandlesCanOpenDoorConfiguration: [false, true, true, true], @@ -290,7 +290,7 @@ test("the ConfigurationSet command (v4) should serialize correctly", (t) => { }); test("the CapabilitiesGet command should serialize correctly", (t) => { - const cc = new DoorLockCCCapabilitiesGet(host, { nodeId: 1 }); + const cc = new DoorLockCCCapabilitiesGet({ nodeId: 1 }); const expected = buildCCBuffer( Buffer.from([ DoorLockCommand.CapabilitiesGet, // CC Command @@ -314,7 +314,7 @@ test("the CapabilitiesReport command should be deserialized correctly", (t) => { 0b1010, // feature flags ]), ); - const cc = new DoorLockCCCapabilitiesReport(host, { + const cc = new DoorLockCCCapabilitiesReport({ nodeId: 1, data: ccData, context: {} as any, @@ -349,7 +349,7 @@ test("the CapabilitiesReport command should be deserialized correctly", (t) => { // 1, // duration // ]), // ); -// const cc = new DoorLockCCReport(host, { data: ccData }); +// const cc = new DoorLockCCReport({ data: ccData }); // t.is(cc.currentValue, 55); // t.is(cc.targetValue, 66); @@ -362,7 +362,7 @@ test("the CapabilitiesReport command should be deserialized correctly", (t) => { // 1, // Buffer.from([255]), // not a valid command // ); -// const cc: any = new DoorLockCC(host, { +// const cc: any = new DoorLockCC({ // data: serializedCC, // }); // t.is(cc.constructor, DoorLockCC); diff --git a/packages/zwave-js/src/lib/test/cc/DoorLockLoggingCC.test.ts b/packages/zwave-js/src/lib/test/cc/DoorLockLoggingCC.test.ts index c82487f7c8fc..9cb09032a6a6 100644 --- a/packages/zwave-js/src/lib/test/cc/DoorLockLoggingCC.test.ts +++ b/packages/zwave-js/src/lib/test/cc/DoorLockLoggingCC.test.ts @@ -22,7 +22,7 @@ function buildCCBuffer(payload: Buffer): Buffer { } test("the RecordsCountGet command should serialize correctly", (t) => { - const cc = new DoorLockLoggingCCRecordsSupportedGet(host, { + const cc = new DoorLockLoggingCCRecordsSupportedGet({ nodeId: 1, }); const expected = buildCCBuffer( @@ -40,7 +40,7 @@ test("the RecordsCountReport command should be deserialized correctly", (t) => { 0x14, // max records supported (20) ]), ); - const cc = new DoorLockLoggingCCRecordsSupportedReport(host, { + const cc = new DoorLockLoggingCCRecordsSupportedReport({ nodeId: 1, data: ccData, context: {} as any, @@ -50,7 +50,7 @@ test("the RecordsCountReport command should be deserialized correctly", (t) => { }); test("the RecordGet command should serialize correctly", (t) => { - const cc = new DoorLockLoggingCCRecordGet(host, { + const cc = new DoorLockLoggingCCRecordGet({ nodeId: 1, recordNumber: 1, }); @@ -82,7 +82,7 @@ test("the RecordReport command should be deserialized correctly", (t) => { ]), ); - const cc = new DoorLockLoggingCCRecordReport(host, { + const cc = new DoorLockLoggingCCRecordReport({ nodeId: 1, data: ccData, context: {} as any, diff --git a/packages/zwave-js/src/lib/test/cc/EntryControlCC.test.ts b/packages/zwave-js/src/lib/test/cc/EntryControlCC.test.ts index 5cfb64a224e7..630b9bb5aa01 100644 --- a/packages/zwave-js/src/lib/test/cc/EntryControlCC.test.ts +++ b/packages/zwave-js/src/lib/test/cc/EntryControlCC.test.ts @@ -45,7 +45,7 @@ test("the Notification command should deserialize correctly", (t) => { ]), ); - const cc = new EntryControlCCNotification(host, { + const cc = new EntryControlCCNotification({ nodeId: 1, data, context: {} as any, @@ -58,7 +58,7 @@ test("the Notification command should deserialize correctly", (t) => { }); test("the ConfigurationGet command should serialize correctly", (t) => { - const cc = new EntryControlCCConfigurationGet(host, { + const cc = new EntryControlCCConfigurationGet({ nodeId: 1, }); const expected = buildCCBuffer( @@ -70,7 +70,7 @@ test("the ConfigurationGet command should serialize correctly", (t) => { }); test("the ConfigurationSet command should serialize correctly", (t) => { - const cc = new EntryControlCCConfigurationSet(host, { + const cc = new EntryControlCCConfigurationSet({ nodeId: 1, keyCacheSize: 1, keyCacheTimeout: 2, @@ -94,7 +94,7 @@ test("the ConfigurationReport command should be deserialize correctly", (t) => { ]), ); - const cc = new EntryControlCCConfigurationReport(host, { + const cc = new EntryControlCCConfigurationReport({ nodeId: 1, data, context: {} as any, @@ -105,7 +105,7 @@ test("the ConfigurationReport command should be deserialize correctly", (t) => { }); test("the EventSupportedGet command should serialize correctly", (t) => { - const cc = new EntryControlCCEventSupportedGet(host, { + const cc = new EntryControlCCEventSupportedGet({ nodeId: 1, }); const expected = buildCCBuffer( @@ -134,7 +134,7 @@ test("the EventSupportedReport command should be deserialize correctly", (t) => ]), ); - const cc = new EntryControlCCEventSupportedReport(host, { + const cc = new EntryControlCCEventSupportedReport({ nodeId: 1, data, context: {} as any, @@ -154,7 +154,7 @@ test("the EventSupportedReport command should be deserialize correctly", (t) => }); test("the KeySupportedGet command should serialize correctly", (t) => { - const cc = new EntryControlCCKeySupportedGet(host, { nodeId: 1 }); + const cc = new EntryControlCCKeySupportedGet({ nodeId: 1 }); const expected = buildCCBuffer( Buffer.from([ EntryControlCommand.KeySupportedGet, // CC Command @@ -172,7 +172,7 @@ test("the KeySupportedReport command should be deserialize correctly", (t) => { ]), ); - const cc = new EntryControlCCKeySupportedReport(host, { + const cc = new EntryControlCCKeySupportedReport({ nodeId: 1, data, context: {} as any, diff --git a/packages/zwave-js/src/lib/test/cc/FibaroCC.test.ts b/packages/zwave-js/src/lib/test/cc/FibaroCC.test.ts index 33ca24da25f0..ecfa727c74e0 100644 --- a/packages/zwave-js/src/lib/test/cc/FibaroCC.test.ts +++ b/packages/zwave-js/src/lib/test/cc/FibaroCC.test.ts @@ -26,7 +26,7 @@ function buildCCBuffer(payload: Buffer): Buffer { } test("the Set Tilt command should serialize correctly", (t) => { - const cc = new FibaroVenetianBlindCCSet(host, { + const cc = new FibaroVenetianBlindCCSet({ nodeId: 2, tilt: 99, }); @@ -50,7 +50,7 @@ test("the Report command should be deserialized correctly", (t) => { 0x00, // Tilt ]), ); - const cc = CommandClass.from(host, { + const cc = CommandClass.from({ nodeId: 2, data: ccData, context: {} as any, @@ -61,7 +61,7 @@ test("the Report command should be deserialized correctly", (t) => { }); test("FibaroVenetianBlindCCSet should expect no response", (t) => { - const cc = new FibaroVenetianBlindCCSet(host, { + const cc = new FibaroVenetianBlindCCSet({ nodeId: 2, tilt: 7, }); @@ -69,18 +69,18 @@ test("FibaroVenetianBlindCCSet should expect no response", (t) => { }); test("FibaroVenetianBlindCCGet should expect a response", (t) => { - const cc = new FibaroVenetianBlindCCGet(host, { + const cc = new FibaroVenetianBlindCCGet({ nodeId: 2, }); t.true(cc.expectsCCResponse()); }); test("FibaroVenetianBlindCCSet => FibaroVenetianBlindCCReport = unexpected", (t) => { - const ccRequest = new FibaroVenetianBlindCCSet(host, { + const ccRequest = new FibaroVenetianBlindCCSet({ nodeId: 2, tilt: 7, }); - const ccResponse = new FibaroVenetianBlindCCReport(host, { + const ccResponse = new FibaroVenetianBlindCCReport({ nodeId: 2, data: buildCCBuffer( Buffer.from([ @@ -97,10 +97,10 @@ test("FibaroVenetianBlindCCSet => FibaroVenetianBlindCCReport = unexpected", (t) }); test("FibaroVenetianBlindCCGet => FibaroVenetianBlindCCReport = expected", (t) => { - const ccRequest = new FibaroVenetianBlindCCGet(host, { + const ccRequest = new FibaroVenetianBlindCCGet({ nodeId: 2, }); - const ccResponse = new FibaroVenetianBlindCCReport(host, { + const ccResponse = new FibaroVenetianBlindCCReport({ nodeId: 2, data: buildCCBuffer( Buffer.from([ diff --git a/packages/zwave-js/src/lib/test/cc/HumidityControlModeCC.test.ts b/packages/zwave-js/src/lib/test/cc/HumidityControlModeCC.test.ts index e4070aa7277c..fb39ca7a96c7 100644 --- a/packages/zwave-js/src/lib/test/cc/HumidityControlModeCC.test.ts +++ b/packages/zwave-js/src/lib/test/cc/HumidityControlModeCC.test.ts @@ -25,7 +25,7 @@ function buildCCBuffer(payload: Buffer): Buffer { } test("the Get command should serialize correctly", (t) => { - const cc = new HumidityControlModeCCGet(host, { + const cc = new HumidityControlModeCCGet({ nodeId, }); const expected = buildCCBuffer( @@ -37,7 +37,7 @@ test("the Get command should serialize correctly", (t) => { }); test("the Set command should serialize correctly", (t) => { - const cc = new HumidityControlModeCCSet(host, { + const cc = new HumidityControlModeCCSet({ nodeId, mode: HumidityControlMode.Auto, }); @@ -57,7 +57,7 @@ test("the Report command should be deserialized correctly", (t) => { HumidityControlMode.Auto, // current value ]), ); - const cc = new HumidityControlModeCCReport(host, { + const cc = new HumidityControlModeCCReport({ nodeId, data: ccData, context: {} as any, @@ -73,7 +73,7 @@ test("the Report command should set the correct value", (t) => { HumidityControlMode.Auto, // current value ]), ); - const report = new HumidityControlModeCCReport(host, { + const report = new HumidityControlModeCCReport({ nodeId, data: ccData, context: {} as any, @@ -94,7 +94,7 @@ test("the Report command should set the correct metadata", (t) => { HumidityControlMode.Auto, // current value ]), ); - const cc = new HumidityControlModeCCReport(host, { + const cc = new HumidityControlModeCCReport({ nodeId, data: ccData, context: {} as any, @@ -112,7 +112,7 @@ test("the Report command should set the correct metadata", (t) => { }); test("the SupportedGet command should serialize correctly", (t) => { - const cc = new HumidityControlModeCCSupportedGet(host, { + const cc = new HumidityControlModeCCSupportedGet({ nodeId, }); const expected = buildCCBuffer( @@ -130,7 +130,7 @@ test("the SupportedReport command should be deserialized correctly", (t) => { (1 << HumidityControlMode.Off) | (1 << HumidityControlMode.Auto), ]), ); - const cc = new HumidityControlModeCCSupportedReport(host, { + const cc = new HumidityControlModeCCSupportedReport({ nodeId, data: ccData, context: {} as any, @@ -149,7 +149,7 @@ test("the SupportedReport command should set the correct metadata", (t) => { (1 << HumidityControlMode.Off) | (1 << HumidityControlMode.Auto), ]), ); - const cc = new HumidityControlModeCCSupportedReport(host, { + const cc = new HumidityControlModeCCSupportedReport({ nodeId, data: ccData, context: {} as any, diff --git a/packages/zwave-js/src/lib/test/cc/HumidityControlOperatingStateCC.test.ts b/packages/zwave-js/src/lib/test/cc/HumidityControlOperatingStateCC.test.ts index b9306f6e4f84..0242cd68f4f1 100644 --- a/packages/zwave-js/src/lib/test/cc/HumidityControlOperatingStateCC.test.ts +++ b/packages/zwave-js/src/lib/test/cc/HumidityControlOperatingStateCC.test.ts @@ -20,7 +20,7 @@ function buildCCBuffer(payload: Buffer): Buffer { } test("the Get command should serialize correctly", (t) => { - const cc = new HumidityControlOperatingStateCCGet(host, { + const cc = new HumidityControlOperatingStateCCGet({ nodeId: 1, }); const expected = buildCCBuffer( @@ -38,7 +38,7 @@ test("the Report command should be deserialized correctly", (t) => { HumidityControlOperatingState.Humidifying, // state ]), ); - const cc = new HumidityControlOperatingStateCCReport(host, { + const cc = new HumidityControlOperatingStateCCReport({ nodeId: 1, data: ccData, context: {} as any, diff --git a/packages/zwave-js/src/lib/test/cc/HumidityControlSetpointCC.test.ts b/packages/zwave-js/src/lib/test/cc/HumidityControlSetpointCC.test.ts index 3d51bc842047..4166dbda4fdc 100644 --- a/packages/zwave-js/src/lib/test/cc/HumidityControlSetpointCC.test.ts +++ b/packages/zwave-js/src/lib/test/cc/HumidityControlSetpointCC.test.ts @@ -28,7 +28,7 @@ const host = createTestingHost(); const nodeId = 2; test("the Get command should serialize correctly", (t) => { - const cc = new HumidityControlSetpointCCGet(host, { + const cc = new HumidityControlSetpointCCGet({ nodeId: nodeId, setpointType: HumidityControlSetpointType.Humidifier, }); @@ -42,7 +42,7 @@ test("the Get command should serialize correctly", (t) => { }); test("the Set command should serialize correctly", (t) => { - const cc = new HumidityControlSetpointCCSet(host, { + const cc = new HumidityControlSetpointCCSet({ nodeId: nodeId, setpointType: HumidityControlSetpointType.Humidifier, value: 57, @@ -70,7 +70,7 @@ test("the Report command should be deserialized correctly", (t) => { encodeFloatWithScale(12, 1), ]), ); - const cc = new HumidityControlSetpointCCReport(host, { + const cc = new HumidityControlSetpointCCReport({ nodeId: nodeId, data: ccData, context: {} as any, @@ -96,7 +96,7 @@ test("the Report command should set the correct value", (t) => { encodeFloatWithScale(12, 1), ]), ); - const report = new HumidityControlSetpointCCReport(host, { + const report = new HumidityControlSetpointCCReport({ nodeId: nodeId, data: ccData, context: {} as any, @@ -128,7 +128,7 @@ test("the Report command should set the correct metadata", (t) => { encodeFloatWithScale(12, 1), ]), ); - const report = new HumidityControlSetpointCCReport(host, { + const report = new HumidityControlSetpointCCReport({ nodeId: nodeId, data: ccData, context: {} as any, @@ -149,7 +149,7 @@ test("the Report command should set the correct metadata", (t) => { }); test("the SupportedGet command should serialize correctly", (t) => { - const cc = new HumidityControlSetpointCCSupportedGet(host, { + const cc = new HumidityControlSetpointCCSupportedGet({ nodeId: nodeId, }); const expected = buildCCBuffer( @@ -168,7 +168,7 @@ test("the SupportedReport command should be deserialized correctly", (t) => { | (1 << HumidityControlSetpointType.Auto), ]), ); - const cc = new HumidityControlSetpointCCSupportedReport(host, { + const cc = new HumidityControlSetpointCCSupportedReport({ nodeId: nodeId, data: ccData, context: {} as any, @@ -188,7 +188,7 @@ test("the SupportedReport command should set the correct value", (t) => { | (1 << HumidityControlSetpointType.Auto), ]), ); - const report = new HumidityControlSetpointCCSupportedReport(host, { + const report = new HumidityControlSetpointCCSupportedReport({ nodeId: nodeId, data: ccData, context: {} as any, @@ -206,7 +206,7 @@ test("the SupportedReport command should set the correct value", (t) => { }); test("the ScaleSupportedGet command should serialize correctly", (t) => { - const cc = new HumidityControlSetpointCCScaleSupportedGet(host, { + const cc = new HumidityControlSetpointCCScaleSupportedGet({ nodeId: nodeId, setpointType: HumidityControlSetpointType.Auto, }); @@ -226,7 +226,7 @@ test("the ScaleSupportedReport command should be deserialized correctly", (t) => 0b11, // percent + absolute ]), ); - const cc = new HumidityControlSetpointCCScaleSupportedReport(host, { + const cc = new HumidityControlSetpointCCScaleSupportedReport({ nodeId: nodeId, data: ccData, context: {} as any, @@ -245,7 +245,7 @@ test("the ScaleSupportedReport command should be deserialized correctly", (t) => }); test("the CapabilitiesGet command should serialize correctly", (t) => { - const cc = new HumidityControlSetpointCCCapabilitiesGet(host, { + const cc = new HumidityControlSetpointCCCapabilitiesGet({ nodeId: nodeId, setpointType: HumidityControlSetpointType.Auto, }); @@ -269,7 +269,7 @@ test("the CapabilitiesReport command should be deserialized correctly", (t) => { encodeFloatWithScale(90, 1), ]), ); - const cc = new HumidityControlSetpointCCCapabilitiesReport(host, { + const cc = new HumidityControlSetpointCCCapabilitiesReport({ nodeId: nodeId, data: ccData, context: {} as any, @@ -293,7 +293,7 @@ test("the CapabilitiesReport command should set the correct metadata", (t) => { encodeFloatWithScale(90, 1), ]), ); - const report = new HumidityControlSetpointCCCapabilitiesReport(host, { + const report = new HumidityControlSetpointCCCapabilitiesReport({ nodeId: nodeId, data: ccData, context: {} as any, diff --git a/packages/zwave-js/src/lib/test/cc/IndicatorCC.test.ts b/packages/zwave-js/src/lib/test/cc/IndicatorCC.test.ts index a289db4fd407..05a6cd7f2f03 100644 --- a/packages/zwave-js/src/lib/test/cc/IndicatorCC.test.ts +++ b/packages/zwave-js/src/lib/test/cc/IndicatorCC.test.ts @@ -24,7 +24,7 @@ function buildCCBuffer(payload: Buffer): Buffer { const host = createTestingHost(); test("the Get command (V1) should serialize correctly", (t) => { - const cc = new IndicatorCCGet(host, { nodeId: 1 }); + const cc = new IndicatorCCGet({ nodeId: 1 }); const expected = buildCCBuffer( Buffer.from([ IndicatorCommand.Get, // CC Command @@ -34,7 +34,7 @@ test("the Get command (V1) should serialize correctly", (t) => { }); test("the Get command (V2) should serialize correctly", (t) => { - const cc = new IndicatorCCGet(host, { + const cc = new IndicatorCCGet({ nodeId: 1, indicatorId: 5, }); @@ -48,7 +48,7 @@ test("the Get command (V2) should serialize correctly", (t) => { }); test("the Set command (v1) should serialize correctly", (t) => { - const cc = new IndicatorCCSet(host, { + const cc = new IndicatorCCSet({ nodeId: 2, value: 23, }); @@ -62,7 +62,7 @@ test("the Set command (v1) should serialize correctly", (t) => { }); test("the Set command (v2) should serialize correctly", (t) => { - const cc = new IndicatorCCSet(host, { + const cc = new IndicatorCCSet({ nodeId: 2, values: [ { @@ -100,7 +100,7 @@ test("the Report command (v1) should be deserialized correctly", (t) => { 55, // value ]), ); - const cc = new IndicatorCCReport(host, { + const cc = new IndicatorCCReport({ nodeId: 1, data: ccData, context: {} as any, @@ -124,7 +124,7 @@ test("the Report command (v2) should be deserialized correctly", (t) => { 1, // value ]), ); - const cc = new IndicatorCCReport(host, { + const cc = new IndicatorCCReport({ nodeId: 1, data: ccData, context: {} as any, @@ -151,7 +151,7 @@ test("deserializing an unsupported command should return an unspecified version const serializedCC = buildCCBuffer( Buffer.from([255]), // not a valid command ); - const cc: any = new IndicatorCC(host, { + const cc: any = new IndicatorCC({ nodeId: 1, data: serializedCC, context: {} as any, @@ -163,7 +163,6 @@ test("the value IDs should be translated properly", (t) => { const valueId = IndicatorCCValues.valueV2(0x43, 2).endpoint(2); const testNode = createTestNode(host, { id: 2 }); const ccInstance = CommandClass.createInstanceUnchecked( - host, testNode, CommandClasses.Indicator, )!; diff --git a/packages/zwave-js/src/lib/test/cc/LanguageCC.test.ts b/packages/zwave-js/src/lib/test/cc/LanguageCC.test.ts index 65670b823004..123641b29e2f 100644 --- a/packages/zwave-js/src/lib/test/cc/LanguageCC.test.ts +++ b/packages/zwave-js/src/lib/test/cc/LanguageCC.test.ts @@ -21,7 +21,7 @@ function buildCCBuffer(payload: Buffer): Buffer { } test("the Get command should serialize correctly", (t) => { - const cc = new LanguageCCGet(host, { nodeId: 1 }); + const cc = new LanguageCCGet({ nodeId: 1 }); const expected = buildCCBuffer( Buffer.from([ LanguageCommand.Get, // CC Command @@ -31,7 +31,7 @@ test("the Get command should serialize correctly", (t) => { }); test("the Set command should serialize correctly (w/o country code)", (t) => { - const cc = new LanguageCCSet(host, { + const cc = new LanguageCCSet({ nodeId: 2, language: "deu", }); @@ -48,7 +48,7 @@ test("the Set command should serialize correctly (w/o country code)", (t) => { }); test("the Set command should serialize correctly (w/ country code)", (t) => { - const cc = new LanguageCCSet(host, { + const cc = new LanguageCCSet({ nodeId: 2, language: "deu", country: "DE", @@ -78,7 +78,7 @@ test("the Report command should be deserialized correctly (w/o country code)", ( 0x75, ]), ); - const cc = new LanguageCCReport(host, { + const cc = new LanguageCCReport({ nodeId: 4, data: ccData, context: {} as any, @@ -101,7 +101,7 @@ test("the Report command should be deserialized correctly (w/ country code)", (t 0x45, ]), ); - const cc = new LanguageCCReport(host, { + const cc = new LanguageCCReport({ nodeId: 4, data: ccData, context: {} as any, @@ -115,7 +115,7 @@ test("deserializing an unsupported command should return an unspecified version const serializedCC = buildCCBuffer( Buffer.from([255]), // not a valid command ); - const cc: any = new LanguageCC(host, { + const cc: any = new LanguageCC({ nodeId: 4, data: serializedCC, context: {} as any, diff --git a/packages/zwave-js/src/lib/test/cc/ManufacturerSpecificCC.test.ts b/packages/zwave-js/src/lib/test/cc/ManufacturerSpecificCC.test.ts index 9b81d16e3b1f..ecb39a3c1f84 100644 --- a/packages/zwave-js/src/lib/test/cc/ManufacturerSpecificCC.test.ts +++ b/packages/zwave-js/src/lib/test/cc/ManufacturerSpecificCC.test.ts @@ -19,7 +19,7 @@ function buildCCBuffer(payload: Buffer): Buffer { } test("the Get command should serialize correctly", (t) => { - const cc = new ManufacturerSpecificCCGet(host, { nodeId: 1 }); + const cc = new ManufacturerSpecificCCGet({ nodeId: 1 }); const expected = buildCCBuffer( Buffer.from([ ManufacturerSpecificCommand.Get, // CC Command @@ -40,7 +40,7 @@ test("the Report command (v1) should be deserialized correctly", (t) => { 0x06, ]), ); - const cc = new ManufacturerSpecificCCReport(host, { + const cc = new ManufacturerSpecificCCReport({ nodeId: 2, data: ccData, context: {} as any, diff --git a/packages/zwave-js/src/lib/test/cc/MeterCC.test.ts b/packages/zwave-js/src/lib/test/cc/MeterCC.test.ts index 4d4e960ebdac..a335be76bad0 100644 --- a/packages/zwave-js/src/lib/test/cc/MeterCC.test.ts +++ b/packages/zwave-js/src/lib/test/cc/MeterCC.test.ts @@ -31,7 +31,7 @@ const host = createTestingHost(); const node2 = createTestNode(host, { id: 2 }); test("the Get command (V1) should serialize correctly", (t) => { - const cc = new MeterCCGet(host, { nodeId: 1 }); + const cc = new MeterCCGet({ nodeId: 1 }); const expected = buildCCBuffer( Buffer.from([ MeterCommand.Get, // CC Command @@ -47,7 +47,7 @@ test("the Get command (V1) should serialize correctly", (t) => { }); test("the Get command (V2) should serialize correctly", (t) => { - const cc = new MeterCCGet(host, { nodeId: 1, scale: 0x03 }); + const cc = new MeterCCGet({ nodeId: 1, scale: 0x03 }); const expected = buildCCBuffer( Buffer.from([ MeterCommand.Get, // CC Command @@ -64,7 +64,7 @@ test("the Get command (V2) should serialize correctly", (t) => { }); test("the Get command (V3) should serialize correctly", (t) => { - const cc = new MeterCCGet(host, { nodeId: 1, scale: 0x06 }); + const cc = new MeterCCGet({ nodeId: 1, scale: 0x06 }); const expected = buildCCBuffer( Buffer.from([ MeterCommand.Get, // CC Command @@ -81,7 +81,7 @@ test("the Get command (V3) should serialize correctly", (t) => { }); test("the Get command (V4) should serialize correctly", (t) => { - const cc = new MeterCCGet(host, { nodeId: 1, scale: 0x0f }); + const cc = new MeterCCGet({ nodeId: 1, scale: 0x0f }); const expected = buildCCBuffer( Buffer.from([ MeterCommand.Get, // CC Command @@ -99,7 +99,7 @@ test("the Get command (V4) should serialize correctly", (t) => { }); test("the SupportedGet command should serialize correctly", (t) => { - const cc = new MeterCCSupportedGet(host, { nodeId: 1 }); + const cc = new MeterCCSupportedGet({ nodeId: 1 }); const expected = buildCCBuffer( Buffer.from([ MeterCommand.SupportedGet, // CC Command @@ -109,7 +109,7 @@ test("the SupportedGet command should serialize correctly", (t) => { }); test("the Reset command (V2) should serialize correctly", (t) => { - const cc = new MeterCCReset(host, { nodeId: 1 }); + const cc = new MeterCCReset({ nodeId: 1 }); const expected = buildCCBuffer( Buffer.from([ MeterCommand.Reset, // CC Command @@ -119,7 +119,7 @@ test("the Reset command (V2) should serialize correctly", (t) => { }); test("the Reset command (V6) should serialize correctly", (t) => { - const cc = new MeterCCReset(host, { + const cc = new MeterCCReset({ nodeId: 1, type: 7, scale: 3, @@ -146,7 +146,7 @@ test("the Report command (V1) should be deserialized correctly", (t) => { 55, // value ]), ); - const cc = new MeterCCReport(host, { + const cc = new MeterCCReport({ nodeId: 1, data: ccData, context: {} as any, @@ -171,7 +171,7 @@ test("the Report command (V2) should be deserialized correctly (no time delta)", 0, ]), ); - const cc = new MeterCCReport(host, { + const cc = new MeterCCReport({ nodeId: 1, data: ccData, context: {} as any, @@ -197,7 +197,7 @@ test("the Report command (V2) should be deserialized correctly (with time delta) 54, // previous value ]), ); - const cc = new MeterCCReport(host, { + const cc = new MeterCCReport({ nodeId: 1, data: ccData, context: {} as any, @@ -223,7 +223,7 @@ test("the Report command (V3) should be deserialized correctly", (t) => { 54, // previous value ]), ); - const cc = new MeterCCReport(host, { + const cc = new MeterCCReport({ nodeId: 1, data: ccData, context: {} as any, @@ -245,7 +245,7 @@ test("the Report command (V4) should be deserialized correctly", (t) => { 0b01, // Scale2 ]), ); - const cc = new MeterCCReport(host, { + const cc = new MeterCCReport({ nodeId: 1, data: ccData, context: {} as any, @@ -268,7 +268,7 @@ test("the Report command should validate that a known meter type is given", (t) ]), ); - const report = new MeterCCReport(host, { + const report = new MeterCCReport({ nodeId: 1, data: ccData, context: {} as any, @@ -294,7 +294,7 @@ test("the Report command should validate that a known meter scale is given", (t) ]), ); - const report = new MeterCCReport(host, { + const report = new MeterCCReport({ nodeId: 1, data: ccData, context: {} as any, @@ -327,7 +327,7 @@ test("the SupportedReport command (V2/V3) should be deserialized correctly", (t) 0b01101110, // supported scales ]), ); - const cc = new MeterCCSupportedReport(host, { + const cc = new MeterCCSupportedReport({ nodeId: 1, data: ccData, context: {} as any, @@ -350,7 +350,7 @@ test("the SupportedReport command (V4/V5) should be deserialized correctly", (t) 1, ]), ); - const cc = new MeterCCSupportedReport(host, { + const cc = new MeterCCSupportedReport({ nodeId: 1, data: ccData, context: {} as any, @@ -373,7 +373,7 @@ test("the SupportedReport command (V4/V5) should be deserialized correctly", (t) // 1, // ]), // ); -// const cc = new MeterCCSupportedReport(host, { +// const cc = new MeterCCSupportedReport({ // nodeId: 1, // data: ccData, // }); @@ -388,7 +388,7 @@ test("deserializing an unsupported command should return an unspecified version const serializedCC = buildCCBuffer( Buffer.from([255]), // not a valid command ); - const cc: any = new MeterCC(host, { + const cc: any = new MeterCC({ nodeId: 1, data: serializedCC, context: {} as any, diff --git a/packages/zwave-js/src/lib/test/cc/MultiChannelAssociationCC.test.ts b/packages/zwave-js/src/lib/test/cc/MultiChannelAssociationCC.test.ts index 89d5907970a5..c30089a19a20 100644 --- a/packages/zwave-js/src/lib/test/cc/MultiChannelAssociationCC.test.ts +++ b/packages/zwave-js/src/lib/test/cc/MultiChannelAssociationCC.test.ts @@ -23,7 +23,7 @@ function buildCCBuffer(payload: Buffer): Buffer { } test("the SupportedGroupingsGet command should serialize correctly", (t) => { - const cc = new MultiChannelAssociationCCSupportedGroupingsGet(host, { + const cc = new MultiChannelAssociationCCSupportedGroupingsGet({ nodeId: 1, }); const expected = buildCCBuffer( @@ -41,7 +41,7 @@ test("the SupportedGroupingsReport command should be deserialized correctly", (t 7, // # of groups ]), ); - const cc = new MultiChannelAssociationCCSupportedGroupingsReport(host, { + const cc = new MultiChannelAssociationCCSupportedGroupingsReport({ nodeId: 4, data: ccData, context: {} as any, @@ -51,7 +51,7 @@ test("the SupportedGroupingsReport command should be deserialized correctly", (t }); test("the Set command should serialize correctly (node IDs only)", (t) => { - const cc = new MultiChannelAssociationCCSet(host, { + const cc = new MultiChannelAssociationCCSet({ nodeId: 2, groupId: 5, nodeIds: [1, 2, 5], @@ -70,7 +70,7 @@ test("the Set command should serialize correctly (node IDs only)", (t) => { }); test("the Set command should serialize correctly (endpoint addresses only)", (t) => { - const cc = new MultiChannelAssociationCCSet(host, { + const cc = new MultiChannelAssociationCCSet({ nodeId: 2, groupId: 5, endpoints: [ @@ -101,7 +101,7 @@ test("the Set command should serialize correctly (endpoint addresses only)", (t) }); test("the Set command should serialize correctly (both options)", (t) => { - const cc = new MultiChannelAssociationCCSet(host, { + const cc = new MultiChannelAssociationCCSet({ nodeId: 2, groupId: 5, nodeIds: [1, 2, 3], @@ -137,7 +137,7 @@ test("the Set command should serialize correctly (both options)", (t) => { }); test("the Get command should serialize correctly", (t) => { - const cc = new MultiChannelAssociationCCGet(host, { + const cc = new MultiChannelAssociationCCGet({ nodeId: 1, groupId: 9, }); @@ -163,7 +163,7 @@ test("the Report command should be deserialized correctly (node IDs only)", (t) 5, ]), ); - const cc = new MultiChannelAssociationCCReport(host, { + const cc = new MultiChannelAssociationCCReport({ nodeId: 4, data: ccData, context: {} as any, @@ -192,7 +192,7 @@ test("the Report command should be deserialized correctly (endpoint addresses on 0b11010111, ]), ); - const cc = new MultiChannelAssociationCCReport(host, { + const cc = new MultiChannelAssociationCCReport({ nodeId: 4, data: ccData, context: {} as any, @@ -230,7 +230,7 @@ test("the Report command should be deserialized correctly (both options)", (t) = 0b11010111, ]), ); - const cc = new MultiChannelAssociationCCReport(host, { + const cc = new MultiChannelAssociationCCReport({ nodeId: 4, data: ccData, context: {} as any, @@ -250,7 +250,7 @@ test("the Report command should be deserialized correctly (both options)", (t) = }); test("the Remove command should serialize correctly (node IDs only)", (t) => { - const cc = new MultiChannelAssociationCCRemove(host, { + const cc = new MultiChannelAssociationCCRemove({ nodeId: 2, groupId: 5, nodeIds: [1, 2, 5], @@ -269,7 +269,7 @@ test("the Remove command should serialize correctly (node IDs only)", (t) => { }); test("the Remove command should serialize correctly (endpoint addresses only)", (t) => { - const cc = new MultiChannelAssociationCCRemove(host, { + const cc = new MultiChannelAssociationCCRemove({ nodeId: 2, groupId: 5, endpoints: [ @@ -300,7 +300,7 @@ test("the Remove command should serialize correctly (endpoint addresses only)", }); test("the Remove command should serialize correctly (both options)", (t) => { - const cc = new MultiChannelAssociationCCRemove(host, { + const cc = new MultiChannelAssociationCCRemove({ nodeId: 2, groupId: 5, nodeIds: [1, 2, 3], @@ -336,7 +336,7 @@ test("the Remove command should serialize correctly (both options)", (t) => { }); test("the Remove command should serialize correctly (both empty)", (t) => { - const cc = new MultiChannelAssociationCCRemove(host, { + const cc = new MultiChannelAssociationCCRemove({ nodeId: 2, groupId: 5, }); @@ -354,7 +354,7 @@ test("the Remove command should serialize correctly (both empty)", (t) => { // 1, // Buffer.from([255]), // not a valid command // ); -// const cc: any = new MultiChannelAssociationCC(host, { +// const cc: any = new MultiChannelAssociationCC({ // data: serializedCC, // }); // t.is(cc.constructor, MultiChannelAssociationCC); diff --git a/packages/zwave-js/src/lib/test/cc/MultiChannelCC.test.ts b/packages/zwave-js/src/lib/test/cc/MultiChannelCC.test.ts index 078204441cfa..71fe1285885d 100644 --- a/packages/zwave-js/src/lib/test/cc/MultiChannelCC.test.ts +++ b/packages/zwave-js/src/lib/test/cc/MultiChannelCC.test.ts @@ -31,7 +31,7 @@ function buildCCBuffer(payload: Buffer): Buffer { } test("is an encapsulating CommandClass", (t) => { - let cc: CommandClass = new BasicCCSet(host, { + let cc: CommandClass = new BasicCCSet({ nodeId: 1, targetValue: 50, }); @@ -40,7 +40,7 @@ test("is an encapsulating CommandClass", (t) => { }); test("the EndPointGet command should serialize correctly", (t) => { - const cc = new MultiChannelCCEndPointGet(host, { nodeId: 1 }); + const cc = new MultiChannelCCEndPointGet({ nodeId: 1 }); const expected = buildCCBuffer( Buffer.from([ MultiChannelCommand.EndPointGet, // CC Command @@ -50,7 +50,7 @@ test("the EndPointGet command should serialize correctly", (t) => { }); test("the CapabilityGet command should serialize correctly", (t) => { - const cc = new MultiChannelCCCapabilityGet(host, { + const cc = new MultiChannelCCCapabilityGet({ nodeId: 2, requestedEndpoint: 7, }); @@ -64,7 +64,7 @@ test("the CapabilityGet command should serialize correctly", (t) => { }); test("the EndPointFind command should serialize correctly", (t) => { - const cc = new MultiChannelCCEndPointFind(host, { + const cc = new MultiChannelCCEndPointFind({ nodeId: 2, genericClass: 0x01, specificClass: 0x02, @@ -80,7 +80,7 @@ test("the EndPointFind command should serialize correctly", (t) => { }); test("the CommandEncapsulation command should serialize correctly", (t) => { - let cc: CommandClass = new BasicCCSet(host, { + let cc: CommandClass = new BasicCCSet({ nodeId: 2, targetValue: 5, endpoint: 7, @@ -100,7 +100,7 @@ test("the CommandEncapsulation command should serialize correctly", (t) => { }); test("the AggregatedMembersGet command should serialize correctly", (t) => { - const cc = new MultiChannelCCAggregatedMembersGet(host, { + const cc = new MultiChannelCCAggregatedMembersGet({ nodeId: 2, requestedEndpoint: 6, }); @@ -115,14 +115,14 @@ test("the AggregatedMembersGet command should serialize correctly", (t) => { test("the CommandEncapsulation command should also accept V1CommandEncapsulation as a response", (t) => { // GH#938 - const sent = new MultiChannelCCCommandEncapsulation(host, { + const sent = new MultiChannelCCCommandEncapsulation({ nodeId: 2, destination: 2, - encapsulated: new BasicCCGet(host, { nodeId: 2 }), + encapsulated: new BasicCCGet({ nodeId: 2 }), }); - const received = new MultiChannelCCV1CommandEncapsulation(host, { + const received = new MultiChannelCCV1CommandEncapsulation({ nodeId: 2, - encapsulated: new BasicCCReport(host, { + encapsulated: new BasicCCReport({ nodeId: 2, currentValue: 50, }), @@ -141,7 +141,7 @@ test("the CommandEncapsulation command should also accept V1CommandEncapsulation // 1, // duration // ]), // ); -// const cc = new MultiChannelCCReport(host, { data: ccData }); +// const cc = new MultiChannelCCReport({ data: ccData }); // t.is(cc.currentValue, 55); // t.is(cc.targetValue, 66); @@ -153,7 +153,7 @@ test("deserializing an unsupported command should return an unspecified version const serializedCC = buildCCBuffer( Buffer.from([255]), // not a valid command ); - const cc: any = new MultiChannelCC(host, { + const cc: any = new MultiChannelCC({ nodeId: 1, data: serializedCC, context: {} as any, @@ -190,7 +190,7 @@ test("deserializing an unsupported command should return an unspecified version test("MultiChannelCC/BasicCCGet should expect a response", (t) => { const ccRequest = MultiChannelCC.encapsulate( host, - new BasicCCGet(host, { + new BasicCCGet({ nodeId: 2, endpoint: 2, }), @@ -201,7 +201,7 @@ test("MultiChannelCC/BasicCCGet should expect a response", (t) => { test("MultiChannelCC/BasicCCGet (multicast) should expect NO response", (t) => { const ccRequest = MultiChannelCC.encapsulate( host, - new BasicCCGet(host, { + new BasicCCGet({ nodeId: 2, endpoint: 2, }), @@ -214,7 +214,7 @@ test("MultiChannelCC/BasicCCGet (multicast) should expect NO response", (t) => { test("MultiChannelCC/BasicCCSet should expect NO response", (t) => { const ccRequest = MultiChannelCC.encapsulate( host, - new BasicCCSet(host, { + new BasicCCSet({ nodeId: 2, endpoint: 2, targetValue: 7, @@ -226,14 +226,14 @@ test("MultiChannelCC/BasicCCSet should expect NO response", (t) => { test("MultiChannelCC/BasicCCGet => MultiChannelCC/BasicCCReport = expected", (t) => { const ccRequest = MultiChannelCC.encapsulate( host, - new BasicCCGet(host, { + new BasicCCGet({ nodeId: 2, endpoint: 2, }), ); const ccResponse = MultiChannelCC.encapsulate( host, - new BasicCCReport(host, { + new BasicCCReport({ nodeId: ccRequest.nodeId, currentValue: 7, }), @@ -246,14 +246,14 @@ test("MultiChannelCC/BasicCCGet => MultiChannelCC/BasicCCReport = expected", (t) test("MultiChannelCC/BasicCCGet => MultiChannelCC/BasicCCGet = unexpected", (t) => { const ccRequest = MultiChannelCC.encapsulate( host, - new BasicCCGet(host, { + new BasicCCGet({ nodeId: 2, endpoint: 2, }), ); const ccResponse = MultiChannelCC.encapsulate( host, - new BasicCCGet(host, { + new BasicCCGet({ nodeId: ccRequest.nodeId, endpoint: 2, }), @@ -266,13 +266,13 @@ test("MultiChannelCC/BasicCCGet => MultiChannelCC/BasicCCGet = unexpected", (t) test("MultiChannelCC/BasicCCGet => MultiCommandCC/BasicCCReport = unexpected", (t) => { const ccRequest = MultiChannelCC.encapsulate( host, - new BasicCCGet(host, { + new BasicCCGet({ nodeId: 2, endpoint: 2, }), ); const ccResponse = MultiCommandCC.encapsulate(host, [ - new BasicCCReport(host, { + new BasicCCReport({ nodeId: ccRequest.nodeId, currentValue: 7, }), diff --git a/packages/zwave-js/src/lib/test/cc/MultiCommandCC.test.ts b/packages/zwave-js/src/lib/test/cc/MultiCommandCC.test.ts index 660e6d9abfc2..5d7fdf794583 100644 --- a/packages/zwave-js/src/lib/test/cc/MultiCommandCC.test.ts +++ b/packages/zwave-js/src/lib/test/cc/MultiCommandCC.test.ts @@ -10,7 +10,7 @@ import test from "ava"; const host = createTestingHost(); test("is a multi-encapsulating CommandClass", (t) => { - let cc: CommandClass = new BasicCCSet(host, { + let cc: CommandClass = new BasicCCSet({ nodeId: 1, targetValue: 50, }); diff --git a/packages/zwave-js/src/lib/test/cc/MultilevelSwitchCC.test.ts b/packages/zwave-js/src/lib/test/cc/MultilevelSwitchCC.test.ts index 9d2a54aafe15..9abaca1e6c75 100644 --- a/packages/zwave-js/src/lib/test/cc/MultilevelSwitchCC.test.ts +++ b/packages/zwave-js/src/lib/test/cc/MultilevelSwitchCC.test.ts @@ -24,7 +24,7 @@ function buildCCBuffer(payload: Buffer): Buffer { } test("the Get command should serialize correctly", (t) => { - const cc = new MultilevelSwitchCCGet(host, { nodeId: 1 }); + const cc = new MultilevelSwitchCCGet({ nodeId: 1 }); const expected = buildCCBuffer( Buffer.from([ MultilevelSwitchCommand.Get, // CC Command @@ -34,7 +34,7 @@ test("the Get command should serialize correctly", (t) => { }); test("the Set command should serialize correctly (no duration)", (t) => { - const cc = new MultilevelSwitchCCSet(host, { + const cc = new MultilevelSwitchCCSet({ nodeId: 2, targetValue: 55, }); @@ -55,7 +55,7 @@ test("the Set command should serialize correctly (no duration)", (t) => { }); test("the Set command (V2) should serialize correctly", (t) => { - const cc = new MultilevelSwitchCCSet(host, { + const cc = new MultilevelSwitchCCSet({ nodeId: 2, targetValue: 55, duration: new Duration(2, "minutes"), @@ -83,7 +83,7 @@ test("the Report command (V1) should be deserialized correctly", (t) => { 55, // current value ]), ); - const cc = new MultilevelSwitchCCReport(host, { + const cc = new MultilevelSwitchCCReport({ nodeId: 2, data: ccData, context: {} as any, @@ -103,7 +103,7 @@ test("the Report command (v4) should be deserialized correctly", (t) => { 1, // duration ]), ); - const cc = new MultilevelSwitchCCReport(host, { + const cc = new MultilevelSwitchCCReport({ nodeId: 2, data: ccData, context: {} as any, @@ -116,7 +116,7 @@ test("the Report command (v4) should be deserialized correctly", (t) => { }); test("the StopLevelChange command should serialize correctly", (t) => { - const cc = new MultilevelSwitchCCStopLevelChange(host, { + const cc = new MultilevelSwitchCCStopLevelChange({ nodeId: 1, }); const expected = buildCCBuffer( @@ -128,7 +128,7 @@ test("the StopLevelChange command should serialize correctly", (t) => { }); test("the StartLevelChange command (V2) should serialize correctly (down, ignore start level, with duration)", (t) => { - const cc = new MultilevelSwitchCCStartLevelChange(host, { + const cc = new MultilevelSwitchCCStartLevelChange({ nodeId: 2, direction: "down", ignoreStartLevel: true, @@ -153,7 +153,7 @@ test("the StartLevelChange command (V2) should serialize correctly (down, ignore }); test("the SupportedGet command should serialize correctly", (t) => { - const cc = new MultilevelSwitchCCSupportedGet(host, { + const cc = new MultilevelSwitchCCSupportedGet({ nodeId: 1, }); const expected = buildCCBuffer( @@ -168,7 +168,7 @@ test("deserializing an unsupported command should return an unspecified version const serializedCC = buildCCBuffer( Buffer.from([255]), // not a valid command ); - const cc: any = new MultilevelSwitchCC(host, { + const cc: any = new MultilevelSwitchCC({ nodeId: 2, data: serializedCC, context: {} as any, diff --git a/packages/zwave-js/src/lib/test/cc/NoOperationCC.test.ts b/packages/zwave-js/src/lib/test/cc/NoOperationCC.test.ts index d64dbae3f886..6e989b490328 100644 --- a/packages/zwave-js/src/lib/test/cc/NoOperationCC.test.ts +++ b/packages/zwave-js/src/lib/test/cc/NoOperationCC.test.ts @@ -15,7 +15,7 @@ function buildCCBuffer(payload: Buffer): Buffer { } test("the CC should serialize correctly", (t) => { - const cc = new NoOperationCC(host, { nodeId: 1 }); + const cc = new NoOperationCC({ nodeId: 1 }); const expected = buildCCBuffer( Buffer.from([]), // No command! ); @@ -27,6 +27,6 @@ test("the CC should be deserialized correctly", (t) => { Buffer.from([]), // No command! ); t.notThrows(() => - new NoOperationCC(host, { nodeId: 2, data: ccData, context: {} as any }) + new NoOperationCC({ nodeId: 2, data: ccData, context: {} as any }) ); }); diff --git a/packages/zwave-js/src/lib/test/cc/PowerlevelCC.test.ts b/packages/zwave-js/src/lib/test/cc/PowerlevelCC.test.ts index 84e196f00247..0505807c0410 100644 --- a/packages/zwave-js/src/lib/test/cc/PowerlevelCC.test.ts +++ b/packages/zwave-js/src/lib/test/cc/PowerlevelCC.test.ts @@ -22,7 +22,7 @@ function buildCCBuffer(payload: Buffer): Buffer { } test("the Get command should serialize correctly", (t) => { - const cc = new PowerlevelCCGet(host, { nodeId: 1 }); + const cc = new PowerlevelCCGet({ nodeId: 1 }); const expected = buildCCBuffer( Buffer.from([ PowerlevelCommand.Get, // CC Command @@ -32,7 +32,7 @@ test("the Get command should serialize correctly", (t) => { }); test("the Set NormalPower command should serialize correctly", (t) => { - const cc = new PowerlevelCCSet(host, { + const cc = new PowerlevelCCSet({ nodeId: 2, powerlevel: Powerlevel["Normal Power"], }); @@ -47,7 +47,7 @@ test("the Set NormalPower command should serialize correctly", (t) => { }); test("the Set NormalPower command with timeout should serialize correctly", (t) => { - const cc = new PowerlevelCCSet(host, { + const cc = new PowerlevelCCSet({ nodeId: 2, powerlevel: Powerlevel["Normal Power"], timeout: 50, @@ -63,7 +63,7 @@ test("the Set NormalPower command with timeout should serialize correctly", (t) }); test("the Set Custom power command should serialize correctly", (t) => { - const cc = new PowerlevelCCSet(host, { + const cc = new PowerlevelCCSet({ nodeId: 2, powerlevel: Powerlevel["-1 dBm"], timeout: 50, @@ -86,7 +86,7 @@ test("the Report command should be deserialized correctly (NormalPower)", (t) => 50, // timeout (ignored because NormalPower) ]), ); - const cc = new PowerlevelCCReport(host, { + const cc = new PowerlevelCCReport({ nodeId: 5, data: ccData, context: {} as any, @@ -104,7 +104,7 @@ test("the Report command should be deserialized correctly (custom power)", (t) = 50, // timeout (ignored because NormalPower) ]), ); - const cc = new PowerlevelCCReport(host, { + const cc = new PowerlevelCCReport({ nodeId: 5, data: ccData, context: {} as any, @@ -118,7 +118,7 @@ test("deserializing an unsupported command should return an unspecified version const serializedCC = buildCCBuffer( Buffer.from([255]), // not a valid command ); - const cc: any = new PowerlevelCC(host, { + const cc: any = new PowerlevelCC({ nodeId: 1, data: serializedCC, context: {} as any, diff --git a/packages/zwave-js/src/lib/test/cc/SceneActivationCC.test.ts b/packages/zwave-js/src/lib/test/cc/SceneActivationCC.test.ts index 816011639a55..670ead3b48bb 100644 --- a/packages/zwave-js/src/lib/test/cc/SceneActivationCC.test.ts +++ b/packages/zwave-js/src/lib/test/cc/SceneActivationCC.test.ts @@ -19,7 +19,7 @@ function buildCCBuffer(payload: Buffer): Buffer { } test("the Set command (without Duration) should serialize correctly", (t) => { - const cc = new SceneActivationCCSet(host, { + const cc = new SceneActivationCCSet({ nodeId: 2, sceneId: 55, }); @@ -34,7 +34,7 @@ test("the Set command (without Duration) should serialize correctly", (t) => { }); test("the Set command (with Duration) should serialize correctly", (t) => { - const cc = new SceneActivationCCSet(host, { + const cc = new SceneActivationCCSet({ nodeId: 2, sceneId: 56, dimmingDuration: new Duration(1, "minutes"), @@ -57,7 +57,7 @@ test("the Set command should be deserialized correctly", (t) => { 0x00, // 0 seconds ]), ); - const cc = new SceneActivationCCSet(host, { + const cc = new SceneActivationCCSet({ nodeId: 2, data: ccData, context: {} as any, @@ -71,7 +71,7 @@ test("deserializing an unsupported command should return an unspecified version const serializedCC = buildCCBuffer( Buffer.from([255]), // not a valid command ); - const cc: any = new SceneActivationCC(host, { + const cc: any = new SceneActivationCC({ nodeId: 2, data: serializedCC, context: {} as any, diff --git a/packages/zwave-js/src/lib/test/cc/SceneActuatorConfigurationCC.test.ts b/packages/zwave-js/src/lib/test/cc/SceneActuatorConfigurationCC.test.ts index e07fbbe8552d..7a017569ec06 100644 --- a/packages/zwave-js/src/lib/test/cc/SceneActuatorConfigurationCC.test.ts +++ b/packages/zwave-js/src/lib/test/cc/SceneActuatorConfigurationCC.test.ts @@ -21,7 +21,7 @@ function buildCCBuffer(payload: Buffer): Buffer { } test("the Get command should serialize correctly", (t) => { - const cc = new SceneActuatorConfigurationCCGet(host, { + const cc = new SceneActuatorConfigurationCCGet({ nodeId: 2, sceneId: 1, }); @@ -35,7 +35,7 @@ test("the Get command should serialize correctly", (t) => { }); test("the Set command should serialize correctly with level", (t) => { - const cc = new SceneActuatorConfigurationCCSet(host, { + const cc = new SceneActuatorConfigurationCCSet({ nodeId: 2, sceneId: 2, level: 0x00, @@ -54,7 +54,7 @@ test("the Set command should serialize correctly with level", (t) => { }); test("the Set command should serialize correctly with undefined level", (t) => { - const cc = new SceneActuatorConfigurationCCSet(host, { + const cc = new SceneActuatorConfigurationCCSet({ nodeId: 2, sceneId: 2, // level: undefined, @@ -81,7 +81,7 @@ test("the Report command (v1) should be deserialized correctly", (t) => { 0x05, // dimmingDuration ]), ); - const cc = new SceneActuatorConfigurationCCReport(host, { + const cc = new SceneActuatorConfigurationCCReport({ nodeId: 2, data: ccData, context: {} as any, @@ -96,7 +96,7 @@ test("deserializing an unsupported command should return an unspecified version const serializedCC = buildCCBuffer( Buffer.from([255]), // not a valid command ); - const cc: any = new SceneActuatorConfigurationCC(host, { + const cc: any = new SceneActuatorConfigurationCC({ nodeId: 2, data: serializedCC, context: {} as any, diff --git a/packages/zwave-js/src/lib/test/cc/SceneControllerConfigurationCC.test.ts b/packages/zwave-js/src/lib/test/cc/SceneControllerConfigurationCC.test.ts index 43bd787b9846..4bef4a2f4dcf 100644 --- a/packages/zwave-js/src/lib/test/cc/SceneControllerConfigurationCC.test.ts +++ b/packages/zwave-js/src/lib/test/cc/SceneControllerConfigurationCC.test.ts @@ -34,7 +34,7 @@ function prepareTest(): { host: TestingHost; node2: IZWaveNode } { test("the Get command should serialize correctly", (t) => { const { host } = prepareTest(); - const cc = new SceneControllerConfigurationCCGet(host, { + const cc = new SceneControllerConfigurationCCGet({ nodeId: 2, groupId: 1, }); @@ -51,7 +51,7 @@ test.skip("the Get command should throw if GroupId > groupCount", (t) => { const { host } = prepareTest(); // TODO: This check now lives on the CC API t.notThrows(() => { - new SceneControllerConfigurationCCGet(host, { + new SceneControllerConfigurationCCGet({ nodeId: 2, groupId: fakeGroupCount + 1, }); @@ -60,7 +60,7 @@ test.skip("the Get command should throw if GroupId > groupCount", (t) => { test("the Set command should serialize correctly", (t) => { const { host } = prepareTest(); - const cc = new SceneControllerConfigurationCCSet(host, { + const cc = new SceneControllerConfigurationCCSet({ nodeId: 2, groupId: 3, sceneId: 240, @@ -79,7 +79,7 @@ test("the Set command should serialize correctly", (t) => { test("the Set command should serialize correctly with undefined duration", (t) => { const { host } = prepareTest(); - const cc = new SceneControllerConfigurationCCSet(host, { + const cc = new SceneControllerConfigurationCCSet({ nodeId: 2, groupId: 3, sceneId: 240, @@ -101,7 +101,7 @@ test.skip("the Set command should throw if GroupId > groupCount", (t) => { // TODO: This check now lives on the CC API t.notThrows( () => - new SceneControllerConfigurationCCSet(host, { + new SceneControllerConfigurationCCSet({ nodeId: 2, groupId: fakeGroupCount + 1, sceneId: 240, @@ -120,7 +120,7 @@ test("the Report command (v1) should be deserialized correctly", (t) => { 0x05, // dimming duration ]), ); - const cc = new SceneControllerConfigurationCCReport(host, { + const cc = new SceneControllerConfigurationCCReport({ nodeId: 2, data: ccData, context: {} as any, @@ -136,7 +136,7 @@ test("deserializing an unsupported command should return an unspecified version const serializedCC = buildCCBuffer( Buffer.from([255]), // not a valid command ); - const cc: any = new SceneControllerConfigurationCC(host, { + const cc: any = new SceneControllerConfigurationCC({ nodeId: 1, data: serializedCC, context: {} as any, diff --git a/packages/zwave-js/src/lib/test/cc/SupervisionCC.test.ts b/packages/zwave-js/src/lib/test/cc/SupervisionCC.test.ts index 2e0be00a4c6c..b382c7c9e1ce 100644 --- a/packages/zwave-js/src/lib/test/cc/SupervisionCC.test.ts +++ b/packages/zwave-js/src/lib/test/cc/SupervisionCC.test.ts @@ -8,7 +8,7 @@ const host = createTestingHost(); test("SupervisionCCGet should expect a response", (t) => { const ccRequest = SupervisionCC.encapsulate( host, - new BasicCCSet(host, { + new BasicCCSet({ nodeId: 2, targetValue: 5, }), @@ -19,12 +19,12 @@ test("SupervisionCCGet should expect a response", (t) => { test("SupervisionCC/BasicCCSet => SupervisionCCReport (correct session ID) = expected", (t) => { const ccRequest = SupervisionCC.encapsulate( host, - new BasicCCSet(host, { + new BasicCCSet({ nodeId: 2, targetValue: 5, }), ); - const ccResponse = new SupervisionCCReport(host, { + const ccResponse = new SupervisionCCReport({ nodeId: 2, moreUpdatesFollow: false, sessionId: ccRequest.sessionId, @@ -37,12 +37,12 @@ test("SupervisionCC/BasicCCSet => SupervisionCCReport (correct session ID) = exp test("SupervisionCC/BasicCCSet => SupervisionCCReport (wrong session ID) = unexpected", (t) => { const ccRequest = SupervisionCC.encapsulate( host, - new BasicCCSet(host, { + new BasicCCSet({ nodeId: 2, targetValue: 5, }), ); - const ccResponse = new SupervisionCCReport(host, { + const ccResponse = new SupervisionCCReport({ nodeId: 2, moreUpdatesFollow: false, sessionId: ccRequest.sessionId + 1, diff --git a/packages/zwave-js/src/lib/test/cc/ThermostatFanModeCC.test.ts b/packages/zwave-js/src/lib/test/cc/ThermostatFanModeCC.test.ts index f03eac134009..47f13f581a62 100644 --- a/packages/zwave-js/src/lib/test/cc/ThermostatFanModeCC.test.ts +++ b/packages/zwave-js/src/lib/test/cc/ThermostatFanModeCC.test.ts @@ -21,7 +21,7 @@ function buildCCBuffer(payload: Buffer): Buffer { } test("the Get command should serialize correctly", (t) => { - const cc = new ThermostatFanModeCCGet(host, { nodeId: 5 }); + const cc = new ThermostatFanModeCCGet({ nodeId: 5 }); const expected = buildCCBuffer( Buffer.from([ ThermostatFanModeCommand.Get, // CC Command @@ -31,7 +31,7 @@ test("the Get command should serialize correctly", (t) => { }); test("the Set command should serialize correctly (off = false)", (t) => { - const cc = new ThermostatFanModeCCSet(host, { + const cc = new ThermostatFanModeCCSet({ nodeId: 5, mode: ThermostatFanMode["Auto medium"], off: false, @@ -46,7 +46,7 @@ test("the Set command should serialize correctly (off = false)", (t) => { }); test("the Set command should serialize correctly (off = true)", (t) => { - const cc = new ThermostatFanModeCCSet(host, { + const cc = new ThermostatFanModeCCSet({ nodeId: 5, mode: ThermostatFanMode["Auto medium"], off: true, @@ -67,7 +67,7 @@ test("the Report command should be deserialized correctly", (t) => { 0b1000_0010, // Off bit set to 1 and Auto high mode ]), ); - const cc = new ThermostatFanModeCCReport(host, { + const cc = new ThermostatFanModeCCReport({ nodeId: 5, data: ccData, context: {} as any, diff --git a/packages/zwave-js/src/lib/test/cc/ThermostatFanStateCC.test.ts b/packages/zwave-js/src/lib/test/cc/ThermostatFanStateCC.test.ts index 4b17d6c55f25..a8267806d3bd 100644 --- a/packages/zwave-js/src/lib/test/cc/ThermostatFanStateCC.test.ts +++ b/packages/zwave-js/src/lib/test/cc/ThermostatFanStateCC.test.ts @@ -21,7 +21,7 @@ function buildCCBuffer(payload: Buffer): Buffer { } test("the Get command should serialize correctly", (t) => { - const cc = new ThermostatFanStateCCGet(host, { nodeId: 1 }); + const cc = new ThermostatFanStateCCGet({ nodeId: 1 }); const expected = buildCCBuffer( Buffer.from([ ThermostatFanStateCommand.Get, // CC Command @@ -37,7 +37,7 @@ test("the Report command (v1 - v2) should be deserialized correctly", (t) => { ThermostatFanState["Idle / off"], // state ]), ); - const cc = new ThermostatFanStateCCReport(host, { + const cc = new ThermostatFanStateCCReport({ nodeId: 1, data: ccData, context: {} as any, @@ -50,7 +50,7 @@ test("deserializing an unsupported command should return an unspecified version const serializedCC = buildCCBuffer( Buffer.from([255]), // not a valid command ); - const cc: any = new ThermostatFanStateCC(host, { + const cc: any = new ThermostatFanStateCC({ nodeId: 1, data: serializedCC, context: {} as any, diff --git a/packages/zwave-js/src/lib/test/cc/TimeCC.test.ts b/packages/zwave-js/src/lib/test/cc/TimeCC.test.ts index c7837be7fe59..682b49f2ce30 100644 --- a/packages/zwave-js/src/lib/test/cc/TimeCC.test.ts +++ b/packages/zwave-js/src/lib/test/cc/TimeCC.test.ts @@ -22,7 +22,7 @@ function buildCCBuffer(payload: Buffer): Buffer { } test("the TimeGet command should serialize correctly", (t) => { - const cc = new TimeCCTimeGet(host, { nodeId: 1 }); + const cc = new TimeCCTimeGet({ nodeId: 1 }); const expected = buildCCBuffer( Buffer.from([ TimeCommand.TimeGet, // CC Command @@ -40,7 +40,7 @@ test("the TimeReport command should be deserialized correctly", (t) => { 59, ]), ); - const cc = new TimeCCTimeReport(host, { + const cc = new TimeCCTimeReport({ nodeId: 8, data: ccData, context: {} as any, @@ -52,7 +52,7 @@ test("the TimeReport command should be deserialized correctly", (t) => { }); test("the DateGet command should serialize correctly", (t) => { - const cc = new TimeCCDateGet(host, { nodeId: 1 }); + const cc = new TimeCCDateGet({ nodeId: 1 }); const expected = buildCCBuffer( Buffer.from([ TimeCommand.DateGet, // CC Command @@ -71,7 +71,7 @@ test("the DateReport command should be deserialized correctly", (t) => { 17, ]), ); - const cc = new TimeCCDateReport(host, { + const cc = new TimeCCDateReport({ nodeId: 8, data: ccData, context: {} as any, @@ -86,7 +86,7 @@ test("deserializing an unsupported command should return an unspecified version const serializedCC = buildCCBuffer( Buffer.from([255]), // not a valid command ); - const cc: any = new TimeCC(host, { + const cc: any = new TimeCC({ nodeId: 8, data: serializedCC, context: {} as any, diff --git a/packages/zwave-js/src/lib/test/cc/WakeUpCC.test.ts b/packages/zwave-js/src/lib/test/cc/WakeUpCC.test.ts index 02be66cedd84..8fb60a603854 100644 --- a/packages/zwave-js/src/lib/test/cc/WakeUpCC.test.ts +++ b/packages/zwave-js/src/lib/test/cc/WakeUpCC.test.ts @@ -11,7 +11,7 @@ import { randomBytes } from "node:crypto"; const host = createTestingHost(); test("WakeUpCCNoMoreInformation should expect no response", (t) => { - const cc = new WakeUpCCNoMoreInformation(host, { + const cc = new WakeUpCCNoMoreInformation({ nodeId: 2, endpoint: 2, }); @@ -21,7 +21,7 @@ test("WakeUpCCNoMoreInformation should expect no response", (t) => { test("MultiChannelCC/WakeUpCCNoMoreInformation should expect NO response", (t) => { const ccRequest = MultiChannelCC.encapsulate( host, - new WakeUpCCNoMoreInformation(host, { + new WakeUpCCNoMoreInformation({ nodeId: 2, endpoint: 2, }), @@ -45,7 +45,7 @@ test("SecurityCC/WakeUpCCNoMoreInformation should expect NO response", (t) => { host, host.ownNodeId, securityManager as any, - new WakeUpCCNoMoreInformation(host, { + new WakeUpCCNoMoreInformation({ nodeId: 2, endpoint: 2, }), diff --git a/packages/zwave-js/src/lib/test/cc/ZWavePlusCC.test.ts b/packages/zwave-js/src/lib/test/cc/ZWavePlusCC.test.ts index c8339cc93297..f9764aec4e6f 100644 --- a/packages/zwave-js/src/lib/test/cc/ZWavePlusCC.test.ts +++ b/packages/zwave-js/src/lib/test/cc/ZWavePlusCC.test.ts @@ -15,7 +15,7 @@ function buildCCBuffer(payload: Buffer): Buffer { } test("The Get command should serialize correctly", (t) => { - const cc = new ZWavePlusCCGet(host, { + const cc = new ZWavePlusCCGet({ nodeId: 1, }); const expected = buildCCBuffer( diff --git a/packages/zwave-js/src/lib/test/compat/binarySensorReportAnyUseFirstSupported.test.ts b/packages/zwave-js/src/lib/test/compat/binarySensorReportAnyUseFirstSupported.test.ts index 6ea72a92123b..456fbdbe0297 100644 --- a/packages/zwave-js/src/lib/test/compat/binarySensorReportAnyUseFirstSupported.test.ts +++ b/packages/zwave-js/src/lib/test/compat/binarySensorReportAnyUseFirstSupported.test.ts @@ -39,7 +39,7 @@ integrationTest( }; // Incorrectly respond with 0xFF as the sensor type - const cc = new BinarySensorCCReport(self.host, { + const cc = new BinarySensorCCReport({ nodeId: controller.ownNodeId, type: BinarySensorType.Any, value: true, diff --git a/packages/zwave-js/src/lib/test/compat/invalidCallbackFunctionTypes.test.ts b/packages/zwave-js/src/lib/test/compat/invalidCallbackFunctionTypes.test.ts index ef03665fe741..502a31cfc079 100644 --- a/packages/zwave-js/src/lib/test/compat/invalidCallbackFunctionTypes.test.ts +++ b/packages/zwave-js/src/lib/test/compat/invalidCallbackFunctionTypes.test.ts @@ -44,7 +44,7 @@ integrationTest( customSetup: async (driver, controller, mockNode) => { // Incorrectly respond to AssignSUCReturnRoute with DeleteSUCReturnRoute const handleAssignSUCReturnRoute: MockControllerBehavior = { - async onHostMessage(host, controller, msg) { + async onHostMessage(controller, msg) { if (msg instanceof AssignSUCReturnRouteRequest) { // Check if this command is legal right now const state = controller.state.get( @@ -70,7 +70,6 @@ integrationTest( // Send the command to the node const node = controller.nodes.get(msg.getNodeId()!)!; const command = new ZWaveProtocolCCAssignSUCReturnRoute( - host, { nodeId: node.id, destinationNodeId: controller.ownNodeId, @@ -86,7 +85,7 @@ integrationTest( const ackPromise = controller.sendToNode(node, frame); // Notify the host that the message was sent - const res = new AssignSUCReturnRouteResponse(host, { + const res = new AssignSUCReturnRouteResponse({ wasExecuted: true, }); await controller.sendMessageToHost(res); @@ -114,15 +113,12 @@ integrationTest( if (expectCallback) { const cb = - new DeleteSUCReturnRouteRequestTransmitReport( - host, - { - callbackId: msg.callbackId!, - transmitStatus: ack - ? TransmitStatus.OK - : TransmitStatus.NoAck, - }, - ); + new DeleteSUCReturnRouteRequestTransmitReport({ + callbackId: msg.callbackId!, + transmitStatus: ack + ? TransmitStatus.OK + : TransmitStatus.NoAck, + }); await controller.sendMessageToHost(cb); } @@ -134,7 +130,7 @@ integrationTest( // Incorrectly respond to DeleteSUCReturnRoute with a message with function type 0 const handleDeleteSUCReturnRoute: MockControllerBehavior = { - async onHostMessage(host, controller, msg) { + async onHostMessage(controller, msg) { if (msg instanceof DeleteSUCReturnRouteRequest) { // Check if this command is legal right now const state = controller.state.get( @@ -160,7 +156,6 @@ integrationTest( // Send the command to the node const node = controller.nodes.get(msg.getNodeId()!)!; const command = new ZWaveProtocolCCAssignSUCReturnRoute( - host, { nodeId: node.id, destinationNodeId: controller.ownNodeId, @@ -176,7 +171,7 @@ integrationTest( const ackPromise = controller.sendToNode(node, frame); // Notify the host that the message was sent - const res = new DeleteSUCReturnRouteResponse(host, { + const res = new DeleteSUCReturnRouteResponse({ wasExecuted: true, }); await controller.sendMessageToHost(res); @@ -204,15 +199,12 @@ integrationTest( if (expectCallback) { const cb = - new DeleteSUCReturnRouteRequestTransmitReport( - host, - { - callbackId: msg.callbackId!, - transmitStatus: ack - ? TransmitStatus.OK - : TransmitStatus.NoAck, - }, - ); + new DeleteSUCReturnRouteRequestTransmitReport({ + callbackId: msg.callbackId!, + transmitStatus: ack + ? TransmitStatus.OK + : TransmitStatus.NoAck, + }); // @ts-expect-error 0 is not a valid function type cb.functionType = 0; diff --git a/packages/zwave-js/src/lib/test/compat/notificationAlarmMapping.test.ts b/packages/zwave-js/src/lib/test/compat/notificationAlarmMapping.test.ts index f6efbff44482..e0b90d97733b 100644 --- a/packages/zwave-js/src/lib/test/compat/notificationAlarmMapping.test.ts +++ b/packages/zwave-js/src/lib/test/compat/notificationAlarmMapping.test.ts @@ -31,7 +31,7 @@ integrationTest( async testBody(t, driver, node, mockController, mockNode) { // Send a report that should be mapped to notifications - const cc = new NotificationCCReport(mockNode.host, { + const cc = new NotificationCCReport({ nodeId: 2, alarmType: 18, alarmLevel: 2, diff --git a/packages/zwave-js/src/lib/test/compat/reInterviewWakeUpNIF.test.ts b/packages/zwave-js/src/lib/test/compat/reInterviewWakeUpNIF.test.ts index 4fa3c8a31040..f124ca57ec5e 100644 --- a/packages/zwave-js/src/lib/test/compat/reInterviewWakeUpNIF.test.ts +++ b/packages/zwave-js/src/lib/test/compat/reInterviewWakeUpNIF.test.ts @@ -31,7 +31,7 @@ integrationTest( await wait(500); // Send a NIF to trigger the re-interview - const cc = new ZWaveProtocolCCNodeInformationFrame(mockNode.host, { + const cc = new ZWaveProtocolCCNodeInformationFrame({ nodeId: mockNode.id, ...mockNode.capabilities, supportedCCs: [...mockNode.implementedCCs] diff --git a/packages/zwave-js/src/lib/test/compliance/decodeLowerS2Keys.test.ts b/packages/zwave-js/src/lib/test/compliance/decodeLowerS2Keys.test.ts index b7f2867a0fd8..5ea59f9ac67a 100644 --- a/packages/zwave-js/src/lib/test/compliance/decodeLowerS2Keys.test.ts +++ b/packages/zwave-js/src/lib/test/compliance/decodeLowerS2Keys.test.ts @@ -79,7 +79,7 @@ integrationTest( const nonce = sm2Node.generateNonce( controller.ownNodeId, ); - const cc = new Security2CCNonceReport(self.host, { + const cc = new Security2CCNonceReport({ nodeId: controller.ownNodeId, ownNodeId: self.id, securityManagers: self.securityManagers, @@ -110,10 +110,10 @@ integrationTest( ); // The node sends an S2-encapsulated command, but with a lower security class than expected - let innerCC: CommandClass = new TimeCCTimeGet(mockNode.host, { + let innerCC: CommandClass = new TimeCCTimeGet({ nodeId: mockController.ownNodeId, }); - let cc = new Security2CCMessageEncapsulation(mockNode.host, { + let cc = new Security2CCMessageEncapsulation({ nodeId: mockController.ownNodeId, ownNodeId: mockNode.id, encapsulated: innerCC, @@ -153,11 +153,11 @@ integrationTest( mockNode.clearReceivedControllerFrames(); // Now the node queries our securely supported commands - innerCC = new Security2CCCommandsSupportedGet(mockNode.host, { + innerCC = new Security2CCCommandsSupportedGet({ nodeId: mockController.ownNodeId, }); - cc = new Security2CCMessageEncapsulation(mockNode.host, { + cc = new Security2CCMessageEncapsulation({ nodeId: mockController.ownNodeId, ownNodeId: mockNode.id, encapsulated: innerCC, diff --git a/packages/zwave-js/src/lib/test/compliance/discardInsecureCommands.test.ts b/packages/zwave-js/src/lib/test/compliance/discardInsecureCommands.test.ts index 151ba627d994..32612ed3beab 100644 --- a/packages/zwave-js/src/lib/test/compliance/discardInsecureCommands.test.ts +++ b/packages/zwave-js/src/lib/test/compliance/discardInsecureCommands.test.ts @@ -75,7 +75,7 @@ integrationTest( const nonce = smNode.generateNonce( controller.ownNodeId, ); - const cc = new Security2CCNonceReport(self.host, { + const cc = new Security2CCNonceReport({ nodeId: controller.ownNodeId, ownNodeId: self.id, securityManagers: self.securityManagers, @@ -102,7 +102,7 @@ integrationTest( const nonce = smNode.generateNonce( controller.ownNodeId, ); - const cc = new Security2CCNonceReport(self.host, { + const cc = new Security2CCNonceReport({ nodeId: controller.ownNodeId, ownNodeId: self.id, securityManagers: self.securityManagers, @@ -128,8 +128,7 @@ integrationTest( // Send a secure command that should be handled let nodeToHost: CommandClass = Security2CC.encapsulate( - mockNode.host, - new BasicCCReport(mockNode.host, { + new BasicCCReport({ nodeId: mockController.ownNodeId, currentValue: 99, }), @@ -149,7 +148,7 @@ integrationTest( t.is(currentValue, 99); // Then send an unencypted one that should be discarded - nodeToHost = new BasicCCReport(mockNode.host, { + nodeToHost = new BasicCCReport({ nodeId: mockController.ownNodeId, currentValue: 1, }); diff --git a/packages/zwave-js/src/lib/test/compliance/encapsulationAnswerAsAsked.test.ts b/packages/zwave-js/src/lib/test/compliance/encapsulationAnswerAsAsked.test.ts index e8261ce512e5..4fd87ee2aa53 100644 --- a/packages/zwave-js/src/lib/test/compliance/encapsulationAnswerAsAsked.test.ts +++ b/packages/zwave-js/src/lib/test/compliance/encapsulationAnswerAsAsked.test.ts @@ -41,10 +41,10 @@ integrationTest( testBody: async (t, driver, node, mockController, mockNode) => { // We know that the driver must respond to Z-Wave Plus Info Get // so we can use that to test - const zwpRequest = new ZWavePlusCCGet(mockNode.host, { + const zwpRequest = new ZWavePlusCCGet({ nodeId: mockController.ownNodeId, }); - const cc = CRC16CC.encapsulate(mockNode.host, zwpRequest); + const cc = CRC16CC.encapsulate(zwpRequest); await mockNode.sendToController(createMockZWaveRequestFrame(cc)); const { payload: response } = await mockNode.expectControllerFrame( @@ -88,10 +88,10 @@ integrationTest( testBody: async (t, driver, node, mockController, mockNode) => { // We know that the driver must respond to Z-Wave Plus Info Get // so we can use that to test - const zwpRequest = new ZWavePlusCCGet(mockNode.host, { + const zwpRequest = new ZWavePlusCCGet({ nodeId: mockController.ownNodeId, }); - const cc = MultiChannelCC.encapsulate(mockNode.host, zwpRequest); + const cc = MultiChannelCC.encapsulate(zwpRequest); cc.endpointIndex = 2; await mockNode.sendToController(createMockZWaveRequestFrame(cc)); @@ -138,12 +138,11 @@ integrationTest( }, testBody: async (t, driver, node, mockController, mockNode) => { - const basicReport = new BasicCCReport(mockNode.host, { + const basicReport = new BasicCCReport({ nodeId: mockController.ownNodeId, currentValue: 0, }); const cc = SupervisionCC.encapsulate( - mockNode.host, basicReport, driver.getNextSupervisionSessionId(mockNode.id), ); @@ -193,16 +192,15 @@ integrationTest( }, testBody: async (t, driver, node, mockController, mockNode) => { - const basicReport = new BasicCCReport(mockNode.host, { + const basicReport = new BasicCCReport({ nodeId: mockController.ownNodeId, currentValue: 0, }); const supervised = SupervisionCC.encapsulate( - mockNode.host, basicReport, driver.getNextSupervisionSessionId(mockNode.id), ); - const cc = MultiChannelCC.encapsulate(mockNode.host, supervised); + const cc = MultiChannelCC.encapsulate(supervised); cc.endpointIndex = 2; await mockNode.sendToController(createMockZWaveRequestFrame(cc)); diff --git a/packages/zwave-js/src/lib/test/compliance/handleMultiCommandPayload.test.ts b/packages/zwave-js/src/lib/test/compliance/handleMultiCommandPayload.test.ts index 5ccefaf26cd4..0e86c08eb1c1 100644 --- a/packages/zwave-js/src/lib/test/compliance/handleMultiCommandPayload.test.ts +++ b/packages/zwave-js/src/lib/test/compliance/handleMultiCommandPayload.test.ts @@ -31,15 +31,15 @@ integrationTest("All CCs contained in a Multi Command CC are handled", { testBody: async (t, driver, node, mockController, mockNode) => { // This one requires a response - const zwpRequest = new ZWavePlusCCGet(mockNode.host, { + const zwpRequest = new ZWavePlusCCGet({ nodeId: mockController.ownNodeId, }); // This one updates a value - const scaSet = new SceneActivationCCSet(mockNode.host, { + const scaSet = new SceneActivationCCSet({ nodeId: mockController.ownNodeId, sceneId: 7, }); - const cc = MultiCommandCC.encapsulate(mockNode.host, [ + const cc = MultiCommandCC.encapsulate([ zwpRequest, scaSet, ]); diff --git a/packages/zwave-js/src/lib/test/compliance/secureNodeSecureEndpoint.test.ts b/packages/zwave-js/src/lib/test/compliance/secureNodeSecureEndpoint.test.ts index 6b71f4157d8d..45c276005024 100644 --- a/packages/zwave-js/src/lib/test/compliance/secureNodeSecureEndpoint.test.ts +++ b/packages/zwave-js/src/lib/test/compliance/secureNodeSecureEndpoint.test.ts @@ -126,7 +126,7 @@ integrationTest( const nonce = smNode.generateNonce( controller.ownNodeId, ); - const cc = new Security2CCNonceReport(self.host, { + const cc = new Security2CCNonceReport({ nodeId: controller.ownNodeId, ownNodeId: self.id, securityManagers: self.securityManagers, @@ -153,7 +153,7 @@ integrationTest( const nonce = smNode.generateNonce( controller.ownNodeId, ); - const cc = new Security2CCNonceReport(self.host, { + const cc = new Security2CCNonceReport({ nodeId: controller.ownNodeId, ownNodeId: self.id, securityManagers: self.securityManagers, @@ -183,8 +183,7 @@ integrationTest( ); const cc = Security2CC.encapsulate( - self.host, - new Security2CCCommandsSupportedReport(self.host, { + new Security2CCCommandsSupportedReport({ nodeId: controller.ownNodeId, supportedCCs: isHighestGranted ? [...mockNode.implementedCCs.entries()] @@ -217,8 +216,7 @@ integrationTest( instanceof MultiChannelCCEndPointGet ) { const cc = Security2CC.encapsulate( - self.host, - new MultiChannelCCEndPointReport(self.host, { + new MultiChannelCCEndPointReport({ nodeId: controller.ownNodeId, countIsDynamic: false, identicalCapabilities: false, @@ -243,8 +241,7 @@ integrationTest( ) { const request = receivedCC.encapsulated; const cc = Security2CC.encapsulate( - self.host, - new MultiChannelCCEndPointFindReport(self.host, { + new MultiChannelCCEndPointFindReport({ nodeId: controller.ownNodeId, genericClass: request.genericClass, specificClass: request.specificClass, @@ -272,8 +269,7 @@ integrationTest( receivedCC.encapsulated.requestedEndpoint, )!; const cc = Security2CC.encapsulate( - self.host, - new MultiChannelCCCapabilityReport(self.host, { + new MultiChannelCCCapabilityReport({ nodeId: controller.ownNodeId, endpointIndex: endpoint.index, genericDeviceClass: diff --git a/packages/zwave-js/src/lib/test/driver/assemblePartialCCs.test.ts b/packages/zwave-js/src/lib/test/driver/assemblePartialCCs.test.ts index 78494ae333e1..7506bfe66368 100644 --- a/packages/zwave-js/src/lib/test/driver/assemblePartialCCs.test.ts +++ b/packages/zwave-js/src/lib/test/driver/assemblePartialCCs.test.ts @@ -50,7 +50,7 @@ test.afterEach.always(async (t) => { test.serial("returns true when a non-partial CC is received", (t) => { const { driver } = t.context; - const cc = new BasicCCSet(driver, { nodeId: 2, targetValue: 50 }); + const cc = new BasicCCSet({ nodeId: 2, targetValue: 50 }); const msg = new ApplicationCommandRequest(driver, { command: cc, }); @@ -61,7 +61,7 @@ test.serial( "returns true when a partial CC is received that expects no more reports", (t) => { const { driver } = t.context; - const cc = new AssociationCCReport(driver, { + const cc = new AssociationCCReport({ nodeId: 2, data: Buffer.from([ CommandClasses.Association, @@ -86,7 +86,7 @@ test.serial( "returns false when a partial CC is received that expects more reports", (t) => { const { driver } = t.context; - const cc = new AssociationCCReport(driver, { + const cc = new AssociationCCReport({ nodeId: 2, data: Buffer.from([ CommandClasses.Association, @@ -111,7 +111,7 @@ test.serial( "returns true when the final partial CC is received and merges its data", (t) => { const { driver } = t.context; - const cc1 = new AssociationCCReport(driver, { + const cc1 = new AssociationCCReport({ nodeId: 2, data: Buffer.from([ CommandClasses.Association, @@ -125,7 +125,7 @@ test.serial( ]), context: {} as any, }); - const cc2 = new AssociationCCReport(driver, { + const cc2 = new AssociationCCReport({ nodeId: 2, data: Buffer.from([ CommandClasses.Association, @@ -158,9 +158,9 @@ test.serial( test.serial("does not crash when receiving a Multi Command CC", (t) => { const { driver } = t.context; - const cc1 = new BasicCCSet(driver, { nodeId: 2, targetValue: 25 }); - const cc2 = new BasicCCSet(driver, { nodeId: 2, targetValue: 50 }); - const cc = new MultiCommandCCCommandEncapsulation(driver, { + const cc1 = new BasicCCSet({ nodeId: 2, targetValue: 25 }); + const cc2 = new BasicCCSet({ nodeId: 2, targetValue: 50 }); + const cc = new MultiCommandCCCommandEncapsulation({ nodeId: 2, encapsulated: [cc1, cc2], }); @@ -172,8 +172,8 @@ test.serial("does not crash when receiving a Multi Command CC", (t) => { test.serial("supports nested partial/non-partial CCs", (t) => { const { driver } = t.context; - const cc1 = new BasicCCSet(driver, { nodeId: 2, targetValue: 25 }); - const cc = new SecurityCCCommandEncapsulation(driver, { + const cc1 = new BasicCCSet({ nodeId: 2, targetValue: 25 }); + const cc = new SecurityCCCommandEncapsulation({ nodeId: 2, ownNodeId: driver.ownNodeId, securityManager: driver.securityManager!, @@ -189,7 +189,7 @@ test.serial("supports nested partial/non-partial CCs", (t) => { test.serial("supports nested partial/partial CCs (part 1)", (t) => { const { driver } = t.context; - const cc = new SecurityCCCommandEncapsulation(driver, { + const cc = new SecurityCCCommandEncapsulation({ nodeId: 2, ownNodeId: driver.ownNodeId, securityManager: driver.securityManager!, @@ -214,7 +214,7 @@ test.serial("supports nested partial/partial CCs (part 1)", (t) => { test.serial("supports nested partial/partial CCs (part 2)", (t) => { const { driver } = t.context; - const cc = new SecurityCCCommandEncapsulation(driver, { + const cc = new SecurityCCCommandEncapsulation({ nodeId: 2, ownNodeId: driver.ownNodeId, securityManager: driver.securityManager!, @@ -241,7 +241,7 @@ test.serial( "returns false when a partial CC throws Deserialization_NotImplemented during merging", (t) => { const { driver } = t.context; - const cc = new AssociationCCReport(driver, { + const cc = new AssociationCCReport({ nodeId: 2, data: Buffer.from([ CommandClasses.Association, @@ -272,7 +272,7 @@ test.serial( "returns false when a partial CC throws CC_NotImplemented during merging", (t) => { const { driver } = t.context; - const cc = new AssociationCCReport(driver, { + const cc = new AssociationCCReport({ nodeId: 2, data: Buffer.from([ CommandClasses.Association, @@ -303,7 +303,7 @@ test.serial( "returns false when a partial CC throws PacketFormat_InvalidPayload during merging", (t) => { const { driver } = t.context; - const cc = new AssociationCCReport(driver, { + const cc = new AssociationCCReport({ nodeId: 2, data: Buffer.from([ CommandClasses.Association, @@ -332,7 +332,7 @@ test.serial( test.serial("passes other errors during merging through", (t) => { const { driver } = t.context; - const cc = new AssociationCCReport(driver, { + const cc = new AssociationCCReport({ nodeId: 2, data: Buffer.from([ CommandClasses.Association, diff --git a/packages/zwave-js/src/lib/test/driver/computeNetCCPayloadSize.test.ts b/packages/zwave-js/src/lib/test/driver/computeNetCCPayloadSize.test.ts index 12d094559ec5..d8d6e79bf0e8 100644 --- a/packages/zwave-js/src/lib/test/driver/computeNetCCPayloadSize.test.ts +++ b/packages/zwave-js/src/lib/test/driver/computeNetCCPayloadSize.test.ts @@ -44,7 +44,7 @@ test.afterEach.always(async (t) => { test("should compute the correct net payload sizes", (t) => { const { driver } = t.context; const testMsg1 = new SendDataRequest(driver, { - command: new SecurityCCCommandEncapsulation(driver, { + command: new SecurityCCCommandEncapsulation({ nodeId: 2, ownNodeId: driver.ownNodeId, securityManager: driver.securityManager!, @@ -55,13 +55,13 @@ test("should compute the correct net payload sizes", (t) => { testMsg1.command.encapsulated = undefined as any; t.is(driver.computeNetCCPayloadSize(testMsg1), 26); - const multiChannelCC = new MultiChannelCCCommandEncapsulation(driver, { + const multiChannelCC = new MultiChannelCCCommandEncapsulation({ nodeId: 2, destination: 1, encapsulated: {} as any, }); const testMsg2 = new SendDataRequest(driver, { - command: new SecurityCCCommandEncapsulation(driver, { + command: new SecurityCCCommandEncapsulation({ nodeId: 2, ownNodeId: driver.ownNodeId, securityManager: driver.securityManager!, @@ -72,7 +72,7 @@ test("should compute the correct net payload sizes", (t) => { multiChannelCC.encapsulated = undefined as any; t.is(driver.computeNetCCPayloadSize(testMsg2), 54 - 20 - 4); - const testMsg3 = new FirmwareUpdateMetaDataCC(driver, { + const testMsg3 = new FirmwareUpdateMetaDataCC({ nodeId: 2, }); testMsg3.toggleEncapsulationFlag(EncapsulationFlags.Security, true); diff --git a/packages/zwave-js/src/lib/test/driver/controllerJammed.test.ts b/packages/zwave-js/src/lib/test/driver/controllerJammed.test.ts index 6cae0c34b127..74beb19e964a 100644 --- a/packages/zwave-js/src/lib/test/driver/controllerJammed.test.ts +++ b/packages/zwave-js/src/lib/test/driver/controllerJammed.test.ts @@ -42,7 +42,7 @@ integrationTest("update the controller status and wait if TX status is Fail", { customSetup: async (driver, controller, mockNode) => { // Return a TX status of Fail when desired const handleSendData: MockControllerBehavior = { - async onHostMessage(host, controller, msg) { + async onHostMessage(controller, msg) { if (msg instanceof SendDataRequest) { if (!shouldFail) { // Defer to the default behavior @@ -69,7 +69,7 @@ integrationTest("update the controller status and wait if TX status is Fail", { ); // Notify the host that the message was sent - const res = new SendDataResponse(host, { + const res = new SendDataResponse({ wasSent: true, }); await controller.sendMessageToHost(res); @@ -81,7 +81,7 @@ integrationTest("update the controller status and wait if TX status is Fail", { MockControllerCommunicationState.Idle, ); - const cb = new SendDataRequestTransmitReport(host, { + const cb = new SendDataRequestTransmitReport({ callbackId: msg.callbackId!, transmitStatus: TransmitStatus.Fail, txReport: { @@ -159,7 +159,7 @@ integrationTest( customSetup: async (driver, controller, mockNode) => { // Return a TX status of Fail when desired const handleSendData: MockControllerBehavior = { - async onHostMessage(host, controller, msg) { + async onHostMessage(controller, msg) { // Soft reset should restore normal operation if (msg instanceof SoftResetRequest) { shouldFail = false; @@ -192,7 +192,7 @@ integrationTest( ); // Notify the host that the message was sent - const res = new SendDataResponse(host, { + const res = new SendDataResponse({ wasSent: true, }); await controller.sendMessageToHost(res); @@ -204,7 +204,7 @@ integrationTest( MockControllerCommunicationState.Idle, ); - const cb = new SendDataRequestTransmitReport(host, { + const cb = new SendDataRequestTransmitReport({ callbackId: msg.callbackId!, transmitStatus: TransmitStatus.Fail, txReport: { @@ -305,7 +305,7 @@ integrationTestMulti( customSetup: async (driver, controller, mockNodes) => { // Return a TX status of Fail when desired const handleSendData: MockControllerBehavior = { - async onHostMessage(host, controller, msg) { + async onHostMessage(controller, msg) { if (msg instanceof SendDataRequest) { // Commands to node 3 work normally if (msg.getNodeId() === 3) { @@ -333,7 +333,7 @@ integrationTestMulti( ); // Notify the host that the message was sent - const res = new SendDataResponse(host, { + const res = new SendDataResponse({ wasSent: true, }); await controller.sendMessageToHost(res); @@ -345,7 +345,7 @@ integrationTestMulti( MockControllerCommunicationState.Idle, ); - const cb = new SendDataRequestTransmitReport(host, { + const cb = new SendDataRequestTransmitReport({ callbackId: msg.callbackId!, transmitStatus: TransmitStatus.Fail, txReport: { diff --git a/packages/zwave-js/src/lib/test/driver/createCCValuesUsingKnownVersion.test.ts b/packages/zwave-js/src/lib/test/driver/createCCValuesUsingKnownVersion.test.ts index 4a5d62822cb4..42219793a1f7 100644 --- a/packages/zwave-js/src/lib/test/driver/createCCValuesUsingKnownVersion.test.ts +++ b/packages/zwave-js/src/lib/test/driver/createCCValuesUsingKnownVersion.test.ts @@ -19,7 +19,7 @@ integrationTest("CC values are created using the known CC version", { ), testBody: async (t, driver, node, mockController, mockNode) => { - const batteryReport = new BatteryCCReport(mockNode.host, { + const batteryReport = new BatteryCCReport({ nodeId: mockController.ownNodeId, isLow: true, }); diff --git a/packages/zwave-js/src/lib/test/driver/handleNonImplementedCCs.test.ts b/packages/zwave-js/src/lib/test/driver/handleNonImplementedCCs.test.ts index 47ba91182e00..4da3efc61d06 100644 --- a/packages/zwave-js/src/lib/test/driver/handleNonImplementedCCs.test.ts +++ b/packages/zwave-js/src/lib/test/driver/handleNonImplementedCCs.test.ts @@ -22,7 +22,7 @@ integrationTest( 1000, ); - const cc = new CommandClass(mockNode.host, { + const cc = new CommandClass({ nodeId: mockController.ownNodeId, ccId: CommandClasses["Anti-Theft"], ccCommand: 0x02, // Get diff --git a/packages/zwave-js/src/lib/test/driver/ignoreCCVersion0ForKnownSupportedCCs.test.ts b/packages/zwave-js/src/lib/test/driver/ignoreCCVersion0ForKnownSupportedCCs.test.ts index 5124e74f5e0d..dca5da8aca41 100644 --- a/packages/zwave-js/src/lib/test/driver/ignoreCCVersion0ForKnownSupportedCCs.test.ts +++ b/packages/zwave-js/src/lib/test/driver/ignoreCCVersion0ForKnownSupportedCCs.test.ts @@ -77,7 +77,7 @@ integrationTest( const nonce = smNode.generateNonce( controller.ownNodeId, ); - const cc = new Security2CCNonceReport(self.host, { + const cc = new Security2CCNonceReport({ nodeId: controller.ownNodeId, ownNodeId: self.id, securityManagers: self.securityManagers, @@ -104,7 +104,7 @@ integrationTest( const nonce = smNode.generateNonce( controller.ownNodeId, ); - const cc = new Security2CCNonceReport(self.host, { + const cc = new Security2CCNonceReport({ nodeId: controller.ownNodeId, ownNodeId: self.id, securityManagers: self.securityManagers, @@ -130,18 +130,14 @@ integrationTest( instanceof Security2CCCommandsSupportedGet ) { let cc: CommandClass = - new Security2CCCommandsSupportedReport( - self.host, - { - nodeId: controller.ownNodeId, - supportedCCs: [ - // The node supports Version CC securely - CommandClasses.Version, - ], - }, - ); + new Security2CCCommandsSupportedReport({ + nodeId: controller.ownNodeId, + supportedCCs: [ + // The node supports Version CC securely + CommandClasses.Version, + ], + }); cc = Security2CC.encapsulate( - self.host, cc, self.id, self.securityManagers, @@ -162,17 +158,12 @@ integrationTest( && receivedCC.encapsulated.requestedCC === CommandClasses["Security 2"] ) { - let cc: CommandClass = new VersionCCCommandClassReport( - self.host, - { - nodeId: controller.ownNodeId, - requestedCC: - receivedCC.encapsulated.requestedCC, - ccVersion: 0, - }, - ); + let cc: CommandClass = new VersionCCCommandClassReport({ + nodeId: controller.ownNodeId, + requestedCC: receivedCC.encapsulated.requestedCC, + ccVersion: 0, + }); cc = Security2CC.encapsulate( - self.host, cc, self.id, self.securityManagers, @@ -227,7 +218,7 @@ integrationTest( controller.ownNodeId, 8, ); - const cc = new SecurityCCNonceReport(self.host, { + const cc = new SecurityCCNonceReport({ nodeId: controller.ownNodeId, nonce, }); @@ -244,7 +235,7 @@ integrationTest( && receivedCC.encapsulated instanceof SecurityCCCommandsSupportedGet ) { - const nonceGet = new SecurityCCNonceGet(self.host, { + const nonceGet = new SecurityCCNonceGet({ nodeId: controller.ownNodeId, }); await self.sendToController( @@ -267,19 +258,15 @@ integrationTest( const receiverNonce = nonceReport.payload.nonce; const response: CommandClass = - new SecurityCCCommandsSupportedReport( - self.host, - { - nodeId: controller.ownNodeId, - supportedCCs: [ - // The node supports Version CC securely - CommandClasses.Version, - ], - controlledCCs: [], - }, - ); + new SecurityCCCommandsSupportedReport({ + nodeId: controller.ownNodeId, + supportedCCs: [ + // The node supports Version CC securely + CommandClasses.Version, + ], + controlledCCs: [], + }); const cc = SecurityCC.encapsulate( - self.host, self.id, self.securityManagers.securityManager!, response, @@ -308,7 +295,7 @@ integrationTest( === CommandClasses.Security ) { await wait(100); - const nonceGet = new SecurityCCNonceGet(self.host, { + const nonceGet = new SecurityCCNonceGet({ nodeId: controller.ownNodeId, }); await self.sendToController( @@ -331,18 +318,14 @@ integrationTest( const receiverNonce = nonceReport.payload.nonce; const response: CommandClass = - new VersionCCCommandClassReport( - self.host, - { - nodeId: controller.ownNodeId, - requestedCC: - receivedCC.encapsulated.requestedCC, - ccVersion: 0, - }, - ); + new VersionCCCommandClassReport({ + nodeId: controller.ownNodeId, + requestedCC: + receivedCC.encapsulated.requestedCC, + ccVersion: 0, + }); const cc = SecurityCC.encapsulate( - self.host, self.id, self.securityManagers.securityManager!, response, diff --git a/packages/zwave-js/src/lib/test/driver/multiStageResponseNoTimeout.test.ts b/packages/zwave-js/src/lib/test/driver/multiStageResponseNoTimeout.test.ts index 5b45f9ef9859..abfd5aa06510 100644 --- a/packages/zwave-js/src/lib/test/driver/multiStageResponseNoTimeout.test.ts +++ b/packages/zwave-js/src/lib/test/driver/multiStageResponseNoTimeout.test.ts @@ -37,7 +37,7 @@ integrationTest( async handleCC(controller, self, receivedCC) { if (receivedCC instanceof ConfigurationCCNameGet) { await wait(700); - let cc = new ConfigurationCCNameReport(self.host, { + let cc = new ConfigurationCCNameReport({ nodeId: controller.ownNodeId, parameter: receivedCC.parameter, name: "Test para", @@ -51,7 +51,7 @@ integrationTest( await wait(700); - cc = new ConfigurationCCNameReport(self.host, { + cc = new ConfigurationCCNameReport({ nodeId: controller.ownNodeId, parameter: receivedCC.parameter, name: "meter", @@ -100,16 +100,13 @@ integrationTest( const respondToConfigurationNameGet: MockNodeBehavior = { async handleCC(controller, self, receivedCC) { if (receivedCC instanceof ConfigurationCCNameGet) { - const configCC = new ConfigurationCCNameReport( - self.host, - { - nodeId: controller.ownNodeId, - parameter: receivedCC.parameter, - name: - "Veeeeeeeeeeeeeeeeeeeeeeeeery loooooooooooooooooong parameter name", - reportsToFollow: 0, - }, - ); + const configCC = new ConfigurationCCNameReport({ + nodeId: controller.ownNodeId, + parameter: receivedCC.parameter, + name: + "Veeeeeeeeeeeeeeeeeeeeeeeeery loooooooooooooooooong parameter name", + reportsToFollow: 0, + }); const serialized = configCC.serialize(); const segment1 = serialized.subarray( 0, @@ -119,25 +116,19 @@ integrationTest( const sessionId = 7; - const tsFS = new TransportServiceCCFirstSegment( - self.host, - { - nodeId: controller.ownNodeId, - sessionId, - datagramSize: serialized.length, - partialDatagram: segment1, - }, - ); - const tsSS = new TransportServiceCCSubsequentSegment( - self.host, - { - nodeId: controller.ownNodeId, - sessionId, - datagramSize: serialized.length, - datagramOffset: segment1.length, - partialDatagram: segment2, - }, - ); + const tsFS = new TransportServiceCCFirstSegment({ + nodeId: controller.ownNodeId, + sessionId, + datagramSize: serialized.length, + partialDatagram: segment1, + }); + const tsSS = new TransportServiceCCSubsequentSegment({ + nodeId: controller.ownNodeId, + sessionId, + datagramSize: serialized.length, + datagramOffset: segment1.length, + partialDatagram: segment2, + }); await wait(700); await self.sendToController( @@ -185,7 +176,7 @@ integrationTest("GET requests DO time out if there's no matching response", { handleCC(controller, self, receivedCC) { if (receivedCC instanceof ConfigurationCCNameGet) { // This is not the response you're looking for - const cc = new BasicCCReport(self.host, { + const cc = new BasicCCReport({ nodeId: controller.ownNodeId, currentValue: 1, }); diff --git a/packages/zwave-js/src/lib/test/driver/nodeAsleepBlockNonceReport.test.ts b/packages/zwave-js/src/lib/test/driver/nodeAsleepBlockNonceReport.test.ts index 8d5c8c740bd3..73a87927d27e 100644 --- a/packages/zwave-js/src/lib/test/driver/nodeAsleepBlockNonceReport.test.ts +++ b/packages/zwave-js/src/lib/test/driver/nodeAsleepBlockNonceReport.test.ts @@ -49,7 +49,7 @@ integrationTest( controller.ownNodeId, 8, ); - const cc = new SecurityCCNonceReport(self.host, { + const cc = new SecurityCCNonceReport({ nodeId: controller.ownNodeId, nonce, }); @@ -85,7 +85,7 @@ integrationTest( node.markAsAsleep(); mockNode.autoAckControllerFrames = false; - let nonceRequest = new SecurityCCNonceGet(mockNode.host, { + let nonceRequest = new SecurityCCNonceGet({ nodeId: mockController.ownNodeId, }); await mockNode.sendToController( @@ -123,7 +123,7 @@ integrationTest( mockNode.autoAckControllerFrames = true; // And subsequent requests must be answered - nonceRequest = new SecurityCCNonceGet(mockNode.host, { + nonceRequest = new SecurityCCNonceGet({ nodeId: mockController.ownNodeId, }); await mockNode.sendToController( diff --git a/packages/zwave-js/src/lib/test/driver/nodeAsleepNoReject.test.ts b/packages/zwave-js/src/lib/test/driver/nodeAsleepNoReject.test.ts index ccf364258096..4b7ced4e020a 100644 --- a/packages/zwave-js/src/lib/test/driver/nodeAsleepNoReject.test.ts +++ b/packages/zwave-js/src/lib/test/driver/nodeAsleepNoReject.test.ts @@ -23,7 +23,7 @@ integrationTest( t.is(node2.status, NodeStatus.Awake); - const command1 = new BasicCCSet(driver, { + const command1 = new BasicCCSet({ nodeId: 2, targetValue: 99, }); @@ -31,7 +31,7 @@ integrationTest( maxSendAttempts: 1, }); - const command2 = new BasicCCGet(driver, { + const command2 = new BasicCCGet({ nodeId: 2, }); driver.sendCommand(command2, { diff --git a/packages/zwave-js/src/lib/test/driver/nodeDeadReject.test.ts b/packages/zwave-js/src/lib/test/driver/nodeDeadReject.test.ts index 943270a0dba5..a5d07c6e0b85 100644 --- a/packages/zwave-js/src/lib/test/driver/nodeDeadReject.test.ts +++ b/packages/zwave-js/src/lib/test/driver/nodeDeadReject.test.ts @@ -20,7 +20,7 @@ integrationTest( t.is(node2.status, NodeStatus.Alive); - const command1 = new BasicCCSet(driver, { + const command1 = new BasicCCSet({ nodeId: 2, targetValue: 99, }); @@ -33,7 +33,7 @@ integrationTest( driver.driverLog.print("basicSetPromise rejected"); }); // Don't throw here, do it below - const command2 = new BasicCCGet(driver, { + const command2 = new BasicCCGet({ nodeId: 2, }); const basicGetPromise = driver.sendCommand(command2, { @@ -88,7 +88,7 @@ integrationTest( t.is(node2.status, NodeStatus.Alive); - const command1 = new BasicCCSet(driver, { + const command1 = new BasicCCSet({ nodeId: 2, targetValue: 99, }); @@ -101,7 +101,7 @@ integrationTest( driver.driverLog.print("basicSetPromise rejected"); }); - const command2 = new BasicCCGet(driver, { + const command2 = new BasicCCGet({ nodeId: 2, }); const basicGetPromise = driver.sendCommand(command2, { diff --git a/packages/zwave-js/src/lib/test/driver/notificationPushNoAGI.test.ts b/packages/zwave-js/src/lib/test/driver/notificationPushNoAGI.test.ts index 8c3655868a75..9a684da3dd2c 100644 --- a/packages/zwave-js/src/lib/test/driver/notificationPushNoAGI.test.ts +++ b/packages/zwave-js/src/lib/test/driver/notificationPushNoAGI.test.ts @@ -35,7 +35,7 @@ integrationTest( if (receivedCC instanceof NotificationCCGet) { const notificationType = receivedCC.notificationType || 0x06; - const cc = new NotificationCCReport(self.host, { + const cc = new NotificationCCReport({ nodeId: controller.ownNodeId, notificationType, notificationEvent: notificationType === 0x06 diff --git a/packages/zwave-js/src/lib/test/driver/reInterviewAssumeAwake.test.ts b/packages/zwave-js/src/lib/test/driver/reInterviewAssumeAwake.test.ts index 5c8b1d94c5f7..1c6cfb43015a 100644 --- a/packages/zwave-js/src/lib/test/driver/reInterviewAssumeAwake.test.ts +++ b/packages/zwave-js/src/lib/test/driver/reInterviewAssumeAwake.test.ts @@ -25,7 +25,7 @@ integrationTest("Assume a node to be awake at the start of a re-interview", { await wait(100); // Send a WakeUpNotification to the node to trigger the interview - const cc = new WakeUpCCWakeUpNotification(mockNode.host, { + const cc = new WakeUpCCWakeUpNotification({ nodeId: mockController.ownNodeId, }); await mockNode.sendToController( @@ -47,7 +47,7 @@ integrationTest("Assume a node to be awake at the start of a re-interview", { waitForWakeup: true, }); - const cc = new WakeUpCCWakeUpNotification(mockNode.host, { + const cc = new WakeUpCCWakeUpNotification({ nodeId: mockController.ownNodeId, }); await mockNode.sendToController( diff --git a/packages/zwave-js/src/lib/test/driver/receiveMessages.test.ts b/packages/zwave-js/src/lib/test/driver/receiveMessages.test.ts index 3e68b58bb74f..866dd57275c1 100644 --- a/packages/zwave-js/src/lib/test/driver/receiveMessages.test.ts +++ b/packages/zwave-js/src/lib/test/driver/receiveMessages.test.ts @@ -37,7 +37,7 @@ test.serial( async (t) => { const { driver, controller } = t.context; const req = new ApplicationCommandRequest(driver, { - command: new WakeUpCCIntervalSet(driver, { + command: new WakeUpCCIntervalSet({ nodeId: 1, controllerNodeId: 2, wakeUpInterval: 5, diff --git a/packages/zwave-js/src/lib/test/driver/s0AndS2Encapsulation.test.ts b/packages/zwave-js/src/lib/test/driver/s0AndS2Encapsulation.test.ts index 0815debba5ad..ea33e8ce33fe 100644 --- a/packages/zwave-js/src/lib/test/driver/s0AndS2Encapsulation.test.ts +++ b/packages/zwave-js/src/lib/test/driver/s0AndS2Encapsulation.test.ts @@ -95,7 +95,7 @@ integrationTest("S0 commands are S0-encapsulated, even when S2 is supported", { controller.ownNodeId, 8, ); - const cc = new SecurityCCNonceReport(self.host, { + const cc = new SecurityCCNonceReport({ nodeId: controller.ownNodeId, nonce, }); @@ -124,7 +124,7 @@ integrationTest("S0 commands are S0-encapsulated, even when S2 is supported", { const nonce = sm2Node.generateNonce( controller.ownNodeId, ); - const cc = new Security2CCNonceReport(self.host, { + const cc = new Security2CCNonceReport({ nodeId: controller.ownNodeId, ownNodeId: self.id, securityManagers: self.securityManagers, @@ -151,7 +151,7 @@ integrationTest("S0 commands are S0-encapsulated, even when S2 is supported", { const nonce = sm2Node.generateNonce( controller.ownNodeId, ); - const cc = new Security2CCNonceReport(self.host, { + const cc = new Security2CCNonceReport({ nodeId: controller.ownNodeId, ownNodeId: self.id, securityManagers: self.securityManagers, @@ -173,14 +173,13 @@ integrationTest("S0 commands are S0-encapsulated, even when S2 is supported", { receivedCC instanceof Security2CCMessageEncapsulation && receivedCC.encapsulated instanceof SupervisionCCGet ) { - let cc: CommandClass = new SupervisionCCReport(self.host, { + let cc: CommandClass = new SupervisionCCReport({ nodeId: controller.ownNodeId, sessionId: receivedCC.encapsulated.sessionId, moreUpdatesFollow: false, status: SupervisionStatus.Success, }); cc = Security2CC.encapsulate( - self.host, cc, self.id, self.securityManagers, diff --git a/packages/zwave-js/src/lib/test/driver/s0Encapsulation.test.ts b/packages/zwave-js/src/lib/test/driver/s0Encapsulation.test.ts index ef746bf84148..6d64a8924894 100644 --- a/packages/zwave-js/src/lib/test/driver/s0Encapsulation.test.ts +++ b/packages/zwave-js/src/lib/test/driver/s0Encapsulation.test.ts @@ -49,7 +49,7 @@ integrationTest("Communication via Security S0 works", { controller.ownNodeId, 8, ); - const cc = new SecurityCCNonceReport(self.host, { + const cc = new SecurityCCNonceReport({ nodeId: controller.ownNodeId, nonce, }); @@ -67,7 +67,7 @@ integrationTest("Communication via Security S0 works", { && receivedCC.encapsulated instanceof SecurityCCCommandsSupportedGet ) { - const nonceGet = new SecurityCCNonceGet(self.host, { + const nonceGet = new SecurityCCNonceGet({ nodeId: controller.ownNodeId, }); await self.sendToController( @@ -88,14 +88,11 @@ integrationTest("Communication via Security S0 works", { ); const receiverNonce = nonceReport.payload.nonce; - const response = new SecurityCCCommandsSupportedReport( - self.host, - { - nodeId: controller.ownNodeId, - supportedCCs: [CommandClasses.Basic], - controlledCCs: [], - }, - ); + const response = new SecurityCCCommandsSupportedReport({ + nodeId: controller.ownNodeId, + supportedCCs: [CommandClasses.Basic], + controlledCCs: [], + }); const cc = SecurityCC.encapsulate( self.host, self.id, @@ -124,7 +121,7 @@ integrationTest("Communication via Security S0 works", { receivedCC instanceof SecurityCCCommandEncapsulation && receivedCC.encapsulated instanceof BasicCCGet ) { - const nonceGet = new SecurityCCNonceGet(self.host, { + const nonceGet = new SecurityCCNonceGet({ nodeId: controller.ownNodeId, }); await self.sendToController( @@ -145,7 +142,7 @@ integrationTest("Communication via Security S0 works", { ); const receiverNonce = nonceReport.payload.nonce; - const response = new BasicCCReport(self.host, { + const response = new BasicCCReport({ nodeId: controller.ownNodeId, currentValue: ++queryCount, }); diff --git a/packages/zwave-js/src/lib/test/driver/s0EncapsulationTwoNodes.test.ts b/packages/zwave-js/src/lib/test/driver/s0EncapsulationTwoNodes.test.ts index 4a54fa3a7762..81257b1e38cb 100644 --- a/packages/zwave-js/src/lib/test/driver/s0EncapsulationTwoNodes.test.ts +++ b/packages/zwave-js/src/lib/test/driver/s0EncapsulationTwoNodes.test.ts @@ -70,7 +70,7 @@ integrationTest( controller.ownNodeId, 8, ); - const cc = new SecurityCCNonceReport(self.host, { + const cc = new SecurityCCNonceReport({ nodeId: controller.ownNodeId, nonce, }); @@ -88,7 +88,7 @@ integrationTest( && receivedCC.encapsulated instanceof SecurityCCCommandsSupportedGet ) { - const nonceGet = new SecurityCCNonceGet(self.host, { + const nonceGet = new SecurityCCNonceGet({ nodeId: controller.ownNodeId, }); await self.sendToController( @@ -113,14 +113,11 @@ integrationTest( const receiverNonce = nonceReport.payload.nonce; const response = - new SecurityCCCommandsSupportedReport( - self.host, - { - nodeId: controller.ownNodeId, - supportedCCs: [CommandClasses.Basic], - controlledCCs: [], - }, - ); + new SecurityCCCommandsSupportedReport({ + nodeId: controller.ownNodeId, + supportedCCs: [CommandClasses.Basic], + controlledCCs: [], + }); const cc = SecurityCC.encapsulate( self.host, self.id, @@ -156,7 +153,7 @@ integrationTest( await wait(750); } - const nonceGet = new SecurityCCNonceGet(self.host, { + const nonceGet = new SecurityCCNonceGet({ nodeId: controller.ownNodeId, }); await self.sendToController( @@ -180,7 +177,7 @@ integrationTest( ); const receiverNonce = nonceReport.payload.nonce; - const response = new BasicCCReport(self.host, { + const response = new BasicCCReport({ nodeId: controller.ownNodeId, currentValue: queryCount, }); diff --git a/packages/zwave-js/src/lib/test/driver/s2Collisions.test.ts b/packages/zwave-js/src/lib/test/driver/s2Collisions.test.ts index 2dd4c0a3e4a4..be1ff71d905b 100644 --- a/packages/zwave-js/src/lib/test/driver/s2Collisions.test.ts +++ b/packages/zwave-js/src/lib/test/driver/s2Collisions.test.ts @@ -87,7 +87,7 @@ integrationTest( const nonce = smNode.generateNonce( controller.ownNodeId, ); - const cc = new Security2CCNonceReport(self.host, { + const cc = new Security2CCNonceReport({ nodeId: controller.ownNodeId, ownNodeId: self.id, securityManagers: self.securityManagers, @@ -114,7 +114,7 @@ integrationTest( const nonce = smNode.generateNonce( controller.ownNodeId, ); - const cc = new Security2CCNonceReport(self.host, { + const cc = new Security2CCNonceReport({ nodeId: controller.ownNodeId, ownNodeId: self.id, securityManagers: self.securityManagers, @@ -138,17 +138,13 @@ integrationTest( && receivedCC.encapsulated instanceof SupervisionCCGet ) { - let cc: CommandClass = new SupervisionCCReport( - self.host, - { - nodeId: controller.ownNodeId, - sessionId: receivedCC.encapsulated.sessionId, - moreUpdatesFollow: false, - status: SupervisionStatus.Success, - }, - ); + let cc: CommandClass = new SupervisionCCReport({ + nodeId: controller.ownNodeId, + sessionId: receivedCC.encapsulated.sessionId, + moreUpdatesFollow: false, + status: SupervisionStatus.Success, + }); cc = Security2CC.encapsulate( - self.host, cc, self.id, self.securityManagers, @@ -172,8 +168,7 @@ integrationTest( // Now create a collision by having both parties send at the same time const nodeToHost = Security2CC.encapsulate( - mockNode.host, - new BinarySwitchCCReport(mockNode.host, { + new BinarySwitchCCReport({ nodeId: mockController.ownNodeId, currentValue: true, }), @@ -264,7 +259,7 @@ integrationTest( const nonce = smNode.generateNonce( controller.ownNodeId, ); - const cc = new Security2CCNonceReport(self.host, { + const cc = new Security2CCNonceReport({ nodeId: controller.ownNodeId, ownNodeId: self.id, securityManagers: self.securityManagers, @@ -291,7 +286,7 @@ integrationTest( const nonce = smNode.generateNonce( controller.ownNodeId, ); - const cc = new Security2CCNonceReport(self.host, { + const cc = new Security2CCNonceReport({ nodeId: controller.ownNodeId, ownNodeId: self.id, securityManagers: self.securityManagers, @@ -319,8 +314,7 @@ integrationTest( // Now create a collision by having both parties send at the same time const nodeToHost = Security2CC.encapsulate( - mockNode.host, - new BasicCCReport(mockNode.host, { + new BasicCCReport({ nodeId: mockController.ownNodeId, currentValue: 99, }), @@ -404,7 +398,7 @@ integrationTest( const nonce = smNode.generateNonce( controller.ownNodeId, ); - const cc = new Security2CCNonceReport(self.host, { + const cc = new Security2CCNonceReport({ nodeId: controller.ownNodeId, ownNodeId: self.id, securityManagers: self.securityManagers, @@ -431,7 +425,7 @@ integrationTest( const nonce = smNode.generateNonce( controller.ownNodeId, ); - const cc = new Security2CCNonceReport(self.host, { + const cc = new Security2CCNonceReport({ nodeId: controller.ownNodeId, ownNodeId: self.id, securityManagers: self.securityManagers, @@ -455,17 +449,13 @@ integrationTest( && receivedCC.encapsulated instanceof SupervisionCCGet ) { - let cc: CommandClass = new SupervisionCCReport( - self.host, - { - nodeId: controller.ownNodeId, - sessionId: receivedCC.encapsulated.sessionId, - moreUpdatesFollow: false, - status: SupervisionStatus.Success, - }, - ); + let cc: CommandClass = new SupervisionCCReport({ + nodeId: controller.ownNodeId, + sessionId: receivedCC.encapsulated.sessionId, + moreUpdatesFollow: false, + status: SupervisionStatus.Success, + }); cc = Security2CC.encapsulate( - self.host, cc, self.id, self.securityManagers, @@ -493,15 +483,11 @@ integrationTest( const turnOff = node.commandClasses["Binary Switch"].set(false); // Node sends supervised Binary Switch report at the same time - let nodeToHost: CommandClass = new BinarySwitchCCReport( - mockNode.host, - { - nodeId: mockController.ownNodeId, - currentValue: true, - }, - ); + let nodeToHost: CommandClass = new BinarySwitchCCReport({ + nodeId: mockController.ownNodeId, + currentValue: true, + }); nodeToHost = SupervisionCC.encapsulate( - mockNode.host, nodeToHost, driver.getNextSupervisionSessionId( mockController.ownNodeId, @@ -509,7 +495,6 @@ integrationTest( false, ); nodeToHost = Security2CC.encapsulate( - mockNode.host, nodeToHost, mockNode.id, mockNode.securityManagers, @@ -539,8 +524,7 @@ integrationTest( // // Now create a collision by having both parties send at the same time // const nodeToHost = Security2CC.encapsulate( - // mockNode.host, - // new BasicCCReport(mockNode.host, { + // new BasicCCReport({ // nodeId: mockController.ownNodeId, // currentValue: 99, // }), diff --git a/packages/zwave-js/src/lib/test/driver/sendDataAbortAfterTimeout.test.ts b/packages/zwave-js/src/lib/test/driver/sendDataAbortAfterTimeout.test.ts index a31756586112..18d87f88d962 100644 --- a/packages/zwave-js/src/lib/test/driver/sendDataAbortAfterTimeout.test.ts +++ b/packages/zwave-js/src/lib/test/driver/sendDataAbortAfterTimeout.test.ts @@ -38,7 +38,7 @@ integrationTest( customSetup: async (driver, mockController, mockNode) => { // This is almost a 1:1 copy of the default behavior, except that the callback never gets sent const handleBrokenSendData: MockControllerBehavior = { - async onHostMessage(host, controller, msg) { + async onHostMessage(controller, msg) { // If the controller is operating normally, defer to the default behavior if (!shouldTimeOut) return false; @@ -65,7 +65,7 @@ integrationTest( lastCallbackId = msg.callbackId!; // Notify the host that the message was sent - const res = new SendDataResponse(host, { + const res = new SendDataResponse({ wasSent: true, }); await controller.sendMessageToHost(res); @@ -73,7 +73,7 @@ integrationTest( return true; } else if (msg instanceof SendDataAbort) { // Finish the transmission by sending the callback - const cb = new SendDataRequestTransmitReport(host, { + const cb = new SendDataRequestTransmitReport({ callbackId: lastCallbackId, transmitStatus: TransmitStatus.NoAck, }); @@ -95,7 +95,7 @@ integrationTest( mockController.defineBehavior(handleBrokenSendData); const handleSoftReset: MockControllerBehavior = { - onHostMessage(host, controller, msg) { + onHostMessage(controller, msg) { // Soft reset should restore normal operation if (msg instanceof SoftResetRequest) { shouldTimeOut = false; @@ -160,7 +160,7 @@ integrationTest( // customSetup: async (driver, mockController, mockNode) => { // // This is almost a 1:1 copy of the default behavior, except that the callback never gets sent // const handleBrokenSendData: MockControllerBehavior = { -// async onHostMessage(host, controller, msg) { +// async onHostMessage(controller, msg) { // if (msg instanceof SendDataRequest) { // // Check if this command is legal right now // const state = controller.state.get( @@ -182,7 +182,7 @@ integrationTest( // ); // // Notify the host that the message was sent -// const res = new SendDataResponse(host, { +// const res = new SendDataResponse({ // wasSent: true, // }); // await controller.sendMessageToHost(res); @@ -255,7 +255,7 @@ integrationTest( // customSetup: async (driver, mockController, mockNode) => { // // This is almost a 1:1 copy of the default behavior, except that the callback never gets sent // const handleBrokenSendData: MockControllerBehavior = { -// async onHostMessage(host, controller, msg) { +// async onHostMessage(controller, msg) { // // If the controller is operating normally, defer to the default behavior // if (!shouldTimeOut) return false; @@ -280,7 +280,7 @@ integrationTest( // ); // // Notify the host that the message was sent -// const res = new SendDataResponse(host, { +// const res = new SendDataResponse({ // wasSent: true, // }); // await controller.sendMessageToHost(res); @@ -300,7 +300,7 @@ integrationTest( // mockController.defineBehavior(handleBrokenSendData); // const handleSoftReset: MockControllerBehavior = { -// onHostMessage(host, controller, msg) { +// onHostMessage(controller, msg) { // // Soft reset should restore normal operation // if (msg instanceof SoftResetRequest) { // shouldTimeOut = false; @@ -356,10 +356,10 @@ integrationTest( // customSetup: async (driver, mockController, mockNode) => { // // This is almost a 1:1 copy of the default behavior, except that the callback never gets sent // const handleBrokenRequestNodeInfo: MockControllerBehavior = { -// async onHostMessage(host, controller, msg) { +// async onHostMessage(controller, msg) { // if (msg instanceof RequestNodeInfoRequest) { // // Notify the host that the message was sent -// const res = new RequestNodeInfoResponse(host, { +// const res = new RequestNodeInfoResponse({ // wasSent: true, // }); // await controller.sendMessageToHost(res); diff --git a/packages/zwave-js/src/lib/test/driver/sendDataFailThrow.test.ts b/packages/zwave-js/src/lib/test/driver/sendDataFailThrow.test.ts index 64f25107e7de..f43ae4ca1503 100644 --- a/packages/zwave-js/src/lib/test/driver/sendDataFailThrow.test.ts +++ b/packages/zwave-js/src/lib/test/driver/sendDataFailThrow.test.ts @@ -67,7 +67,7 @@ test.serial( const ACK = Buffer.from([MessageHeaders.ACK]); - const command = new BasicCCSet(driver, { + const command = new BasicCCSet({ nodeId: 2, targetValue: 99, }); @@ -132,7 +132,7 @@ test.serial( const ACK = Buffer.from([MessageHeaders.ACK]); - const command = new BasicCCSet(driver, { + const command = new BasicCCSet({ nodeId: 2, targetValue: 99, }); diff --git a/packages/zwave-js/src/lib/test/driver/sendDataMissingCallbackAbort.test.ts b/packages/zwave-js/src/lib/test/driver/sendDataMissingCallbackAbort.test.ts index 6dd90d3264c7..1ffdf8940737 100644 --- a/packages/zwave-js/src/lib/test/driver/sendDataMissingCallbackAbort.test.ts +++ b/packages/zwave-js/src/lib/test/driver/sendDataMissingCallbackAbort.test.ts @@ -54,7 +54,7 @@ integrationTest( customSetup: async (driver, mockController, mockNode) => { // This is almost a 1:1 copy of the default behavior, except that the callback never gets sent const handleBrokenSendData: MockControllerBehavior = { - async onHostMessage(host, controller, msg) { + async onHostMessage(controller, msg) { // If the controller is operating normally, defer to the default behavior if (!shouldTimeOut) return false; @@ -79,7 +79,7 @@ integrationTest( ); // Notify the host that the message was sent - const res = new SendDataResponse(host, { + const res = new SendDataResponse({ wasSent: true, }); await controller.sendMessageToHost(res); @@ -99,7 +99,7 @@ integrationTest( mockController.defineBehavior(handleBrokenSendData); const handleSoftReset: MockControllerBehavior = { - onHostMessage(host, controller, msg) { + onHostMessage(controller, msg) { // Soft reset should restore normal operation if (msg instanceof SoftResetRequest) { shouldTimeOut = false; @@ -158,7 +158,7 @@ integrationTest( customSetup: async (driver, mockController, mockNode) => { // This is almost a 1:1 copy of the default behavior, except that the callback never gets sent const handleBrokenSendData: MockControllerBehavior = { - async onHostMessage(host, controller, msg) { + async onHostMessage(controller, msg) { if (msg instanceof SendDataRequest) { // Check if this command is legal right now const state = controller.state.get( @@ -180,7 +180,7 @@ integrationTest( ); // Notify the host that the message was sent - const res = new SendDataResponse(host, { + const res = new SendDataResponse({ wasSent: true, }); await controller.sendMessageToHost(res); @@ -253,7 +253,7 @@ integrationTest( customSetup: async (driver, mockController, mockNode) => { // This is almost a 1:1 copy of the default behavior, except that the callback never gets sent const handleBrokenSendData: MockControllerBehavior = { - async onHostMessage(host, controller, msg) { + async onHostMessage(controller, msg) { // If the controller is operating normally, defer to the default behavior if (!shouldTimeOut) return false; @@ -278,7 +278,7 @@ integrationTest( ); // Notify the host that the message was sent - const res = new SendDataResponse(host, { + const res = new SendDataResponse({ wasSent: true, }); await controller.sendMessageToHost(res); @@ -298,7 +298,7 @@ integrationTest( mockController.defineBehavior(handleBrokenSendData); const handleSoftReset: MockControllerBehavior = { - onHostMessage(host, controller, msg) { + onHostMessage(controller, msg) { // Soft reset should restore normal operation if (msg instanceof SoftResetRequest) { shouldTimeOut = false; @@ -354,10 +354,10 @@ integrationTest( customSetup: async (driver, mockController, mockNode) => { // This is almost a 1:1 copy of the default behavior, except that the callback never gets sent const handleBrokenRequestNodeInfo: MockControllerBehavior = { - async onHostMessage(host, controller, msg) { + async onHostMessage(controller, msg) { if (msg instanceof RequestNodeInfoRequest) { // Notify the host that the message was sent - const res = new RequestNodeInfoResponse(host, { + const res = new RequestNodeInfoResponse({ wasSent: true, }); await controller.sendMessageToHost(res); @@ -409,7 +409,7 @@ integrationTest( customSetup: async (driver, mockController, mockNode) => { // This is almost a 1:1 copy of the default behavior, except that the callback never gets sent const handleBrokenSendData: MockControllerBehavior = { - async onHostMessage(host, controller, msg) { + async onHostMessage(controller, msg) { // If the controller is operating normally, defer to the default behavior if (!shouldTimeOut) return false; @@ -434,7 +434,7 @@ integrationTest( ); // Notify the host that the message was sent - const res = new SendDataResponse(host, { + const res = new SendDataResponse({ wasSent: true, }); await controller.sendMessageToHost(res); @@ -520,7 +520,7 @@ integrationTest( customSetup: async (driver, mockController, mockNode) => { // This is almost a 1:1 copy of the default behavior, except that the callback never gets sent const handleBrokenSendData: MockControllerBehavior = { - async onHostMessage(host, controller, msg) { + async onHostMessage(controller, msg) { // If the controller is operating normally, defer to the default behavior if (!shouldTimeOut) return false; @@ -545,7 +545,7 @@ integrationTest( ); // Notify the host that the message was sent - const res = new SendDataResponse(host, { + const res = new SendDataResponse({ wasSent: true, }); await controller.sendMessageToHost(res); @@ -628,7 +628,7 @@ integrationTestMulti( customSetup: async (driver, mockController, mockNodes) => { // This is almost a 1:1 copy of the default behavior, except that the callback never gets sent const handleBrokenSendData: MockControllerBehavior = { - async onHostMessage(host, controller, msg) { + async onHostMessage(controller, msg) { // If the controller is operating normally, defer to the default behavior if (!shouldTimeOut) return false; @@ -653,7 +653,7 @@ integrationTestMulti( ); // Notify the host that the message was sent - const res = new SendDataResponse(host, { + const res = new SendDataResponse({ wasSent: true, }); await controller.sendMessageToHost(res); @@ -740,7 +740,7 @@ integrationTest( customSetup: async (driver, mockController, mockNode) => { // This is almost a 1:1 copy of the default behavior, except that the callback never gets sent const handleBrokenSendData: MockControllerBehavior = { - async onHostMessage(host, controller, msg) { + async onHostMessage(controller, msg) { // If the controller is operating normally, defer to the default behavior if (!shouldTimeOut) return false; @@ -765,7 +765,7 @@ integrationTest( ); // Notify the host that the message was sent - const res = new SendDataResponse(host, { + const res = new SendDataResponse({ wasSent: true, }); await controller.sendMessageToHost(res); diff --git a/packages/zwave-js/src/lib/test/driver/sendDataMissingResponse.test.ts b/packages/zwave-js/src/lib/test/driver/sendDataMissingResponse.test.ts index e0ef16c14cb0..4d65daafb1dc 100644 --- a/packages/zwave-js/src/lib/test/driver/sendDataMissingResponse.test.ts +++ b/packages/zwave-js/src/lib/test/driver/sendDataMissingResponse.test.ts @@ -37,7 +37,7 @@ integrationTest( customSetup: async (driver, mockController, mockNode) => { // This is almost a 1:1 copy of the default behavior, except that the response and callback never get sent const handleBrokenSendData: MockControllerBehavior = { - async onHostMessage(host, controller, msg) { + async onHostMessage(controller, msg) { // If the controller is operating normally, defer to the default behavior if (!shouldTimeOut) return false; @@ -60,7 +60,7 @@ integrationTest( return true; } else if (msg instanceof SendDataAbort) { // Finish the transmission by sending the callback - const cb = new SendDataRequestTransmitReport(host, { + const cb = new SendDataRequestTransmitReport({ callbackId: lastCallbackId, transmitStatus: TransmitStatus.NoAck, }); @@ -131,7 +131,7 @@ integrationTest( customSetup: async (driver, mockController, mockNode) => { // This is almost a 1:1 copy of the default behavior, except that the response and callback never get sent const handleBrokenSendData: MockControllerBehavior = { - async onHostMessage(host, controller, msg) { + async onHostMessage(controller, msg) { // If the controller is operating normally, defer to the default behavior if (!shouldTimeOut) return false; @@ -213,7 +213,7 @@ integrationTest( // customSetup: async (driver, mockController, mockNode) => { // // This is almost a 1:1 copy of the default behavior, except that the callback never gets sent // const handleBrokenSendData: MockControllerBehavior = { -// async onHostMessage(host, controller, msg) { +// async onHostMessage(controller, msg) { // if (msg instanceof SendDataRequest) { // // Check if this command is legal right now // const state = controller.state.get( @@ -235,7 +235,7 @@ integrationTest( // ); // // Notify the host that the message was sent -// const res = new SendDataResponse(host, { +// const res = new SendDataResponse({ // wasSent: true, // }); // await controller.sendMessageToHost(res); @@ -308,7 +308,7 @@ integrationTest( // customSetup: async (driver, mockController, mockNode) => { // // This is almost a 1:1 copy of the default behavior, except that the callback never gets sent // const handleBrokenSendData: MockControllerBehavior = { -// async onHostMessage(host, controller, msg) { +// async onHostMessage(controller, msg) { // // If the controller is operating normally, defer to the default behavior // if (!shouldTimeOut) return false; @@ -333,7 +333,7 @@ integrationTest( // ); // // Notify the host that the message was sent -// const res = new SendDataResponse(host, { +// const res = new SendDataResponse({ // wasSent: true, // }); // await controller.sendMessageToHost(res); @@ -353,7 +353,7 @@ integrationTest( // mockController.defineBehavior(handleBrokenSendData); // const handleSoftReset: MockControllerBehavior = { -// onHostMessage(host, controller, msg) { +// onHostMessage(controller, msg) { // // Soft reset should restore normal operation // if (msg instanceof SoftResetRequest) { // shouldTimeOut = false; @@ -409,10 +409,10 @@ integrationTest( // customSetup: async (driver, mockController, mockNode) => { // // This is almost a 1:1 copy of the default behavior, except that the callback never gets sent // const handleBrokenRequestNodeInfo: MockControllerBehavior = { -// async onHostMessage(host, controller, msg) { +// async onHostMessage(controller, msg) { // if (msg instanceof RequestNodeInfoRequest) { // // Notify the host that the message was sent -// const res = new RequestNodeInfoResponse(host, { +// const res = new RequestNodeInfoResponse({ // wasSent: true, // }); // await controller.sendMessageToHost(res); diff --git a/packages/zwave-js/src/lib/test/driver/setValueFailedSupervisionGet.test.ts b/packages/zwave-js/src/lib/test/driver/setValueFailedSupervisionGet.test.ts index c42947f2cb4d..07d31ad25340 100644 --- a/packages/zwave-js/src/lib/test/driver/setValueFailedSupervisionGet.test.ts +++ b/packages/zwave-js/src/lib/test/driver/setValueFailedSupervisionGet.test.ts @@ -32,7 +32,7 @@ integrationTest( const respondToSupervisionGet: MockNodeBehavior = { handleCC(controller, self, receivedCC) { if (receivedCC instanceof SupervisionCCGet) { - const cc = new SupervisionCCReport(self.host, { + const cc = new SupervisionCCReport({ nodeId: controller.ownNodeId, sessionId: receivedCC.sessionId, moreUpdatesFollow: false, @@ -47,7 +47,7 @@ integrationTest( const respondToBinarySwitchGet: MockNodeBehavior = { handleCC(controller, self, receivedCC) { if (receivedCC instanceof BinarySwitchCCGet) { - const cc = new BinarySwitchCCReport(self.host, { + const cc = new BinarySwitchCCReport({ nodeId: controller.ownNodeId, currentValue: false, }); diff --git a/packages/zwave-js/src/lib/test/driver/setValueNoSupervision.test.ts b/packages/zwave-js/src/lib/test/driver/setValueNoSupervision.test.ts index a61159b46ade..e956097502aa 100644 --- a/packages/zwave-js/src/lib/test/driver/setValueNoSupervision.test.ts +++ b/packages/zwave-js/src/lib/test/driver/setValueNoSupervision.test.ts @@ -29,7 +29,7 @@ integrationTest("setValue without supervision: expect validation GET", { const respondToBinarySwitchGet: MockNodeBehavior = { handleCC(controller, self, receivedCC) { if (receivedCC instanceof BinarySwitchCCGet) { - const cc = new BinarySwitchCCReport(self.host, { + const cc = new BinarySwitchCCReport({ nodeId: controller.ownNodeId, currentValue: false, }); diff --git a/packages/zwave-js/src/lib/test/driver/setValueSucceedAfterFailure.test.ts b/packages/zwave-js/src/lib/test/driver/setValueSucceedAfterFailure.test.ts index 5103ae634f6d..216ec6dadf6f 100644 --- a/packages/zwave-js/src/lib/test/driver/setValueSucceedAfterFailure.test.ts +++ b/packages/zwave-js/src/lib/test/driver/setValueSucceedAfterFailure.test.ts @@ -46,11 +46,11 @@ integrationTest( return { action: "stop" }; } - let cc: CommandClass = new BasicCCReport(self.host, { + let cc: CommandClass = new BasicCCReport({ nodeId: controller.ownNodeId, currentValue: Math.round(Math.random() * 99), }); - cc = new MultiChannelCCCommandEncapsulation(self.host, { + cc = new MultiChannelCCCommandEncapsulation({ nodeId: controller.ownNodeId, destination: receivedCC.endpointIndex, endpoint: receivedCC.destination as number, diff --git a/packages/zwave-js/src/lib/test/driver/setValueSuccessfulSupervisionNoGet.test.ts b/packages/zwave-js/src/lib/test/driver/setValueSuccessfulSupervisionNoGet.test.ts index b3abc96466ac..b33e29ec0735 100644 --- a/packages/zwave-js/src/lib/test/driver/setValueSuccessfulSupervisionNoGet.test.ts +++ b/packages/zwave-js/src/lib/test/driver/setValueSuccessfulSupervisionNoGet.test.ts @@ -32,7 +32,7 @@ integrationTest( const respondToSupervisionGet: MockNodeBehavior = { handleCC(controller, self, receivedCC) { if (receivedCC instanceof SupervisionCCGet) { - const cc = new SupervisionCCReport(self.host, { + const cc = new SupervisionCCReport({ nodeId: controller.ownNodeId, sessionId: receivedCC.sessionId, moreUpdatesFollow: false, diff --git a/packages/zwave-js/src/lib/test/driver/setValueSupervision255Get.test.ts b/packages/zwave-js/src/lib/test/driver/setValueSupervision255Get.test.ts index 6c078727c23e..ff0c5d8d4e75 100644 --- a/packages/zwave-js/src/lib/test/driver/setValueSupervision255Get.test.ts +++ b/packages/zwave-js/src/lib/test/driver/setValueSupervision255Get.test.ts @@ -32,7 +32,7 @@ integrationTest( const respondToSupervisionGet: MockNodeBehavior = { handleCC(controller, self, receivedCC) { if (receivedCC instanceof SupervisionCCGet) { - const cc = new SupervisionCCReport(self.host, { + const cc = new SupervisionCCReport({ nodeId: controller.ownNodeId, sessionId: receivedCC.sessionId, moreUpdatesFollow: false, @@ -54,7 +54,7 @@ integrationTest( && !!receivedCC.encapsulated.duration ?.toMilliseconds() ) { - const cc1 = new SupervisionCCReport(self.host, { + const cc1 = new SupervisionCCReport({ nodeId: controller.ownNodeId, sessionId: receivedCC.sessionId, moreUpdatesFollow: true, @@ -62,7 +62,7 @@ integrationTest( duration: receivedCC.encapsulated.duration, }); - const cc2 = new SupervisionCCReport(self.host, { + const cc2 = new SupervisionCCReport({ nodeId: controller.ownNodeId, sessionId: receivedCC.sessionId, moreUpdatesFollow: false, @@ -118,7 +118,7 @@ integrationTest( const respondToMultilevelSwitchGet: MockNodeBehavior = { handleCC(controller, self, receivedCC) { if (receivedCC instanceof MultilevelSwitchCCGet) { - const cc = new MultilevelSwitchCCReport(self.host, { + const cc = new MultilevelSwitchCCReport({ nodeId: controller.ownNodeId, targetValue: 88, currentValue: 88, diff --git a/packages/zwave-js/src/lib/test/driver/setValueSupervisionSuccessMoreUpdates.test.ts b/packages/zwave-js/src/lib/test/driver/setValueSupervisionSuccessMoreUpdates.test.ts index 563d7da2cc0f..37646ee63fec 100644 --- a/packages/zwave-js/src/lib/test/driver/setValueSupervisionSuccessMoreUpdates.test.ts +++ b/packages/zwave-js/src/lib/test/driver/setValueSupervisionSuccessMoreUpdates.test.ts @@ -31,7 +31,7 @@ integrationTest( const respondToSupervisionGet: MockNodeBehavior = { async handleCC(controller, self, receivedCC) { if (receivedCC instanceof SupervisionCCGet) { - const cc = new SupervisionCCReport(self.host, { + const cc = new SupervisionCCReport({ nodeId: controller.ownNodeId, sessionId: receivedCC.sessionId, moreUpdatesFollow: true, // <-- this is the important part diff --git a/packages/zwave-js/src/lib/test/driver/setValueSupervisionWorking.test.ts b/packages/zwave-js/src/lib/test/driver/setValueSupervisionWorking.test.ts index 1d433b7284de..a5b315070b79 100644 --- a/packages/zwave-js/src/lib/test/driver/setValueSupervisionWorking.test.ts +++ b/packages/zwave-js/src/lib/test/driver/setValueSupervisionWorking.test.ts @@ -43,7 +43,7 @@ integrationTest( const respondToSupervisionGet: MockNodeBehavior = { async handleCC(controller, self, receivedCC) { if (receivedCC instanceof SupervisionCCGet) { - let cc = new SupervisionCCReport(self.host, { + let cc = new SupervisionCCReport({ nodeId: controller.ownNodeId, sessionId: receivedCC.sessionId, moreUpdatesFollow: true, @@ -58,7 +58,7 @@ integrationTest( await wait(2000); - cc = new SupervisionCCReport(self.host, { + cc = new SupervisionCCReport({ nodeId: controller.ownNodeId, sessionId: receivedCC.sessionId, moreUpdatesFollow: false, diff --git a/packages/zwave-js/src/lib/test/driver/targetValueVersionUnknown.test.ts b/packages/zwave-js/src/lib/test/driver/targetValueVersionUnknown.test.ts index 82b7d41eacc6..eee929d1fc53 100644 --- a/packages/zwave-js/src/lib/test/driver/targetValueVersionUnknown.test.ts +++ b/packages/zwave-js/src/lib/test/driver/targetValueVersionUnknown.test.ts @@ -37,7 +37,7 @@ integrationTest( const respondToBinarySwitchGet: MockNodeBehavior = { handleCC(controller, self, receivedCC) { if (receivedCC instanceof BinarySwitchCCGet) { - const cc = new BinarySwitchCCReport(self.host, { + const cc = new BinarySwitchCCReport({ nodeId: controller.ownNodeId, currentValue: true, }); @@ -73,7 +73,7 @@ integrationTest( const respondToBinarySwitchGet: MockNodeBehavior = { handleCC(controller, self, receivedCC) { if (receivedCC instanceof BinarySwitchCCGet) { - const cc = new BinarySwitchCCReport(self.host, { + const cc = new BinarySwitchCCReport({ nodeId: controller.ownNodeId, currentValue: true, }); diff --git a/packages/zwave-js/src/lib/test/driver/unknownValues.test.ts b/packages/zwave-js/src/lib/test/driver/unknownValues.test.ts index 12847b6cedb2..a8d0b7d34dae 100644 --- a/packages/zwave-js/src/lib/test/driver/unknownValues.test.ts +++ b/packages/zwave-js/src/lib/test/driver/unknownValues.test.ts @@ -44,7 +44,7 @@ integrationTest(`Basic Reports with the UNKNOWN state are correctly handled`, { const respondToBasicGet: MockNodeBehavior = { handleCC(controller, self, receivedCC) { if (receivedCC instanceof BasicCCGet) { - const cc = new BasicCCReport(self.host, { + const cc = new BasicCCReport({ nodeId: controller.ownNodeId, currentValue: 0, targetValue: 0, @@ -66,7 +66,7 @@ integrationTest(`Basic Reports with the UNKNOWN state are correctly handled`, { t.is(node.getValue(currentValueId), 0); // Send an update with UNKNOWN state - const cc = new BasicCCReport(mockNode.host, { + const cc = new BasicCCReport({ nodeId: mockController.ownNodeId, currentValue: 254, targetValue: 254, @@ -113,7 +113,7 @@ integrationTest( t.is(node.getValue(currentValueId), UNKNOWN_STATE); // Send an initial state - let cc = new MultilevelSwitchCCReport(mockNode.host, { + let cc = new MultilevelSwitchCCReport({ nodeId: mockController.ownNodeId, currentValue: 0, targetValue: 0, @@ -131,7 +131,7 @@ integrationTest( t.is(node.getValue(currentValueId), 0); // Send an update with UNKNOWN state - cc = new MultilevelSwitchCCReport(mockNode.host, { + cc = new MultilevelSwitchCCReport({ nodeId: mockController.ownNodeId, currentValue: 254, targetValue: 254, @@ -185,7 +185,7 @@ integrationTest( t.is(node.getValue(currentValueId), NOT_KNOWN); // Send an initial state - let cc = new BinarySwitchCCReport(mockNode.host, { + let cc = new BinarySwitchCCReport({ nodeId: mockController.ownNodeId, currentValue: false, targetValue: false, @@ -204,7 +204,7 @@ integrationTest( t.is(node.getValue(currentValueId), false); // Send an update with UNKNOWN state - cc = new BinarySwitchCCReport(mockNode.host, { + cc = new BinarySwitchCCReport({ nodeId: mockController.ownNodeId, currentValue: UNKNOWN_STATE, targetValue: UNKNOWN_STATE, diff --git a/packages/zwave-js/src/lib/test/driver/unresponsiveStick.test.ts b/packages/zwave-js/src/lib/test/driver/unresponsiveStick.test.ts index 6bee1771cc01..6cb55c48f74d 100644 --- a/packages/zwave-js/src/lib/test/driver/unresponsiveStick.test.ts +++ b/packages/zwave-js/src/lib/test/driver/unresponsiveStick.test.ts @@ -19,7 +19,7 @@ integrationTest( async customSetup(driver, mockController, mockNode) { const doNotRespond: MockControllerBehavior = { - onHostMessage(host, controller, msg) { + onHostMessage(controller, msg) { if (!shouldRespond) { // Soft reset should restore normal operation if (msg instanceof SoftResetRequest) { @@ -72,7 +72,7 @@ integrationTest( async customSetup(driver, mockController, mockNode) { const doNotRespond: MockControllerBehavior = { - onHostMessage(host, controller, msg) { + onHostMessage(controller, msg) { if (!shouldRespond) return true; return false; @@ -144,7 +144,7 @@ integrationTest( async customSetup(driver, mockController, mockNode) { const doNotRespond: MockControllerBehavior = { - onHostMessage(host, controller, msg) { + onHostMessage(controller, msg) { if (!shouldRespond) { return true; } diff --git a/packages/zwave-js/src/lib/test/node/legacyRefreshActuatorSensorCCs.test.ts b/packages/zwave-js/src/lib/test/node/legacyRefreshActuatorSensorCCs.test.ts index 967805cd7a4a..8e7a1dba50e4 100644 --- a/packages/zwave-js/src/lib/test/node/legacyRefreshActuatorSensorCCs.test.ts +++ b/packages/zwave-js/src/lib/test/node/legacyRefreshActuatorSensorCCs.test.ts @@ -51,7 +51,7 @@ integrationTest( const respondToMultilevelSwitchGet: MockNodeBehavior = { handleCC(controller, self, receivedCC) { if (receivedCC instanceof MultilevelSwitchCCGet) { - const cc = new MultilevelSwitchCCReport(self.host, { + const cc = new MultilevelSwitchCCReport({ nodeId: controller.ownNodeId, targetValue: 88, currentValue: 88, diff --git a/packages/zwave-js/src/lib/zniffer/CCParsingContext.ts b/packages/zwave-js/src/lib/zniffer/CCParsingContext.ts deleted file mode 100644 index d68d894f5f16..000000000000 --- a/packages/zwave-js/src/lib/zniffer/CCParsingContext.ts +++ /dev/null @@ -1,96 +0,0 @@ -/* eslint-disable @typescript-eslint/no-unused-vars */ -import { getImplementedVersion } from "@zwave-js/cc"; -import { DeviceConfig } from "@zwave-js/config"; -import { - type CommandClasses, - type MaybeNotKnown, - SecurityClass, - type SecurityManager, - type SecurityManager2, -} from "@zwave-js/core"; -import { type ZWaveHost } from "@zwave-js/host"; - -export class ZnifferCCParsingContext implements ZWaveHost { - public constructor( - public readonly ownNodeId: number, - public readonly homeId: number, - public readonly securityManager: SecurityManager | undefined, - public readonly securityManager2: SecurityManager2 | undefined, - public readonly securityManagerLR: SecurityManager2 | undefined, - ) {} - - getSafeCCVersion( - cc: CommandClasses, - nodeId: number, - endpointIndex?: number, - ): number { - // We don't know any versions of the node. Try parsing with the highest version we support - return getImplementedVersion(cc); - } - - getSupportedCCVersion( - cc: CommandClasses, - nodeId: number, - endpointIndex?: number, - ): number { - // We don't know any versions of the node. Try parsing with the highest version we support - return getImplementedVersion(cc); - } - - isCCSecure( - cc: CommandClasses, - nodeId: number, - endpointIndex?: number, - ): boolean { - // Don't care when parsing - return false; - } - - getHighestSecurityClass(nodeId: number): MaybeNotKnown { - return SecurityClass.S2_AccessControl; - } - - hasSecurityClass( - nodeId: number, - securityClass: SecurityClass, - ): MaybeNotKnown { - // We don't actually know. Attempt parsing with all security classes - return true; - } - - setSecurityClass( - nodeId: number, - securityClass: SecurityClass, - granted: boolean, - ): void { - // Do nothing - } - - getDeviceConfig(nodeId: number): DeviceConfig | undefined { - // Disable strict validation while parsing certain CCs - // Most of this stuff isn't actually needed, only the compat flags... - return new DeviceConfig( - "unknown.json", - false, - "UNKNOWN_MANUFACTURER", - 0x0000, - "UNKNOWN_PRODUCT", - "UNKNOWN_DESCRIPTION", - [], - { - min: "0.0", - max: "255.255", - }, - true, - undefined, - undefined, - undefined, - undefined, - // ...down here: - { - disableStrictEntryControlDataValidation: true, - disableStrictMeasurementValidation: true, - }, - ); - } -} diff --git a/packages/zwave-js/src/lib/zniffer/Zniffer.ts b/packages/zwave-js/src/lib/zniffer/Zniffer.ts index 5972a5f080ec..2dda6357f7fe 100644 --- a/packages/zwave-js/src/lib/zniffer/Zniffer.ts +++ b/packages/zwave-js/src/lib/zniffer/Zniffer.ts @@ -5,6 +5,7 @@ import { Security2CCNonceReport, SecurityCCNonceReport, } from "@zwave-js/cc"; +import { DeviceConfig } from "@zwave-js/config"; import { CommandClasses, type LogConfig, @@ -67,7 +68,6 @@ import fs from "node:fs/promises"; import { sdkVersionGte } from "../controller/utils"; import { type ZWaveOptions } from "../driver/ZWaveOptions"; import { ZnifferLogger } from "../log/Zniffer"; -import { ZnifferCCParsingContext } from "./CCParsingContext"; import { type CorruptedFrame, type Frame, @@ -227,6 +227,34 @@ export class Zniffer extends TypedEventEmitter { ): void { // Do nothing }, + + getDeviceConfig(_nodeId: number): DeviceConfig | undefined { + // Disable strict validation while parsing certain CCs + // Most of this stuff isn't actually needed, only the compat flags... + return new DeviceConfig( + "unknown.json", + false, + "UNKNOWN_MANUFACTURER", + 0x0000, + "UNKNOWN_PRODUCT", + "UNKNOWN_DESCRIPTION", + [], + { + min: "0.0", + max: "255.255", + }, + true, + undefined, + undefined, + undefined, + undefined, + // ...down here: + { + disableStrictEntryControlDataValidation: true, + disableStrictMeasurementValidation: true, + }, + ); + }, }; } @@ -536,16 +564,8 @@ supported frequencies: ${ } // TODO: Support parsing multicast S2 frames - - const ctx = new ZnifferCCParsingContext( - destNodeId, - mpdu.homeId, - destSecurityManager, - destSecurityManager2, - destSecurityManagerLR, - ); try { - cc = CommandClass.from(ctx, { + cc = CommandClass.from({ data: mpdu.payload, fromEncapsulation: false, nodeId: mpdu.sourceNodeId, @@ -553,6 +573,9 @@ supported frequencies: ${ homeId: mpdu.homeId, ownNodeId: destNodeId, sourceNodeId: mpdu.sourceNodeId, + securityManager: destSecurityManager, + securityManager2: destSecurityManager2, + securityManagerLR: destSecurityManagerLR, ...this.parsingContext, }, });