@@ -313,7 +313,7 @@ function sunricherSRZG9002K16Pro(): ModernExtend {
313
313
314
314
const fromZigbee : Fz . Converter [ ] = [
315
315
{
316
- cluster : 0xff03 ,
316
+ cluster,
317
317
type : [ 'raw' ] ,
318
318
convert : ( model , msg , publish , options , meta ) => {
319
319
const bytes = [ ...msg . data ] ;
@@ -368,6 +368,67 @@ function sunricherSRZG9002K16Pro(): ModernExtend {
368
368
} ;
369
369
}
370
370
371
+ function sunricherIndicatorLight ( ) : ModernExtend {
372
+ const cluster = 0xfc8b ;
373
+ const attribute = 0xf001 ;
374
+ const data_type = 0x20 ;
375
+ const manufacturerCode = 0x120b ;
376
+
377
+ const exposes : Expose [ ] = [
378
+ e . enum ( 'indicator_light' , ea . ALL , [ 'on' , 'off' ] ) . withDescription ( 'Enable/disable the LED indicator' ) . withCategory ( 'config' ) ,
379
+ ] ;
380
+
381
+ const fromZigbee : Fz . Converter [ ] = [
382
+ {
383
+ cluster,
384
+ type : [ 'attributeReport' , 'readResponse' ] ,
385
+ convert : ( model , msg , publish , options , meta ) => {
386
+ if ( ! Object . prototype . hasOwnProperty . call ( msg . data , attribute ) ) return ;
387
+ const indicatorLight = msg . data [ attribute ] ;
388
+ const firstBit = indicatorLight & 0x01 ;
389
+ return { indicator_light : firstBit === 1 ? 'on' : 'off' } ;
390
+ } ,
391
+ } satisfies Fz . Converter ,
392
+ ] ;
393
+
394
+ const toZigbee : Tz . Converter [ ] = [
395
+ {
396
+ key : [ 'indicator_light' ] ,
397
+ convertSet : async ( entity , key , value , meta ) => {
398
+ const attributeRead = await entity . read ( cluster , [ attribute ] ) ;
399
+ if ( attributeRead === undefined ) return ;
400
+
401
+ // @ts -expect-error ignore
402
+ const currentValue = attributeRead [ attribute ] ;
403
+ const newValue = value === 'on' ? currentValue | 0x01 : currentValue & ~ 0x01 ;
404
+
405
+ await entity . write ( cluster , { [ attribute ] : { value : newValue , type : data_type } } , { manufacturerCode} ) ;
406
+
407
+ return { state : { indicator_light : value } } ;
408
+ } ,
409
+ convertGet : async ( entity , key , meta ) => {
410
+ await entity . read ( cluster , [ attribute ] , { manufacturerCode} ) ;
411
+ } ,
412
+ } ,
413
+ ] ;
414
+
415
+ const configure : [ Configure ] = [
416
+ async ( device , coordinatorEndpoint , definition ) => {
417
+ const endpoint = device . getEndpoint ( 1 ) ;
418
+ await endpoint . bind ( cluster , coordinatorEndpoint ) ;
419
+ await endpoint . read ( cluster , [ attribute ] , { manufacturerCode} ) ;
420
+ } ,
421
+ ] ;
422
+
423
+ return {
424
+ exposes,
425
+ configure,
426
+ fromZigbee,
427
+ toZigbee,
428
+ isModernExtend : true ,
429
+ } ;
430
+ }
431
+
371
432
const fzLocal = {
372
433
sunricher_SRZGP2801K45C : {
373
434
cluster : 'greenPower' ,
@@ -419,7 +480,47 @@ const definitions: DefinitionWithExtend[] = [
419
480
model : 'SR-ZG9030F-PS' ,
420
481
vendor : 'Sunricher' ,
421
482
description : 'Smart human presence sensor' ,
422
- extend : [ m . illuminance ( { scale : ( value ) => value } ) , m . occupancy ( ) , m . commandsOnOff ( ) ] ,
483
+ extend : [
484
+ m . illuminance ( { scale : ( value ) => value } ) ,
485
+ m . occupancy ( ) ,
486
+ m . commandsOnOff ( ) ,
487
+ m . deviceAddCustomCluster ( 'sunricherSensor' , {
488
+ ID : 0xfc8b ,
489
+ manufacturerCode : 0x120b ,
490
+ attributes : {
491
+ indicatorLight : { ID : 0xf001 , type : 0x20 } ,
492
+ detectionArea : { ID : 0xf002 , type : 0x20 } ,
493
+ illuminanceThreshold : { ID : 0xf004 , type : 0x20 } ,
494
+ } ,
495
+ commands : { } ,
496
+ commandsResponse : { } ,
497
+ } ) ,
498
+ sunricherIndicatorLight ( ) ,
499
+ m . numeric ( {
500
+ name : 'detection_area' ,
501
+ cluster : 'sunricherSensor' ,
502
+ attribute : 'detectionArea' ,
503
+ description : 'Detection area range (default: 50%)' ,
504
+ valueMin : 0 ,
505
+ valueMax : 100 ,
506
+ valueStep : 1 ,
507
+ unit : '%' ,
508
+ access : 'ALL' ,
509
+ entityCategory : 'config' ,
510
+ } ) ,
511
+ m . numeric ( {
512
+ name : 'illuminance_threshold' ,
513
+ cluster : 'sunricherSensor' ,
514
+ attribute : 'illuminanceThreshold' ,
515
+ description : 'Illuminance threshold for triggering (default: 100)' ,
516
+ valueMin : 10 ,
517
+ valueMax : 100 ,
518
+ valueStep : 1 ,
519
+ unit : 'lx' ,
520
+ access : 'ALL' ,
521
+ entityCategory : 'config' ,
522
+ } ) ,
523
+ ] ,
423
524
} ,
424
525
{
425
526
zigbeeModel : [ 'HK-SENSOR-GAS' ] ,
0 commit comments