Skip to content

Commit f624ab2

Browse files
authored
fix(ignore): improve testing by using herdsman directly (#11656)
1 parent 9cebc0d commit f624ab2

11 files changed

Lines changed: 245 additions & 150 deletions

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
"dependencies": {
4646
"iconv-lite": "^0.7.2",
4747
"semver": "^7.7.4",
48-
"zigbee-herdsman": "^9.0.10"
48+
"zigbee-herdsman": "^9.0.11"
4949
},
5050
"exports": {
5151
".": "./dist/index.js",

pnpm-lock.yaml

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/devices/smartthings.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,12 @@ export const definitions: DefinitionWithExtend[] = [
147147
await reporting.bind(endpoint, coordinatorEndpoint, ["msTemperatureMeasurement", "genPowerCfg", "manuSpecificSamsungAccelerometer"]);
148148
await reporting.temperature(endpoint);
149149
await reporting.batteryVoltage(endpoint);
150-
const payloadA = reporting.payload<"manuSpecificSamsungAccelerometer">("acceleration", 10, constants.repInterval.MINUTE, 1);
150+
const payloadA = reporting.payload<"manuSpecificSamsungAccelerometer", SamsungAccelerometer>(
151+
"acceleration",
152+
10,
153+
constants.repInterval.MINUTE,
154+
1,
155+
);
151156
await endpoint.configureReporting("manuSpecificSamsungAccelerometer", payloadA, options);
152157
const payloadX = reporting.payload<"manuSpecificSamsungAccelerometer", SamsungAccelerometer>(
153158
"xAxis",
@@ -351,7 +356,12 @@ export const definitions: DefinitionWithExtend[] = [
351356
await endpoint.write("manuSpecificSamsungAccelerometer", {2: {value: 0x0276, type: 0x21}}, options);
352357
await reporting.temperature(endpoint);
353358
await reporting.batteryVoltage(endpoint);
354-
const payloadA = reporting.payload<"manuSpecificSamsungAccelerometer">("acceleration", 10, constants.repInterval.MINUTE, 1);
359+
const payloadA = reporting.payload<"manuSpecificSamsungAccelerometer", SamsungAccelerometer>(
360+
"acceleration",
361+
10,
362+
constants.repInterval.MINUTE,
363+
1,
364+
);
355365
await endpoint.configureReporting("manuSpecificSamsungAccelerometer", payloadA, options);
356366
const payloadX = reporting.payload<"manuSpecificSamsungAccelerometer", SamsungAccelerometer>(
357367
"xAxis",

test/checkDefinition.test.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import {describe, it} from "vitest";
22
import {Zcl} from "zigbee-herdsman";
33
import * as fz from "../src/converters/fromZigbee";
4-
import {fzLocal, smartthingsExtend} from "../src/devices/smartthings";
4+
import {fzLocal} from "../src/devices/smartthings";
55
import {repInterval} from "../src/lib/constants";
66
import {assertDefinition, mockDevice, reportingItem} from "./utils";
77

@@ -10,10 +10,9 @@ describe("Check definition", () => {
1010
await assertDefinition({
1111
device: mockDevice({
1212
modelID: "multi",
13-
endpoints: [{ID: 1, inputClusters: ["msTemperatureMeasurement", "genPowerCfg", "manuSpecificSamsungAccelerometer", "genPollCtrl"]}],
13+
endpoints: [{ID: 1, inputClusters: ["msTemperatureMeasurement", "genPowerCfg", "genPollCtrl"], inputClusterIDs: [0xfc02]}],
1414
}),
1515
meta: undefined,
16-
extend: [smartthingsExtend.addManuSpecificSamsungAccelerometerCluster()],
1716
fromZigbee: [fz.temperature, fz.battery, fz.ias_contact_alarm_1, fzLocal.acceleration],
1817
toZigbee: [],
1918
exposes: ["battery", "battery_low", "contact", "moving", "tamper", "temperature", "x_axis", "y_axis", "z_axis"],

test/generateDefinition.test.ts

Lines changed: 71 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {describe, expect, test} from "vitest";
1+
import {describe, expect, test, vi} from "vitest";
22
import {Zcl} from "zigbee-herdsman";
33
import {findByDevice, generateExternalDefinitionSource} from "../src";
44
import * as fz from "../src/converters/fromZigbee";
@@ -203,9 +203,11 @@ export default {
203203
test("input(genOnOff, lightingColorCtrl)", async () => {
204204
const attributes = {
205205
lightingColorCtrl: {
206-
colorCapabilities: 254,
207-
colorTempPhysicalMin: 100,
208-
colorTempPhysicalMax: 500,
206+
attributes: {
207+
colorCapabilities: 254,
208+
colorTempPhysicalMin: 100,
209+
colorTempPhysicalMax: 500,
210+
},
209211
},
210212
};
211213

@@ -271,9 +273,11 @@ export default {
271273
test("light with color and color temperature", async () => {
272274
const attributes = {
273275
lightingColorCtrl: {
274-
colorCapabilities: 254,
275-
colorTempPhysicalMin: 100,
276-
colorTempPhysicalMax: 500,
276+
attributes: {
277+
colorCapabilities: 254,
278+
colorTempPhysicalMin: 100,
279+
colorTempPhysicalMax: 500,
280+
},
277281
},
278282
};
279283

@@ -339,9 +343,11 @@ export default {
339343
test("Philips light with color and color temperature", async () => {
340344
const attributes = {
341345
lightingColorCtrl: {
342-
colorCapabilities: 254,
343-
colorTempPhysicalMin: 100,
344-
colorTempPhysicalMax: 500,
346+
attributes: {
347+
colorCapabilities: 254,
348+
colorTempPhysicalMin: 100,
349+
colorTempPhysicalMax: 500,
350+
},
345351
},
346352
};
347353

@@ -413,16 +419,20 @@ export default {
413419
test("Electricity meter", async () => {
414420
const attributes = {
415421
haElectricalMeasurement: {
416-
acPowerDivisor: 1000,
417-
acPowerMultiplier: 1,
418-
acCurrentDivisor: 1000,
419-
acCurrentMultiplier: 1,
420-
acVoltageDivisor: 1000,
421-
acVoltageMultiplier: 1,
422+
attributes: {
423+
acPowerDivisor: 1000,
424+
acPowerMultiplier: 1,
425+
acCurrentDivisor: 1000,
426+
acCurrentMultiplier: 1,
427+
acVoltageDivisor: 1000,
428+
acVoltageMultiplier: 1,
429+
},
422430
},
423431
seMetering: {
424-
divisor: 1000,
425-
multiplier: 1,
432+
attributes: {
433+
divisor: 1000,
434+
multiplier: 1,
435+
},
426436
},
427437
};
428438

@@ -490,13 +500,15 @@ export default {
490500
test("Electricity DC meter", async () => {
491501
const attributes = {
492502
haElectricalMeasurement: {
493-
measurementType: 1 << 6,
494-
dcPowerDivisor: 10000,
495-
dcPowerMultiplier: 1,
496-
dcCurrentDivisor: 1000,
497-
dcCurrentMultiplier: 1,
498-
dcVoltageDivisor: 100,
499-
dcVoltageMultiplier: 1,
503+
attributes: {
504+
measurementType: 1 << 6,
505+
dcPowerDivisor: 10000,
506+
dcPowerMultiplier: 1,
507+
dcCurrentDivisor: 1000,
508+
dcCurrentMultiplier: 1,
509+
dcVoltageDivisor: 100,
510+
dcVoltageMultiplier: 1,
511+
},
500512
},
501513
};
502514

@@ -548,24 +560,34 @@ export default {
548560
test("input(genBinaryInput), output(genBinaryOutput, genAnalogOutput)", async () => {
549561
const attr10 = {
550562
genBinaryInput: {
551-
description: "my_binary_name",
563+
attributes: {
564+
description: "my_binary_name",
565+
},
552566
},
553567
genAnalogOutput: {
554-
description: "my_output_name",
555-
applicationType: 0,
556-
engineeringUnits: 62,
557-
minPresentValue: 0.0,
558-
maxPresentValue: 30.0,
559-
resolution: 0.1,
560-
presentValue: 15.0,
568+
attributes: {
569+
description: "my_output_name",
570+
applicationType: 0,
571+
engineeringUnits: 62,
572+
minPresentValue: 0.0,
573+
maxPresentValue: 30.0,
574+
resolution: 0.1,
575+
presentValue: 15.0,
576+
},
561577
},
562578
};
563579

564580
await assertGeneratedDefinition({
565581
device: mockDevice({
566582
modelID: "temp",
567583
endpoints: [
568-
{ID: 10, inputClusters: ["genBinaryInput", "genBinaryOutput", "genAnalogOutput"], outputClusters: [], attributes: attr10},
584+
{
585+
ID: 10,
586+
inputClusters: ["genBinaryInput", "genBinaryOutput", "genAnalogOutput"],
587+
outputClusters: [],
588+
attributes: attr10,
589+
read: vi.fn(async () => Promise.reject(new Error("use-fallback"))),
590+
},
569591
],
570592
}),
571593
meta: undefined,
@@ -599,13 +621,15 @@ export default {
599621
test("input(genAnalogInput), x2 endpoints", async () => {
600622
const attr10 = {
601623
genAnalogInput: {
602-
description: "my_custom_name",
603-
applicationType: 0,
604-
engineeringUnits: 62,
605-
minPresentValue: 0.0,
606-
maxPresentValue: 30.0,
607-
resolution: 0.1,
608-
presentValue: 15.0,
624+
attributes: {
625+
description: "my_custom_name",
626+
applicationType: 0,
627+
engineeringUnits: 62,
628+
minPresentValue: 0.0,
629+
maxPresentValue: 30.0,
630+
resolution: 0.1,
631+
presentValue: 15.0,
632+
},
609633
},
610634
};
611635

@@ -614,7 +638,12 @@ export default {
614638
modelID: "temp",
615639
endpoints: [
616640
{ID: 10, inputClusters: ["genAnalogInput"], outputClusters: [], attributes: attr10},
617-
{ID: 11, inputClusters: ["genAnalogInput"], outputClusters: []},
641+
{
642+
ID: 11,
643+
inputClusters: ["genAnalogInput"],
644+
outputClusters: [],
645+
read: vi.fn(async () => Promise.reject(new Error("use-fallback"))),
646+
},
618647
],
619648
}),
620649
meta: {multiEndpoint: true},

0 commit comments

Comments
 (0)