Skip to content

Commit

Permalink
refactor: replace some instances of IZWaveEndpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
AlCalzone committed Oct 9, 2024
1 parent 7510a38 commit be65623
Show file tree
Hide file tree
Showing 18 changed files with 82 additions and 69 deletions.
4 changes: 2 additions & 2 deletions packages/cc/src/cc/AlarmSensorCC.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {
CommandClasses,
type IZWaveEndpoint,
type EndpointId,
type MaybeNotKnown,
type MessageOrCCLogEntry,
MessagePriority,
Expand Down Expand Up @@ -289,7 +289,7 @@ duration: ${currentValue.duration}`;
*/
public static getSupportedSensorTypesCached(
applHost: ZWaveApplicationHost,
endpoint: IZWaveEndpoint,
endpoint: EndpointId,
): MaybeNotKnown<AlarmSensorType[]> {
return applHost
.getValueDB(endpoint.nodeId)
Expand Down
8 changes: 4 additions & 4 deletions packages/cc/src/cc/AssociationCC.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type {
IZWaveEndpoint,
EndpointId,
MaybeNotKnown,
MessageRecord,
SupervisionResult,
Expand Down Expand Up @@ -307,7 +307,7 @@ export class AssociationCC extends CommandClass {
*/
public static getGroupCountCached(
applHost: ZWaveApplicationHost,
endpoint: IZWaveEndpoint,
endpoint: EndpointId,
): number {
return (
applHost
Expand All @@ -324,7 +324,7 @@ export class AssociationCC extends CommandClass {
*/
public static getMaxNodesCached(
applHost: ZWaveApplicationHost,
endpoint: IZWaveEndpoint,
endpoint: EndpointId,
groupId: number,
): number {
return (
Expand All @@ -351,7 +351,7 @@ export class AssociationCC extends CommandClass {
*/
public static getAllDestinationsCached(
applHost: ZWaveApplicationHost,
endpoint: IZWaveEndpoint,
endpoint: EndpointId,
): ReadonlyMap<number, readonly AssociationAddress[]> {
const ret = new Map<number, AssociationAddress[]>();
const groupCount = this.getGroupCountCached(applHost, endpoint);
Expand Down
6 changes: 4 additions & 2 deletions packages/cc/src/cc/AssociationGroupInfoCC.ts
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ export class AssociationGroupInfoCC extends CommandClass {
/** Returns the name of an association group */
public static getGroupNameCached(
applHost: ZWaveApplicationHost,
endpoint: IZWaveEndpoint,
endpoint: EndpointId,
groupId: number,
): MaybeNotKnown<string> {
return applHost
Expand Down Expand Up @@ -288,7 +288,7 @@ export class AssociationGroupInfoCC extends CommandClass {
/** Returns the dictionary of all commands issued by the given association group */
public static getIssuedCommandsCached(
applHost: ZWaveApplicationHost,
endpoint: IZWaveEndpoint,
endpoint: EndpointId,
groupId: number,
): MaybeNotKnown<ReadonlyMap<CommandClasses, readonly number[]>> {
return applHost
Expand All @@ -302,6 +302,7 @@ export class AssociationGroupInfoCC extends CommandClass {

public static findGroupsForIssuedCommand(
applHost: ZWaveApplicationHost,
// FIXME: GH#7261 ID and endpoint capabilities would be enough
endpoint: IZWaveEndpoint,
ccId: CommandClasses,
command: number,
Expand Down Expand Up @@ -332,6 +333,7 @@ export class AssociationGroupInfoCC extends CommandClass {

private static getAssociationGroupCountCached(
applHost: ZWaveApplicationHost,
// FIXME: GH#7261 ID and endpoint capabilities would be enough
endpoint: IZWaveEndpoint,
): number {
// The association group count is either determined by the
Expand Down
4 changes: 2 additions & 2 deletions packages/cc/src/cc/BinarySensorCC.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {
CommandClasses,
type IZWaveEndpoint,
type EndpointId,
type MaybeNotKnown,
type MessageOrCCLogEntry,
MessagePriority,
Expand Down Expand Up @@ -308,7 +308,7 @@ export class BinarySensorCC extends CommandClass {
*/
public static getSupportedSensorTypesCached(
applHost: ZWaveApplicationHost,
endpoint: IZWaveEndpoint,
endpoint: EndpointId,
): MaybeNotKnown<BinarySensorType[]> {
return applHost
.getValueDB(endpoint.nodeId)
Expand Down
3 changes: 3 additions & 0 deletions packages/cc/src/cc/ConfigurationCC.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ type NormalizedConfigurationCCAPISetOptions =

function createConfigurationCCInstance(
applHost: ZWaveApplicationHost,
// FIXME: GH#7261 ID and index should be enough
endpoint: IZWaveEndpoint | IVirtualEndpoint,
): ConfigurationCC {
return CommandClass.createInstanceUnchecked(
Expand All @@ -156,6 +157,7 @@ function createConfigurationCCInstance(

function normalizeConfigurationCCAPISetOptions(
applHost: ZWaveApplicationHost,
// FIXME: GH#7261 ID and index should be enough
endpoint: IZWaveEndpoint | IVirtualEndpoint,
options: ConfigurationCCAPISetOptions,
): NormalizedConfigurationCCAPISetOptions {
Expand Down Expand Up @@ -213,6 +215,7 @@ function normalizeConfigurationCCAPISetOptions(

function bulkMergePartialParamValues(
applHost: ZWaveApplicationHost,
// FIXME: GH#7261 ID and index should be enough
endpoint: IZWaveEndpoint | IVirtualEndpoint,
options: NormalizedConfigurationCCAPISetOptions[],
): (NormalizedConfigurationCCAPISetOptions & { bitMask?: undefined })[] {
Expand Down
16 changes: 8 additions & 8 deletions packages/cc/src/cc/DoorLockCC.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {
CommandClasses,
Duration,
type IZWaveEndpoint,
type EndpointId,
type MaybeNotKnown,
type MessageOrCCLogEntry,
MessagePriority,
Expand Down Expand Up @@ -254,7 +254,7 @@ export const DoorLockCCValues = Object.freeze({

function shouldAutoCreateLatchStatusValue(
applHost: ZWaveApplicationHost,
endpoint: IZWaveEndpoint,
endpoint: EndpointId,
): boolean {
const valueDB = applHost.tryGetValueDB(endpoint.nodeId);
if (!valueDB) return false;
Expand All @@ -265,7 +265,7 @@ function shouldAutoCreateLatchStatusValue(

function shouldAutoCreateBoltStatusValue(
applHost: ZWaveApplicationHost,
endpoint: IZWaveEndpoint,
endpoint: EndpointId,
): boolean {
const valueDB = applHost.tryGetValueDB(endpoint.nodeId);
if (!valueDB) return false;
Expand All @@ -276,7 +276,7 @@ function shouldAutoCreateBoltStatusValue(

function shouldAutoCreateDoorStatusValue(
applHost: ZWaveApplicationHost,
endpoint: IZWaveEndpoint,
endpoint: EndpointId,
): boolean {
const valueDB = applHost.tryGetValueDB(endpoint.nodeId);
if (!valueDB) return false;
Expand All @@ -287,7 +287,7 @@ function shouldAutoCreateDoorStatusValue(

function shouldAutoCreateTwistAssistConfigValue(
applHost: ZWaveApplicationHost,
endpoint: IZWaveEndpoint,
endpoint: EndpointId,
): boolean {
const valueDB = applHost.tryGetValueDB(endpoint.nodeId);
if (!valueDB) return false;
Expand All @@ -298,7 +298,7 @@ function shouldAutoCreateTwistAssistConfigValue(

function shouldAutoCreateBlockToBlockConfigValue(
applHost: ZWaveApplicationHost,
endpoint: IZWaveEndpoint,
endpoint: EndpointId,
): boolean {
const valueDB = applHost.tryGetValueDB(endpoint.nodeId);
if (!valueDB) return false;
Expand All @@ -309,7 +309,7 @@ function shouldAutoCreateBlockToBlockConfigValue(

function shouldAutoCreateAutoRelockConfigValue(
applHost: ZWaveApplicationHost,
endpoint: IZWaveEndpoint,
endpoint: EndpointId,
): boolean {
const valueDB = applHost.tryGetValueDB(endpoint.nodeId);
if (!valueDB) return false;
Expand All @@ -320,7 +320,7 @@ function shouldAutoCreateAutoRelockConfigValue(

function shouldAutoCreateHoldAndReleaseConfigValue(
applHost: ZWaveApplicationHost,
endpoint: IZWaveEndpoint,
endpoint: EndpointId,
): boolean {
const valueDB = applHost.tryGetValueDB(endpoint.nodeId);
if (!valueDB) return false;
Expand Down
4 changes: 2 additions & 2 deletions packages/cc/src/cc/IndicatorCC.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { ConfigManager } from "@zwave-js/config";
import {
CommandClasses,
type IZWaveEndpoint,
type EndpointId,
Indicator,
type MaybeNotKnown,
type MessageOrCCLogEntry,
Expand Down Expand Up @@ -850,7 +850,7 @@ export class IndicatorCC extends CommandClass {

public static getSupportedPropertyIDsCached(
applHost: ZWaveApplicationHost,
endpoint: IZWaveEndpoint,
endpoint: EndpointId,
indicatorId: number,
): MaybeNotKnown<number[]> {
return applHost
Expand Down
8 changes: 4 additions & 4 deletions packages/cc/src/cc/IrrigationCC.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {
CommandClasses,
type IZWaveEndpoint,
type EndpointId,
type MaybeNotKnown,
type MessageOrCCLogEntry,
MessagePriority,
Expand Down Expand Up @@ -1119,7 +1119,7 @@ export class IrrigationCC extends CommandClass {
*/
public static getMaxValveTableSizeCached(
applHost: ZWaveApplicationHost,
endpoint: IZWaveEndpoint,
endpoint: EndpointId,
): MaybeNotKnown<number> {
return applHost
.getValueDB(endpoint.nodeId)
Expand All @@ -1134,7 +1134,7 @@ export class IrrigationCC extends CommandClass {
*/
public static getNumValvesCached(
applHost: ZWaveApplicationHost,
endpoint: IZWaveEndpoint,
endpoint: EndpointId,
): MaybeNotKnown<number> {
return applHost
.getValueDB(endpoint.nodeId)
Expand All @@ -1147,7 +1147,7 @@ export class IrrigationCC extends CommandClass {
*/
public static supportsMasterValveCached(
applHost: ZWaveApplicationHost,
endpoint: IZWaveEndpoint,
endpoint: EndpointId,
): boolean {
return !!applHost
.getValueDB(endpoint.nodeId)
Expand Down
10 changes: 5 additions & 5 deletions packages/cc/src/cc/MeterCC.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import {
type FloatParameters,
type IZWaveEndpoint,
type MaybeUnknown,
encodeBitMask,
encodeFloatWithScale,
Expand All @@ -13,6 +12,7 @@ import {
} from "@zwave-js/core";
import {
CommandClasses,
type EndpointId,
type MaybeNotKnown,
type MessageOrCCLogEntry,
MessagePriority,
Expand Down Expand Up @@ -782,7 +782,7 @@ supports reset: ${suppResp.supportsReset}`;
*/
public static getMeterTypeCached(
applHost: ZWaveApplicationHost,
endpoint: IZWaveEndpoint,
endpoint: EndpointId,
): MaybeNotKnown<number> {
return applHost
.getValueDB(endpoint.nodeId)
Expand All @@ -795,7 +795,7 @@ supports reset: ${suppResp.supportsReset}`;
*/
public static getSupportedScalesCached(
applHost: ZWaveApplicationHost,
endpoint: IZWaveEndpoint,
endpoint: EndpointId,
): MaybeNotKnown<number[]> {
return applHost
.getValueDB(endpoint.nodeId)
Expand All @@ -808,7 +808,7 @@ supports reset: ${suppResp.supportsReset}`;
*/
public static supportsResetCached(
applHost: ZWaveApplicationHost,
endpoint: IZWaveEndpoint,
endpoint: EndpointId,
): MaybeNotKnown<boolean> {
return applHost
.getValueDB(endpoint.nodeId)
Expand All @@ -821,7 +821,7 @@ supports reset: ${suppResp.supportsReset}`;
*/
public static getSupportedRateTypesCached(
applHost: ZWaveApplicationHost,
endpoint: IZWaveEndpoint,
endpoint: EndpointId,
): MaybeNotKnown<RateType[]> {
return applHost
.getValueDB(endpoint.nodeId)
Expand Down
8 changes: 4 additions & 4 deletions packages/cc/src/cc/MultiChannelAssociationCC.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type {
IZWaveEndpoint,
EndpointId,
MessageRecord,
SupervisionResult,
} from "@zwave-js/core/safe";
Expand Down Expand Up @@ -371,7 +371,7 @@ export class MultiChannelAssociationCC extends CommandClass {
*/
public static getGroupCountCached(
applHost: ZWaveApplicationHost,
endpoint: IZWaveEndpoint,
endpoint: EndpointId,
): number {
return (
applHost
Expand All @@ -390,7 +390,7 @@ export class MultiChannelAssociationCC extends CommandClass {
*/
public static getMaxNodesCached(
applHost: ZWaveApplicationHost,
endpoint: IZWaveEndpoint,
endpoint: EndpointId,
groupId: number,
): number {
return (
Expand All @@ -410,7 +410,7 @@ export class MultiChannelAssociationCC extends CommandClass {
*/
public static getAllDestinationsCached(
applHost: ZWaveApplicationHost,
endpoint: IZWaveEndpoint,
endpoint: EndpointId,
): ReadonlyMap<number, readonly AssociationAddress[]> {
const ret = new Map<number, AssociationAddress[]>();
const groupCount = this.getGroupCountCached(applHost, endpoint);
Expand Down
6 changes: 3 additions & 3 deletions packages/cc/src/cc/MultilevelSensorCC.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
timespan,
} from "@zwave-js/core";
import type {
IZWaveEndpoint,
EndpointId,
MessageOrCCLogEntry,
MessageRecord,
Scale,
Expand Down Expand Up @@ -568,7 +568,7 @@ value: ${mlsResponse.value}${
*/
public static getSupportedSensorTypesCached(
applHost: ZWaveApplicationHost,
endpoint: IZWaveEndpoint,
endpoint: EndpointId,
): MaybeNotKnown<number[]> {
return applHost
.getValueDB(endpoint.nodeId)
Expand All @@ -585,7 +585,7 @@ value: ${mlsResponse.value}${
*/
public static getSupportedScalesCached(
applHost: ZWaveApplicationHost,
endpoint: IZWaveEndpoint,
endpoint: EndpointId,
sensorType: number,
): MaybeNotKnown<number[]> {
return applHost
Expand Down
4 changes: 2 additions & 2 deletions packages/cc/src/cc/NotificationCC.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
import {
CommandClasses,
Duration,
type IZWaveEndpoint,
type EndpointId,
type MaybeNotKnown,
type MessageOrCCLogEntry,
MessagePriority,
Expand Down Expand Up @@ -213,7 +213,7 @@ export const NotificationCCValues = Object.freeze({

function shouldAutoCreateSimpleDoorSensorValue(
applHost: ZWaveApplicationHost,
endpoint: IZWaveEndpoint,
endpoint: EndpointId,
): boolean {
const valueDB = applHost.tryGetValueDB(endpoint.nodeId);
if (!valueDB) return false;
Expand Down
4 changes: 2 additions & 2 deletions packages/cc/src/cc/SceneControllerConfigurationCC.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {
CommandClasses,
Duration,
type IZWaveEndpoint,
type EndpointId,
type MaybeNotKnown,
type MessageOrCCLogEntry,
MessagePriority,
Expand Down Expand Up @@ -465,7 +465,7 @@ dimming duration: ${group.dimmingDuration.toString()}`;
*/
public static getGroupCountCached(
applHost: ZWaveApplicationHost,
endpoint: IZWaveEndpoint,
endpoint: EndpointId,
): number {
return (
applHost.getDeviceConfig?.(endpoint.nodeId)?.compat
Expand Down
Loading

0 comments on commit be65623

Please sign in to comment.