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