Compare commits

..

3 Commits

Author SHA1 Message Date
db8caf9c58 add device to firebase & stop moving it from the OEM space 2025-06-30 09:46:32 +03:00
c7a4ff1194 fix: schedule device types (#441) 2025-06-29 15:27:55 +03:00
8a4633b158 Merge pull request #439 from SyncrowIOT/add-check-log-to-trace-the-map-issue
feat: enhance device status handling with caching and batch processin…
2025-06-25 18:59:37 -06:00
2 changed files with 11 additions and 6 deletions

View File

@ -3,6 +3,7 @@ import * as fs from 'fs';
import { ProjectParam } from '@app/common/dto/project-param.dto'; import { ProjectParam } from '@app/common/dto/project-param.dto';
import { SuccessResponseDto } from '@app/common/dto/success.response.dto'; import { SuccessResponseDto } from '@app/common/dto/success.response.dto';
import { DeviceStatusFirebaseService } from '@app/common/firebase/devices-status/services/devices-status.service';
import { TuyaService } from '@app/common/integrations/tuya/services/tuya.service'; import { TuyaService } from '@app/common/integrations/tuya/services/tuya.service';
import { CommunityRepository } from '@app/common/modules/community/repositories'; import { CommunityRepository } from '@app/common/modules/community/repositories';
import { DeviceRepository } from '@app/common/modules/device/repositories'; import { DeviceRepository } from '@app/common/modules/device/repositories';
@ -20,6 +21,7 @@ export class DeviceCommissionService {
constructor( constructor(
private readonly tuyaService: TuyaService, private readonly tuyaService: TuyaService,
private readonly deviceService: DeviceService, private readonly deviceService: DeviceService,
private readonly deviceStatusFirebaseService: DeviceStatusFirebaseService,
private readonly communityRepository: CommunityRepository, private readonly communityRepository: CommunityRepository,
private readonly spaceRepository: SpaceRepository, private readonly spaceRepository: SpaceRepository,
private readonly subspaceRepository: SubspaceRepository, private readonly subspaceRepository: SubspaceRepository,
@ -209,6 +211,10 @@ export class DeviceCommissionService {
rawDeviceId, rawDeviceId,
tuyaSpaceId, tuyaSpaceId,
); );
await this.deviceStatusFirebaseService.addDeviceStatusByDeviceUuid(
rawDeviceId,
);
successCount.value++; successCount.value++;
console.log( console.log(
`Device ${rawDeviceId} successfully processed and transferred to Tuya space ${tuyaSpaceId}`, `Device ${rawDeviceId} successfully processed and transferred to Tuya space ${tuyaSpaceId}`,

View File

@ -50,7 +50,7 @@ export class ScheduleService {
// Corrected condition for supported device types // Corrected condition for supported device types
this.ensureProductTypeSupportedForSchedule( this.ensureProductTypeSupportedForSchedule(
ProductType[deviceDetails.productDevice.prodType], deviceDetails.productDevice.prodType as ProductType,
); );
return this.enableScheduleDeviceInTuya( return this.enableScheduleDeviceInTuya(
@ -74,7 +74,7 @@ export class ScheduleService {
// Corrected condition for supported device types // Corrected condition for supported device types
this.ensureProductTypeSupportedForSchedule( this.ensureProductTypeSupportedForSchedule(
ProductType[deviceDetails.productDevice.prodType], deviceDetails.productDevice.prodType as ProductType,
); );
return await this.deleteScheduleDeviceInTuya( return await this.deleteScheduleDeviceInTuya(
@ -97,7 +97,7 @@ export class ScheduleService {
} }
this.ensureProductTypeSupportedForSchedule( this.ensureProductTypeSupportedForSchedule(
ProductType[deviceDetails.productDevice.prodType], deviceDetails.productDevice.prodType as ProductType,
); );
await this.addScheduleDeviceInTuya( await this.addScheduleDeviceInTuya(
@ -120,9 +120,8 @@ export class ScheduleService {
} }
// Corrected condition for supported device types // Corrected condition for supported device types
this.ensureProductTypeSupportedForSchedule( this.ensureProductTypeSupportedForSchedule(
ProductType[deviceDetails.productDevice.prodType], deviceDetails.productDevice.prodType as ProductType,
); );
const schedules = await this.getScheduleDeviceInTuya( const schedules = await this.getScheduleDeviceInTuya(
deviceDetails.deviceTuyaUuid, deviceDetails.deviceTuyaUuid,
category, category,
@ -162,7 +161,7 @@ export class ScheduleService {
// Corrected condition for supported device types // Corrected condition for supported device types
this.ensureProductTypeSupportedForSchedule( this.ensureProductTypeSupportedForSchedule(
ProductType[deviceDetails.productDevice.prodType], deviceDetails.productDevice.prodType as ProductType,
); );
await this.updateScheduleDeviceInTuya( await this.updateScheduleDeviceInTuya(