Jump to content

Wifi-enabled 'Smart Plugs' with a local REST API


MWareman

Recommended Posts

So - a product space I've not been paying much attention to recently - but many, many options out there with little detail on the feature that matters - no cloud dependency..

I need to be able to reboot my ISYs by remote - from the other ISYs (I have 3). Two of the ISYs are zwave (but you cannot bind outlets to more than one ISY) - two are Insteon (same limitation) - the third ISY (the one integrated with Zigbee to my power company) has neither zwave or a PLM. The one thing in common is they all have the network module.

So - I'm now looking for simple plug-in controllable outlets that implement a local REST API that I can call from any of the three ISYs to power cycle any of the ISYs (and likely other things, like Foscams etc) so I can reboot devices while away from home, yet allow the devices to be moved around the house. Most that I'm finding have some kind of cloud dependency (which I'm trying to avoid).

I know Snoff's can do this (with custom firmware) - but they aren't simply plug and go (have to wire them inline). Are there any better options?

Link to comment

I nominate the Kasa Smart plug: https://www.amazon.com/TP-Link-Kasa-Smart-Wifi-Plug/dp/B07RCNB2L3/  (there's also a slightly more expensive model with load sensing built in.)

The local API is undocumented, but @Jimbo figured it out and wrote a node server.  I'm certain if you're not interested in running the nodeserver that you could in fact peak at his code get what you need to craft a NR, just be sure to reserve IP addresses so they can't jump IP's.

Can't beat the price either.  I've purchased 12 and finally had enough devices to automate christmas last year.

Link to comment
8 minutes ago, MrBill said:

I nominate the Kasa Smart plug: https://www.amazon.com/TP-Link-Kasa-Smart-Wifi-Plug/dp/B07RCNB2L3/  (there's also a slightly more expensive model with load sensing built in.)

The local API is undocumented, but @Jimbo figured it out and wrote a node server.  I'm certain if you're not interested in running the nodeserver that you could in fact peak at his code get what you need to craft a NR, just be sure to reserve IP addresses so they can't jump IP's.

Can't beat the price either.  I've purchased 12 and finally had enough devices to automate christmas last year.

I second the Kasa plugs. They emailed a code this morning for 30% off the exact item @MrBill llinked to above. Unfortunately, it is a one use code which I quickly took advantage of but even without the discount, they are a good deal.... and Prime Day starts tomorrow.

Link to comment

From the way I understand it the local API is 100% local, it's just not documented (or not documented by tp-link, there's a lot of reverse engineering discussion available online).  They do "phone home" tho in the form of some cloud instance that allows you to reach them via the app from outside your network.   If your local network allows you to create traffic rules I'll bet you could block the device from making its cloud connection and it would still function via the local API, that's only a guess tho.  They work perfectly local only with the nodeserver/ISY.

The 4-pack is always like 24.99 (if it's not wait a few days and it will be again.) resulting in normal everyday if purchased in 4 packs ~6.25/each  For Prime day they've been getting a lot of press out of discounting the 1 and 2 packs to about the same level, but the 4 pack stayed at its everyday price.    

I was hoping for a deal on other model that reports load, but it so far doesn't look like it's going to get a prime day discount.  I only need 1 of that model tho so if it's not discounted I'll just order it.

Link to comment
15 minutes ago, MrBill said:

From the way I understand it the local API is 100% local, it's just not documented (or not documented by tp-link, there's a lot of reverse engineering discussion available online).  They do "phone home" tho in the form of some cloud instance that allows you to reach them via the app from outside your network.   If your local network allows you to create traffic rules I'll bet you could block the device from making its cloud connection and it would still function via the local API, that's only a guess tho.  They work perfectly local only with the nodeserver/ISY.

I use the Kasa app to set up the device names which are pulled into the Kasa Nodeserver so there's no configuration there. A Kasa account is used only to control outside of the LAN which I don't use. The app works locally without logging in but blocking traffic to *.tplinkcloud.com assures there's no phoning home. Of course you do need to open it up to install firmware updates to the device but I've only had to do that when I first installed the device.

Link to comment
27 minutes ago, DaveStLou said:

I use the Kasa app to set up the device names which are pulled into the Kasa Nodeserver so there's no configuration there. A Kasa account is used only to control outside of the LAN which I don't use. The app works locally without logging in but blocking traffic to *.tplinkcloud.com assures there's no phoning home. Of course you do need to open it up to install firmware updates to the device but I've only had to do that when I first installed the device.

That's the part I assumed but never tried.    Natively the device has to keep the cloud server up to date, otherwise the reverse proxy feature of the app could never work when your outside the local network.  When your phone app is suddenly used away it has to know how to reach the module being manipulated.

Link to comment

So - 4 pack arrived. These things certainly respond fast to the app on Android and IOS.

