Skip to content

Commit 8263316

Browse files
committed
Implemented e.list() on alarms
1 parent 70d6577 commit 8263316

File tree

1 file changed

+24
-20
lines changed

1 file changed

+24
-20
lines changed

src/devices/amina.ts

+24-20
Original file line numberDiff line numberDiff line change
@@ -28,19 +28,27 @@ const aminaControlAttributes = {
2828
};
2929

3030
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',
4248
];
4349

50+
const aminaAlarmsEnum = e.enum('alarm', ea.STATE_GET, aminaAlarms);
51+
4452
const fzLocal = {
4553
ev_status: {
4654
cluster: 'aminaControlCluster',
@@ -77,25 +85,21 @@ const fzLocal = {
7785
const result: KeyValue = {};
7886

7987
if (msg.data.alarms !== undefined) {
80-
result.alarms = [];
88+
const activeAlarms = [];
8189
result.alarm_active = false;
8290

8391
for (let i = 0; i < 16; i++) {
8492
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]);
9194
result.alarm_active = true;
9295
}
9396
}
9497

9598
if (result.alarm_active === false) {
96-
result.alarms = 'No Alarm';
99+
activeAlarms.push(aminaAlarmsEnum.values[0]);
97100
}
98101

102+
result.alarms = activeAlarms;
99103
return result;
100104
}
101105
},
@@ -141,7 +145,7 @@ const definitions: DefinitionWithExtend[] = [
141145
toZigbee: [tzLocal.ev_status, tzLocal.alarms, tzLocal.charge_limit],
142146
exposes: [
143147
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'),
145149
],
146150
extend: [
147151
deviceAddCustomCluster('aminaControlCluster', {

0 commit comments

Comments
 (0)