Skip to content

Commit f482272

Browse files
authored
feat: Add SR-ZG9002KR12-Pro expose and add ZG9380A zigbeeModel for SR-ZG9042MP (#8388)
1 parent 6711655 commit f482272

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

src/devices/sunricher.ts

+8-6
Original file line numberDiff line numberDiff line change
@@ -203,9 +203,7 @@ const fzLocal = {
203203
convert: (model, msg, publish, options, meta) => {
204204
const bytes = [...msg.data];
205205
const messageType = bytes[3];
206-
const buttons: string[] = [];
207206
let action = 'unknown';
208-
let speed = 0;
209207

210208
if (messageType === 0x01) {
211209
const pressTypeMask: number = bytes[6];
@@ -226,15 +224,17 @@ const fzLocal = {
226224
16: 'k12',
227225
};
228226

227+
const actionButtons: string[] = [];
229228
for (let i = 0; i < 16; i++) {
230229
if ((buttonMask >> i) & 1) {
231230
const button = i + 1;
232-
buttons.push(specialButtonMap[button] ?? `k${button}`);
231+
actionButtons.push(specialButtonMap[button] ?? `k${button}`);
233232
}
234233
}
234+
return {action, action_buttons: actionButtons};
235235
} else if (messageType === 0x03) {
236236
const directionMask = bytes[4];
237-
speed = bytes[6];
237+
const actionSpeed = bytes[6];
238238

239239
const directionMap: {[key: number]: string} = {
240240
0x01: 'clockwise',
@@ -243,9 +243,10 @@ const fzLocal = {
243243
const direction = directionMap[directionMask] || 'unknown';
244244

245245
action = `${direction}_rotation`;
246+
return {action, action_speed: actionSpeed};
246247
}
247248

248-
return {action, buttons, speed};
249+
return {action};
249250
},
250251
} satisfies Fz.Converter,
251252
};
@@ -268,9 +269,10 @@ const definitions: DefinitionWithExtend[] = [
268269
description: 'Zigbee smart wall panel remote',
269270
extend: [battery()],
270271
fromZigbee: [fzLocal.sunricher_SRZG9002KR12Pro],
272+
exposes: [e.action(['short_press', 'double_press', 'hold', 'hold_released', 'clockwise_rotation', 'anti_clockwise_rotation'])],
271273
},
272274
{
273-
zigbeeModel: ['ZV9380A'],
275+
zigbeeModel: ['ZV9380A', 'ZG9380A'],
274276
model: 'SR-ZG9042MP',
275277
vendor: 'Sunricher',
276278
description: 'Zigbee three phase power meter',

0 commit comments

Comments
 (0)