[RELEASE] Etekcity Vesync Smart In-Wall Wifi Light Switch API and Device Handlers

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.
3 Likes

I’m working on it…

Update: 1 year later… [RELEASE] Etekcity Vesync Smart In-Wall Wifi Light Switch API

2 Likes

Take a look at


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).

1 Like

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
  1. 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.

Any thoughts?

@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.

  1. Are you using the SmartThings classic app?
  2. 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.

  1. In the IDE, go to the “Live Logging” tab
  2. In your app, tap the plug on/off button
  3. At the top of the Live Logging screen, filter to your plug.
  4. 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.

Great, works perfect now, thanks!!

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.

Worked perfectly… Thank you very much!!!

Nic,

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.

Again thanks on a good job.
Louie

Louie, are you able to send me any logs from your 15A plugs?

Thanks for looking into it.

Louie

(Attachment plug logs.txt is missing)

Fantastic work. Can be cleaned up on setup, but well worth the 20 minutes to get mine set up! Thanks again!

1 Like

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.

As far as I can tell the answer is no. I believe he speaks to that in the original post.

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.