mirror of
https://github.com/SyncrowIOT/backend.git
synced 2025-07-17 03:05:13 +00:00
finished refactor devices module
This commit is contained in:
@ -123,6 +123,7 @@ export class AutomationService {
|
||||
);
|
||||
const formattedCondition = await this.prepareConditions(
|
||||
params.conditions,
|
||||
projectUuid,
|
||||
);
|
||||
|
||||
const response = await this.tuyaService.createAutomation(
|
||||
@ -585,7 +586,10 @@ export class AutomationService {
|
||||
updateAutomationDto;
|
||||
try {
|
||||
const formattedActions = await this.prepareActions(actions, projectUuid);
|
||||
const formattedCondition = await this.prepareConditions(conditions);
|
||||
const formattedCondition = await this.prepareConditions(
|
||||
conditions,
|
||||
projectUuid,
|
||||
);
|
||||
const response = await this.tuyaService.updateAutomation(
|
||||
automationUuid,
|
||||
spaceTuyaUuid,
|
||||
@ -722,6 +726,7 @@ export class AutomationService {
|
||||
const device = await this.deviceService.getDeviceByDeviceUuid(
|
||||
action.entity_id,
|
||||
false,
|
||||
projectUuid,
|
||||
);
|
||||
if (device) {
|
||||
action.entity_id = device.deviceTuyaUuid;
|
||||
@ -759,7 +764,10 @@ export class AutomationService {
|
||||
return convertedData;
|
||||
}
|
||||
|
||||
private async prepareConditions(conditions: Condition[]) {
|
||||
private async prepareConditions(
|
||||
conditions: Condition[],
|
||||
projectUuid: string,
|
||||
) {
|
||||
const convertedData = convertKeysToSnakeCase(conditions);
|
||||
await Promise.all(
|
||||
convertedData.map(async (condition) => {
|
||||
@ -767,6 +775,7 @@ export class AutomationService {
|
||||
const device = await this.deviceService.getDeviceByDeviceUuid(
|
||||
condition.entity_id,
|
||||
false,
|
||||
projectUuid,
|
||||
);
|
||||
if (device) {
|
||||
condition.entity_id = device.deviceTuyaUuid;
|
||||
|
Reference in New Issue
Block a user