finished config with 6 scene device

This commit is contained in:
faris Aljohari
2024-11-19 20:44:45 -06:00
parent 25ce2f7b94
commit 9510905fb4
8 changed files with 81 additions and 30 deletions

View File

@ -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 } },