To get then working from ISY. This is what I've found (It's a little dated - but the Bash script works!): https://blog.georgovassilis.com/2016/05/07/controlling-the-tp-link-hs100-wi-fi-smart-plug/

Putting this script on a Linux system and running it I am able to turn the outlet on and off. Win.

It lists the following TCP payloads sent to TCP/9999:

On:  AAAAKtDygfiL/5r31e+UtsWg1Iv5nPCR6LfEsNGlwOLYo4HyhueT9tTu36Lfog==

Off: AAAAKtDygfiL/5r31e+UtsWg1Iv5nPCR6LfEsNGlwOLYo4HyhueT9tTu3qPeow==

This is run thru base64 to decode it - and then piped to Netcat to send the binary stream to the device. Works beautifully.

Running into trouble on ISY though. Working with 'On' - I convert the Base64 string to Ascii value (which is what I believe ISY should accept):

https://www.multiutil.com/base64-to-binary-converter/

0,0,0,42,239,191,189,239,191,189,239,191,189,239,191,189,239,191,189,239,191,189,239,191,189,239,191,189,239,148,182,197,160,212,139,239,191,189,239,191,189,239,191,189,239,191,189,196,176,209,165,239,191,189,239,191,189,216,163,239,191,189,239,191,189,239,191,189,239,191,189,239,191,189,239,191,189,223,162,223,162

Converting the commas to semicolons gives:

0;0;0;42;239;191;189;239;191;189;239;191;189;239;191;189;239;191;189;239;191;189;239;191;189;239;191;189;239;148;182;197;160;212;139;239;191;189;239;191;189;239;191;189;239;191;189;196;176;209;165;239;191;189;239;191;189;216;163;239;191;189;239;191;189;239;191;189;239;191;189;239;191;189;239;191;189;223;162;223;162

As a Network rule:
image.thumb.png.ff673d23da7476d6cc6861e4e51e857e.png

