@@ -28,19 +28,27 @@ const aminaControlAttributes = {
28
28
} ;
29
29
30
30
const aminaAlarms = [
31
- 'Welded relay' ,
32
- 'Wrong voltage balance' ,
33
- 'RDC-DD DC leakage' ,
34
- 'RDC-DD AC leakage' ,
35
- 'High temperature' ,
36
- 'Overvoltage' ,
37
- 'Overcurrent' ,
38
- 'Car communication error' ,
39
- 'Charger processing error' ,
40
- 'Critical overcurrent' ,
41
- 'Critical powerloss' ,
31
+ 'no_alarm' ,
32
+ 'welded_relay' , // Bit 0 starts here
33
+ 'wrong_voltage_balance' ,
34
+ 'rdc_dd_dc_leakage' ,
35
+ 'rdc_dd_ac_leakage' ,
36
+ 'high_temperature' ,
37
+ 'overvoltage' ,
38
+ 'undervoltage' ,
39
+ 'overcurrent' ,
40
+ 'car_communication_error' ,
41
+ 'charger_processing_error' ,
42
+ 'critical_overcurrent' ,
43
+ 'critical_powerloss' ,
44
+ 'unknown_alarm_bit_12' ,
45
+ 'unknown_alarm_bit_13' ,
46
+ 'unknown_alarm_bit_14' ,
47
+ 'unknown_alarm_bit_15' ,
42
48
] ;
43
49
50
+ const aminaAlarmsEnum = e . enum ( 'alarm' , ea . STATE_GET , aminaAlarms ) ;
51
+
44
52
const fzLocal = {
45
53
ev_status : {
46
54
cluster : 'aminaControlCluster' ,
@@ -77,25 +85,21 @@ const fzLocal = {
77
85
const result : KeyValue = { } ;
78
86
79
87
if ( msg . data . alarms !== undefined ) {
80
- result . alarms = [ ] ;
88
+ const activeAlarms = [ ] ;
81
89
result . alarm_active = false ;
82
90
83
91
for ( let i = 0 ; i < 16 ; i ++ ) {
84
92
if ( ( msg . data [ 'alarms' ] >> i ) & 0x01 ) {
85
- let alarm = aminaAlarms [ i ] ;
86
- if ( alarm === undefined ) {
87
- alarm = `Unknown Alarm bit #${ i } ` ;
88
- }
89
-
90
- ( result . alarms as string [ ] ) . push ( alarm ) ;
93
+ activeAlarms . push ( aminaAlarmsEnum . values [ i + 1 ] ) ;
91
94
result . alarm_active = true ;
92
95
}
93
96
}
94
97
95
98
if ( result . alarm_active === false ) {
96
- result . alarms = 'No Alarm' ;
99
+ activeAlarms . push ( aminaAlarmsEnum . values [ 0 ] ) ;
97
100
}
98
101
102
+ result . alarms = activeAlarms ;
99
103
return result ;
100
104
}
101
105
} ,
@@ -141,7 +145,7 @@ const definitions: DefinitionWithExtend[] = [
141
145
toZigbee : [ tzLocal . ev_status , tzLocal . alarms , tzLocal . charge_limit ] ,
142
146
exposes : [
143
147
e . text ( 'ev_status' , ea . STATE_GET ) . withDescription ( 'Current charging status' ) ,
144
- e . text ( 'alarms' , ea . STATE_GET ) . withDescription ( 'Alarms reported by EV Charger ' ) ,
148
+ e . list ( 'alarms' , ea . STATE_GET , aminaAlarmsEnum ) . withDescription ( 'List of active alarms ' ) ,
145
149
] ,
146
150
extend : [
147
151
deviceAddCustomCluster ( 'aminaControlCluster' , {
0 commit comments