1
+ import { Zcl } from 'zigbee-herdsman' ;
2
+
1
3
import fz from '../converters/fromZigbee' ;
2
4
import tz from '../converters/toZigbee' ;
3
5
import * as exposes from '../lib/exposes' ;
6
+ import { deviceAddCustomCluster } from '../lib/modernExtend' ;
4
7
import * as ota from '../lib/ota' ;
5
8
import * as reporting from '../lib/reporting' ;
6
9
import { DefinitionWithExtend , Fz , KeyValue , Tz } from '../lib/types' ;
@@ -13,6 +16,19 @@ const switchTypeValues = ['maintained_state', 'maintained_toggle', 'momentary_st
13
16
14
17
const defaultOnOffStateValues = [ 'on' , 'off' , 'previous' ] ;
15
18
19
+ const manufacturerOptions = { manufacturerCode : Zcl . ManufacturerCode . CUSTOM_PERENIO } ;
20
+
21
+ const perenioExtend = {
22
+ addCustomClusterPerenio : ( ) =>
23
+ deviceAddCustomCluster ( 'perenioSpecific' , {
24
+ ID : 64635 ,
25
+ manufacturerCode : Zcl . ManufacturerCode . CUSTOM_PERENIO ,
26
+ attributes : { } ,
27
+ commands : { } ,
28
+ commandsResponse : { } ,
29
+ } ) ,
30
+ } ;
31
+
16
32
const fzPerenio = {
17
33
diagnostic : {
18
34
cluster : 'haDiagnostic' ,
@@ -48,7 +64,7 @@ const fzPerenio = {
48
64
} ,
49
65
} satisfies Fz . Converter ,
50
66
smart_plug : {
51
- cluster : '64635 ' ,
67
+ cluster : 'perenioSpecific ' ,
52
68
type : [ 'attributeReport' , 'readResponse' ] ,
53
69
convert : ( model , msg , publish , options , meta ) => {
54
70
const result : KeyValue = { } ;
@@ -142,55 +158,55 @@ const tzPerenio = {
142
158
on : 1 ,
143
159
previous : 2 ,
144
160
} ;
145
- await entity . write ( 64635 , { 0 : { value : powerOnStateLookup [ val ] , type : 0x20 } } , { manufacturerCode : 0x007b } ) ;
161
+ await entity . write ( 'perenioSpecific' , { 0 : { value : powerOnStateLookup [ val ] , type : 0x20 } } , manufacturerOptions ) ;
146
162
return { state : { default_on_off_state : val } } ;
147
163
} ,
148
164
convertGet : async ( entity , key , meta ) => {
149
- await entity . read ( 64635 , [ 0 ] ) ;
165
+ await entity . read ( 'perenioSpecific' , [ 0 ] ) ;
150
166
} ,
151
167
} satisfies Tz . Converter ,
152
168
alarms_reset : {
153
169
key : [ 'alarm_voltage_min' , 'alarm_voltage_max' , 'alarm_power_max' , 'alarm_consumed_energy' ] ,
154
170
convertSet : async ( entity , key , val , meta ) => {
155
- await entity . write ( 64635 , { 1 : { value : 0 , type : 0x20 } } , { manufacturerCode : 0x007b } ) ;
171
+ await entity . write ( 'perenioSpecific' , { 1 : { value : 0 , type : 0x20 } } , manufacturerOptions ) ;
156
172
return { state : { alarm_voltage_min : false , alarm_voltage_max : false , alarm_power_max : false , alarm_consumed_energy : false } } ;
157
173
} ,
158
174
convertGet : async ( entity , key , meta ) => {
159
- await entity . read ( 64635 , [ 1 ] ) ;
175
+ await entity . read ( 'perenioSpecific' , [ 1 ] ) ;
160
176
} ,
161
177
} satisfies Tz . Converter ,
162
178
alarms_limits : {
163
179
key : [ 'voltage_min' , 'voltage_max' , 'power_max' , 'consumed_energy_limit' ] ,
164
180
convertSet : async ( entity , key , val , meta ) => {
165
181
switch ( key ) {
166
182
case 'voltage_min' :
167
- await entity . write ( 64635 , { 4 : { value : val , type : 0x21 } } , { manufacturerCode : 0x007b } ) ;
183
+ await entity . write ( 'perenioSpecific' , { 4 : { value : val , type : 0x21 } } , manufacturerOptions ) ;
168
184
break ;
169
185
case 'voltage_max' :
170
- await entity . write ( 64635 , { 5 : { value : val , type : 0x21 } } , { manufacturerCode : 0x007b } ) ;
186
+ await entity . write ( 'perenioSpecific' , { 5 : { value : val , type : 0x21 } } , manufacturerOptions ) ;
171
187
break ;
172
188
case 'power_max' :
173
- await entity . write ( 64635 , { 11 : { value : val , type : 0x21 } } , { manufacturerCode : 0x007b } ) ;
189
+ await entity . write ( 'perenioSpecific' , { 11 : { value : val , type : 0x21 } } , manufacturerOptions ) ;
174
190
break ;
175
191
case 'consumed_energy_limit' :
176
- await entity . write ( 64635 , { 15 : { value : val , type : 0x21 } } , { manufacturerCode : 0x007b } ) ;
192
+ await entity . write ( 'perenioSpecific' , { 15 : { value : val , type : 0x21 } } , manufacturerOptions ) ;
177
193
break ;
178
194
}
179
195
return { state : { [ key ] : val } } ;
180
196
} ,
181
197
convertGet : async ( entity , key , meta ) => {
182
198
switch ( key ) {
183
199
case 'voltage_min' :
184
- await entity . read ( 64635 , [ 4 ] ) ;
200
+ await entity . read ( 'perenioSpecific' , [ 4 ] ) ;
185
201
break ;
186
202
case 'voltage_max' :
187
- await entity . read ( 64635 , [ 5 ] ) ;
203
+ await entity . read ( 'perenioSpecific' , [ 5 ] ) ;
188
204
break ;
189
205
case 'power_max' :
190
- await entity . read ( 64635 , [ 11 ] ) ;
206
+ await entity . read ( 'perenioSpecific' , [ 11 ] ) ;
191
207
break ;
192
208
case 'consumed_energy_limit' :
193
- await entity . read ( 64635 , [ 15 ] ) ;
209
+ await entity . read ( 'perenioSpecific' , [ 15 ] ) ;
194
210
break ;
195
211
}
196
212
} ,
@@ -347,11 +363,12 @@ const definitions: DefinitionWithExtend[] = [
347
363
model : 'PEHPL0X' ,
348
364
vendor : 'Perenio' ,
349
365
description : 'Power link' ,
366
+ extend : [ perenioExtend . addCustomClusterPerenio ( ) ] ,
350
367
fromZigbee : [ fz . on_off , fzPerenio . smart_plug , fz . metering ] ,
351
368
toZigbee : [ tzPerenio . on_off_mod , tzPerenio . default_state , tzPerenio . alarms_reset , tzPerenio . alarms_limits ] ,
352
369
configure : async ( device , coordinatorEndpoint ) => {
353
370
const endpoint = device . getEndpoint ( 1 ) ;
354
- await reporting . bind ( endpoint , coordinatorEndpoint , [ 'genOnOff' , 64635 ] ) ;
371
+ await reporting . bind ( endpoint , coordinatorEndpoint , [ 'genOnOff' , 'perenioSpecific' ] ) ;
355
372
const payload = [
356
373
{
357
374
attribute : 'onOff' ,
@@ -361,32 +378,32 @@ const definitions: DefinitionWithExtend[] = [
361
378
} ,
362
379
] ;
363
380
await endpoint . configureReporting ( 'genOnOff' , payload ) ;
364
- await endpoint . configureReporting ( 64635 , [
381
+ await endpoint . configureReporting ( 'perenioSpecific' , [
365
382
{
366
383
attribute : { ID : 0x000a , type : 0x21 } ,
367
384
minimumReportInterval : 5 ,
368
385
maximumReportInterval : 60 ,
369
386
reportableChange : 0 ,
370
387
} ,
371
388
] ) ;
372
- await endpoint . configureReporting ( 64635 , [
389
+ await endpoint . configureReporting ( 'perenioSpecific' , [
373
390
{
374
391
attribute : { ID : 0x000e , type : 0x23 } ,
375
392
minimumReportInterval : 5 ,
376
393
maximumReportInterval : 60 ,
377
394
reportableChange : 0 ,
378
395
} ,
379
396
] ) ;
380
- await endpoint . configureReporting ( 64635 , [
397
+ await endpoint . configureReporting ( 'perenioSpecific' , [
381
398
{
382
399
attribute : { ID : 0x0003 , type : 0x21 } ,
383
400
minimumReportInterval : 5 ,
384
401
maximumReportInterval : 5 ,
385
402
reportableChange : 0 ,
386
403
} ,
387
404
] ) ;
388
- await endpoint . read ( 64635 , [ 0 , 1 , 2 , 3 ] ) ;
389
- await endpoint . read ( 64635 , [ 4 , 5 , 11 , 15 ] ) ;
405
+ await endpoint . read ( 'perenioSpecific' , [ 0 , 1 , 2 , 3 ] ) ;
406
+ await endpoint . read ( 'perenioSpecific' , [ 4 , 5 , 11 , 15 ] ) ;
390
407
} ,
391
408
exposes : [
392
409
e . switch ( ) ,
0 commit comments