Merge pull request #108 from SyncrowIOT/add-battery-percentage-to-water-leak-device

finished added battery to water leak
This commit is contained in:
faris Aljohari
2024-10-04 14:11:17 -05:00
committed by GitHub
2 changed files with 14 additions and 0 deletions

View File

@ -12,4 +12,5 @@ export enum ProductType {
THREE_3TG = '3GT',
TWO_2TG = '2GT',
ONE_1TG = '1GT',
WL = 'WL',
}

View File

@ -839,6 +839,19 @@ export class DeviceService {
battery = batteryStatus.value;
}
}
// Check if the device is a water leak sensor (WL)
if (device.productDevice.prodType === ProductType.WL) {
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 {