Save and test and.....   It does not work :(
 

Seems to be the same payload - but obviously missing something. Does anyone have a working example? I'm trying to avoid using the Poly so I can use a network rule on each of my three ISYs to control any of the devices.

Thanks!

Link to comment

I am running the node server now but back in the day someone had posted on here, but I can't seem to find it now, their NR. I still had 2 of them on my ISY.

Here is the command that worked for me, at least back then. I am unable to try it now as these two switches have been deleted. These were copied right from the NR. 

This was to turn on:

0;0;0;42;208;242;129;248;139;255;154;247;213;239;148;182;197;160;212;139;249;156;240;145;232;183;196;176;209;165;192;226;216;163;129;242;134;231;147;246;212;238;223;162;223;162

This was to turn off:

0;0;0;42;208;242;129;248;139;255;154;247;213;239;148;182;197;160;212;139;249;156;240;145;232;183;196;176;209;165;192;226;216;163;129;242;134;231;147;246;212;238;222;163;222;163

I was pretty impressed also with the speed they switched at when using the NR. They are still very responsive when using the node server.

Not sure if any f/w updates to the devices have broken them from working the same or not, I hope these work for you.

-Tim

Link to comment
22 hours ago, TJF1960 said:

I am running the node server now but back in the day someone had posted on here, but I can't seem to find it now, their NR. I still had 2 of them on my ISY.

Here is the command that worked for me, at least back then. I am unable to try it now as these two switches have been deleted. These were copied right from the NR. 

This was to turn on:

0;0;0;42;208;242;129;248;139;255;154;247;213;239;148;182;197;160;212;139;249;156;240;145;232;183;196;176;209;165;192;226;216;163;129;242;134;231;147;246;212;238;223;162;223;162

This was to turn off:

0;0;0;42;208;242;129;248;139;255;154;247;213;239;148;182;197;160;212;139;249;156;240;145;232;183;196;176;209;165;192;226;216;163;129;242;134;231;147;246;212;238;222;163;222;163

I was pretty impressed also with the speed they switched at when using the NR. They are still very responsive when using the node server.

Not sure if any f/w updates to the devices have broken them from working the same or not, I hope these work for you.

-Tim

Tim,

This worked perfectly! Thank you so much!

Michael.

Link to comment
  • 7 months later...

I purchased a 4 pack and got them running on the Kasa AP using static IP addresses from my DHCP server. I downloaded the shell script mentioned by @MWareman and that works just fine. Now I would like to integrate with my ISY994, but I am now lost. I see that @TJF1960 posted some information on how to enter the information into the 'Network Resources' but after finding and entering the information, I am still not getting any response from the switch. I have tried both TCP and UDP without any result.

I then tried the server that @MrBill mentioned was written by @Jimbo but I could not find enough information on the GIT page to get the server running. I am not finding 'Polyglot Server' in the UI and I don't see anything Kasa on the Polyglot Cloud page. I did see some other items submitted by @Jimbo there.

Link to comment
On 2/1/2022 at 2:01 PM, coinserv said:

I purchased a 4 pack and got them running on the Kasa AP using static IP addresses from my DHCP server. I downloaded the shell script mentioned by @MWareman and that works just fine. Now I would like to integrate with my ISY994, but I am now lost. I see that @TJF1960 posted some information on how to enter the information into the 'Network Resources' but after finding and entering the information, I am still not getting any response from the switch. I have tried both TCP and UDP without any result.

I then tried the server that @MrBill mentioned was written by @Jimbo but I could not find enough information on the GIT page to get the server running. I am not finding 'Polyglot Server' in the UI and I don't see anything Kasa on the Polyglot Cloud page. I did see some other items submitted by @Jimbo there.

This is what is working for me as an ISY NR (I have 8 of these now - 16 total NRs on on and one off per device)

Use TCP, to port 9999 and mode 'Binary'. Set the IP. Use the body applicable:

ON:
0;0;0;42;208;242;129;248;139;255;154;247;213;239;148;182;197;160;212;139;249;156;240;145;232;183;196;176;209;165;192;226;216;163;129;242;134;231;147;246;212;238;222;163;222;163

OFF:
0;0;0;42;208;242;129;248;139;255;154;247;213;239;148;182;197;160;212;139;249;156;240;145;232;183;196;176;209;165;192;226;216;163;129;242;134;231;147;246;212;238;223;162;223;162

Michael.

 

Link to comment

I was able to set them to 'binary', but that did not change anything. 

What I am doing is on the 'Network Resources' page, after entering and saving the information, I highlight the command and press the 'test' button at the bottom of the screen.

Even if the 'test' button worked, I dont see anything added on the Main page that would allow me to include these devices in any programs.

I hit the road for a month starting tomorrow. Maybe there will be an answer by the time I get back home.

 

Link to comment

I don't know that there is anything added to the main page that would result from having a network resource.  Of course, any network resource that you add would show up under the "configuration" tab of the admin console>>>network tab>>>network resources.

Once you create a working network resource, they are available only by invoking by programs.  They can be added to a program via action: networking>>>resource>>>pick-the-one-you-want.

 

Link to comment
9 hours ago, coinserv said:

I was able to set them to 'binary', but that did not change anything. 

What I am doing is on the 'Network Resources' page, after entering and saving the information, I highlight the command and press the 'test' button at the bottom of the screen.

Even if the 'test' button worked, I dont see anything added on the Main page that would allow me to include these devices in any programs.

I hit the road for a month starting tomorrow. Maybe there will be an answer by the time I get back home.

 

You must hit the save button first before testing any NR.

Link to comment
10 hours ago, coinserv said:

I highlight the command and press the 'test' button at the bottom of the screen.

the test button is eccentric... you can only push it when it's ready... see below for more info.

1 hour ago, larryllix said:

You must hit the save button first before testing any NR.

Two different save button's must be pressed first... then you must re-highlight the NR you were working on... THEN and only then the Test button works.

Link to comment

Only suggestions I have is perhaps double check the IP, and try a higher timeout (like 5000 to be sure).

Another place to look for issues is the ISY error log,  Tools > Error log

Does anything happen when you press test after 2 saves?   You could also try creating a program with just the network resource in the Then body, then save the program and right click it and "run then"

 

Link to comment
2 hours ago, coinserv said:

Thanks for the help. IP is fine. Units work with Kasa iPhone app AND with the BASH script. I just wanted to integrate it with ISY.

Heading out for extended vacation. Will pick this up again in a couple months.

Enjoy your vacation. I have moved to the Kasa NodeServer on Polisy V3 but pulled up the Network Resources I used prior just to compare and mine looks the same except I have timeout set to 1,000 but 500 works as well (YMMV):

Screenshot 2022-02-10 093143.png

Since the Network Resources still work, below is the response I get when I test them (both on and off have the same response):

Screenshot 2022-02-10 093243.png

Link to comment
  • 2 months later...
On 6/20/2021 at 3:53 PM, MWareman said:

Seems the Shell Smart Plug US looks to be perfect - but still at preorder (so not soon enough for an upcoming trip :( )  

https://shopusa.shelly.cloud/shelly-plug-us-wifi-smart-home-automation#392

May the item I'm looking for long term. Are there other options that are clear about their support for a local API?

I've got a couple of Shelley smart plugs (US) - but one died and replacement via tech support has been a nightmare (still no go 5 months later).  Great product but not a great support organization.

Link to comment

Archived

This topic is now archived and is closed to further replies.


  • Recently Browsing

    • No registered users viewing this page.
  • Who's Online (See full list)

  • Forum Statistics

    • Total Topics
      36.9k
    • Total Posts
      370.2k
×
×
  • Create New...