mirror of
https://github.com/SyncrowIOT/backend.git
synced 2025-11-26 08:54:54 +00:00
finished config with 6 scene device
This commit is contained in:
@ -53,7 +53,7 @@ import { SceneService } from 'src/scene/services';
|
||||
import { AddAutomationDto } from 'src/automation/dtos';
|
||||
import { TuyaService } from '@app/common/integrations/tuya/services/tuya.service';
|
||||
import { SceneDeviceRepository } from '@app/common/modules/scene-device/repositories';
|
||||
import { FourSceneSwitchesEnum } from '@app/common/constants/four-scene.enum';
|
||||
import { SceneSwitchesTypeEnum } from '@app/common/constants/scene-switch-type.enum';
|
||||
|
||||
@Injectable()
|
||||
export class DeviceService {
|
||||
@ -1220,7 +1220,7 @@ export class DeviceService {
|
||||
|
||||
return descendants;
|
||||
}
|
||||
async addSceneToFourSceneDevice(
|
||||
async addSceneToSceneDevice(
|
||||
deviceUuid: string,
|
||||
addSceneToFourSceneDeviceDto: AddSceneToFourSceneDeviceDto,
|
||||
) {
|
||||
@ -1319,7 +1319,8 @@ export class DeviceService {
|
||||
throw new HttpException(errorMessage, errorStatus);
|
||||
}
|
||||
}
|
||||
async getSceneFourSceneDevice(
|
||||
|
||||
async getSceneBySceneDevice(
|
||||
deviceUuid: string,
|
||||
getSceneFourSceneDeviceDto: GetSceneFourSceneDeviceDto,
|
||||
) {
|
||||
@ -1328,7 +1329,7 @@ export class DeviceService {
|
||||
where: {
|
||||
device: { uuid: deviceUuid },
|
||||
switchName:
|
||||
getSceneFourSceneDeviceDto.switchName as FourSceneSwitchesEnum, // Cast the string to the enum
|
||||
getSceneFourSceneDeviceDto.switchName as SceneSwitchesTypeEnum, // Cast the string to the enum
|
||||
},
|
||||
relations: ['device', 'scene'],
|
||||
});
|
||||
@ -1347,10 +1348,13 @@ export class DeviceService {
|
||||
};
|
||||
}
|
||||
} catch (error) {
|
||||
throw new HttpException('Scene device not found', HttpStatus.NOT_FOUND);
|
||||
throw new HttpException(
|
||||
error.message || 'Scene device not found',
|
||||
error.status || HttpStatus.NOT_FOUND,
|
||||
);
|
||||
}
|
||||
}
|
||||
async getScenesFourSceneDevice(deviceUuid: string): Promise<any[]> {
|
||||
async getScenesBySceneDevice(deviceUuid: string): Promise<any[]> {
|
||||
try {
|
||||
const sceneDevices = await this.sceneDeviceRepository.find({
|
||||
where: { device: { uuid: deviceUuid } },
|
||||
|
||||
Reference in New Issue
Block a user