turn on all the updates data points

This commit is contained in:
faris Aljohari
2025-06-23 07:33:01 -06:00
parent ff370b2baa
commit cf19f08dca

View File

@ -226,49 +226,49 @@ export class DeviceStatusFirebaseService {
});
await this.deviceStatusLogRepository.save(newLogs);
// if (addDeviceStatusDto.productType === ProductType.PC) {
// const energyCodes = new Set([
// PowerClampEnergyEnum.ENERGY_CONSUMED,
// PowerClampEnergyEnum.ENERGY_CONSUMED_A,
// PowerClampEnergyEnum.ENERGY_CONSUMED_B,
// PowerClampEnergyEnum.ENERGY_CONSUMED_C,
// ]);
if (addDeviceStatusDto.productType === ProductType.PC) {
const energyCodes = new Set([
PowerClampEnergyEnum.ENERGY_CONSUMED,
PowerClampEnergyEnum.ENERGY_CONSUMED_A,
PowerClampEnergyEnum.ENERGY_CONSUMED_B,
PowerClampEnergyEnum.ENERGY_CONSUMED_C,
]);
// const energyStatus = addDeviceStatusDto?.log?.properties?.find((status) =>
// energyCodes.has(status.code),
// );
const energyStatus = addDeviceStatusDto?.log?.properties?.find((status) =>
energyCodes.has(status.code),
);
// if (energyStatus) {
// await this.powerClampService.updateEnergyConsumedHistoricalData(
// addDeviceStatusDto.deviceUuid,
// );
// }
// }
if (energyStatus) {
await this.powerClampService.updateEnergyConsumedHistoricalData(
addDeviceStatusDto.deviceUuid,
);
}
}
// if (
// addDeviceStatusDto.productType === ProductType.CPS ||
// addDeviceStatusDto.productType === ProductType.WPS
// ) {
// const occupancyCodes = new Set([PresenceSensorEnum.PRESENCE_STATE]);
if (
addDeviceStatusDto.productType === ProductType.CPS ||
addDeviceStatusDto.productType === ProductType.WPS
) {
const occupancyCodes = new Set([PresenceSensorEnum.PRESENCE_STATE]);
// const occupancyStatus = addDeviceStatusDto?.log?.properties?.find(
// (status) => occupancyCodes.has(status.code),
// );
const occupancyStatus = addDeviceStatusDto?.log?.properties?.find(
(status) => occupancyCodes.has(status.code),
);
// if (occupancyStatus) {
// await this.occupancyService.updateOccupancySensorHistoricalData(
// addDeviceStatusDto.deviceUuid,
// );
// await this.occupancyService.updateOccupancySensorHistoricalDurationData(
// addDeviceStatusDto.deviceUuid,
// );
// }
// }
// if (addDeviceStatusDto.productType === ProductType.AQI) {
// await this.aqiDataService.updateAQISensorHistoricalData(
// addDeviceStatusDto.deviceUuid,
// );
// }
if (occupancyStatus) {
await this.occupancyService.updateOccupancySensorHistoricalData(
addDeviceStatusDto.deviceUuid,
);
await this.occupancyService.updateOccupancySensorHistoricalDurationData(
addDeviceStatusDto.deviceUuid,
);
}
}
if (addDeviceStatusDto.productType === ProductType.AQI) {
await this.aqiDataService.updateAQISensorHistoricalData(
addDeviceStatusDto.deviceUuid,
);
}
// Return the updated data
const snapshot: DataSnapshot = await get(dataRef);
return snapshot.val();