finished add battery value for the door sensor device

This commit is contained in:
faris Aljohari
2024-10-01 16:24:24 -05:00
parent fc67a751ca
commit a00f784229
2 changed files with 13 additions and 0 deletions

View File

@ -8,4 +8,5 @@ export enum ProductType {
TWO_G = '2G',
ONE_G = '1G',
WH = 'WH',
DS = 'DS',
}

View File

@ -826,7 +826,19 @@ export class DeviceService {
battery = batteryStatus.value;
}
}
// Check if the device is a door sensor (DS)
if (device.productDevice.prodType === ProductType.DS) {
const doorSensorInstructionsStatus =
await this.getDevicesInstructionStatus(device.uuid);
const batteryStatus: any = doorSensorInstructionsStatus.status.find(
(status: any) => status.code === 'battery_percentage',
);
if (batteryStatus) {
battery = batteryStatus.value;
}
}
const spaceDevice = device?.spaceDevice;
const parentDevice = spaceDevice?.parent;
return {