zigbee-herdsman-converters 23.49.0 → 23.50.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +46 -0
- package/dist/devices/bacchus.d.ts.map +1 -1
- package/dist/devices/bacchus.js +79 -13
- package/dist/devices/bacchus.js.map +1 -1
- package/dist/devices/custom_devices_diy.js +1 -1
- package/dist/devices/custom_devices_diy.js.map +1 -1
- package/dist/devices/cwd.js +34 -1
- package/dist/devices/cwd.js.map +1 -1
- package/dist/devices/ikea.d.ts.map +1 -1
- package/dist/devices/ikea.js +12 -6
- package/dist/devices/ikea.js.map +1 -1
- package/dist/devices/imou.d.ts.map +1 -1
- package/dist/devices/imou.js +7 -0
- package/dist/devices/imou.js.map +1 -1
- package/dist/devices/lifecontrol.d.ts.map +1 -1
- package/dist/devices/lifecontrol.js +4 -1
- package/dist/devices/lifecontrol.js.map +1 -1
- package/dist/devices/lumi.js +1 -1
- package/dist/devices/lumi.js.map +1 -1
- package/dist/devices/moes.d.ts.map +1 -1
- package/dist/devices/moes.js +99 -1
- package/dist/devices/moes.js.map +1 -1
- package/dist/devices/onenuo.js +1 -1
- package/dist/devices/onenuo.js.map +1 -1
- package/dist/devices/philips.d.ts.map +1 -1
- package/dist/devices/philips.js +10 -2
- package/dist/devices/philips.js.map +1 -1
- package/dist/devices/pushok.d.ts.map +1 -1
- package/dist/devices/pushok.js +13 -1
- package/dist/devices/pushok.js.map +1 -1
- package/dist/devices/senoro.js +1 -1
- package/dist/devices/senoro.js.map +1 -1
- package/dist/devices/slacky_diy.d.ts.map +1 -1
- package/dist/devices/slacky_diy.js +19 -17
- package/dist/devices/slacky_diy.js.map +1 -1
- package/dist/devices/sonoff.d.ts.map +1 -1
- package/dist/devices/sonoff.js +0 -24
- package/dist/devices/sonoff.js.map +1 -1
- package/dist/devices/sunricher.d.ts.map +1 -1
- package/dist/devices/sunricher.js +264 -0
- package/dist/devices/sunricher.js.map +1 -1
- package/dist/devices/third_reality.js +2 -2
- package/dist/devices/third_reality.js.map +1 -1
- package/dist/devices/tuya.d.ts.map +1 -1
- package/dist/devices/tuya.js +75 -22
- package/dist/devices/tuya.js.map +1 -1
- package/dist/devices/zigbeetlc.d.ts.map +1 -1
- package/dist/devices/zigbeetlc.js +20 -0
- package/dist/devices/zigbeetlc.js.map +1 -1
- package/dist/lib/ikea.js +1 -1
- package/dist/lib/ikea.js.map +1 -1
- package/dist/lib/lumi.d.ts.map +1 -1
- package/dist/lib/lumi.js +3 -1
- package/dist/lib/lumi.js.map +1 -1
- package/dist/lib/modernExtend.d.ts +7 -2
- package/dist/lib/modernExtend.d.ts.map +1 -1
- package/dist/lib/modernExtend.js +218 -225
- package/dist/lib/modernExtend.js.map +1 -1
- package/dist/lib/ota.d.ts +1 -0
- package/dist/lib/ota.d.ts.map +1 -1
- package/dist/lib/ota.js +4 -4
- package/dist/lib/ota.js.map +1 -1
- package/dist/lib/types.d.ts +1 -0
- package/dist/lib/types.d.ts.map +1 -1
- package/dist/lib/ubisys.d.ts.map +1 -1
- package/dist/lib/ubisys.js +3 -1
- package/dist/lib/ubisys.js.map +1 -1
- package/dist/models-index.json +1 -1
- package/package.json +4 -4
package/dist/lib/modernExtend.js
CHANGED
|
@@ -32,6 +32,9 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
32
32
|
return result;
|
|
33
33
|
};
|
|
34
34
|
})();
|
|
35
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
+
};
|
|
35
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
39
|
exports.GPDF_COMMANDS = exports.TIME_LOOKUP = void 0;
|
|
37
40
|
exports.setupAttributes = setupAttributes;
|
|
@@ -84,6 +87,7 @@ exports.deviceAddCustomCluster = deviceAddCustomCluster;
|
|
|
84
87
|
exports.ignoreClusterReport = ignoreClusterReport;
|
|
85
88
|
exports.bindCluster = bindCluster;
|
|
86
89
|
const zigbee_herdsman_1 = require("zigbee-herdsman");
|
|
90
|
+
const node_assert_1 = __importDefault(require("node:assert"));
|
|
87
91
|
const fz = __importStar(require("../converters/fromZigbee"));
|
|
88
92
|
const tz = __importStar(require("../converters/toZigbee"));
|
|
89
93
|
const logger_1 = require("../lib/logger");
|
|
@@ -199,20 +203,28 @@ async function setupAttributes(entity, coordinatorEndpoint, cluster, config, con
|
|
|
199
203
|
}
|
|
200
204
|
}
|
|
201
205
|
}
|
|
202
|
-
function setupConfigureForReporting(cluster, attribute,
|
|
206
|
+
function setupConfigureForReporting(cluster, attribute, args) {
|
|
207
|
+
const { config = false, access = undefined, endpointNames = undefined, singleEndpoint = false } = args;
|
|
203
208
|
const configureReporting = !!config;
|
|
204
209
|
const read = !!(access & exposes_1.access.GET);
|
|
205
210
|
if (configureReporting || read) {
|
|
206
211
|
const configure = async (device, coordinatorEndpoint, definition) => {
|
|
207
212
|
const reportConfig = config ? { ...config, attribute: attribute } : { attribute, min: -1, max: -1, change: -1 };
|
|
208
|
-
let
|
|
213
|
+
let endpoints;
|
|
209
214
|
if (endpointNames) {
|
|
215
|
+
(0, node_assert_1.default)(!singleEndpoint, "`endpointNames` cannot be used together with `singleEndpoint`");
|
|
210
216
|
const definitionEndpoints = definition.endpoint(device);
|
|
211
217
|
const endpointIds = endpointNames.map((e) => definitionEndpoints[e]);
|
|
212
|
-
|
|
218
|
+
endpoints = device.endpoints.filter((e) => endpointIds.includes(e.ID));
|
|
219
|
+
}
|
|
220
|
+
else {
|
|
221
|
+
endpoints = getEndpointsWithCluster(device, cluster, "input");
|
|
222
|
+
if (singleEndpoint) {
|
|
223
|
+
endpoints = [endpoints[0]];
|
|
224
|
+
}
|
|
213
225
|
}
|
|
214
|
-
for (const
|
|
215
|
-
await setupAttributes(
|
|
226
|
+
for (const endpoint of endpoints) {
|
|
227
|
+
await setupAttributes(endpoint, coordinatorEndpoint, cluster, [reportConfig], configureReporting, read);
|
|
216
228
|
}
|
|
217
229
|
};
|
|
218
230
|
return configure;
|
|
@@ -285,9 +297,8 @@ function forcePowerSource(args) {
|
|
|
285
297
|
];
|
|
286
298
|
return { configure, isModernExtend: true };
|
|
287
299
|
}
|
|
288
|
-
function linkQuality(args) {
|
|
289
|
-
|
|
290
|
-
args = { reporting: false, attribute: "zclVersion", reportingConfig: { min: "1_HOUR", max: "4_HOURS", change: 0 }, ...args };
|
|
300
|
+
function linkQuality(args = {}) {
|
|
301
|
+
const { reporting = false, attribute = "zclVersion", reportingConfig = { min: "1_HOUR", max: "4_HOURS", change: 0 } } = args;
|
|
291
302
|
// Exposes is empty because the application (e.g. Z2M) adds a linkquality sensor
|
|
292
303
|
// for every device already.
|
|
293
304
|
const exposes = [];
|
|
@@ -301,24 +312,13 @@ function linkQuality(args) {
|
|
|
301
312
|
},
|
|
302
313
|
];
|
|
303
314
|
const result = { exposes, fromZigbee, isModernExtend: true };
|
|
304
|
-
if (
|
|
305
|
-
result.configure = [setupConfigureForReporting("genBasic",
|
|
315
|
+
if (reporting) {
|
|
316
|
+
result.configure = [setupConfigureForReporting("genBasic", attribute, { config: reportingConfig, access: exposes_1.access.GET })];
|
|
306
317
|
}
|
|
307
318
|
return result;
|
|
308
319
|
}
|
|
309
|
-
function battery(args) {
|
|
310
|
-
|
|
311
|
-
args = {
|
|
312
|
-
percentage: true,
|
|
313
|
-
voltage: false,
|
|
314
|
-
lowStatus: false,
|
|
315
|
-
percentageReporting: true,
|
|
316
|
-
voltageReporting: false,
|
|
317
|
-
dontDividePercentage: false,
|
|
318
|
-
percentageReportingConfig: { min: "1_HOUR", max: "MAX", change: 10 },
|
|
319
|
-
voltageReportingConfig: { min: "1_HOUR", max: "MAX", change: 10 },
|
|
320
|
-
...args,
|
|
321
|
-
};
|
|
320
|
+
function battery(args = {}) {
|
|
321
|
+
const { percentage = true, voltage = false, lowStatus = false, percentageReporting = true, voltageReporting = false, dontDividePercentage = false, percentageReportingConfig = { min: "1_HOUR", max: "MAX", change: 10 }, voltageReportingConfig = { min: "1_HOUR", max: "MAX", change: 10 }, } = args;
|
|
322
322
|
const exposes = [];
|
|
323
323
|
if (args.percentage) {
|
|
324
324
|
exposes.push(exposes_1.presets
|
|
@@ -403,10 +403,18 @@ function battery(args) {
|
|
|
403
403
|
const result = { exposes, fromZigbee, toZigbee, configure: [], isModernExtend: true };
|
|
404
404
|
if (args.percentageReporting || args.voltageReporting) {
|
|
405
405
|
if (args.percentageReporting) {
|
|
406
|
-
result.configure.push(setupConfigureForReporting("genPowerCfg", "batteryPercentageRemaining",
|
|
406
|
+
result.configure.push(setupConfigureForReporting("genPowerCfg", "batteryPercentageRemaining", {
|
|
407
|
+
config: args.percentageReportingConfig,
|
|
408
|
+
access: exposes_1.access.STATE_GET,
|
|
409
|
+
singleEndpoint: true,
|
|
410
|
+
}));
|
|
407
411
|
}
|
|
408
412
|
if (args.voltageReporting) {
|
|
409
|
-
result.configure.push(setupConfigureForReporting("genPowerCfg", "batteryVoltage",
|
|
413
|
+
result.configure.push(setupConfigureForReporting("genPowerCfg", "batteryVoltage", {
|
|
414
|
+
config: args.voltageReportingConfig,
|
|
415
|
+
access: exposes_1.access.STATE_GET,
|
|
416
|
+
singleEndpoint: true,
|
|
417
|
+
}));
|
|
410
418
|
}
|
|
411
419
|
result.configure.push((0, utils_1.configureSetPowerSourceWhenUnknown)("Battery"));
|
|
412
420
|
}
|
|
@@ -419,11 +427,15 @@ function battery(args) {
|
|
|
419
427
|
result.meta = meta;
|
|
420
428
|
}
|
|
421
429
|
if (args.lowStatusReportingConfig) {
|
|
422
|
-
result.configure.push(setupConfigureForReporting("genPowerCfg", "batteryAlarmState",
|
|
430
|
+
result.configure.push(setupConfigureForReporting("genPowerCfg", "batteryAlarmState", {
|
|
431
|
+
config: args.lowStatusReportingConfig,
|
|
432
|
+
access: exposes_1.access.STATE_GET,
|
|
433
|
+
singleEndpoint: true,
|
|
434
|
+
}));
|
|
423
435
|
}
|
|
424
436
|
return result;
|
|
425
437
|
}
|
|
426
|
-
function deviceTemperature(args) {
|
|
438
|
+
function deviceTemperature(args = {}) {
|
|
427
439
|
return numeric({
|
|
428
440
|
name: "device_temperature",
|
|
429
441
|
cluster: "genDeviceTempCfg",
|
|
@@ -436,16 +448,15 @@ function deviceTemperature(args) {
|
|
|
436
448
|
...args,
|
|
437
449
|
});
|
|
438
450
|
}
|
|
439
|
-
function identify(args) {
|
|
440
|
-
|
|
441
|
-
args = { isSleepy: false, ...args };
|
|
451
|
+
function identify(args = { isSleepy: false }) {
|
|
452
|
+
const { isSleepy } = args;
|
|
442
453
|
const normal = exposes_1.presets.enum("identify", exposes_1.access.SET, ["identify"]).withDescription("Initiate device identification").withCategory("config");
|
|
443
454
|
const sleepy = exposes_1.presets
|
|
444
455
|
.enum("identify", exposes_1.access.SET, ["identify"])
|
|
445
456
|
.withDescription("Initiate device identification. This device is asleep by default." +
|
|
446
457
|
"You may need to wake it up first before sending the identify command.")
|
|
447
458
|
.withCategory("config");
|
|
448
|
-
const exposes =
|
|
459
|
+
const exposes = isSleepy ? [sleepy] : [normal];
|
|
449
460
|
const identifyTimeout = exposes_1.presets
|
|
450
461
|
.numeric("identify_timeout", exposes_1.access.SET)
|
|
451
462
|
.withDescription("Sets the duration of the identification procedure in seconds (i.e., how long the device would flash)." +
|
|
@@ -464,27 +475,24 @@ function identify(args) {
|
|
|
464
475
|
];
|
|
465
476
|
return { exposes, toZigbee, isModernExtend: true };
|
|
466
477
|
}
|
|
467
|
-
function onOff(args) {
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
const
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
const toZigbee = [args?.endpointNames ? { ...tz.on_off, endpoints: args?.endpointNames } : tz.on_off];
|
|
475
|
-
if (args.powerOnBehavior) {
|
|
476
|
-
exposes.push(...(0, utils_1.exposeEndpoints)(exposes_1.presets.power_on_behavior(["off", "on", "toggle", "previous"]), args.endpointNames));
|
|
478
|
+
function onOff(args = {}) {
|
|
479
|
+
const { powerOnBehavior = true, skipDuplicateTransaction = false, configureReporting = true, endpointNames = undefined, description = undefined, ota = false, } = args;
|
|
480
|
+
const exposes = description ? (0, utils_1.exposeEndpoints)(exposes_1.presets.switch(description), endpointNames) : (0, utils_1.exposeEndpoints)(exposes_1.presets.switch(), endpointNames);
|
|
481
|
+
const fromZigbee = [skipDuplicateTransaction ? fz.on_off_skip_duplicate_transaction : fz.on_off];
|
|
482
|
+
const toZigbee = [endpointNames ? { ...tz.on_off, endpoints: endpointNames } : tz.on_off];
|
|
483
|
+
if (powerOnBehavior) {
|
|
484
|
+
exposes.push(...(0, utils_1.exposeEndpoints)(exposes_1.presets.power_on_behavior(["off", "on", "toggle", "previous"]), endpointNames));
|
|
477
485
|
fromZigbee.push(fz.power_on_behavior);
|
|
478
486
|
toZigbee.push(tz.power_on_behavior);
|
|
479
487
|
}
|
|
480
488
|
const result = { exposes, fromZigbee, toZigbee, isModernExtend: true };
|
|
481
|
-
if (
|
|
482
|
-
result.ota =
|
|
483
|
-
if (
|
|
489
|
+
if (ota)
|
|
490
|
+
result.ota = ota;
|
|
491
|
+
if (configureReporting) {
|
|
484
492
|
result.configure = [
|
|
485
493
|
async (device, coordinatorEndpoint) => {
|
|
486
494
|
await setupAttributes(device, coordinatorEndpoint, "genOnOff", [{ attribute: "onOff", min: "MIN", max: "MAX", change: 1 }]);
|
|
487
|
-
if (
|
|
495
|
+
if (powerOnBehavior) {
|
|
488
496
|
try {
|
|
489
497
|
// Don't fail configure if reading this attribute fails, some devices don't support it.
|
|
490
498
|
await setupAttributes(device, coordinatorEndpoint, "genOnOff", [{ attribute: "startUpOnOff", min: "MIN", max: "MAX", change: 1 }], false);
|
|
@@ -504,12 +512,11 @@ function onOff(args) {
|
|
|
504
512
|
}
|
|
505
513
|
return result;
|
|
506
514
|
}
|
|
507
|
-
function commandsOnOff(args) {
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
actions = args.commands.flatMap((c) => args.endpointNames.map((e) => `${c}_${e}`));
|
|
515
|
+
function commandsOnOff(args = {}) {
|
|
516
|
+
const { commands = ["on", "off", "toggle"], bind = true, endpointNames = undefined } = args;
|
|
517
|
+
let actions = commands;
|
|
518
|
+
if (endpointNames) {
|
|
519
|
+
actions = commands.flatMap((c) => endpointNames.map((e) => `${c}_${e}`));
|
|
513
520
|
}
|
|
514
521
|
const exposes = [exposes_1.presets.enum("action", exposes_1.access.STATE, actions).withDescription("Triggered action (e.g. a button click)")];
|
|
515
522
|
const actionPayloadLookup = {
|
|
@@ -532,8 +539,8 @@ function commandsOnOff(args) {
|
|
|
532
539
|
},
|
|
533
540
|
];
|
|
534
541
|
const result = { exposes, fromZigbee, isModernExtend: true };
|
|
535
|
-
if (
|
|
536
|
-
result.configure = [setupConfigureForBinding("genOnOff", "output",
|
|
542
|
+
if (bind)
|
|
543
|
+
result.configure = [setupConfigureForBinding("genOnOff", "output", endpointNames)];
|
|
537
544
|
return result;
|
|
538
545
|
}
|
|
539
546
|
function customTimeResponse(start) {
|
|
@@ -572,7 +579,7 @@ function customTimeResponse(start) {
|
|
|
572
579
|
}
|
|
573
580
|
// #endregion
|
|
574
581
|
// #region Measurement and Sensing
|
|
575
|
-
function illuminance(args) {
|
|
582
|
+
function illuminance(args = {}) {
|
|
576
583
|
const luxScale = (value, type) => {
|
|
577
584
|
let result = value;
|
|
578
585
|
if (type === "from") {
|
|
@@ -608,7 +615,7 @@ function illuminance(args) {
|
|
|
608
615
|
result.exposes.push(exposeIlluminanceRaw);
|
|
609
616
|
return result;
|
|
610
617
|
}
|
|
611
|
-
function temperature(args) {
|
|
618
|
+
function temperature(args = {}) {
|
|
612
619
|
return numeric({
|
|
613
620
|
name: "temperature",
|
|
614
621
|
cluster: "msTemperatureMeasurement",
|
|
@@ -621,7 +628,7 @@ function temperature(args) {
|
|
|
621
628
|
...args,
|
|
622
629
|
});
|
|
623
630
|
}
|
|
624
|
-
function pressure(args) {
|
|
631
|
+
function pressure(args = {}) {
|
|
625
632
|
return numeric({
|
|
626
633
|
name: "pressure",
|
|
627
634
|
cluster: "msPressureMeasurement",
|
|
@@ -634,7 +641,7 @@ function pressure(args) {
|
|
|
634
641
|
...args,
|
|
635
642
|
});
|
|
636
643
|
}
|
|
637
|
-
function flow(args) {
|
|
644
|
+
function flow(args = {}) {
|
|
638
645
|
return numeric({
|
|
639
646
|
name: "flow",
|
|
640
647
|
cluster: "msFlowMeasurement",
|
|
@@ -647,7 +654,7 @@ function flow(args) {
|
|
|
647
654
|
...args,
|
|
648
655
|
});
|
|
649
656
|
}
|
|
650
|
-
function humidity(args) {
|
|
657
|
+
function humidity(args = {}) {
|
|
651
658
|
return numeric({
|
|
652
659
|
name: "humidity",
|
|
653
660
|
cluster: "msRelativeHumidity",
|
|
@@ -660,7 +667,7 @@ function humidity(args) {
|
|
|
660
667
|
...args,
|
|
661
668
|
});
|
|
662
669
|
}
|
|
663
|
-
function soilMoisture(args) {
|
|
670
|
+
function soilMoisture(args = {}) {
|
|
664
671
|
return numeric({
|
|
665
672
|
name: "soil_moisture",
|
|
666
673
|
cluster: "msSoilMoisture",
|
|
@@ -673,12 +680,11 @@ function soilMoisture(args) {
|
|
|
673
680
|
...args,
|
|
674
681
|
});
|
|
675
682
|
}
|
|
676
|
-
function occupancy(args) {
|
|
677
|
-
|
|
678
|
-
args = { reporting: true, reportingConfig: { min: "MIN", max: "1_HOUR", change: 0 }, ...args };
|
|
683
|
+
function occupancy(args = {}) {
|
|
684
|
+
const { reporting = true, reportingConfig = { min: "MIN", max: "1_HOUR", change: 0 }, pirConfig = undefined, ultrasonicConfig = undefined, contactConfig = undefined, endpointNames = undefined, } = args;
|
|
679
685
|
const templateExposes = [exposes_1.presets.occupancy().withAccess(exposes_1.access.STATE_GET)];
|
|
680
|
-
const exposes =
|
|
681
|
-
? templateExposes.flatMap((exp) =>
|
|
686
|
+
const exposes = endpointNames
|
|
687
|
+
? templateExposes.flatMap((exp) => endpointNames.map((ep) => exp.withEndpoint(ep)))
|
|
682
688
|
: templateExposes;
|
|
683
689
|
const fromZigbee = [
|
|
684
690
|
{
|
|
@@ -686,7 +692,7 @@ function occupancy(args) {
|
|
|
686
692
|
type: ["attributeReport", "readResponse"],
|
|
687
693
|
options: [exposes_1.options.no_occupancy_since_false()],
|
|
688
694
|
convert: (model, msg, publish, options, meta) => {
|
|
689
|
-
if ("occupancy" in msg.data && (!
|
|
695
|
+
if ("occupancy" in msg.data && (!endpointNames || endpointNames.includes((0, utils_1.getEndpointName)(msg, model, meta).toString()))) {
|
|
690
696
|
const propertyName = (0, utils_1.postfixWithEndpointName)("occupancy", msg, model, meta);
|
|
691
697
|
const payload = { [propertyName]: (msg.data.occupancy & 1) > 0 };
|
|
692
698
|
(0, utils_1.noOccupancySince)(msg.endpoint, options, publish, payload[propertyName] ? "stop" : "start");
|
|
@@ -707,13 +713,13 @@ function occupancy(args) {
|
|
|
707
713
|
const settingsTemplate = {
|
|
708
714
|
cluster: "msOccupancySensing",
|
|
709
715
|
description: "",
|
|
710
|
-
endpointNames:
|
|
716
|
+
endpointNames: endpointNames,
|
|
711
717
|
access: "ALL",
|
|
712
718
|
entityCategory: "config",
|
|
713
719
|
};
|
|
714
720
|
const attributesForReading = [];
|
|
715
|
-
if (
|
|
716
|
-
if (
|
|
721
|
+
if (pirConfig) {
|
|
722
|
+
if (pirConfig.includes("otu_delay")) {
|
|
717
723
|
settingsExtends.push(numeric({
|
|
718
724
|
name: "occupancy_timeout",
|
|
719
725
|
attribute: "pirOToUDelay",
|
|
@@ -725,7 +731,7 @@ function occupancy(args) {
|
|
|
725
731
|
}));
|
|
726
732
|
attributesForReading.push("pirOToUDelay");
|
|
727
733
|
}
|
|
728
|
-
if (
|
|
734
|
+
if (pirConfig.includes("uto_delay")) {
|
|
729
735
|
settingsExtends.push(numeric({
|
|
730
736
|
name: "pir_uto_delay",
|
|
731
737
|
attribute: "pirUToODelay",
|
|
@@ -735,7 +741,7 @@ function occupancy(args) {
|
|
|
735
741
|
}));
|
|
736
742
|
attributesForReading.push("pirUToODelay");
|
|
737
743
|
}
|
|
738
|
-
if (
|
|
744
|
+
if (pirConfig.includes("uto_threshold")) {
|
|
739
745
|
settingsExtends.push(numeric({
|
|
740
746
|
name: "pir_uto_threshold",
|
|
741
747
|
attribute: "pirUToOThreshold",
|
|
@@ -746,8 +752,8 @@ function occupancy(args) {
|
|
|
746
752
|
attributesForReading.push("pirUToOThreshold");
|
|
747
753
|
}
|
|
748
754
|
}
|
|
749
|
-
if (
|
|
750
|
-
if (
|
|
755
|
+
if (ultrasonicConfig) {
|
|
756
|
+
if (pirConfig.includes("otu_delay")) {
|
|
751
757
|
settingsExtends.push(numeric({
|
|
752
758
|
name: "ultrasonic_otu_delay",
|
|
753
759
|
attribute: "ultrasonicOToUDelay",
|
|
@@ -757,7 +763,7 @@ function occupancy(args) {
|
|
|
757
763
|
}));
|
|
758
764
|
attributesForReading.push("ultrasonicOToUDelay");
|
|
759
765
|
}
|
|
760
|
-
if (
|
|
766
|
+
if (pirConfig.includes("uto_delay")) {
|
|
761
767
|
settingsExtends.push(numeric({
|
|
762
768
|
name: "ultrasonic_uto_delay",
|
|
763
769
|
attribute: "ultrasonicUToODelay",
|
|
@@ -767,7 +773,7 @@ function occupancy(args) {
|
|
|
767
773
|
}));
|
|
768
774
|
attributesForReading.push("ultrasonicUToODelay");
|
|
769
775
|
}
|
|
770
|
-
if (
|
|
776
|
+
if (pirConfig.includes("uto_threshold")) {
|
|
771
777
|
settingsExtends.push(numeric({
|
|
772
778
|
name: "ultrasonic_uto_threshold",
|
|
773
779
|
attribute: "ultrasonicUToOThreshold",
|
|
@@ -778,8 +784,8 @@ function occupancy(args) {
|
|
|
778
784
|
attributesForReading.push("ultrasonicUToOThreshold");
|
|
779
785
|
}
|
|
780
786
|
}
|
|
781
|
-
if (
|
|
782
|
-
if (
|
|
787
|
+
if (contactConfig) {
|
|
788
|
+
if (pirConfig.includes("otu_delay")) {
|
|
783
789
|
settingsExtends.push(numeric({
|
|
784
790
|
name: "contact_otu_delay",
|
|
785
791
|
attribute: "contactOToUDelay",
|
|
@@ -789,7 +795,7 @@ function occupancy(args) {
|
|
|
789
795
|
}));
|
|
790
796
|
attributesForReading.push("contactOToUDelay");
|
|
791
797
|
}
|
|
792
|
-
if (
|
|
798
|
+
if (pirConfig.includes("uto_delay")) {
|
|
793
799
|
settingsExtends.push(numeric({
|
|
794
800
|
name: "contact_uto_delay",
|
|
795
801
|
attribute: "contactUToODelay",
|
|
@@ -799,7 +805,7 @@ function occupancy(args) {
|
|
|
799
805
|
}));
|
|
800
806
|
attributesForReading.push("contactUToODelay");
|
|
801
807
|
}
|
|
802
|
-
if (
|
|
808
|
+
if (pirConfig.includes("uto_threshold")) {
|
|
803
809
|
settingsExtends.push(numeric({
|
|
804
810
|
name: "contact_uto_threshold",
|
|
805
811
|
attribute: "contactUToOThreshold",
|
|
@@ -815,13 +821,17 @@ function occupancy(args) {
|
|
|
815
821
|
settingsExtends.map((extend) => toZigbee.push(...extend.toZigbee));
|
|
816
822
|
const configure = [];
|
|
817
823
|
if (attributesForReading.length > 0)
|
|
818
|
-
configure.push(setupConfigureForReading("msOccupancySensing", attributesForReading,
|
|
819
|
-
if (
|
|
820
|
-
configure.push(setupConfigureForReporting("msOccupancySensing", "occupancy",
|
|
824
|
+
configure.push(setupConfigureForReading("msOccupancySensing", attributesForReading, endpointNames));
|
|
825
|
+
if (reporting) {
|
|
826
|
+
configure.push(setupConfigureForReporting("msOccupancySensing", "occupancy", {
|
|
827
|
+
config: reportingConfig,
|
|
828
|
+
access: exposes_1.access.STATE_GET,
|
|
829
|
+
endpointNames: endpointNames,
|
|
830
|
+
}));
|
|
821
831
|
}
|
|
822
832
|
return { exposes, fromZigbee, toZigbee, configure, isModernExtend: true };
|
|
823
833
|
}
|
|
824
|
-
function co2(args) {
|
|
834
|
+
function co2(args = {}) {
|
|
825
835
|
return numeric({
|
|
826
836
|
name: "co2",
|
|
827
837
|
cluster: "msCO2",
|
|
@@ -835,7 +845,7 @@ function co2(args) {
|
|
|
835
845
|
...args,
|
|
836
846
|
});
|
|
837
847
|
}
|
|
838
|
-
function pm25(args) {
|
|
848
|
+
function pm25(args = {}) {
|
|
839
849
|
return numeric({
|
|
840
850
|
name: "pm25",
|
|
841
851
|
cluster: "pm25Measurement",
|
|
@@ -847,24 +857,24 @@ function pm25(args) {
|
|
|
847
857
|
...args,
|
|
848
858
|
});
|
|
849
859
|
}
|
|
850
|
-
function light(args) {
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
if (
|
|
854
|
-
|
|
860
|
+
function light(args = {}) {
|
|
861
|
+
const { effect = true, powerOnBehavior = true, configureReporting = false, ota = false, color = undefined, levelConfig = undefined, turnsOffAtBrightness1 = false, endpointNames = undefined, levelReportingConfig = undefined, } = args;
|
|
862
|
+
let { colorTemp = undefined } = args;
|
|
863
|
+
if (colorTemp) {
|
|
864
|
+
colorTemp = { startup: true, ...colorTemp };
|
|
855
865
|
}
|
|
856
|
-
const argsColor =
|
|
866
|
+
const argsColor = color
|
|
857
867
|
? {
|
|
858
868
|
modes: ["xy"],
|
|
859
869
|
applyRedFix: false,
|
|
860
870
|
enhancedHue: true,
|
|
861
|
-
...((0, utils_1.isObject)(
|
|
871
|
+
...((0, utils_1.isObject)(color) ? color : {}),
|
|
862
872
|
}
|
|
863
873
|
: false;
|
|
864
|
-
const lightExpose = (0, utils_1.exposeEndpoints)(exposes_1.presets.light().withBrightness(),
|
|
874
|
+
const lightExpose = (0, utils_1.exposeEndpoints)(exposes_1.presets.light().withBrightness(), endpointNames);
|
|
865
875
|
const fromZigbee = [fz.on_off, fz.brightness, fz.ignore_basic_report, fz.level_config];
|
|
866
876
|
const toZigbee = [
|
|
867
|
-
|
|
877
|
+
endpointNames ? { ...tz.light_onoff_brightness, endpoints: endpointNames } : tz.light_onoff_brightness,
|
|
868
878
|
tz.ignore_transition,
|
|
869
879
|
tz.level_config,
|
|
870
880
|
tz.ignore_rate,
|
|
@@ -872,24 +882,24 @@ function light(args) {
|
|
|
872
882
|
tz.light_brightness_step,
|
|
873
883
|
];
|
|
874
884
|
const meta = {};
|
|
875
|
-
if (
|
|
885
|
+
if (colorTemp || argsColor) {
|
|
876
886
|
fromZigbee.push(fz.color_colortemp);
|
|
877
|
-
if (
|
|
887
|
+
if (colorTemp && argsColor)
|
|
878
888
|
toZigbee.push(tz.light_color_colortemp);
|
|
879
|
-
else if (
|
|
889
|
+
else if (colorTemp)
|
|
880
890
|
toZigbee.push(tz.light_colortemp);
|
|
881
891
|
else if (argsColor)
|
|
882
892
|
toZigbee.push(tz.light_color);
|
|
883
893
|
toZigbee.push(tz.light_color_mode, tz.light_color_options);
|
|
884
894
|
}
|
|
885
|
-
if (
|
|
895
|
+
if (colorTemp) {
|
|
886
896
|
// biome-ignore lint/complexity/noForEach: ignored using `--suppress`
|
|
887
|
-
lightExpose.forEach((e) => e.withColorTemp(
|
|
897
|
+
lightExpose.forEach((e) => e.withColorTemp(colorTemp.range));
|
|
888
898
|
toZigbee.push(tz.light_colortemp_move, tz.light_colortemp_step);
|
|
889
|
-
if (
|
|
899
|
+
if (colorTemp.startup) {
|
|
890
900
|
toZigbee.push(tz.light_colortemp_startup);
|
|
891
901
|
// biome-ignore lint/complexity/noForEach: ignored using `--suppress`
|
|
892
|
-
lightExpose.forEach((e) => e.withColorTempStartup(
|
|
902
|
+
lightExpose.forEach((e) => e.withColorTempStartup(colorTemp.range));
|
|
893
903
|
}
|
|
894
904
|
}
|
|
895
905
|
if (argsColor) {
|
|
@@ -906,37 +916,37 @@ function light(args) {
|
|
|
906
916
|
meta.supportsEnhancedHue = false;
|
|
907
917
|
}
|
|
908
918
|
}
|
|
909
|
-
if (
|
|
919
|
+
if (levelConfig) {
|
|
910
920
|
// biome-ignore lint/complexity/noForEach: ignored using `--suppress`
|
|
911
|
-
lightExpose.forEach((e) => e.withLevelConfig(
|
|
921
|
+
lightExpose.forEach((e) => e.withLevelConfig(levelConfig.disabledFeatures ?? []));
|
|
912
922
|
toZigbee.push(tz.level_config);
|
|
913
923
|
}
|
|
914
924
|
const exposes = lightExpose;
|
|
915
|
-
if (
|
|
925
|
+
if (effect) {
|
|
916
926
|
const effects = exposes_1.presets.effect();
|
|
917
|
-
if (
|
|
927
|
+
if (color) {
|
|
918
928
|
effects.values.push("colorloop", "stop_colorloop");
|
|
919
929
|
}
|
|
920
|
-
exposes.push(...(0, utils_1.exposeEndpoints)(effects,
|
|
930
|
+
exposes.push(...(0, utils_1.exposeEndpoints)(effects, endpointNames));
|
|
921
931
|
toZigbee.push(tz.effect);
|
|
922
932
|
}
|
|
923
|
-
if (
|
|
924
|
-
exposes.push(...(0, utils_1.exposeEndpoints)(exposes_1.presets.power_on_behavior(["off", "on", "toggle", "previous"]),
|
|
933
|
+
if (powerOnBehavior) {
|
|
934
|
+
exposes.push(...(0, utils_1.exposeEndpoints)(exposes_1.presets.power_on_behavior(["off", "on", "toggle", "previous"]), endpointNames));
|
|
925
935
|
fromZigbee.push(fz.power_on_behavior);
|
|
926
936
|
toZigbee.push(tz.power_on_behavior);
|
|
927
937
|
}
|
|
928
|
-
if (
|
|
929
|
-
meta.turnsOffAtBrightness1 =
|
|
938
|
+
if (turnsOffAtBrightness1) {
|
|
939
|
+
meta.turnsOffAtBrightness1 = turnsOffAtBrightness1;
|
|
930
940
|
}
|
|
931
941
|
const configure = [
|
|
932
942
|
async (device, coordinatorEndpoint, definition) => {
|
|
933
943
|
await (0, light_1.configure)(device, coordinatorEndpoint, true);
|
|
934
|
-
if (
|
|
944
|
+
if (configureReporting) {
|
|
935
945
|
await setupAttributes(device, coordinatorEndpoint, "genOnOff", [{ attribute: "onOff", min: "MIN", max: "MAX", change: 1 }]);
|
|
936
946
|
await setupAttributes(device, coordinatorEndpoint, "genLevelCtrl", [
|
|
937
|
-
{ attribute: "currentLevel", min: "5_SECONDS", max: "MAX", change: 1, ...(
|
|
947
|
+
{ attribute: "currentLevel", min: "5_SECONDS", max: "MAX", change: 1, ...(levelReportingConfig || {}) },
|
|
938
948
|
]);
|
|
939
|
-
if (
|
|
949
|
+
if (colorTemp) {
|
|
940
950
|
await setupAttributes(device, coordinatorEndpoint, "lightingColorCtrl", [
|
|
941
951
|
{ attribute: "colorTemperature", min: "10_SECONDS", max: "MAX", change: 1 },
|
|
942
952
|
]);
|
|
@@ -956,66 +966,56 @@ function light(args) {
|
|
|
956
966
|
(0, utils_1.configureSetPowerSourceWhenUnknown)("Mains (single phase)"),
|
|
957
967
|
];
|
|
958
968
|
const result = { exposes, fromZigbee, toZigbee, configure, meta, isModernExtend: true };
|
|
959
|
-
if (
|
|
960
|
-
result.ota =
|
|
969
|
+
if (ota)
|
|
970
|
+
result.ota = ota;
|
|
961
971
|
return result;
|
|
962
972
|
}
|
|
963
|
-
function commandsLevelCtrl(args) {
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
...args,
|
|
976
|
-
};
|
|
977
|
-
let actions = args.commands;
|
|
978
|
-
if (args.endpointNames) {
|
|
979
|
-
actions = args.commands.flatMap((c) => args.endpointNames.map((e) => `${c}_${e}`));
|
|
973
|
+
function commandsLevelCtrl(args = {}) {
|
|
974
|
+
const { commands = [
|
|
975
|
+
"brightness_move_to_level",
|
|
976
|
+
"brightness_move_up",
|
|
977
|
+
"brightness_move_down",
|
|
978
|
+
"brightness_step_up",
|
|
979
|
+
"brightness_step_down",
|
|
980
|
+
"brightness_stop",
|
|
981
|
+
], bind = true, endpointNames = undefined, } = args;
|
|
982
|
+
let actions = commands;
|
|
983
|
+
if (endpointNames) {
|
|
984
|
+
actions = commands.flatMap((c) => endpointNames.map((e) => `${c}_${e}`));
|
|
980
985
|
}
|
|
981
986
|
const exposes = [
|
|
982
987
|
exposes_1.presets.enum("action", exposes_1.access.STATE, actions).withDescription("Triggered action (e.g. a button click)").withCategory("diagnostic"),
|
|
983
988
|
];
|
|
984
989
|
const fromZigbee = [fz.command_move_to_level, fz.command_move, fz.command_step, fz.command_stop];
|
|
985
990
|
const result = { exposes, fromZigbee, isModernExtend: true };
|
|
986
|
-
if (
|
|
987
|
-
result.configure = [setupConfigureForBinding("genLevelCtrl", "output",
|
|
991
|
+
if (bind)
|
|
992
|
+
result.configure = [setupConfigureForBinding("genLevelCtrl", "output", endpointNames)];
|
|
988
993
|
return result;
|
|
989
994
|
}
|
|
990
|
-
function commandsColorCtrl(args) {
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
...args,
|
|
1015
|
-
};
|
|
1016
|
-
let actions = args.commands;
|
|
1017
|
-
if (args.endpointNames) {
|
|
1018
|
-
actions = args.commands.flatMap((c) => args.endpointNames.map((e) => `${c}_${e}`));
|
|
995
|
+
function commandsColorCtrl(args = {}) {
|
|
996
|
+
const { commands = [
|
|
997
|
+
"color_temperature_move_stop",
|
|
998
|
+
"color_temperature_move_up",
|
|
999
|
+
"color_temperature_move_down",
|
|
1000
|
+
"color_temperature_step_up",
|
|
1001
|
+
"color_temperature_step_down",
|
|
1002
|
+
"enhanced_move_to_hue_and_saturation",
|
|
1003
|
+
"move_to_hue_and_saturation",
|
|
1004
|
+
"color_hue_step_up",
|
|
1005
|
+
"color_hue_step_down",
|
|
1006
|
+
"color_saturation_step_up",
|
|
1007
|
+
"color_saturation_step_down",
|
|
1008
|
+
"color_loop_set",
|
|
1009
|
+
"color_temperature_move",
|
|
1010
|
+
"color_move",
|
|
1011
|
+
"hue_move",
|
|
1012
|
+
"hue_stop",
|
|
1013
|
+
"move_to_saturation",
|
|
1014
|
+
"move_to_hue",
|
|
1015
|
+
], bind = true, endpointNames = undefined, } = args;
|
|
1016
|
+
let actions = commands;
|
|
1017
|
+
if (endpointNames) {
|
|
1018
|
+
actions = commands.flatMap((c) => endpointNames.map((e) => `${c}_${e}`));
|
|
1019
1019
|
}
|
|
1020
1020
|
const exposes = [
|
|
1021
1021
|
exposes_1.presets.enum("action", exposes_1.access.STATE, actions).withDescription("Triggered action (e.g. a button click)").withCategory("diagnostic"),
|
|
@@ -1035,8 +1035,8 @@ function commandsColorCtrl(args) {
|
|
|
1035
1035
|
fz.command_move_to_hue,
|
|
1036
1036
|
];
|
|
1037
1037
|
const result = { exposes, fromZigbee, isModernExtend: true };
|
|
1038
|
-
if (
|
|
1039
|
-
result.configure = [setupConfigureForBinding("lightingColorCtrl", "output",
|
|
1038
|
+
if (bind)
|
|
1039
|
+
result.configure = [setupConfigureForBinding("lightingColorCtrl", "output", endpointNames)];
|
|
1040
1040
|
return result;
|
|
1041
1041
|
}
|
|
1042
1042
|
function lightingBallast() {
|
|
@@ -1059,16 +1059,9 @@ function lightingBallast() {
|
|
|
1059
1059
|
return result;
|
|
1060
1060
|
}
|
|
1061
1061
|
function lock(args) {
|
|
1062
|
-
|
|
1063
|
-
args = { ...args };
|
|
1062
|
+
const { endpointNames = undefined, pinCodeCount } = args;
|
|
1064
1063
|
const fromZigbee = [fz.lock, fz.lock_operation_event, fz.lock_programming_event, fz.lock_pin_code_response, fz.lock_user_status_response];
|
|
1065
|
-
const toZigbee = [
|
|
1066
|
-
{ ...tz.lock, endpoints: args?.endpointNames },
|
|
1067
|
-
tz.pincode_lock,
|
|
1068
|
-
tz.lock_userstatus,
|
|
1069
|
-
tz.lock_auto_relock_time,
|
|
1070
|
-
tz.lock_sound_volume,
|
|
1071
|
-
];
|
|
1064
|
+
const toZigbee = [{ ...tz.lock, endpoints: endpointNames }, tz.pincode_lock, tz.lock_userstatus, tz.lock_auto_relock_time, tz.lock_sound_volume];
|
|
1072
1065
|
const exposes = [
|
|
1073
1066
|
exposes_1.presets.lock(),
|
|
1074
1067
|
exposes_1.presets.pincode(),
|
|
@@ -1079,60 +1072,64 @@ function lock(args) {
|
|
|
1079
1072
|
exposes_1.presets.sound_volume(),
|
|
1080
1073
|
];
|
|
1081
1074
|
const configure = [
|
|
1082
|
-
setupConfigureForReporting("closuresDoorLock", "lockState", { min: "MIN", max: "1_HOUR", change: 0 }, exposes_1.access.STATE_GET),
|
|
1075
|
+
setupConfigureForReporting("closuresDoorLock", "lockState", { config: { min: "MIN", max: "1_HOUR", change: 0 }, access: exposes_1.access.STATE_GET }),
|
|
1083
1076
|
];
|
|
1084
|
-
const meta = { pinCodeCount:
|
|
1077
|
+
const meta = { pinCodeCount: pinCodeCount };
|
|
1085
1078
|
const result = { fromZigbee, toZigbee, exposes, configure, meta, isModernExtend: true };
|
|
1086
|
-
if (
|
|
1087
|
-
result.exposes = (0, utils_1.flatten)(exposes.map((expose) =>
|
|
1079
|
+
if (endpointNames) {
|
|
1080
|
+
result.exposes = (0, utils_1.flatten)(exposes.map((expose) => endpointNames.map((endpoint) => expose.clone().withEndpoint(endpoint))));
|
|
1088
1081
|
}
|
|
1089
1082
|
return result;
|
|
1090
1083
|
}
|
|
1091
1084
|
function windowCovering(args) {
|
|
1092
|
-
|
|
1093
|
-
args = { stateSource: "lift", configureReporting: true, ...args };
|
|
1085
|
+
const { stateSource = "lift", configureReporting = true, controls, coverInverted = false, coverMode, endpointNames = undefined } = args;
|
|
1094
1086
|
let coverExpose = exposes_1.presets.cover();
|
|
1095
|
-
if (
|
|
1087
|
+
if (controls.includes("lift"))
|
|
1096
1088
|
coverExpose = coverExpose.withPosition();
|
|
1097
|
-
if (
|
|
1089
|
+
if (controls.includes("tilt"))
|
|
1098
1090
|
coverExpose = coverExpose.withTilt();
|
|
1099
1091
|
const exposes = [coverExpose];
|
|
1100
1092
|
const fromZigbee = [fz.cover_position_tilt];
|
|
1101
|
-
const toZigbee = [{ ...tz.cover_state, endpoints:
|
|
1093
|
+
const toZigbee = [{ ...tz.cover_state, endpoints: endpointNames }, tz.cover_position_tilt];
|
|
1102
1094
|
const result = { exposes, fromZigbee, toZigbee, isModernExtend: true };
|
|
1103
|
-
if (
|
|
1095
|
+
if (configureReporting) {
|
|
1104
1096
|
const configure = [];
|
|
1105
|
-
if (
|
|
1106
|
-
configure.push(setupConfigureForReporting("closuresWindowCovering", "currentPositionLiftPercentage", {
|
|
1097
|
+
if (controls.includes("lift")) {
|
|
1098
|
+
configure.push(setupConfigureForReporting("closuresWindowCovering", "currentPositionLiftPercentage", {
|
|
1099
|
+
config: { min: "1_SECOND", max: "MAX", change: 1 },
|
|
1100
|
+
access: exposes_1.access.STATE_GET,
|
|
1101
|
+
}));
|
|
1107
1102
|
}
|
|
1108
|
-
if (
|
|
1109
|
-
configure.push(setupConfigureForReporting("closuresWindowCovering", "currentPositionTiltPercentage", {
|
|
1103
|
+
if (controls.includes("tilt")) {
|
|
1104
|
+
configure.push(setupConfigureForReporting("closuresWindowCovering", "currentPositionTiltPercentage", {
|
|
1105
|
+
config: { min: "1_SECOND", max: "MAX", change: 1 },
|
|
1106
|
+
access: exposes_1.access.STATE_GET,
|
|
1107
|
+
}));
|
|
1110
1108
|
}
|
|
1111
1109
|
result.configure = configure;
|
|
1112
1110
|
}
|
|
1113
|
-
if (
|
|
1111
|
+
if (coverInverted || stateSource === "tilt") {
|
|
1114
1112
|
const meta = {};
|
|
1115
|
-
if (
|
|
1113
|
+
if (coverInverted)
|
|
1116
1114
|
meta.coverInverted = true;
|
|
1117
|
-
if (
|
|
1115
|
+
if (stateSource === "tilt")
|
|
1118
1116
|
meta.coverStateFromTilt = true;
|
|
1119
1117
|
result.meta = meta;
|
|
1120
1118
|
}
|
|
1121
|
-
if (
|
|
1119
|
+
if (coverMode) {
|
|
1122
1120
|
result.toZigbee.push(tz.cover_mode);
|
|
1123
1121
|
result.exposes.push(exposes_1.presets.cover_mode());
|
|
1124
1122
|
}
|
|
1125
|
-
if (
|
|
1126
|
-
result.exposes = (0, utils_1.flatten)(exposes.map((expose) =>
|
|
1123
|
+
if (endpointNames) {
|
|
1124
|
+
result.exposes = (0, utils_1.flatten)(exposes.map((expose) => endpointNames.map((endpoint) => expose.clone().withEndpoint(endpoint))));
|
|
1127
1125
|
}
|
|
1128
1126
|
return result;
|
|
1129
1127
|
}
|
|
1130
|
-
function commandsWindowCovering(args) {
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
actions = args.commands.flatMap((c) => args.endpointNames.map((e) => `${c}_${e}`));
|
|
1128
|
+
function commandsWindowCovering(args = {}) {
|
|
1129
|
+
const { commands = ["open", "close", "stop"], bind = true, endpointNames = undefined } = args;
|
|
1130
|
+
let actions = commands;
|
|
1131
|
+
if (endpointNames) {
|
|
1132
|
+
actions = commands.flatMap((c) => endpointNames.map((e) => `${c}_${e}`));
|
|
1136
1133
|
}
|
|
1137
1134
|
const exposes = [
|
|
1138
1135
|
exposes_1.presets.enum("action", exposes_1.access.STATE, actions).withDescription("Triggered action (e.g. a button click)").withCategory("diagnostic"),
|
|
@@ -1156,8 +1153,8 @@ function commandsWindowCovering(args) {
|
|
|
1156
1153
|
},
|
|
1157
1154
|
];
|
|
1158
1155
|
const result = { exposes, fromZigbee, isModernExtend: true };
|
|
1159
|
-
if (
|
|
1160
|
-
result.configure = [setupConfigureForBinding("closuresWindowCovering", "output",
|
|
1156
|
+
if (bind)
|
|
1157
|
+
result.configure = [setupConfigureForBinding("closuresWindowCovering", "output", endpointNames)];
|
|
1161
1158
|
return result;
|
|
1162
1159
|
}
|
|
1163
1160
|
function iasZoneAlarm(args) {
|
|
@@ -1302,7 +1299,8 @@ function iasZoneAlarm(args) {
|
|
|
1302
1299
|
}
|
|
1303
1300
|
return { fromZigbee, exposes, isModernExtend: true, ...(configure && { configure }) };
|
|
1304
1301
|
}
|
|
1305
|
-
function iasWarning(args) {
|
|
1302
|
+
function iasWarning(args = {}) {
|
|
1303
|
+
const { reversePayload = false } = args;
|
|
1306
1304
|
const warningMode = { stop: 0, burglar: 1, fire: 2, emergency: 3, police_panic: 4, fire_panic: 5, emergency_panic: 6 };
|
|
1307
1305
|
// levels for siren, strobe and squawk are identical
|
|
1308
1306
|
const level = { low: 0, medium: 1, high: 2, very_high: 3 };
|
|
@@ -1336,7 +1334,7 @@ function iasWarning(args) {
|
|
|
1336
1334
|
};
|
|
1337
1335
|
// biome-ignore lint/suspicious/noImplicitAnyLet: ignored using `--suppress`
|
|
1338
1336
|
let info;
|
|
1339
|
-
if (
|
|
1337
|
+
if (reversePayload) {
|
|
1340
1338
|
info = (0, utils_1.getFromLookup)(values.mode, warningMode) + ((values.strobe ? 1 : 0) << 4) + ((0, utils_1.getFromLookup)(values.level, level) << 6);
|
|
1341
1339
|
}
|
|
1342
1340
|
else {
|
|
@@ -1354,7 +1352,7 @@ function iasWarning(args) {
|
|
|
1354
1352
|
];
|
|
1355
1353
|
return { toZigbee, exposes, isModernExtend: true };
|
|
1356
1354
|
}
|
|
1357
|
-
function genericMeter(args) {
|
|
1355
|
+
function genericMeter(args = {}) {
|
|
1358
1356
|
if (args.cluster !== "electrical") {
|
|
1359
1357
|
const divisors = new Set([
|
|
1360
1358
|
args.cluster === "metering" && (0, utils_1.isObject)(args.power) ? args.power?.divisor : false,
|
|
@@ -1739,9 +1737,8 @@ function genericMeter(args) {
|
|
|
1739
1737
|
}
|
|
1740
1738
|
return result;
|
|
1741
1739
|
}
|
|
1742
|
-
function electricityMeter(args) {
|
|
1743
|
-
|
|
1744
|
-
args = {
|
|
1740
|
+
function electricityMeter(args = {}) {
|
|
1741
|
+
return genericMeter({
|
|
1745
1742
|
type: "electricity",
|
|
1746
1743
|
cluster: "both",
|
|
1747
1744
|
electricalMeasurementType: "ac",
|
|
@@ -1753,12 +1750,10 @@ function electricityMeter(args) {
|
|
|
1753
1750
|
status: false,
|
|
1754
1751
|
extendedStatus: false,
|
|
1755
1752
|
...args,
|
|
1756
|
-
};
|
|
1757
|
-
return genericMeter(args);
|
|
1753
|
+
});
|
|
1758
1754
|
}
|
|
1759
|
-
function gasMeter(args) {
|
|
1760
|
-
|
|
1761
|
-
args = {
|
|
1755
|
+
function gasMeter(args = {}) {
|
|
1756
|
+
return genericMeter({
|
|
1762
1757
|
type: "gas",
|
|
1763
1758
|
cluster: "metering",
|
|
1764
1759
|
configureReporting: true,
|
|
@@ -1766,8 +1761,7 @@ function gasMeter(args) {
|
|
|
1766
1761
|
extendedStatus: true,
|
|
1767
1762
|
producedEnergy: false,
|
|
1768
1763
|
...args,
|
|
1769
|
-
};
|
|
1770
|
-
return genericMeter(args);
|
|
1764
|
+
});
|
|
1771
1765
|
}
|
|
1772
1766
|
// #endregion
|
|
1773
1767
|
// #region Other extends
|
|
@@ -1877,13 +1871,12 @@ function genericGreenPower() {
|
|
|
1877
1871
|
];
|
|
1878
1872
|
return { exposes, fromZigbee, isModernExtend: true };
|
|
1879
1873
|
}
|
|
1880
|
-
function commandsScenes(args) {
|
|
1881
|
-
|
|
1882
|
-
args = { commands: ["recall", "store", "add", "remove", "remove_all"], bind: true, ...args };
|
|
1874
|
+
function commandsScenes(args = {}) {
|
|
1875
|
+
const { commands = ["recall", "store", "add", "remove", "remove_all"], bind = true, endpointNames = undefined } = args;
|
|
1883
1876
|
// biome-ignore lint/style/noNonNullAssertion: ignored using `--suppress`
|
|
1884
|
-
let actions =
|
|
1885
|
-
if (
|
|
1886
|
-
actions =
|
|
1877
|
+
let actions = commands;
|
|
1878
|
+
if (endpointNames) {
|
|
1879
|
+
actions = commands.flatMap((c) => endpointNames.map((e) => `${c}_${e}`));
|
|
1887
1880
|
}
|
|
1888
1881
|
const exposesArray = [exposes_1.presets.enum("action", exposes_1.access.STATE, actions).withDescription("Triggered scene action (e.g. recall a scene)")];
|
|
1889
1882
|
const actionPayloadLookup = {
|
|
@@ -1913,8 +1906,8 @@ function commandsScenes(args) {
|
|
|
1913
1906
|
},
|
|
1914
1907
|
];
|
|
1915
1908
|
const result = { exposes: exposesArray, fromZigbee, isModernExtend: true };
|
|
1916
|
-
if (
|
|
1917
|
-
result.configure = [setupConfigureForBinding("genScenes", "output",
|
|
1909
|
+
if (bind)
|
|
1910
|
+
result.configure = [setupConfigureForBinding("genScenes", "output", endpointNames)];
|
|
1918
1911
|
return result;
|
|
1919
1912
|
}
|
|
1920
1913
|
function enumLookup(args) {
|
|
@@ -1961,7 +1954,7 @@ function enumLookup(args) {
|
|
|
1961
1954
|
: undefined,
|
|
1962
1955
|
},
|
|
1963
1956
|
];
|
|
1964
|
-
const configure = [setupConfigureForReporting(cluster, attribute, reporting, access)];
|
|
1957
|
+
const configure = [setupConfigureForReporting(cluster, attribute, { config: reporting, access })];
|
|
1965
1958
|
return { exposes: [expose], fromZigbee, toZigbee, configure, isModernExtend: true };
|
|
1966
1959
|
}
|
|
1967
1960
|
function numeric(args) {
|
|
@@ -2050,7 +2043,7 @@ function numeric(args) {
|
|
|
2050
2043
|
: undefined,
|
|
2051
2044
|
},
|
|
2052
2045
|
];
|
|
2053
|
-
const configure = [setupConfigureForReporting(cluster, attribute, reporting, access, endpoints)];
|
|
2046
|
+
const configure = [setupConfigureForReporting(cluster, attribute, { config: reporting, access, endpointNames: endpoints })];
|
|
2054
2047
|
return { exposes, fromZigbee, toZigbee, configure, isModernExtend: true };
|
|
2055
2048
|
}
|
|
2056
2049
|
function binary(args) {
|
|
@@ -2095,7 +2088,7 @@ function binary(args) {
|
|
|
2095
2088
|
: undefined,
|
|
2096
2089
|
},
|
|
2097
2090
|
];
|
|
2098
|
-
const configure = [setupConfigureForReporting(cluster, attribute, reporting, access)];
|
|
2091
|
+
const configure = [setupConfigureForReporting(cluster, attribute, { config: reporting, access })];
|
|
2099
2092
|
return { exposes: [expose], fromZigbee, toZigbee, configure, isModernExtend: true };
|
|
2100
2093
|
}
|
|
2101
2094
|
function text(args) {
|
|
@@ -2136,7 +2129,7 @@ function text(args) {
|
|
|
2136
2129
|
: undefined,
|
|
2137
2130
|
},
|
|
2138
2131
|
];
|
|
2139
|
-
const configure = [setupConfigureForReporting(cluster, attribute, reporting, access)];
|
|
2132
|
+
const configure = [setupConfigureForReporting(cluster, attribute, { config: reporting, access })];
|
|
2140
2133
|
return { exposes: [expose], fromZigbee, toZigbee, configure, isModernExtend: true };
|
|
2141
2134
|
}
|
|
2142
2135
|
function actionEnumLookup(args) {
|