Skip to content

Commit 25507ea

Browse files
Remove deprecated TuyaAPI openapi (#16)
Co-authored-by: Andreas Botsikas <[email protected]>
1 parent d7839b1 commit 25507ea

File tree

2 files changed

+28
-1
lines changed

2 files changed

+28
-1
lines changed

index.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,33 @@ class TuyaLinkWizard {
181181
throw error;
182182
}
183183
}
184+
185+
async getLinkedDevices({ ids, pageNumber = 0, pageSize = 100 } = { pageNumber: 0, pageSize: 100 }){
186+
187+
const searchParameters = {
188+
schema: this.schema,
189+
page_no: pageNumber,
190+
page_size: pageSize
191+
};
192+
if (ids) {
193+
searchParameters.device_ids = ids.toString();
194+
}
195+
196+
const response = await this.api.request({
197+
path: '/v1.0/devices',
198+
method: 'GET',
199+
query: searchParameters
200+
});
201+
202+
if (!response.success) {
203+
throw new Error(response.msg);
204+
}
205+
206+
const batchDevices = response.result;
207+
debug('Retrieved device(s)!', batchDevices);
208+
209+
return batchDevices
210+
}
184211
}
185212

186213
module.exports = {wizard: TuyaLinkWizard, manual: TuyaLink};

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@tuyapi/link",
3-
"version": "0.3.4",
3+
"version": "0.4.0",
44
"description": "📡 Effortlessly connect devices to WiFi and the cloud",
55
"main": "index.js",
66
"files": [

0 commit comments

Comments
 (0)