mirror of
https://github.com/SyncrowIOT/backend.git
synced 2025-07-16 02:36:19 +00:00
Add method to update TapToRun scene in Tuya and integrate it in SceneService
This commit is contained in:
@ -120,6 +120,36 @@ export class TuyaService {
|
||||
);
|
||||
}
|
||||
}
|
||||
async updateTapToRunScene(
|
||||
sceneTuyaUuid: string,
|
||||
spaceId: string,
|
||||
sceneName: string,
|
||||
actions: ConvertedAction[],
|
||||
decisionExpr: string,
|
||||
) {
|
||||
const path = `/v2.0/cloud/scene/rule/${sceneTuyaUuid}`;
|
||||
const response = await this.tuya.request({
|
||||
method: 'PUT',
|
||||
path,
|
||||
body: {
|
||||
space_id: spaceId,
|
||||
name: sceneName,
|
||||
type: 'scene',
|
||||
decision_expr: decisionExpr,
|
||||
conditions: [],
|
||||
actions: actions,
|
||||
},
|
||||
});
|
||||
|
||||
if (response.success) {
|
||||
return response;
|
||||
} else {
|
||||
throw new HttpException(
|
||||
`Error fetching scene rule: ${response.msg}`,
|
||||
HttpStatus.BAD_REQUEST,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
async triggerScene(sceneId: string): Promise<TuyaResponseInterface> {
|
||||
const path = `/v2.0/cloud/scene/rule/${sceneId}/actions/trigger`;
|
||||
|
Reference in New Issue
Block a user