forked from Koenkk/zigbee-herdsman-converters
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathniko.ts
610 lines (600 loc) · 30 KB
/
niko.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
import {Zcl} from "zigbee-herdsman";
import * as fz from "../converters/fromZigbee";
import * as tz from "../converters/toZigbee";
import * as exposes from "../lib/exposes";
import {deviceAddCustomCluster} from "../lib/modernExtend";
import * as reporting from "../lib/reporting";
import type {DefinitionWithExtend, Fz, KeyValue, Tz} from "../lib/types";
import * as utils from "../lib/utils";
const e = exposes.presets;
const ea = exposes.access;
const local = {
modernExtend: {
addCustomClusterManuSpecificNikoConfig: () =>
deviceAddCustomCluster("manuSpecificNikoConfig", {
ID: 0xfc00,
manufacturerCode: Zcl.ManufacturerCode.NIKO_NV,
attributes: {
/* WARNING: 0x0000 has different datatypes!
* enum8 (switch) vs. bitmap8 (outlet)
* unknown usage/function on outlet
*/
switchOperationMode: {ID: 0x0000, type: Zcl.DataType.ENUM8},
outletLedColor: {ID: 0x0100, type: Zcl.DataType.UINT24},
outletChildLock: {ID: 0x0101, type: Zcl.DataType.UINT8},
outletLedState: {ID: 0x0104, type: Zcl.DataType.UINT8},
/* WARNING: 0x0107 is not supported on older switches */
ledSyncMode: {ID: 0x0107, type: Zcl.DataType.BITMAP32},
},
commands: {},
commandsResponse: {},
}),
addCustomClusterManuSpecificNikoState: () =>
deviceAddCustomCluster("manuSpecificNikoState", {
ID: 0xfc01,
manufacturerCode: Zcl.ManufacturerCode.NIKO_NV,
attributes: {
switchActionReporting: {ID: 0x0001, type: Zcl.DataType.BITMAP8},
switchAction: {ID: 0x0002, type: Zcl.DataType.UINT8},
},
commands: {},
commandsResponse: {},
}),
},
fz: {
switch_operation_mode: {
cluster: "manuSpecificNikoConfig",
type: ["attributeReport", "readResponse"],
convert: (model, msg, publish, options, meta) => {
const state: KeyValue = {};
if (msg.data.switchOperationMode !== undefined) {
const operationModeMap = {2: "control_relay", 1: "decoupled", 0: "unknown"};
state.operation_mode = utils.getFromLookup(msg.data.switchOperationMode, operationModeMap);
}
return state;
},
} satisfies Fz.Converter,
switch_action: {
cluster: "manuSpecificNikoState",
type: ["attributeReport", "readResponse"],
convert: (model, msg, publish, options, meta) => {
const state: KeyValue = {};
if (msg.data.switchActionReporting !== undefined) {
const actionReportingMap: KeyValue = {0: false, 31: true};
state.action_reporting = utils.getFromLookup(msg.data.switchActionReporting, actionReportingMap);
}
if (msg.data.switchAction !== undefined) {
// NOTE: a single press = two separate values reported, 16 followed by 64
// a hold/release cycle = three separate values, 16, 32, and 48
// https://github.com/Koenkk/zigbee2mqtt/issues/13737#issuecomment-1520002786
const buttonShift: {[key: string]: number} =
model.model === "552-721X1"
? {
"": 4,
ext: 8,
}
: {
left: 4,
left_ext: 8,
right: 12,
right_ext: 16,
};
const actions: {[key: string]: number} = {
single: 4,
hold: 2,
release: 3,
};
for (const button in buttonShift) {
const shiftedValue = (msg.data.switchAction >> buttonShift[button]) & 0xf;
for (const action in actions) {
if (shiftedValue === actions[action]) {
const buttonPostFix = button === "" ? "" : `_${button}`;
const value = action + buttonPostFix;
publish({action: value});
}
}
}
}
},
} satisfies Fz.Converter,
switch_status_led: {
cluster: "manuSpecificNikoConfig",
type: ["attributeReport", "readResponse"],
convert: (model, msg, publish, options, meta) => {
const state: KeyValue = {};
if (msg.data.outletLedState !== undefined) {
state.led_enable = msg.data.outletLedState === 1;
}
if (msg.data.outletLedColor !== undefined) {
const ledStateMap: KeyValue = {0: "OFF", 255: "ON", 65280: "Blue", 16711680: "Red", 16777215: "Purple"};
state.led_state = utils.getFromLookup(msg.data.outletLedColor, ledStateMap);
}
if (msg.data.ledSyncMode !== undefined) {
const ledSyncMap: {[key: number]: string} = {0: "Off", 1: "On", 2: "Inverted"};
if (model.meta.multiEndpoint) {
const endpointOffsetMap: {[key: string]: number} = {l1: 0, l2: 1};
for (const ep in endpointOffsetMap) {
const shift = endpointOffsetMap[ep] * 4;
const mask = 0xf << shift;
const result = (msg.data.ledSyncMode & mask) >> shift;
state[`led_sync_mode_${ep}`] = utils.getFromLookup(result, ledSyncMap);
}
} else {
state.led_sync_mode = utils.getFromLookup(msg.data.ledSyncMode, ledSyncMap);
}
}
return state;
},
} satisfies Fz.Converter,
outlet: {
cluster: "manuSpecificNikoConfig",
type: ["attributeReport", "readResponse"],
convert: (model, msg, publish, options, meta) => {
const state: KeyValue = {};
if (msg.data.outletChildLock !== undefined) {
state.child_lock = msg.data.outletChildLock === 0 ? "LOCK" : "UNLOCK";
}
if (msg.data.outletLedState !== undefined) {
state.led_enable = msg.data.outletLedState === 1;
}
return state;
},
} satisfies Fz.Converter,
},
tz: {
switch_operation_mode: {
key: ["operation_mode"],
convertSet: async (entity, key, value, meta) => {
// WARN: while we can technically write 0x00 to the operationMode attribute
// this seems to brick the device and it will need to be rejoined
utils.assertEndpoint(entity);
const operationModeLookup = {control_relay: 0x02, decoupled: 0x01};
// @ts-expect-error ignore
if (operationModeLookup[value] === undefined) {
throw new Error(`operation_mode was called with an invalid value (${value})`);
}
await utils.enforceEndpoint(entity, key, meta).write(
"manuSpecificNikoConfig",
// @ts-expect-error ignore
{switchOperationMode: operationModeLookup[value]},
);
// @ts-expect-error ignore
return {state: {operation_mode: value.toLowerCase()}};
},
convertGet: async (entity, key, meta) => {
utils.assertEndpoint(entity);
await utils.enforceEndpoint(entity, key, meta).read("manuSpecificNikoConfig", ["switchOperationMode"]);
},
} satisfies Tz.Converter,
switch_action_reporting: {
key: ["action_reporting"],
convertSet: async (entity, key, value, meta) => {
const actionReportingMap: KeyValue = {false: 0x00, true: 0x1f};
// @ts-expect-error ignore
if (actionReportingMap[value] === undefined) {
throw new Error(`action_reporting was called with an invalid value (${value})`);
}
await entity.write(
"manuSpecificNikoState",
// @ts-expect-error ignore
{switchActionReporting: actionReportingMap[value]},
);
return {state: {action_reporting: value}};
},
convertGet: async (entity, key, meta) => {
await entity.read("manuSpecificNikoState", ["switchActionReporting"]);
},
} satisfies Tz.Converter,
switch_led_enable: {
key: ["led_enable"],
convertSet: async (entity, key, value, meta) => {
await entity.write("manuSpecificNikoConfig", {outletLedState: value ? 1 : 0});
await entity.read("manuSpecificNikoConfig", ["outletLedColor"]);
return {state: {led_enable: !!value}};
},
convertGet: async (entity, key, meta) => {
await entity.read("manuSpecificNikoConfig", ["outletLedState"]);
},
} satisfies Tz.Converter,
switch_led_state: {
key: ["led_state"],
convertSet: async (entity, key, value, meta) => {
const ledStateMap: KeyValue = {OFF: 0x00, ON: 0x0000ff, Blue: 0x00ff00, Red: 0xff0000, Purple: 0xffffff};
// @ts-expect-error ignore
if (ledStateMap[value] === undefined) {
throw new Error(`led_state was called with an invalid value (${value})`);
}
await entity.write(
"manuSpecificNikoConfig",
// @ts-expect-error ignore
{outletLedColor: ledStateMap[value]},
);
return {state: {led_state: value}};
},
convertGet: async (entity, key, meta) => {
await entity.read("manuSpecificNikoConfig", ["outletLedColor"]);
},
} satisfies Tz.Converter,
switch_led_sync_mode: {
key: ["led_sync_mode"],
convertSet: async (entity, key, value, meta) => {
const ledSyncMap: {[key: string]: number} = {Off: 0, On: 1, Inverted: 2};
// @ts-expect-error ignore
if (ledSyncMap[value] === undefined) {
throw new Error(`led_sync_mode was called with an invalid value (${value})`);
}
const endpointOffsetMap: {[key: string]: number} = {l1: 0, l2: 1};
let result = 0x00;
if (endpointOffsetMap[meta.endpoint_name] !== undefined) {
// combine states of all endpoints into single value to write to device
for (const ep in endpointOffsetMap) {
// @ts-expect-error ignore
const endpointState: number = ep === meta.endpoint_name ? value : meta.state[`led_sync_mode_${ep}`];
// @ts-expect-error ignore
const endpointValue = ledSyncMap[endpointState] === undefined ? ledSyncMap[value] : ledSyncMap[endpointState];
const shiftedValue = endpointValue << (endpointOffsetMap[ep] * 4);
result = result | shiftedValue;
}
} else {
// @ts-expect-error ignore
result = ledSyncMap[value];
}
await entity.write("manuSpecificNikoConfig", {ledSyncMode: result});
return {state: {led_sync_mode: value}};
},
convertGet: async (entity, key, meta) => {
await entity.read("manuSpecificNikoConfig", ["ledSyncMode"]);
},
} satisfies Tz.Converter,
outlet_child_lock: {
key: ["child_lock"],
convertSet: async (entity, key, value, meta) => {
utils.assertString(value, key);
await entity.write("manuSpecificNikoConfig", {outletChildLock: value.toLowerCase() === "lock" ? 0 : 1});
return {state: {child_lock: value.toLowerCase() === "lock" ? "LOCK" : "UNLOCK"}};
},
convertGet: async (entity, key, meta) => {
await entity.read("manuSpecificNikoConfig", ["outletChildLock"]);
},
} satisfies Tz.Converter,
outlet_led_enable: {
key: ["led_enable"],
convertSet: async (entity, key, value, meta) => {
await entity.write("manuSpecificNikoConfig", {outletLedState: value ? 1 : 0});
return {state: {led_enable: !!value}};
},
convertGet: async (entity, key, meta) => {
await entity.read("manuSpecificNikoConfig", ["outletLedState"]);
},
} satisfies Tz.Converter,
},
};
export const definitions: DefinitionWithExtend[] = [
{
zigbeeModel: ["Connected socket outlet"],
model: "170-33505/170-34605",
vendor: "Niko",
description: "Connected socket outlet",
fromZigbee: [fz.on_off, fz.electrical_measurement, fz.metering, local.fz.outlet],
toZigbee: [tz.on_off, tz.electrical_measurement_power, tz.currentsummdelivered, local.tz.outlet_child_lock, local.tz.outlet_led_enable],
extend: [local.modernExtend.addCustomClusterManuSpecificNikoConfig()],
configure: async (device, coordinatorEndpoint) => {
const endpoint = device.getEndpoint(1);
await reporting.bind(endpoint, coordinatorEndpoint, ["genOnOff", "haElectricalMeasurement", "seMetering"]);
await reporting.onOff(endpoint);
// NOTE: we read them individually, acFrequency* is not supported
// so we cannot use readEletricalMeasurementMultiplierDivisors
await endpoint.read("haElectricalMeasurement", ["acPowerMultiplier", "acPowerDivisor"]);
await reporting.activePower(endpoint, {min: 5, max: 3600, change: 1000});
await endpoint.read("haElectricalMeasurement", ["acCurrentDivisor", "acPowerMultiplier", "acPowerDivisor"]);
await reporting.rmsCurrent(endpoint, {min: 5, max: 3600, change: 100});
await endpoint.read("haElectricalMeasurement", ["acVoltageMultiplier", "acVoltageDivisor", "acCurrentMultiplier"]);
await reporting.rmsVoltage(endpoint, {min: 5, max: 3600, change: 100});
await reporting.readMeteringMultiplierDivisor(endpoint);
await reporting.currentSummDelivered(endpoint, {min: 60, change: 1});
await endpoint.read("manuSpecificNikoConfig", ["outletChildLock"]);
await endpoint.read("manuSpecificNikoConfig", ["outletLedState"]);
},
exposes: [
e.switch(),
e.power().withAccess(ea.STATE_GET),
e.current(),
e.voltage(),
e.energy().withAccess(ea.STATE_GET),
e.binary("child_lock", ea.ALL, "LOCK", "UNLOCK").withDescription("Enables/disables physical input on the device"),
e.binary("led_enable", ea.ALL, true, false).withDescription("Enable LED"),
],
},
{
zigbeeModel: ["Smart plug Zigbee SE"],
model: "552-80698",
vendor: "Niko",
description: "Smart plug with side earthing pin",
fromZigbee: [fz.on_off, fz.electrical_measurement, fz.metering, fz.power_on_behavior],
toZigbee: [tz.on_off, tz.power_on_behavior, tz.electrical_measurement_power, tz.currentsummdelivered],
configure: async (device, coordinatorEndpoint) => {
const endpoint = device.getEndpoint(1);
await reporting.bind(endpoint, coordinatorEndpoint, ["genOnOff", "haElectricalMeasurement", "seMetering"]);
await reporting.onOff(endpoint);
// only activePower seems to be support, although compliance document states otherwise
await endpoint.read("haElectricalMeasurement", ["acPowerMultiplier", "acPowerDivisor"]);
await reporting.activePower(endpoint);
await reporting.readMeteringMultiplierDivisor(endpoint);
await reporting.currentSummDelivered(endpoint, {min: 60, change: 1});
},
exposes: [
e.switch(),
e.power().withAccess(ea.STATE_GET),
e.energy().withAccess(ea.STATE_GET),
e.enum("power_on_behavior", ea.ALL, ["off", "previous", "on"]).withDescription("Controls the behaviour when the device is powered on"),
],
},
{
zigbeeModel: ["Smart plug Zigbee PE"],
model: "552-80699",
vendor: "Niko",
description: "Smart plug with earthing pin",
fromZigbee: [fz.on_off, fz.electrical_measurement, fz.metering, fz.power_on_behavior],
toZigbee: [tz.on_off, tz.power_on_behavior, tz.electrical_measurement_power, tz.currentsummdelivered],
configure: async (device, coordinatorEndpoint) => {
const endpoint = device.getEndpoint(1);
await reporting.bind(endpoint, coordinatorEndpoint, ["genOnOff", "haElectricalMeasurement", "seMetering"]);
await reporting.onOff(endpoint);
// only activePower seems to be support, although compliance document states otherwise
await endpoint.read("haElectricalMeasurement", ["acPowerMultiplier", "acPowerDivisor"]);
await reporting.activePower(endpoint);
await reporting.readMeteringMultiplierDivisor(endpoint);
await reporting.currentSummDelivered(endpoint, {min: 60, change: 1});
},
exposes: [
e.switch(),
e.power().withAccess(ea.STATE_GET),
e.energy().withAccess(ea.STATE_GET),
e.enum("power_on_behavior", ea.ALL, ["off", "previous", "on"]).withDescription("Controls the behaviour when the device is powered on"),
],
},
{
zigbeeModel: ["Connectable motion sensor,Zigbee"],
model: "552-80401",
vendor: "Niko",
description: "Wireless motion sensor",
fromZigbee: [fz.ias_occupancy_alarm_1, fz.battery],
toZigbee: [],
meta: {battery: {voltageToPercentage: "3V_2100"}},
configure: async (device, coordinatorEndpoint) => {
const endpoint = device.getEndpoint(1);
const bindClusters = ["genPowerCfg"];
await reporting.bind(endpoint, coordinatorEndpoint, bindClusters);
await reporting.batteryVoltage(endpoint);
},
exposes: [e.occupancy(), e.battery_low(), e.battery()],
},
{
zigbeeModel: ["Single connectable switch,10A"],
model: "552-721X1",
vendor: "Niko",
description: "Single connectable switch",
fromZigbee: [fz.on_off, local.fz.switch_operation_mode, local.fz.switch_action, local.fz.switch_status_led],
toZigbee: [
tz.on_off,
local.tz.switch_operation_mode,
local.tz.switch_action_reporting,
local.tz.switch_led_enable,
local.tz.switch_led_state,
local.tz.switch_led_sync_mode,
],
extend: [local.modernExtend.addCustomClusterManuSpecificNikoConfig(), local.modernExtend.addCustomClusterManuSpecificNikoState()],
configure: async (device, coordinatorEndpoint) => {
const endpoint = device.getEndpoint(1);
await reporting.bind(endpoint, coordinatorEndpoint, ["genOnOff"]);
await reporting.onOff(endpoint);
await endpoint.read("manuSpecificNikoConfig", ["switchOperationMode", "outletLedState", "outletLedColor"]);
// Enable action reporting by default
await endpoint.write("manuSpecificNikoState", {switchActionReporting: true});
await endpoint.read("manuSpecificNikoState", ["switchActionReporting"]);
await endpoint.read("manuSpecificNikoConfig", ["ledSyncMode"]);
},
exposes: [
e.switch(),
e.action(["single", "hold", "release", "single_ext", "hold_ext", "release_ext"]),
e.enum("operation_mode", ea.ALL, ["control_relay", "decoupled"]),
e.binary("action_reporting", ea.ALL, true, false).withDescription("Enable Action Reporting"),
e.binary("led_enable", ea.ALL, true, false).withDescription("Enable LED"),
e.enum("led_state", ea.ALL, ["ON", "OFF", "Blue", "Red", "Purple"]).withDescription("LED State"),
e.enum("led_sync_mode", ea.ALL, ["Off", "On", "Inverted"]).withDescription("Sync LED with relay state"),
],
},
{
zigbeeModel: ["Double connectable switch,10A"],
model: "552-721X2",
vendor: "Niko",
description: "Double connectable switch",
fromZigbee: [fz.on_off, local.fz.switch_operation_mode, local.fz.switch_action, local.fz.switch_status_led],
toZigbee: [
tz.on_off,
local.tz.switch_operation_mode,
local.tz.switch_action_reporting,
local.tz.switch_led_enable,
local.tz.switch_led_state,
local.tz.switch_led_sync_mode,
],
endpoint: (device) => {
return {l1: 1, l2: 2};
},
extend: [local.modernExtend.addCustomClusterManuSpecificNikoConfig(), local.modernExtend.addCustomClusterManuSpecificNikoState()],
meta: {multiEndpointEnforce: {operation_mode: 1}, multiEndpoint: true},
configure: async (device, coordinatorEndpoint) => {
const ep1 = device.getEndpoint(1);
const ep2 = device.getEndpoint(2);
await reporting.bind(ep1, coordinatorEndpoint, ["genOnOff"]);
await reporting.bind(ep2, coordinatorEndpoint, ["genOnOff"]);
await reporting.onOff(ep1);
await reporting.onOff(ep2);
await ep1.read("manuSpecificNikoConfig", ["switchOperationMode", "outletLedState", "outletLedColor"]);
await ep2.read("manuSpecificNikoConfig", ["switchOperationMode", "outletLedState", "outletLedColor"]);
// Enable action reporting by default
await ep1.write("manuSpecificNikoState", {switchActionReporting: true});
await ep1.read("manuSpecificNikoState", ["switchActionReporting"]);
await ep1.read("manuSpecificNikoConfig", ["ledSyncMode"]);
await ep2.read("manuSpecificNikoConfig", ["ledSyncMode"]);
},
exposes: [
e.switch().withEndpoint("l1"),
e.switch().withEndpoint("l2"),
e.action([
"single_left",
"hold_left",
"release_left",
"single_left_ext",
"hold_left_ext",
"release_left_ext",
"single_right",
"hold_right",
"release_right",
"single_right_ext",
"hold_right_ext",
"release_right_ext",
]),
e.enum("operation_mode", ea.ALL, ["control_relay", "decoupled"]),
e.binary("action_reporting", ea.ALL, true, false).withDescription("Enable Action Reporting"),
e.binary("led_enable", ea.ALL, true, false).withEndpoint("l1").withDescription("Enable LED"),
e.binary("led_enable", ea.ALL, true, false).withEndpoint("l2").withDescription("Enable LED"),
e.enum("led_state", ea.ALL, ["ON", "OFF", "Blue", "Red", "Purple"]).withEndpoint("l1").withDescription("LED State"),
e.enum("led_state", ea.ALL, ["ON", "OFF", "Blue", "Red", "Purple"]).withEndpoint("l2").withDescription("LED State"),
e.enum("led_sync_mode", ea.ALL, ["Off", "On", "Inverted"]).withEndpoint("l1").withDescription("Sync LED with relay state"),
e.enum("led_sync_mode", ea.ALL, ["Off", "On", "Inverted"]).withEndpoint("l2").withDescription("Sync LED with relay state"),
],
},
{
zigbeeModel: ["Connectable dimmer,3-200W,2-wire"],
model: "552-72201",
vendor: "Niko",
description: "Connectable dimmer",
fromZigbee: [fz.on_off, fz.brightness, fz.level_config, fz.command_move, fz.command_stop, local.fz.switch_status_led],
toZigbee: [tz.light_onoff_brightness, tz.level_config, local.tz.switch_led_enable, local.tz.switch_led_state],
extend: [local.modernExtend.addCustomClusterManuSpecificNikoConfig(), local.modernExtend.addCustomClusterManuSpecificNikoState()],
exposes: [
e.light_brightness().withLevelConfig(),
e.binary("led_enable", ea.ALL, true, false).withDescription("Enable LED"),
e.enum("led_state", ea.ALL, ["ON", "OFF", "Blue", "Red", "Purple"]).withDescription("LED State"),
],
configure: async (device, coordinatorEndpoint) => {
const endpoint = device.getEndpoint(1);
await reporting.bind(endpoint, coordinatorEndpoint, ["genOnOff", "genLevelCtrl"]);
await reporting.onOff(endpoint);
await reporting.brightness(endpoint);
await endpoint.read("manuSpecificNikoConfig", ["outletLedState", "outletLedColor"]);
},
},
{
zigbeeModel: ["Connectable motor control,3A"],
model: "552-72301",
vendor: "Niko",
description: "Connectable motor control",
fromZigbee: [fz.cover_position_tilt, fz.battery],
toZigbee: [tz.cover_state, tz.cover_position_tilt],
meta: {coverInverted: true},
configure: async (device, coordinatorEndpoint) => {
const endpoint = device.getEndpoint(1);
await reporting.bind(endpoint, coordinatorEndpoint, ["closuresWindowCovering"]);
await reporting.currentPositionLiftPercentage(endpoint);
},
exposes: [e.cover_position()],
},
{
zigbeeModel: ["Battery switch, 1 button"],
model: "552-720X1",
vendor: "Niko",
description: "Battery switch with 1 button",
fromZigbee: [fz.command_on, fz.command_off, fz.identify, fz.battery, fz.command_move, fz.command_stop],
toZigbee: [],
configure: async (device, coordinatorEndpoint) => {
const endpoint = device.getEndpoint(1);
await reporting.bind(endpoint, coordinatorEndpoint, ["genGroups", "genOnOff", "genLevelCtrl"]);
await reporting.batteryPercentageRemaining(endpoint);
},
exposes: [e.action(["on", "off", "brightness_move_up", "brightness_move_down", "brightness_stop"]), e.battery()],
},
{
zigbeeModel: ["Battery switch, 2 button"],
model: "552-720X2",
vendor: "Niko",
description: "Battery switch with 2 buttons",
meta: {multiEndpoint: true},
fromZigbee: [fz.command_on, fz.command_off, fz.identify, fz.battery, fz.command_move, fz.command_stop],
toZigbee: [],
endpoint: (device) => {
return {left: 1, right: 2};
},
configure: async (device, coordinatorEndpoint) => {
const ep1 = device.getEndpoint(1);
await reporting.bind(ep1, coordinatorEndpoint, ["genGroups", "genOnOff", "genLevelCtrl"]);
await reporting.batteryPercentageRemaining(ep1);
const ep2 = device.getEndpoint(2);
await reporting.bind(ep2, coordinatorEndpoint, ["genOnOff", "genLevelCtrl"]);
},
exposes: [
e.action([
"on_left",
"off_left",
"on_right",
"off_right",
"brightness_move_up_left",
"brightness_move_up_right",
"brightness_move_down_left",
"brightness_move_down_right",
"brightness_stop_left",
"brightness_stop_right",
]),
e.battery(),
],
},
{
zigbeeModel: ["Battery switch, 4 button"],
model: "552-720X4",
vendor: "Niko",
description: "Battery switch with 4 buttons",
meta: {multiEndpoint: true},
fromZigbee: [fz.command_on, fz.command_off, fz.identify, fz.battery, fz.command_move, fz.command_stop],
toZigbee: [],
endpoint: (device) => {
return {top_left: 1, bottom_left: 2, top_right: 3, bottom_right: 4};
},
configure: async (device, coordinatorEndpoint) => {
const ep1 = device.getEndpoint(1);
await reporting.bind(ep1, coordinatorEndpoint, ["genGroups", "genOnOff", "genLevelCtrl"]);
await reporting.batteryPercentageRemaining(ep1);
const ep2 = device.getEndpoint(2);
await reporting.bind(ep2, coordinatorEndpoint, ["genOnOff", "genLevelCtrl"]);
const ep3 = device.getEndpoint(3);
await reporting.bind(ep3, coordinatorEndpoint, ["genOnOff", "genLevelCtrl"]);
const ep4 = device.getEndpoint(4);
await reporting.bind(ep4, coordinatorEndpoint, ["genOnOff", "genLevelCtrl"]);
},
exposes: [
e.action([
"on_top_left",
"off_top_left",
"on_bottom_left",
"off_bottom_left",
"on_top_right",
"off_top_right",
"on_bottom_right",
"off_bottom_right",
"brightness_move_up_top_left",
"brightness_move_up_bottom_left",
"brightness_move_up_top_right",
"brightness_move_up_bottom_right",
"brightness_move_down_top_left",
"brightness_move_down_bottom_left",
"brightness_move_down_top_right",
"brightness_move_down_bottom_right",
"brightness_stop_top_left",
"brightness_stop_bottom_left",
"brightness_stop_top_right",
"brightness_stop_bottom_right",
]),
e.battery(),
],
},
];