Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Xiaomi wired switch] Parse operation mode response #290

Merged
merged 1 commit into from
Feb 20, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions converters/fromZigbee.js
Original file line number Diff line number Diff line change
Expand Up @@ -807,6 +807,21 @@ const converters = {
}
},
},
QBKG04LM_operation_mode: {
cid: 'genBasic',
type: 'devChange',
convert: (model, msg, publish, options) => {
const mappingMode = {
0x12: 'control_relay',
0xFE: 'decoupled',
};
const key = '65314';
if (msg.data.data.hasOwnProperty(key)) {
const mode = mappingMode[msg.data.data[key]];
return {operation_mode: mode};
}
},
},
QBKG03LM_QBKG12LM_state: {
cid: 'genOnOff',
type: 'attReport',
Expand Down Expand Up @@ -837,6 +852,29 @@ const converters = {
}
},
},
QBKG03LM_operation_mode: {
cid: 'genBasic',
type: 'devChange',
convert: (model, msg, publish, options) => {
const mappingButton = {
'65314': 'left',
'65315': 'right',
};
const mappingMode = {
0x12: 'control_left_relay',
0x22: 'control_right_relay',
0xFE: 'decoupled',
};
for (const key in mappingButton) {
if (msg.data.data.hasOwnProperty(key)) {
const payload = {};
const mode = mappingMode[msg.data.data[key]];
payload[`operation_mode_${mappingButton[key]}`] = mode;
return payload;
}
}
},
},
xiaomi_lock_report: {
cid: 'genBasic',
type: 'attReport',
Expand Down
9 changes: 5 additions & 4 deletions converters/toZigbee.js
Original file line number Diff line number Diff line change
Expand Up @@ -856,8 +856,8 @@ const converters = {
}
},
},
xiaomi_decoupled_mode: {
key: ['decoupled_mode'],
xiaomi_switch_operation_mode: {
key: ['operation_mode'],
convert: (key, value, message, type, postfix) => {
const cid = 'genBasic';
const lookupAttrId = {
Expand All @@ -866,9 +866,10 @@ const converters = {
'right': 0xFF23,
};
const lookupState = {
'control_relay': 0x12,
'control_left_relay': 0x12,
'control_right_relay': 0x22,
'decoupled': 0xFE,
'toggle_left': 0x12,
'toggle_right': 0x22,
};
let button;
if (value.hasOwnProperty('button')) {
Expand Down
8 changes: 4 additions & 4 deletions devices.js
Original file line number Diff line number Diff line change
Expand Up @@ -210,9 +210,9 @@ const devices = [
description: 'Aqara single key wired wall switch',
supports: 'on/off',
fromZigbee: [
fz.QBKG04LM_QBKG11LM_state, fz.ignore_onoff_change, fz.ignore_basic_change, fz.ignore_basic_report,
fz.QBKG04LM_QBKG11LM_state, fz.ignore_onoff_change, fz.QBKG04LM_operation_mode, fz.ignore_basic_report,
],
toZigbee: [tz.on_off, tz.xiaomi_decoupled_mode],
toZigbee: [tz.on_off, tz.xiaomi_switch_operation_mode],
ep: (device) => {
return {'system': 1, 'default': 2};
},
Expand All @@ -236,9 +236,9 @@ const devices = [
description: 'Aqara double key wired wall switch',
supports: 'release/hold, on/off',
fromZigbee: [
fz.QBKG03LM_QBKG12LM_state, fz.QBKG03LM_buttons, fz.ignore_basic_change, fz.ignore_basic_report,
fz.QBKG03LM_QBKG12LM_state, fz.QBKG03LM_buttons, fz.QBKG03LM_operation_mode, fz.ignore_basic_report,
],
toZigbee: [tz.on_off, tz.xiaomi_decoupled_mode],
toZigbee: [tz.on_off, tz.xiaomi_switch_operation_mode],
ep: (device) => {
return {'system': 1, 'left': 2, 'right': 3};
},
Expand Down