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

Aqara wall outlet H2 #6925

Merged
merged 5 commits into from
Jan 20, 2024
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
44 changes: 41 additions & 3 deletions src/devices/xiaomi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ import extend from '../lib/extend';
import {
light, numeric, binary, enumLookup, forceDeviceType,
temperature, humidity, forcePowerSource, quirkAddEndpointCluster,
quirkCheckinInterval,
customTimeResponse,
quirkCheckinInterval, onOff, customTimeResponse,
} from '../lib/modernExtend';
const e = exposes.presets;
const ea = exposes.access;
Expand All @@ -18,7 +17,8 @@ import * as xiaomi from '../lib/xiaomi';
const {
xiaomiAction, xiaomiOperationMode, xiaomiPowerOnBehavior, xiaomiZigbeeOTA,
xiaomiSwitchType, aqaraAirQuality, aqaraVoc, aqaraDisplayUnit, xiaomiLight,
xiaomiOutageCountRestoreBindReporting,
xiaomiOutageCountRestoreBindReporting, xiaomiElectricityMeter, xiaomiPower,
xiaomiOverloadProtection, xiaomiLedIndicator, xiaomiButtonLock,
} = xiaomi.modernExtend;
import * as utils from '../lib/utils';
import {Definition, OnEvent, Fz, KeyValue, Tz} from '../lib/types';
Expand Down Expand Up @@ -3424,6 +3424,44 @@ const definitions: Definition[] = [
},
extend: [xiaomiZigbeeOTA()],
},
{
zigbeeModel: ['lumi.plug.aeu001'],
model: 'WP-P01D',
vendor: 'Aqara',
description: 'Aqara wall outlet H2',
extend: [
xiaomiZigbeeOTA(),
onOff({powerOnBehavior: false}),
xiaomiPowerOnBehavior(),
xiaomiPower(),
xiaomiElectricityMeter(),
xiaomiOverloadProtection(),
xiaomiLedIndicator(),
xiaomiButtonLock(),
binary({
name: 'charging_protection',
cluster: 'aqaraOpple',
attribute: {ID: 0x0202, type: 0x10},
valueOn: ['ON', 1],
valueOff: ['OFF', 0],
description: 'Turn off the outlet if the power is below the set limit for half an hour',
access: 'ALL',
zigbeeCommandOptions: {manufacturerCode},
}),
numeric({
name: 'charging_limit',
cluster: 'aqaraOpple',
attribute: {ID: 0x0206, type: 0x39},
valueMin: 0.1,
valueMax: 2,
valueStep: 0.1,
unit: 'W',
description: 'Charging protection power limit',
access: 'ALL',
zigbeeCommandOptions: {manufacturerCode},
}),
],
},
];

export default definitions;
Expand Down
62 changes: 62 additions & 0 deletions src/lib/xiaomi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1468,6 +1468,68 @@ export const xiaomiModernExtend = {
result.ota = ota.zigbeeOTA;
return result;
},
xiaomiPower: (args?: Partial<modernExtend.NumericArgs>) => modernExtend.numeric({
name: 'power',
cluster: 'genAnalogInput',
attribute: 'presentValue',
reporting: {min: '10_SECONDS', max: '1_HOUR', change: 5},
description: 'Instantaneous measured power',
unit: 'W',
access: 'STATE',
zigbeeCommandOptions: {manufacturerCode},
...args,
}),
xiaomiElectricityMeter: (): ModernExtend => {
const exposes = [
e.energy(),
e.voltage(),
e.current(),
e.device_temperature(),
];
const fromZigbee: Fz.Converter[] = [{
cluster: 'aqaraOpple',
type: ['attributeReport', 'readResponse'],
convert: async (model, msg, publish, options, meta) => {
return await numericAttributes2Payload(msg, meta, model, options, msg.data);
},
}];

return {exposes, fromZigbee, isModernExtend: true};
},
xiaomiOverloadProtection: (args?: Partial<modernExtend.NumericArgs>) => modernExtend.numeric({
name: 'overload_protection',
cluster: 'aqaraOpple',
attribute: {ID: 0x020b, type: 0x39},
description: 'Maximum allowed load, turns off if exceeded',
valueMin: 100,
valueMax: 3840,
unit: 'W',
access: 'ALL',
zigbeeCommandOptions: {manufacturerCode},
...args,
}),
xiaomiLedIndicator: (args? :Partial<modernExtend.BinaryArgs>) => modernExtend.binary({
name: 'led_indicator',
cluster: 'aqaraOpple',
attribute: {ID: 0x0203, type: 0x10},
valueOn: ['ON', 1],
valueOff: ['OFF', 0],
description: 'LED indicator',
access: 'ALL',
zigbeeCommandOptions: {manufacturerCode},
...args,
}),
xiaomiButtonLock: (args? :Partial<modernExtend.BinaryArgs>) => modernExtend.binary({
name: 'button_lock',
cluster: 'aqaraOpple',
attribute: {ID: 0x0200, type: 0x20},
valueOn: ['ON', 0],
valueOff: ['OFF', 1],
description: 'Disables the physical switch button',
access: 'ALL',
zigbeeCommandOptions: {manufacturerCode},
...args,
}),
};

export {xiaomiModernExtend as modernExtend};
Expand Down