plasticrake / tplink-smarthome-api

TP-Link Smarthome WiFi API
MIT License
1.02k stars 142 forks source link

reboot HS110 not working #29

Closed Tuxdiver closed 6 years ago

Tuxdiver commented 6 years ago

I tried to reboot a switch (after it stopped sending emeter values), but it only gave an error message: { err_code: -3, err_msg: 'invalid argument' }

I think, your internal reboot command sends the delay value as a string: [2] client.sendTcp({"payload":{"system":{"reboot":{"delay":"1"}}},"host":"192.168.178.27","port":9999,"timeout":5000})

In contrast to

tplink-smarthome-api sendCommand -D 192.168.178.27 '{"system":{"reboot":{"delay":1}}}'
...
[2] client.sendTcp({"payload":{"system":{"reboot":{"delay":1}}},"host":"192.168.178.27","port":9999,"timeout":5000})
...

which worked for me.

Systeminfo:

"sw_ver":"1.1.4 Build 170417 Rel.145118",
"hw_ver":"1.0",
"type":"IOT.SMARTPLUGSWITCH",
"model":"HS110(EU)"
plasticrake commented 6 years ago

I can't reproduce your issue. You didn't provide the code but I assume you are passing a string instead of a number.

const { Client } = require('..');
const client = new Client({logLevel: 'debug'});

client.getDevice({host: '10.0.0.124'}).then((device) => {
  device.reboot(1);
});
[2] client.sendTcp({"payload":{"system":{"reboot":{"delay":1}}},"host":"10.0.0.124","port":9999,"timeout":5000})
[2] client.sendTcp(): attempting to open. host:10.0.0.124, port:9999
[2] client.sendTcp(): socket:connect 10.0.0.124 9999
[2] client.sendTcp(): socket:data 10.0.0.124:9999 segment:1
[2] client.sendTcp(): socket:data message: {"system":{"reboot":{"err_code":0}}}
Tuxdiver commented 6 years ago

Sorry, forget to mention: I used the tplink-smarthome-api CLI

plasticrake commented 6 years ago

Thanks! fixed in v0.21.0