mirror of
https://github.com/SyncrowIOT/backend.git
synced 2025-07-15 18:27:05 +00:00
Merge pull request #165 from SyncrowIOT/fix-add-scene-issue
Update AutomationService to use SceneRepository for scene details
This commit is contained in:
@ -33,6 +33,7 @@ import {
|
|||||||
import { TuyaService } from '@app/common/integrations/tuya/services/tuya.service';
|
import { TuyaService } from '@app/common/integrations/tuya/services/tuya.service';
|
||||||
import { ConvertedAction } from '@app/common/integrations/tuya/interfaces';
|
import { ConvertedAction } from '@app/common/integrations/tuya/interfaces';
|
||||||
import { SceneDeviceRepository } from '@app/common/modules/scene-device/repositories';
|
import { SceneDeviceRepository } from '@app/common/modules/scene-device/repositories';
|
||||||
|
import { SceneRepository } from '@app/common/modules/scene/repositories';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class AutomationService {
|
export class AutomationService {
|
||||||
@ -43,6 +44,7 @@ export class AutomationService {
|
|||||||
private readonly deviceService: DeviceService,
|
private readonly deviceService: DeviceService,
|
||||||
private readonly tuyaService: TuyaService,
|
private readonly tuyaService: TuyaService,
|
||||||
private readonly sceneDeviceRepository: SceneDeviceRepository,
|
private readonly sceneDeviceRepository: SceneDeviceRepository,
|
||||||
|
private readonly sceneRepository: SceneRepository,
|
||||||
) {
|
) {
|
||||||
const accessKey = this.configService.get<string>('auth-config.ACCESS_KEY');
|
const accessKey = this.configService.get<string>('auth-config.ACCESS_KEY');
|
||||||
const secretKey = this.configService.get<string>('auth-config.SECRET_KEY');
|
const secretKey = this.configService.get<string>('auth-config.SECRET_KEY');
|
||||||
@ -245,13 +247,20 @@ export class AutomationService {
|
|||||||
action.actionExecutor !== ActionExecutorEnum.DEVICE_ISSUE &&
|
action.actionExecutor !== ActionExecutorEnum.DEVICE_ISSUE &&
|
||||||
action.actionExecutor !== ActionExecutorEnum.DELAY
|
action.actionExecutor !== ActionExecutorEnum.DELAY
|
||||||
) {
|
) {
|
||||||
const sceneDetails = await this.getTapToRunSceneDetailsTuya(
|
const scene = await this.sceneRepository.findOne({
|
||||||
action.entityId,
|
where: {
|
||||||
);
|
uuid: action.entityId,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
if (scene.uuid) {
|
||||||
|
const sceneDetails = await this.getTapToRunSceneDetailsTuya(
|
||||||
|
scene.sceneTuyaUuid,
|
||||||
|
);
|
||||||
|
|
||||||
if (sceneDetails.id) {
|
if (sceneDetails.id) {
|
||||||
action.name = sceneDetails.name;
|
action.name = sceneDetails.name;
|
||||||
action.type = sceneDetails.type;
|
action.type = sceneDetails.type;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user