plasticrake / tplink-smarthome-api

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

Configure the SSID #65

Open markorajevic opened 5 years ago

markorajevic commented 5 years ago

Hi,

I wasn't able to find it in the documentation, but is it possible to send SSID & Password to plug somehow? So far I wasn't able to configure it in that way.

Post update:

Possible. {"netif":{"set_stainfo":{"ssid":"WiFi","password":"secret","key_type":3}}}

plasticrake commented 5 years ago

You can send a custom command using send or sendCommand. I did not include a function for this as I didn't see it's use as the device would have to be on the network already to receive the command. How are you using it?

dustingraves commented 5 years ago

I second this. I would like to be able to provision plugs automatically for a large scale project. After connecting to the local plug wifi, send new wifi config and go from there.

dustingraves commented 5 years ago

Wifi configuration only seems to be possible when the device is in setup mode.

markorajevic commented 5 years ago

@dustingraves Actually, I am sending this code manually for configuration: let data = { "netif": { "set_stainfo": { "ssid": "ssid_name", "password": "password_here", "key_type": 3 } } }

wcbonner commented 4 years ago

I was really hoping to have this work as I was needing to migrate from one network SSID to another and I didn't want to have to reset the devices and set up my schedules from scratch.

Unfortunately the command seems to work on my HS110 but not the HS105, HS300, or LB110 devices...

pi@WimPi4:~/tplink-smartplug $ tplink-smarthome-api send 192.168.0.40 '{"netif":{"set_stainfo":{"ssid":"WiFi","password":"secret","key_type":3}}}'
Sending to 192.168.0.40: via tcp...
response:
{ netif: { set_stainfo: { mac: 'B0:4E:26:AE:4B:47', err_code: 0 } } }
pi@WimPi4:~/tplink-smartplug $ tplink-smarthome-api send 192.168.0.41 '{"netif":{"set_stainfo":{"ssid":"WiFi","password":"secret","key_type":3}}}'
Sending to 192.168.0.41: via tcp...
response:
{ netif: { set_stainfo: { err_code: 0 } } }

The first device I was trying happened to work and the device reconnected to my new SSID, and the response included the MAC ID. All the other devices responded without the MAC ID and remained on the old SSID.

If you have any other suggestions for me to investigate, I'd love feedback.

mikejr83 commented 3 years ago

This would be helpful. For some reason the Kasa app does not register the HS220 I have correctly. It would be nice to be able to just send the network info from my laptop while connected to the switch's setup WiFi and not have to deal with the app on my phone.