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

Add support for Aqara FP1E. #8043

Merged
merged 1 commit into from
Sep 30, 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
28 changes: 28 additions & 0 deletions src/devices/lumi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1891,6 +1891,34 @@ const definitions: DefinitionWithExtend[] = [
},
extend: [lumiZigbeeOTA()],
},
{
zigbeeModel: ['lumi.sensor_occupy.agl1'],
model: 'FP1E',
vendor: 'Aqara',
description: 'Presence sensor',
fromZigbee: [lumi.fromZigbee.lumi_specific],
toZigbee: [lumi.toZigbee.lumi_motion_sensitivity],
exposes: [
e.device_temperature(),
e.power_outage_count(),
e.motion_sensitivity_select(['low', 'medium', 'high']).withDescription('Select motion sensitivity to use.'),
],
configure: async (device, coordinatorEndpoint) => {
// Retrieve motion sensitivity value
const endpoint = device.getEndpoint(1);
await endpoint.read('manuSpecificLumi', [0x010c], {manufacturerCode: manufacturerCode});
},
extend: [
lumiZigbeeOTA(),
lumi.lumiModernExtend.fp1ePresence(),
lumi.lumiModernExtend.fp1eMovement(),
lumi.lumiModernExtend.fp1eTargetDistance(),
lumi.lumiModernExtend.fp1eDetectionRange(),
lumi.lumiModernExtend.fp1eSpatialLearning(),
lumi.lumiModernExtend.fp1eRestartDevice(),
identify(),
],
},
{
zigbeeModel: ['lumi.sensor_magnet'],
model: 'MCCGQ01LM',
Expand Down
75 changes: 75 additions & 0 deletions src/lib/lumi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2215,6 +2215,81 @@ export const lumiModernExtend = {

return {exposes, fromZigbee, isModernExtend: true};
},
fp1ePresence: () => {
const attribute = {ID: 0x0142, type: 0x20};
return modernExtend.binary({
name: 'presence',
valueOn: [true, 1],
valueOff: [false, 0],
access: 'STATE_GET',
cluster: 'manuSpecificLumi',
attribute: attribute,
description: 'Indicates whether the device detected presence',
});
},
fp1eMovement: () =>
modernExtend.enumLookup({
name: 'movement',
lookup: {unknown_0: 0, unknown_1: 1, no_presence: 2, movement: 3, no_movement: 4},
cluster: 'manuSpecificLumi',
attribute: {ID: 0x0160, type: 0x20},
zigbeeCommandOptions: {disableDefaultResponse: true},
description: 'Is movement detected?',
access: 'STATE_GET',
}),
fp1eTargetDistance: () =>
modernExtend.numeric({
name: 'target_distance',
cluster: 'manuSpecificLumi',
attribute: {ID: 0x015f, type: 0x23},
access: 'STATE_GET',
description: 'Distance to the detected target',
scale: 100,
precision: 2,
unit: 'm',
}),
fp1eDetectionRange: () =>
modernExtend.numeric({
name: 'detection_range',
cluster: 'manuSpecificLumi',
attribute: {ID: 0x015b, type: 0x23},
access: 'ALL',
description: 'The device will monitor presence within the detection range',
scale: 100,
precision: 2,
unit: 'm',
valueMin: 0,
valueMax: 6.0,
valueStep: 0.3,
}),
fp1eSpatialLearning: () => {
return {
isModernExtend: true,
exposes: [e.enum('spatial_learning', ea.SET, ['Start Learning']).withDescription('Initiate AI Spatial Learning.')],
toZigbee: [
{
key: ['spatial_learning'],
convertSet: async (entity, key, value, meta) => {
await entity.write('manuSpecificLumi', {0x0157: {value: 1, type: 0x20}}, manufacturerOptions.lumi);
},
},
],
} satisfies ModernExtend;
},
fp1eRestartDevice: () => {
return {
isModernExtend: true,
exposes: [e.enum('restart_device', ea.SET, ['Restart Device']).withDescription('Restarts the device.')],
toZigbee: [
{
key: ['restart_device'],
convertSet: async (entity, key, value, meta) => {
await entity.write('manuSpecificLumi', {0x00e8: {value: 0x00, type: 0x10}}, manufacturerOptions.lumi);
},
},
],
} satisfies ModernExtend;
},
};

export {lumiModernExtend as modernExtend};
Expand Down
Loading