mirror of
https://github.com/SyncrowIOT/backend.git
synced 2025-07-16 02:36:19 +00:00
Add updateAutomation method and update external service handling
This commit is contained in:
@ -218,6 +218,42 @@ export class TuyaService {
|
||||
|
||||
return response;
|
||||
}
|
||||
async updateAutomation(
|
||||
automationUuid: string,
|
||||
spaceId: string,
|
||||
automationName: string,
|
||||
actions: ConvertedAction[],
|
||||
conditions: any[],
|
||||
decisionExpr: string,
|
||||
effectiveTime: any,
|
||||
) {
|
||||
const path = `/v2.0/cloud/scene/rule/${automationUuid}`;
|
||||
const response = await this.tuya.request({
|
||||
method: 'PUT',
|
||||
path,
|
||||
body: {
|
||||
space_id: spaceId,
|
||||
name: automationName,
|
||||
effective_time: {
|
||||
...effectiveTime,
|
||||
timezone_id: 'Asia/Dubai',
|
||||
},
|
||||
type: 'automation',
|
||||
decision_expr: decisionExpr,
|
||||
conditions: conditions,
|
||||
actions: actions,
|
||||
},
|
||||
});
|
||||
|
||||
if (response.success) {
|
||||
return response;
|
||||
} else {
|
||||
throw new HttpException(
|
||||
`Error fetching automation rule: ${response.msg}`,
|
||||
HttpStatus.BAD_REQUEST,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
async updateAutomationState(
|
||||
spaceId: string,
|
||||
|
Reference in New Issue
Block a user