konsumer / tplink-lightbulb

Control TP-Link smart lightbulbs from nodejs
MIT License
190 stars 32 forks source link

Possible to control a smart plug? #17

Closed mtnptrsn closed 6 years ago

mtnptrsn commented 6 years ago

Is it possible to control a smart plug with this? When I use tplight on <ip> I get this error:

TypeError: Cannot read property 'length' of undefined
    at Object.getTokens (/Users/mtnptrsn/.nvm/versions/node/v7.9.0/lib/node_modules/tplink-lightbulb/node_modules/json-colorizer/src/lib/lexer.js:34:17)
    at colorizeJson (/Users/mtnptrsn/.nvm/versions/node/v7.9.0/lib/node_modules/tplink-lightbulb/node_modules/json-colorizer/src/lib/index.js:5:35)
    at /Users/mtnptrsn/.nvm/versions/node/v7.9.0/lib/node_modules/tplink-lightbulb/build/cli.js:25:50
    at /Users/mtnptrsn/.nvm/versions/node/v7.9.0/lib/node_modules/tplink-lightbulb/build/cli.js:48:26
    at process._tickCallback (internal/process/next_tick.js:109:7)
konsumer commented 6 years ago

I bet it uses a similar protocol, but I have no way of testing. There's instructions in the README for collecting packets, if you're interested, and I might be able to reverse it.

konsumer commented 6 years ago

Ok! I added support for devices that use a relay (like yours.) Test it out with tplight on <ip>. I also updated the support-matrix table, but it could use testing, so please verify all the X'd commands work on your device.

konsumer commented 6 years ago

Smartplug support added (discussion on #18) I also added broadcast IP support, so you can hit a subnet, and updated support-matrix table to the README.

I'm going to close the issue for now, but feel free to open it again, if you have issues with plugs.

mtnptrsn commented 6 years ago

@konsumer Wow! Thank you!