Merge pull request #155 from SyncrowIOT/fix-secne-and-automation-issues

Fix secne and automation issues
This commit is contained in:
hannathkadher
2024-11-25 09:20:48 +04:00
committed by GitHub
3 changed files with 15 additions and 9 deletions

View File

@ -1,4 +1,3 @@
// automation.enum.ts
export enum ActionExecutorEnum {
DEVICE_ISSUE = 'device_issue',
DELAY = 'delay',
@ -17,3 +16,5 @@ export const AUTOMATION_CONFIG = {
COMPARATOR: '==',
SCENE_STATUS_VALUE: 'scene',
};
export const AUTOMATION_TYPE = 'automation';
export const AUTO_PREFIX = 'Auto_';

View File

@ -26,6 +26,8 @@ import {
import { convertKeysToCamelCase } from '@app/common/helper/camelCaseConverter';
import {
ActionExecutorEnum,
AUTO_PREFIX,
AUTOMATION_TYPE,
EntityTypeEnum,
} from '@app/common/constants/automation.enum';
import { TuyaService } from '@app/common/integrations/tuya/services/tuya.service';
@ -154,14 +156,16 @@ export class AutomationService {
throw new HttpException(response.msg, HttpStatus.BAD_REQUEST);
}
return response.result.list.map((item) => {
return {
id: item.id,
name: item.name,
status: item.status,
type: 'automation',
};
});
return response.result.list
.filter((item) => item.name && !item.name.startsWith(AUTO_PREFIX))
.map((item) => {
return {
id: item.id,
name: item.name,
status: item.status,
type: AUTOMATION_TYPE,
};
});
} catch (err) {
if (err instanceof BadRequestException) {
throw err; // Re-throw BadRequestException

View File

@ -459,6 +459,7 @@ export class SceneService {
const space = await this.getSpaceByUuid(scene.spaceUuid);
await this.delete(scene.sceneTuyaUuid, space.spaceTuyaUuid);
await this.sceneRepository.delete({ uuid: sceneUuid });
return new SuccessResponseDto({
message: `Scene with ID ${sceneUuid} deleted successfully`,
});