Home Assistant Community

Investigate and fix vesync.py to work with new VeSync / Etekcity outlets

Tags: #<Tag:0x00007fcf4fe58b90>

The newest model of the VeSync / Etekcity outlets (https://www.amazon.com/dp/B07J5B2ZR8) don’t work with Home Assistant. The old ones work fine, but the latest release does not even show up. Some changes to the API may be needed? Would be nice to get this fixed!

note: I found the API to list the new devices in the source code for the android APK, but I cannot interact with them. This works to list the devices:

curl -d '{"accountID":"xxxxx", "token":"xxxxxxxxxx"}' -H "Content-Type: application/json" -X POST https://smartapi.vesync.com:443/platform/v1/app/devices/

Vesync Wifi Light Switch with Home Assistant - Does it work?

Any luck with this?
I’ve been digging through the APK for ideas, but I haven’t been able to figure anything out.


Not yet, no. Still trying to figure it out. I will check github later today to see if anyone has updated code.


@homefire says he was able to figure out what is going on with the new API and will update the libraries to use it.


Thanks for figuring this out!
I’m not using it for home assistant, i’m using it to import power usage into telegraf/influxDB/Grafana and it works great! Updated my script and the new outlet data showed right up!


Finally finished integrating the changes. Created a new library in hopes HA will integrate it automatically without having to use a custom component.

I’ve uploaded the package to pypi so it can be installed using pip but I haven’t made a pull request to change the HA config in case there are any more changes. I’m new at this so is there anything else I need to do to get it permanently incorporated into home assistant give me a shout.

I’m guessing they changed the API around to support more data collection and streamline the programming for future devices. The old api still works but doesn’t support the newer devices. I made the appropriate corrections for the primary functions, including daily energy usage but I haven’t yet fixed the historical data for yearly, monthly or weekly power usage.

In order to use this with home assistant now you can use the method laid out by @mahodder in his post Etekcity and VeSync :

1st- Move “vesync.py” file from the “src” directory to the “~config/custom_components” folder in your home assistant configuration directory

2nd- Then move the sample home assistant component file (HACustom_Components/switch/vesync.py) to the “~config/custom_components/switch” folder in your home assistant configuration directory

Hopefully this helps someone. I will post the packets I logged in the docs folder of the repository tomorrow in case anyone has any suggestions or changes. Thanks to Mark Perdue for his hard work to create the basis of the code.

Etekcity and VeSync
New VeSync / Etekcity Wifi outlets don't work with Hass

Hi @homefire

I’m trying to make it work your changes into my Hassio without luck.

I have both files in:

/config/custom_components/vesync.py (18KB file)
/config/custom_components/switch/vesync.py (4KB file)

But I have this in the log:

   2019-03-05 17:31:43 ERROR (MainThread) [homeassistant.loader] Error loading custom_components.vesync.switch. Make sure all dependencies are installed
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/homeassistant/loader.py", line 147, in _load_file
    module = importlib.import_module(path)
  File "/usr/local/lib/python3.7/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
  File "<frozen importlib._bootstrap>", line 983, in _find_and_load
  File "<frozen importlib._bootstrap>", line 962, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'custom_components.vesync.switch'; 'custom_components.vesync' is not a package
2019-03-05 17:31:43 INFO (MainThread) [homeassistant.loader] Loaded switch.vesync from custom_components.switch.vesync

What am I doing wrong?

Thanks in advance


Do me a favor, include the latest custom component on my github without changing any lines and remove both vesync.py files. Include the the latest file below in



I am running on a virtual environment, and I realized that it automatically installs the pip package in the requirements line. I’m not sure if it does the same on hassio but I don’t see why it wouldn’t.

I apologize for having to change the repo name but I made a stupid error when naming the package by including a “-”. The files on there should work now. The pull request with HA has been approved already so it should be included in the next distribution.


Now It works, no errors

2019-03-05 20:16:40 INFO (MainThread) [homeassistant.components.switch] Setting up switch.vesync
2019-03-05 20:16:42 INFO (SyncWorker_14) [homeassistant.components.switch.vesync] No VeSync devices found

As you can see, Home Assistant can´t see any device, quite strange because in the Vesync App appear two devices.

Do I need something special in my switch.yaml?. Actually I have this:

  # Etekcity
  - platform: vesync
    username: [email protected]
    password: PasswordVesync

The devices that I have are this ones: ETEKCITY ESW01-EU

Thank you very much for you support


Oops, me being a selfish American I forgot about the rest of the world :cowboy_hat_face:.

I am going to try to adjust the library to include the EU suffix, but I have no way of testing the API responses from here. Are you running the vesync app on an android device or ios?

1 Like

Ha ha.

I have an Android device actually


I will PM you in a few minutes


@homefire your code is working pretty nice for my EU plugs, thanks a lot. You are a genius

The device is totally functional, HA receives the states and W

Do you tink will be an update in home assistant to include this new devices?

Best regards


I will upload new pypi package tonight and submit the pull request to HA. Usually takes up to 2 weeks depending on the timing of the releases.


Sorry for the delay, I updated everything so all that you need to do for full VeSync support is to add this custom component to ~/config/custom_components/vesync/switch.py. No other files need to be moved, it will automatically install dependencies until HA incorporates my PR.


Just wanted to stop by and say thank you @homefire! I’ve been struggling with the same issue and this fixed it for me! You rock!