fix(ignore): update zigbee-herdsman-converters to 22.0.1 (#26418)

Co-authored-by: Nerivec <62446222+Nerivec@users.noreply.github.com>
This commit is contained in:
Koen Kanters
2025-02-18 14:50:01 +00:00
committed by GitHub
co-authored by Nerivec
parent 93af062a9b
commit 7d63a9a0f2
7 changed files with 35 additions and 27 deletions
+5 -8
View File
@@ -1,11 +1,11 @@
import type * as zhc from 'zigbee-herdsman-converters';
import {addDefinition, removeExternalDefinitions} from 'zigbee-herdsman-converters';
import {addExternalDefinition, removeExternalDefinitions} from 'zigbee-herdsman-converters';
import logger from '../util/logger';
import ExternalJSExtension from './externalJS';
type ModuleExports = zhc.Definition | zhc.Definition[];
type ModuleExports = zhc.ExternalDefinitionWithExtend | zhc.ExternalDefinitionWithExtend[];
export default class ExternalConverters extends ExternalJSExtension<ModuleExports> {
constructor(
@@ -43,10 +43,11 @@ export default class ExternalConverters extends ExternalJSExtension<ModuleExport
try {
removeExternalDefinitions(name);
for (const definition of this.getDefinitions(module)) {
const definitions = Array.isArray(module) ? module : [module];
for (const definition of definitions) {
definition.externalConverterName = name;
addDefinition(definition);
addExternalDefinition(definition);
logger.info(`Loaded external converter '${name}'.`);
}
@@ -61,8 +62,4 @@ export default class ExternalConverters extends ExternalJSExtension<ModuleExport
throw error;
}
}
private getDefinitions(module: ModuleExports): zhc.Definition[] {
return Array.isArray(module) ? module : [module];
}
}
+2 -2
View File
@@ -1,10 +1,10 @@
import type * as zhc from 'zigbee-herdsman-converters';
import assert from 'node:assert';
import bind from 'bind-decorator';
import stringify from 'json-stable-stringify-without-jsonify';
import * as zhc from 'zigbee-herdsman-converters';
import logger from '../util/logger';
import * as settings from '../util/settings';
import utils, {assertBinaryExpose, assertEnumExpose, assertNumericExpose, isBinaryExpose, isEnumExpose, isNumericExpose} from '../util/utils';
+1 -1
View File
@@ -63,7 +63,7 @@
"winston-transport": "^4.9.0",
"ws": "^8.18.0",
"zigbee-herdsman": "3.2.6",
"zigbee-herdsman-converters": "21.38.0",
"zigbee-herdsman-converters": "22.0.1",
"zigbee2mqtt-frontend": "0.9.4"
},
"devDependencies": {
+5 -5
View File
@@ -81,8 +81,8 @@ importers:
specifier: 3.2.6
version: 3.2.6
zigbee-herdsman-converters:
specifier: 21.38.0
version: 21.38.0
specifier: 22.0.1
version: 22.0.1
zigbee2mqtt-frontend:
specifier: 0.9.4
version: 0.9.4
@@ -1848,8 +1848,8 @@ packages:
resolution: {integrity: sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q==}
engines: {node: '>=10'}
zigbee-herdsman-converters@21.38.0:
resolution: {integrity: sha512-sGXpVINJ4Ls2KwZAsI7fUhS6oZW3+qEUDpGVRxFLvnIVXJIkSxjAr22IOdQccVS5srEQzzpp7TbddJY8wtgxZQ==}
zigbee-herdsman-converters@22.0.1:
resolution: {integrity: sha512-rgwaPIUPe6an76NG+X9vdO1p+xTieCSqpc4vhJpji0BQvrm+lCS4snBPWUFolONgN7EZcynmvcLki6+MsF5mSw==}
zigbee-herdsman@3.2.6:
resolution: {integrity: sha512-qUNJLEKMOP9zF2C29dESVuTIvQ2jIWmn4Gc7e15PvJ4C4h0Kafe+T5Ujx5CHsxjC8+gZZA6HOSQF1/aufBGkxA==}
@@ -3530,7 +3530,7 @@ snapshots:
yocto-queue@0.1.0: {}
zigbee-herdsman-converters@21.38.0:
zigbee-herdsman-converters@22.0.1:
dependencies:
buffer-crc32: 1.0.0
iconv-lite: 0.6.3
+7 -7
View File
@@ -28,7 +28,7 @@ describe('Extension: ExternalConverters', () => {
const rmSyncSpy = vi.spyOn(fs, 'rmSync');
const writeFileSyncSpy = vi.spyOn(fs, 'writeFileSync');
const zhcAddDefinitionSpy = vi.spyOn(zhc, 'addDefinition');
const zhcAddExternalDefinitionSpy = vi.spyOn(zhc, 'addExternalDefinition');
const zhcRemoveExternalDefinitionsSpy = vi.spyOn(zhc, 'removeExternalDefinitions');
const mocksClear = [
@@ -43,7 +43,7 @@ describe('Extension: ExternalConverters', () => {
mkdirSyncSpy,
rmSyncSpy,
writeFileSyncSpy,
zhcAddDefinitionSpy,
zhcAddExternalDefinitionSpy,
zhcRemoveExternalDefinitionsSpy,
];
@@ -129,7 +129,7 @@ describe('Extension: ExternalConverters', () => {
expect(zhcRemoveExternalDefinitionsSpy).toHaveBeenCalledTimes(2);
expect(zhcRemoveExternalDefinitionsSpy).toHaveBeenNthCalledWith(1, 'mock-external-converter-multiple.js');
expect(zhcRemoveExternalDefinitionsSpy).toHaveBeenNthCalledWith(2, 'mock-external-converter.js');
expect(zhcAddDefinitionSpy).toHaveBeenNthCalledWith(
expect(zhcAddExternalDefinitionSpy).toHaveBeenNthCalledWith(
1,
expect.objectContaining({
mock: 1,
@@ -139,7 +139,7 @@ describe('Extension: ExternalConverters', () => {
description: 'external_1',
}),
);
expect(zhcAddDefinitionSpy).toHaveBeenNthCalledWith(
expect(zhcAddExternalDefinitionSpy).toHaveBeenNthCalledWith(
2,
expect.objectContaining({
mock: 2,
@@ -149,7 +149,7 @@ describe('Extension: ExternalConverters', () => {
description: 'external_2',
}),
);
expect(zhcAddDefinitionSpy).toHaveBeenNthCalledWith(
expect(zhcAddExternalDefinitionSpy).toHaveBeenNthCalledWith(
3,
expect.objectContaining({
mock: true,
@@ -206,7 +206,7 @@ describe('Extension: ExternalConverters', () => {
expect(writeFileSyncSpy).toHaveBeenCalledWith(converterFilePath, converterCode, 'utf8');
expect(zhcRemoveExternalDefinitionsSpy).toHaveBeenCalledTimes(1);
expect(zhcRemoveExternalDefinitionsSpy).toHaveBeenNthCalledWith(1, converterName);
expect(zhcAddDefinitionSpy).toHaveBeenCalledWith(
expect(zhcAddExternalDefinitionSpy).toHaveBeenCalledWith(
expect.objectContaining({
mock: true,
zigbeeModel: ['external_converter_device'],
@@ -288,7 +288,7 @@ describe('Extension: ExternalConverters', () => {
const errorMsg = `Invalid definition`;
zhcAddDefinitionSpy.mockImplementationOnce(() => {
zhcAddExternalDefinitionSpy.mockImplementationOnce(() => {
throw new Error(errorMsg);
});
+10 -2
View File
@@ -9,6 +9,9 @@ import assert from 'node:assert';
import stringify from 'json-stable-stringify-without-jsonify';
import * as zhc from 'zigbee-herdsman-converters';
import {KeyValueAny} from 'zigbee-herdsman-converters/lib/types';
import {Controller} from '../../lib/controller';
import HomeAssistant from '../../lib/extension/homeassistant';
import * as settings from '../../lib/util/settings';
@@ -79,7 +82,12 @@ describe('Extension: HomeAssistant', () => {
it('Should not have duplicate type/object_ids in a mapping', async () => {
const duplicated: string[] = [];
(await import('zigbee-herdsman-converters')).definitions.forEach((d) => {
(await import('zigbee-herdsman-converters/devices/index')).default.forEach((baseDefinition) => {
const d = zhc.prepareDefinition(
// @ts-expect-error inferred type is wrong
baseDefinition,
);
const exposes = typeof d.exposes == 'function' ? d.exposes(undefined, undefined) : d.exposes;
const device = {
definition: d,
@@ -2256,7 +2264,7 @@ describe('Extension: HomeAssistant', () => {
await vi.runOnlyPendingTimersAsync();
await flushPromises();
let payload = {
let payload: KeyValueAny = {
name: 'Chill scene',
command_topic: 'zigbee2mqtt/bulb_color_2/set',
payload_on: '{ "scene_recall": 1 }',
+5 -2
View File
@@ -11,8 +11,6 @@ import * as settings from '../../lib/util/settings';
const mockOnEvent = vi.fn();
const mockLivoloOnEvent = vi.fn();
const mappedLivolo = zhc.findByModel('TI0001')!;
mappedLivolo.onEvent = mockLivoloOnEvent;
// @ts-expect-error mock
zhc.onEvent = mockOnEvent;
@@ -21,6 +19,11 @@ const mocksClear = [mockMQTTPublishAsync, mockLogger.warning, mockLogger.debug];
describe('Extension: OnEvent', () => {
let controller: Controller;
beforeAll(async () => {
const mappedLivolo = (await zhc.findByDevice(devices.LIVOLO))!;
mappedLivolo.onEvent = mockLivoloOnEvent;
});
beforeEach(async () => {
vi.useFakeTimers();
data.writeDefaultConfiguration();