Skip to content

Commit

Permalink
fix(ignore): Use new exports from ZH
Browse files Browse the repository at this point in the history
  • Loading branch information
Nerivec committed Dec 28, 2024
1 parent 329b8c9 commit 1aac676
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 23 deletions.
4 changes: 2 additions & 2 deletions lib/extension/bridge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import objectAssignDeep from 'object-assign-deep';
import winston from 'winston';
import Transport from 'winston-transport';

import {Zcl} from 'zigbee-herdsman';
import * as zhc from 'zigbee-herdsman-converters';
import {Clusters} from 'zigbee-herdsman/dist/zspec/zcl/definition/cluster';

import Device from '../model/device';
import Group from '../model/group';
Expand Down Expand Up @@ -792,7 +792,7 @@ export default class Bridge extends Extension {

async publishDefinitions(): Promise<void> {
const data: Zigbee2MQTTAPI['bridge/definition'] = {
clusters: Clusters,
clusters: Zcl.Clusters,
custom_clusters: {},
};

Expand Down
23 changes: 8 additions & 15 deletions lib/types/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,7 @@ import type TypeGroup from 'lib/model/group';
import type TypeMQTT from 'lib/mqtt';
import type TypeState from 'lib/state';
import type TypeZigbee from 'lib/zigbee';
import type {
CoordinatorVersion as ZHCoordinatorVersion,
LQI as ZHLQI,
NetworkParameters as ZHNetworkParameters,
RoutingTable as ZHRoutingTable,
} from 'zigbee-herdsman/dist/adapter/tstype';
import type * as ZHEvents from 'zigbee-herdsman/dist/controller/events';
import type {Device as ZHDevice, Endpoint as ZHEndpoint, Group as ZHGroup} from 'zigbee-herdsman/dist/controller/model';
import type {AdapterTypes as ZHAdapterTypes, Events as ZHEvents, Models as ZHModels} from 'zigbee-herdsman';
import type {Cluster as ZHCluster, FrameControl as ZHFrameControl} from 'zigbee-herdsman/dist/zspec/zcl/definition/tstype';

import {LogLevel} from 'lib/util/settings';
Expand Down Expand Up @@ -40,13 +33,13 @@ declare global {

// zigbee-herdsman
namespace zh {
type Endpoint = ZHEndpoint;
type Device = ZHDevice;
type Group = ZHGroup;
type LQI = ZHLQI;
type RoutingTable = ZHRoutingTable;
type CoordinatorVersion = ZHCoordinatorVersion;
type NetworkParameters = ZHNetworkParameters;
type Endpoint = ZHModels.Endpoint;
type Device = ZHModels.Device;
type Group = ZHModels.Group;
type LQI = ZHAdapterTypes.LQI;
type RoutingTable = ZHAdapterTypes.RoutingTable;
type CoordinatorVersion = ZHAdapterTypes.CoordinatorVersion;
type NetworkParameters = ZHAdapterTypes.NetworkParameters;
interface Bind {
cluster: ZHCluster;
target: zh.Endpoint | zh.Group;
Expand Down
3 changes: 2 additions & 1 deletion lib/zigbee.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import type {Events as ZHEvents} from 'zigbee-herdsman';

import {randomInt} from 'node:crypto';

import bind from 'bind-decorator';
import stringify from 'json-stable-stringify-without-jsonify';

import {Controller} from 'zigbee-herdsman';
import * as ZHEvents from 'zigbee-herdsman/dist/controller/events';

import Device from './model/device';
import Group from './model/group';
Expand Down
14 changes: 9 additions & 5 deletions test/mocks/zigbeeHerdsman.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import type {Mock} from 'vitest';
import type {AdapterTypes} from 'zigbee-herdsman';

import assert from 'node:assert';

import {Zcl} from 'zigbee-herdsman';
import {CoordinatorVersion, DeviceType, NetworkParameters, StartResult} from 'zigbee-herdsman/dist/adapter/tstype';

import {EventHandler} from './utils';

Expand Down Expand Up @@ -1123,7 +1123,7 @@ export const mockController = {
on: (type: string, handler: EventHandler): void => {
events[type] = handler;
},
start: vi.fn((): Promise<StartResult> => Promise.resolve('reset')),
start: vi.fn((): Promise<AdapterTypes.StartResult> => Promise.resolve('reset')),
stop: vi.fn(),
touchlinkIdentify: vi.fn(),
touchlinkScan: vi.fn(),
Expand All @@ -1136,8 +1136,12 @@ export const mockController = {
isStopping: vi.fn((): boolean => false),
backup: vi.fn(),
coordinatorCheck: vi.fn(),
getCoordinatorVersion: vi.fn((): Promise<CoordinatorVersion> => Promise.resolve({type: 'z-Stack', meta: {version: 1, revision: 20190425}})),
getNetworkParameters: vi.fn((): Promise<NetworkParameters> => Promise.resolve({panID: 0x162a, extendedPanID: '0x64c5fd698daf0c00', channel: 15})),
getCoordinatorVersion: vi.fn(
(): Promise<AdapterTypes.CoordinatorVersion> => Promise.resolve({type: 'z-Stack', meta: {version: 1, revision: 20190425}}),
),
getNetworkParameters: vi.fn(
(): Promise<AdapterTypes.NetworkParameters> => Promise.resolve({panID: 0x162a, extendedPanID: '0x64c5fd698daf0c00', channel: 15}),
),
getDevices: vi.fn((): Device[] => []),
getDevicesIterator: vi.fn(function* (predicate?: (value: Device) => boolean): Generator<Device> {
for (const key in devices) {
Expand All @@ -1148,7 +1152,7 @@ export const mockController = {
}
}
}),
getDevicesByType: vi.fn((type: DeviceType): Device[] =>
getDevicesByType: vi.fn((type: AdapterTypes.DeviceType): Device[] =>
Object.values(devices)
.filter((d) => returnDevices.length === 0 || returnDevices.includes(d.ieeeAddr))
.filter((d) => d.type === type),
Expand Down

0 comments on commit 1aac676

Please sign in to comment.