[New device support]: Aqara H1 Knob With Neutral wired version ZNXNKG01LM
Link
https://www.aqara.com/smart-wall-switch-H1-with-neutral_spec
Database entry
{"id":2,"type":"Router","ieeeAddr":"0x04cf8cdf3c848a45","nwkAddr":14970,"manufId":4447,"manufName":"LUMI","powerSource":"Mains (single phase)","modelId":"lumi.switch.rkna01","epList":[1,2,3,242],"endpoints":{"1":{"profId":260,"epId":1,"devId":256,"inClusterList":[0,2,3,4,5,6,9,1794,2820],"outClusterList":[10,25],"clusters":{"genBasic":{"attributes":{"zclVersion":3}},"aqaraOpple":{"attributes":{"554":3}}},"binds":[{"cluster":10,"type":"endpoint","deviceIeeeAddress":"0x00124b0026b74af2","endpointID":1}],"configuredReportings":[],"meta":{}},"2":{"profId":260,"epId":2,"devId":256,"inClusterList":[0,3,4,5,6],"outClusterList":[],"clusters":{"genBasic":{"attributes":{}}},"binds":[],"configuredReportings":[],"meta":{}},"3":{"profId":260,"epId":3,"devId":256,"inClusterList":[0,3,4,5,6],"outClusterList":[],"clusters":{"genBasic":{"attributes":{}}},"binds":[],"configuredReportings":[],"meta":{}},"242":{"profId":41440,"epId":242,"devId":97,"inClusterList":[],"outClusterList":[33],"clusters":{},"binds":[],"configuredReportings":[],"meta":{}}},"appVersion":24,"stackVersion":2,"hwVersion":1,"dateCode":"11-26-2021","zclVersion":3,"interviewCompleted":true,"meta":{"configured":-983567100},"lastSeen":1667929159187,"defaultSendRequestWhen":"immediate"}
Comments
Below is what I have done:
Searched on supported device page and found that only ZNXNKG02LM (Wireless) version is supported instead of this ZNXNKG01LM (Wired with Neutral) version.
Tried following the support new device page, now running the dev branch, with reference to the already supported wireless version's definition and custom external converters codes in xiaomi.js. Spent a couple days copy and pasting + typing.
Result:
Managed to get the device paired and get most of the functions (those the same as the wireless version) exposed however there is no response shown on "exposes" and "state" page of the device. All these functions I tried to expose are shown as "unavailable" on HA MQTT Integration. I simply dont see any response/debug log from the MQTT console when actions are triggered on the device.
I am not an IT professional, with limited programming knowledge I cannot get this device to work. I have many Aqara devices linked to an Aqara M2 hub as well as homekit originally and currently trying to port everything into HA using Zigbee2MQTT with a Sonoff dongle so that everything is centralized and more advanced automations could be programmed. This is actually the only Aqara device I have at home that is currently not supported out of the box. I have 5-6 of this installed in my whole place, it would be great if I could have this last piece of the puzzle solved to have a 100% working Smart Home Solution. Please help me :'-(
External converter
No response
Supported color modes
No response
Color temperature range
No response
Here is what I have in ZNXNKG01LM.js:
const exposes = require('zigbee-herdsman-converters/lib/exposes'); const fz = {require('zigbee-herdsman-converters/converters/fromZigbee'), legacy: require('zigbee-herdsman-converters/lib/legacy').fromZigbee}; const tz = require('zigbee-herdsman-converters/converters/toZigbee'); const ota = require('zigbee-herdsman-converters/lib/ota'); const constants = require('zigbee-herdsman-converters/lib/constants'); const reporting = require('zigbee-herdsman-converters/lib/reporting'); const extend = require('zigbee-herdsman-converters/lib/extend'); const e = exposes.presets; const ea = exposes.access; const globalStore = require('zigbee-herdsman-converters/lib/store'); const xiaomi = require('zigbee-herdsman-converters/lib/xiaomi');
const xiaomiExtend = { light_onoff_brightness_colortemp: (options={disableColorTempStartup: true}) => ({ ...extend.light_onoff_brightness_colortemp(options), fromZigbee: extend.light_onoff_brightness_colortemp(options).fromZigbee.concat([ fz.xiaomi_bulb_interval, fz.ignore_occupancy_report, fz.ignore_humidity_report, fz.ignore_pressure_report, fz.ignore_temperature_report, ]), }), };
const preventReset = async (type, data, device) => { if ( // options.allow_reset || type !== 'message' || data.type !== 'attributeReport' || data.cluster !== 'genBasic' || !data.data[0xfff0] || // eg: [0xaa, 0x10, 0x05, 0x41, 0x87, 0x01, 0x01, 0x10, 0x00] !data.data[0xFFF0].slice(0, 5).equals(Buffer.from([0xaa, 0x10, 0x05, 0x41, 0x87])) ) { return; } const options = {manufacturerCode: 0x115f}; const payload = {[0xfff0]: { value: [0xaa, 0x10, 0x05, 0x41, 0x47, 0x01, 0x01, 0x10, 0x01], type: 0x41, }}; await device.getEndpoint(1).write('genBasic', payload, options); };
const fzLocal = {
aqara_trv: {
cluster: 'aqaraOpple',
type: ['attributeReport', 'readResponse'],
convert: (model, msg, publish, options, meta) => {
const result = {};
Object.entries(msg.data).forEach(([key, value]) => {
switch (parseInt(key)) {
case 0x0271:
result['system_mode'] = {1: 'heat', 0: 'off'}[value];
break;
case 0x0272:
result['preset'] = {2: 'away', 1: 'auto', 0: 'manual'}[value];
break;
case 0x0273:
result['window_detection'] = {1: 'ON', 0: 'OFF'}[value];
break;
case 0x0274:
result['valve_detection'] = {1: 'ON', 0: 'OFF'}[value];
break;
case 0x0277:
result['child_lock'] = {1: 'LOCK', 0: 'UNLOCK'}[value];
break;
case 0x0279:
result['away_preset_temperature'] = (value / 100).toFixed(1);
break;
case 0x027b:
result['calibrated'] = {1: true, 0: false}[value];
break;
case 0x027e:
result['sensor'] = {1: 'external', 0: 'internal'}[value];
break;
case 0x040a:
result['battery'] = value;
break;
case 0x027a:
result['window_open'] = {1: true, 0: false}[value];
break;
case 0x0275:
result['valve_alarm'] = {1: true, 0: false}[value];
break;
case 0xfff2:
case 0x00ff: // 4e:27:49:bb:24:b6:30:dd:74:de:53:76:89:44:c4:81
case 0x00f7: // 03:28:1f:05:21:01:00:0a:21:00:00:0d:23:19:08:00:00:11:23...
case 0x0276: // 04:3e:01:e0:00:00:09:60:04:38:00:00:06:a4:05:64:00:00:08:98:81:e0:00:00:08:98
case 0x027c: // 0x00
case 0x027d: // 0x00
case 0x0280: // 0x00/0x01
meta.logger.debug(zigbee-herdsman-converters:aqara_trv: Unhandled key ${key} = ${value});
break;
default:
meta.logger.warn(zigbee-herdsman-converters:aqara_trv: Unknown key ${key} = ${value});
}
});
return result;
},
},
};
const tzLocal = { aqara_trv: { key: ['system_mode', 'preset', 'window_detection', 'valve_detection', 'child_lock', 'away_preset_temperature', 'calibrate', 'sensor', 'sensor_temp', 'identify'], convertSet: async (entity, key, value, meta) => { const aqaraHeader = (counter, params, action) => { const header = [0xaa, 0x71, params.length + 3, 0x44, counter]; const integrity = 512 - header.reduce((sum, elem) => sum + elem, 0); return [...header, integrity, action, 0x41, params.length]; }; const sensor = Buffer.from('00158d00019d1b98', 'hex');
switch (key) {
case 'system_mode':
await entity.write('aqaraOpple', {0x0271: {value: {'off': 0, 'heat': 1}[value], type: 0x20}},
{manufacturerCode: 0x115f});
break;
case 'preset':
await entity.write('aqaraOpple', {0x0272: {value: {'manual': 0, 'auto': 1, 'away': 2}[value], type: 0x20}},
{manufacturerCode: 0x115f});
break;
case 'window_detection':
await entity.write('aqaraOpple', {0x0273: {value: {'OFF': 0, 'ON': 1}[value], type: 0x20}},
{manufacturerCode: 0x115f});
break;
case 'valve_detection':
await entity.write('aqaraOpple', {0x0274: {value: {'OFF': 0, 'ON': 1}[value], type: 0x20}},
{manufacturerCode: 0x115f});
break;
case 'child_lock':
await entity.write('aqaraOpple', {0x0277: {value: {'UNLOCK': 0, 'LOCK': 1}[value], type: 0x20}},
{manufacturerCode: 0x115f});
break;
case 'away_preset_temperature':
await entity.write('aqaraOpple', {0x0279: {value: Math.round(value * 100), type: 0x23}}, {manufacturerCode: 0x115f});
break;
case 'sensor': {
const device = Buffer.from(entity.deviceIeeeAddress.substring(2), 'hex');
const timestamp = Buffer.alloc(4);
timestamp.writeUint32BE(Date.now()/1000);
if (value === 'external') {
const params1 = [
...timestamp,
0x3d, 0x04,
...device,
...sensor,
0x00, 0x01, 0x00, 0x55,
0x13, 0x0a, 0x02, 0x00, 0x00, 0x64, 0x04, 0xce, 0xc2, 0xb6, 0xc8,
0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x3d,
0x64,
0x65,
];
const params2 = [
...timestamp,
0x3d, 0x05,
...device,
...sensor,
0x08, 0x00, 0x07, 0xfd,
0x16, 0x0a, 0x02, 0x0a, 0xc9, 0xe8, 0xb1, 0xb8, 0xd4, 0xda, 0xcf, 0xdf, 0xc0, 0xeb,
0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x3d,
0x04,
0x65,
];
const val1 = [...(aqaraHeader(0x12, params1, 0x02)), ...params1];
const val2 = [...(aqaraHeader(0x13, params2, 0x02)), ...params2];
await entity.write('aqaraOpple', {0xfff2: {value: val1, type: 0x41}}, {manufacturerCode: 0x115f});
await entity.write('aqaraOpple', {0xfff2: {value: val2, type: 0x41}}, {manufacturerCode: 0x115f});
} else if (value === 'internal') {
const params1 = [
...timestamp,
0x3d, 0x05,
...device,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
];
const params2 = [
...timestamp,
0x3d, 0x04,
...device,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
];
const val1 = [...(aqaraHeader(0x12, params1, 0x04)), ...params1];
const val2 = [...(aqaraHeader(0x13, params2, 0x04)), ...params2];
await entity.write('aqaraOpple', {0xfff2: {value: val1, type: 0x41}}, {manufacturerCode: 0x115f});
await entity.write('aqaraOpple', {0xfff2: {value: val2, type: 0x41}}, {manufacturerCode: 0x115f});
await entity.read('hvacThermostat', ['localTemp']);
}
break;
}
case 'sensor_temp':
if (meta.state['sensor'] === 'external') {
const temperatureBuf = Buffer.alloc(4);
temperatureBuf.writeFloatBE(Math.round(value * 100));
const params = [...sensor, 0x00, 0x01, 0x00, 0x55, ...temperatureBuf];
const data = [...(aqaraHeader(0x12, params, 0x05)), ...params];
await entity.write('aqaraOpple', {0xfff2: {value: data, type: 0x41}}, {manufacturerCode: 0x115f});
}
break;
case 'calibrate':
await entity.write('aqaraOpple', {0x0270: {value: 1, type: 0x20}}, {manufacturerCode: 0x115F});
break;
case 'identify':
await entity.command('genIdentify', 'identify', {identifytime: 5}, {});
break;
default: // Unknown key
meta.logger.warn(`zigbee-herdsman-converters:aqara_trv: Unhandled key ${key}`);
}
},
convertGet: async (entity, key, meta) => {
const dict = {'system_mode': 0x0271, 'preset': 0x0272, 'window_detection': 0x0273, 'valve_detection': 0x0274,
'child_lock': 0x0277, 'away_preset_temperature': 0x0279, 'calibrated': 0x027b, 'sensor': 0x027e};
if (dict.hasOwnProperty(key)) {
await entity.read('aqaraOpple', [dict[key]], {manufacturerCode: 0x115F});
}
},
},
VOCKQJK11LM_display_unit: {
key: ['display_unit'],
convertSet: async (entity, key, value, meta) => {
await entity.write('aqaraOpple',
{0x0114: {value: xiaomi.VOCKQJK11LMDisplayUnit[value], type: 0x20}}, {manufacturerCode: 0x115F});
return {state: {display_unit: value}};
},
convertGet: async (entity, key, meta) => {
await entity.read('aqaraOpple', [0x0114], {manufacturerCode: 0x115F, disableDefaultResponse: true});
},
},
};
const definition = { zigbeeModel: ['lumi.switch.rkna01'], // The model ID from: Device with modelID 'lumi.remote.rkba01' is not supported. model: 'ZNXNKG01LM', // Vendor model number, look on the device for a model number vendor: 'Xiaomi', // Vendor of the device (only used for documentation and startup logging) description: 'Aqara Smart Knob H1 (With Neutral)', // Description of the device, copy from vendor site. (only used for documentation and startup logging) fromZigbee: [fz.xiaomi_on_off_action, fz.xiaomi_multistate_action, fz.xiaomi_basic, fz.aqara_opple, fz.aqara_knob_rotation], // We will add this later toZigbee: [tz.aqara_opple_operation_mode], // Should be empty, unless device can be controlled (e.g. lights, switches). exposes: [e.battery(), e.battery_voltage(),e.action(['single', 'double', 'hold', 'release', 'start_rotating', 'rotation', 'stop_rotating']), exposes.enum('operation_mode', ea.ALL, ['event', 'command']).withDescription('Button mode'), exposes.numeric('action_rotation_angle', ea.STATE).withUnit('').withDescription('Rotation angle'), exposes.numeric('action_rotation_angle_speed', ea.STATE).withUnit('').withDescription('Rotation angle speed'), exposes.numeric('action_rotation_percent', ea.STATE).withUnit('%').withDescription('Rotation percent'), exposes.numeric('action_rotation_percent_speed', ea.STATE).withUnit('%').withDescription('Rotation percent speed'), exposes.numeric('action_rotation_time', ea.STATE).withUnit('ms').withDescription('Rotation time'), ], // Defines what this device exposes, used for e.g. Home Assistant discovery and in the frontend onEvent: preventReset, configure: async (device, coordinatorEndpoint, logger) => { const endpoint1 = device.getEndpoint(1); await endpoint1.write('aqaraOpple', {'mode': 1}, {manufacturerCode: 0x115f, disableResponse: true}); },
};
module.exports = definition;
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 7 days
support for this product (aqara knob with neutral) would be great for dimmable lights.
in the aqara app you can debound the 3 channels so the relay doesnt activate when pressed once is this possible in Z2M ,i know other aqara switches have the decoupled option so its got to be aint it? Thank you