Not sure how many people have seen or used these but the Etekcity Wifi Light Switches are quite reasonable on amazon and work very well. They have a decent app and integrate with Alexa/Google Home but I wanted some additional options and integrations.
I have reverse engineered the API calls from their smartphone app, and have put together a Python 3 program that allows a number of options to be executed from any device running a python shell. It supports basic on-off commands, queries device state, can dump a detailed list of all your devices associated with your account, and Iāve also added an energy saver mode that can be setup to occasionally poll the status of a switch and turn it off if itās been on to long.
Iād love to take this and convert it into a groovy-based device handler but thought Iād start with python to get the api calls straight as I know Python well.
Iām not great with groovy, so if anyone wants to assist with converting this into a device handler for integration into smartthings feel free.
Hopefully some others find this usefulā¦
Update - Solution 8/29/20
Thanks so much to @nic_kline for his work on building this into working native device handlers.
Check out his github page for the code:
Note The āetekcity-plug-high-amp.srcā should be used to control the in-wall light switches as well as the higher amp plugs.
specifically the pull requests to see how they are pulling the current power usage. (main code branch has a bug in how it gets current power usage)
For some odd reason, veSync returns some power usage numbers as an int, but others as Hex.
To translate the AAA:BBB hex to an int, convert AAA and BBB to integers. Then (A+B)/8192 will give you the current power usage.
Iāve created a telegraf script to pull the data into influxDB and chart with grafana, but thatās separate from smartthings.
I have not tried your interface, but will since I bought a bunch of Etekcity outlets before I bought ST. Have you looked at doing the same for devices that use the Smart Life app? It seems to be the same concept, and I have several of those wall switches I have pulled out and replaced with Z-wave devices. I would like to get some good out of them in my home.
Well that took me a while⦠anyway I got it working for my Etekcity WiFi plugs. Itās still pretty rough but I figured Iād put the first version out here for anybody.
You can add my repo as nicolaskline | smartthings | master and then tap āUpdate from repoā to get the Etekcity-plug handler.
OR⦠use the typical method of adding via the SmartThings classic IDE. You can copy my code and create a new device handler āfrom codeā and paste it in.
You have to add each plug from the IDE. And after installing the devices, just go to the settings on the device, in your app, and put in your username and password from the VeSync app (on each plug, sorry). Then set the name of the plug to match exactly what you have in the VeSync app.
The refresh button is just to use if the plug gets out of sync with SmartThings (turned on manually and ST doesnāt know about it).
Tried your handler out with no success. Since this is my first custom device and real use of the IDE, this is what I did for a sanity check:
1.Added plug to VeSync, tested, verified it works
2. Copied and pasted your code as a new handler, saved
3. Add plug from IDE input:
Name
Device network id (I made this up, something unique)
Type: Etekcity Plug
Location: Home Name
Hub: Home Hub Name
Launched app, opened device settings, entered username/password (verified Iām using the correct combo) and matching device name from VeSync
The plug exists and everything appears normal, except it doesnāt look like the device page matches what you defined in the handler code. For example, the background color when it is on is blue instead of your defined #79b821. There is also no refresh button.
@jtermi03 Thanks for trying it. Everything you did sounds right. Good observation on that green color, but actually that control isnāt used in the app, so the blue color is normal (see screenshot below). Ok, letās check a couple things.
Are you using the SmartThings classic app?
Go to your plug in the app, and tap the gear icon.
2a. You should see Username, and password filled out.
2b. The āPlug Nameā field should have the exact match of the name of your plug in the VeSync app. (The name of the device in SmartThings doesnāt matter) Does the Plug Name field match?
2c. If the app has successfully found your plug youāll see a random string of letters & numbers below the āPlug Nameā field. Do you?
If all that lines up, but itās still not working, do the following.
In the IDE, go to the āLive Loggingā tab
In your app, tap the plug on/off button
At the top of the Live Logging screen, filter to your plug.
Filter out any personal information and send me or post the logs here, especially any errors
Ok @jtermi03, scratch all that last. I did a fresh install like you did and there was a bug. I fixed it and itās the latest code on GitHub. You can just edit the handler and re-paste my latest code in. Or if you connected to my repo just do āUpdate from repoā. Sorry about that.
Nice work! Tried it out on a couple of the plugs I have and works great.
Looking over your code, looks like plugs only right now, and no wall switch support yet? Any plan to add that? I havenāt looked at this much since I published API last year but seem to remember having a hard time figuring out how to make groovy play nice with json payloads.
Exactly! Getting the Json and format right for groovy and that VeSync endpoint was a very annoying.
Yeah I donāt have any switches, only plugs, so thatās how I test. But now that I figured it out I hope to add support for switches and other hardware based on the api you posted.
first off you did a great job on this code, been waiting for this handler for over a year and its fantastic.
I have 10 plugs the first 8 work like a charm, the last 2 i cannot get them to work at all but i believe its because they are the 15Amp plugs, the other 8 are the normal round plugs, if you can verify that I would appreciate it, iām tired of pulling my hair out.
Does this handler provide the power consumption for the outlets?
I have a schedule set in the VeSync app to turn on/off my Dish Network receiver in order to record a couple of daytime programs. That works fine, but I do not want to turn off the receiver if I am watching TV. I would like to develop a Piston that triggers at the time the receiver would normally turn off (the schedule would be ported to the Piston and taken out of VeSync), and if the consumption of the TV (on a separate Etekcity outlet) is above a certain level, do not turn the receiver off.
I do not need help with the Piston itself, only an answer on whether or not I can read the power consumption from the outlet using this device handler.
Will this only work in terms of adding and intitally setting up if Iām on the same WiFi? Kind of new to the SmartThings platform, and very much a google/copy/paste level person. Got the Device Handler set up, in the IDE, setting everything to match, and in the classic app, itās not finding the device name, but I am working on it primarily remotely right now.
Thank so much for the device handler! I had a bit of an issue getting it working, but I finally found the issue. I bought a pack of four outlets from Amazon on Black Friday, then I bought a pack of six the beginning of December. I configured the ten outlets and was testing āOutlet 03ā and could not get it to respond. I turned on āLive Loggingā in the IDE. When resaving the setting for āOutlet 03ā, an error of āCould not find matching device for Outlet 03ā occurred. However, I also found under āGet response data:ā it was only listing Outlets 05-10 (the six pack).
The outlets from the two packs are all model ESW01-USA and look the same, but when I examined the label on the back of the outlets, they are slightly different. Although the information is in different locations on the label, they both match with the exception of the āResistive Loadā and āFCC IDā.
Working outlets have a āResistive Loadā of 8A and an āFCC IDā of 2AB22ESW01-USA
Firmware version is 1.95 but there is an update available. However, Iām not updating since these are working. [EDIT: I decided to upgrade the firmware on one of the outlets to the most recent (2.123) and the outlet continued to work with the device handler.]
Non-working outlets have a āResistive Loadā of 10A and an āFCC IDā of 2AB22-ESW01-USA2
Firmware version is 1.1.27 and are up-to-date. I did perform a firmware update when I originally set these up so Iām not sure if thatās the issue.