Skip to content

Commit

Permalink
feat(add): WP-P01D (#6925)
Browse files Browse the repository at this point in the history
* Aqara wall outlet H2

* lint

* fix description

* Rename

---------

Co-authored-by: Koen Kanters <koenkanters94@gmail.com>
  • Loading branch information
kirovilya and Koenkk authored Jan 20, 2024
1 parent 241fc9a commit a9e5efa
Show file tree
Hide file tree
Showing 2 changed files with 103 additions and 3 deletions.
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

0 comments on commit a9e5efa

Please sign in to comment.