File tree 2 files changed +13
-9
lines changed
2 files changed +13
-9
lines changed Original file line number Diff line number Diff line change @@ -11,6 +11,7 @@ const errors = {
11
11
const customErrors = {
12
12
ch404 : 'Device channel does not exist' ,
13
13
unknown : 'An unknown error occurred' ,
14
+ noDevice : 'No device found' ,
14
15
noDevices : 'No devices found' ,
15
16
noPower : 'No power usage data found' ,
16
17
noSensor : "Can't read sensor data from device" ,
Original file line number Diff line number Diff line change 1
- const { nonce , timestamp , _get } = require ( '../helpers/utilities' ) ;
1
+ const { _get } = require ( '../helpers/utilities' ) ;
2
2
const errors = require ( '../data/errors' ) ;
3
3
4
4
module . exports = {
@@ -16,13 +16,12 @@ module.exports = {
16
16
const { APP_ID } = this ;
17
17
18
18
const device = await this . makeRequest ( {
19
- uri : `/user/device/${ deviceId } ` ,
20
- qs : {
21
- deviceid : deviceId ,
22
- appid : APP_ID ,
23
- nonce,
24
- ts : timestamp ,
25
- version : 8 ,
19
+ method : 'post' ,
20
+ uri : `/v2/device/thing/` ,
21
+ body : {
22
+ thingList : [
23
+ { id : deviceId , itemType : 1 }
24
+ ]
26
25
} ,
27
26
} ) ;
28
27
@@ -32,6 +31,10 @@ module.exports = {
32
31
return { error, msg : errors [ error ] } ;
33
32
}
34
33
35
- return device ;
34
+ if ( device . thingList . length === 0 ) {
35
+ throw new Error ( `${ errors . noDevice } ` ) ;
36
+ }
37
+
38
+ return device . thingList . shift ( ) . itemData ;
36
39
} ,
37
40
} ;
You can’t perform that action at this time.
0 commit comments