➜ tplink-smarthome-api getInfo <ipaddr>
Sending getInfo command to <ipaddr>: via tcp...
response:
{
sysInfo: {
sw_ver: '1.0.2 Build 230901 Rel.153200',
hw_ver: '1.0',
model: 'KP401(US)',
deviceId: '<devid>',
oemId: '<oemid>',
hwId: '<hwid>',
rssi: -81,
latitude_i: 335994,
longitude_i: -1176420,
alias: 'Backyard Fountain',
status: 'new',
obd_src: 'tplink',
mic_type: 'IOT.SMARTPLUGSWITCH',
feature: 'TIM',
mac: '<mac>',
updating: 0,
led_off: 0,
relay_state: 1,
on_time: 1223826,
icon_hash: '',
dev_name: 'Smart Outdoor Plug',
active_mode: 'none',
next_action: { type: -1 },
ntc_state: 0,
err_code: 0
},
cloud: {
info: {
username: 'joe@example.com',
server: 'n-devs.tplinkcloud.com',
binded: 1,
cld_connection: 1,
illegalType: 0,
stopConnect: 0,
tcspStatus: 1,
fwDlPage: '',
tcspInfo: '',
fwNotifyType: -1,
err_code: 0
}
},
emeter: { realtime: {} },
schedule: { nextAction: { type: -1, err_code: 0 } }
}
const { Client } = require('tplink-smarthome-api');
const client = new Client();
const plug = client.getDevice({ host: '<ipaddr>' }).then((device) => {
device.emeter.getRealtime().then((result) => { console.log(result) })
});
➜ node App.js
/path/to/Monitor-TP-Link-SmartPlug/node_modules/tplink-smarthome-api/lib/utils.js:186
throw new ResponseError(errors[0].msg, JSON.stringify(errors[0].response), JSON.stringify(command), [errors[0].module], errors[0].method === undefined ? undefined : [errors[0].method]);
^
ResponseError: err_code not zero response: {"err_code":-1,"err_msg":"module not support"} command: {"emeter":{"get_realtime":{}}}
at processResponse (/path/to/Monitor-TP-Link-SmartPlug/node_modules/tplink-smarthome-api/lib/utils.js:186:15)
at Plug.sendCommand (/path/to/Monitor-TP-Link-SmartPlug/node_modules/tplink-smarthome-api/lib/device/index.js:274:53)
at async Emeter.getRealtime (/path/to/Monitor-TP-Link-SmartPlug/node_modules/tplink-smarthome-api/lib/shared/emeter.js:60:55) {
response: '{"err_code":-1,"err_msg":"module not support"}',
command: '{"emeter":{"get_realtime":{}}}',
modules: [ 'emeter' ],
methods: []
}
Result: