mirror of
https://github.com/SyncrowIOT/backend.git
synced 2025-07-14 18:05:48 +00:00
finished 4scene configration endpoints
This commit is contained in:
@ -30,6 +30,7 @@ import {
|
||||
} from '@app/common/constants/automation.enum';
|
||||
import { TuyaService } from '@app/common/integrations/tuya/services/tuya.service';
|
||||
import { ConvertedAction } from '@app/common/integrations/tuya/interfaces';
|
||||
import { SceneDeviceRepository } from '@app/common/modules/scene-device/repositories';
|
||||
|
||||
@Injectable()
|
||||
export class AutomationService {
|
||||
@ -39,6 +40,7 @@ export class AutomationService {
|
||||
private readonly spaceRepository: SpaceRepository,
|
||||
private readonly deviceService: DeviceService,
|
||||
private readonly tuyaService: TuyaService,
|
||||
private readonly sceneDeviceRepository: SceneDeviceRepository,
|
||||
) {
|
||||
const accessKey = this.configService.get<string>('auth-config.ACCESS_KEY');
|
||||
const secretKey = this.configService.get<string>('auth-config.SECRET_KEY');
|
||||
@ -304,6 +306,16 @@ export class AutomationService {
|
||||
HttpStatus.BAD_REQUEST,
|
||||
);
|
||||
}
|
||||
const existingSceneDevice = await this.sceneDeviceRepository.findOne({
|
||||
where: { automationTuyaUuid: automationUuid },
|
||||
});
|
||||
|
||||
if (existingSceneDevice) {
|
||||
await this.sceneDeviceRepository.delete({
|
||||
automationTuyaUuid: automationUuid,
|
||||
});
|
||||
}
|
||||
|
||||
const response = this.tuyaService.deleteAutomation(
|
||||
automation.spaceId,
|
||||
automationUuid,
|
||||
@ -323,6 +335,15 @@ export class AutomationService {
|
||||
|
||||
async delete(tuyaSpaceId: string, automationUuid: string) {
|
||||
try {
|
||||
const existingSceneDevice = await this.sceneDeviceRepository.findOne({
|
||||
where: { automationTuyaUuid: automationUuid },
|
||||
});
|
||||
|
||||
if (existingSceneDevice) {
|
||||
await this.sceneDeviceRepository.delete({
|
||||
automationTuyaUuid: automationUuid,
|
||||
});
|
||||
}
|
||||
const response = await this.tuyaService.deleteAutomation(
|
||||
tuyaSpaceId,
|
||||
automationUuid,
|
||||
|
Reference in New Issue
Block a user