Skip to main content

pyvesync is a library to manage Etekcity Switches

Project description

pyvesync build status

pyvesync is a library to manage VeSync compatible smart home devices.

Installation

Install the latest version from pip:

pip install pyvesync

Supported Devices

  1. Etekcity Voltson Smart WiFi Outlet (7A model ESW01-USA)
  2. Etekcity Voltson Smart WiFi Outlet (10A model ESW01-EU)
  3. Etekcity Voltson Smart Wifi Outlet (10A model ESW03-USA)
  4. Etekcity Voltson Smart WiFi Outlet (15A model ESW15-USA)
  5. Etekcity Smart WiFi Light Switch (model ESWL01)
  6. Levoit Smart Wifi Air Purifier (LV-PUR131S)

Usage

To start with the module:

from pyvesync import VeSync

manager = VeSync("EMAIL", "PASSWORD", time_zone=DEFAULT_TZ)
manager.login()
manager.update()

my_switch = manager.outlets[0]
# Turn on the first switch
my_switch.turn_on()
# Turn off the first switch
my_switch.turn_off()

# Get energy usage data
manager.update_energy()

# Display outlet device information
for device in manager.outlets:
    device.display()

Configuration

The time_zone argument is optional but the specified time zone must match time zone in the tz database (IANNA Time Zone Database), see this link for reference: tz database. The time zone determines how the energy history is generated for the smart outlets, i.e. for the week starts at 12:01AM Sunday morning at the specified time zone. If no time zone or an invalid time zone is entered the default is America/New_York

#Devices are respectively located in their own lists that can be iterated over
manager.outlets = [VeSyncOutletObjects]
manager.switches = [VeSyncSwitchObjects]
manager.fans = [VeSyncFanObjects]

If outlets are going to be continuously polled, a custom energy update interval can be set - The default is 6 hours (21600 seconds)

manager.energy_update_interval = time # time in seconds

Example Usage

Get electricity metrics of outlets

for s in manager.outlets:
  s.update_energy(check_bypass=False) # Get energy history for each device

API Details

Manager API

VeSync.get_devices() - Returns a list of devices

VeSync.login() - Uses class username and password to login to VeSync

VeSync.update() - Fetch updated information about devices

VeSync.update_all_devices() - Fetch details for all devices (run VeSyncDevice.update())

VeSync.update_energy(bypass_check=False) - Get energy history for all outlets - Builds week, month and year nested energy dictionary. Set bypass_check=True to disable the library from checking the update interval

Device API

VeSyncDevice.turn_on() - Turn on the device

VeSyncDevice.turn_off() - Turn off the device

VeSyncDevice.update() - Fetch updated information about device

VeSyncDevice.active_time - Return active time of the device in minutes

Outlet Specific Energy API

VeSyncOutlet.update_energy(bypass_check=False) - Get outlet energy history - Builds week, month and year nested energy dictionary. Set bypass_check=True to disable the library from checking the update interval

VeSyncOutlet.energy_today - Return current energy usage in kWh

VeSyncOutlet.power - Return current power in watts of the device

VeSyncOutlet.voltage - Return current voltage reading

VesyncOutlet.weekly_energy_total - Return total energy reading for the past week in kWh, starts 12:01AM Sunday morning

VesyncOutlet.monthly_energy_total - Return total energy reading for the past month in kWh

VesyncOutlet.yearly_energy_total - Return total energy reading for the past year in kWh

Model ESW15-USA 15A/1800W API

The rectangular smart switch model supports some additional functionality on top of the regular api call

VeSyncOutlet.turn_on_nightlight() - Turn on the nightlight

VeSyncOutlet.turn_off_nightlight() - Turn off the nightlight

Air Purifier LV-PUR131S Functions

VeSyncFan.fan_level - Return the level of the fan (1-3) or 0 for off

VeSyncFan.filter_life - Return the percentage of filter life remaining

VeSyncFan.air_quality - Return air quality reading

VeSyncFan.auto_mode() - Change mode to auto

VeSyncFan.manual_mode() - Change fan mode to manual with fan level 1

VeSyncFan.sleep_mode() - Change fan mode to sleep

VeSyncFan.change_fan_speed(speed) - Change fan speed with level 1, 2 or 3

VeSyncFan.screen_status - Get Status of screen on/off

Notes

More detailed data is available within the VesyncOutlet by inspecting the VesyncOutlet.energy dictionary.

The VesyncOutlet.energy object includes 3 nested dictionaries week, month, and year that contain detailed weekly, monthly and yearly data

VesyncOutlet.energy['week']['energy_consumption_of_today']
VesyncOutlet.energy['week']['cost_per_kwh'] 
VesyncOutlet.energy['week']['max_energy']
VesyncOutlet.energy['week']['total_energy']
VesyncOutlet.energy['week']['data'] # which itself is a list of values

Integration with Home Assistant

This library is integrated with Home Assistant and documentation can be found at https://www.home-assistant.io/components/vesync/. The library version included with Home Assistant may lag behind development compared to this repository so those wanting to use the latest version can do the following to integrate with HA.

  1. Add a custom_components directory to your Home Assistant configuration directory
  2. Add a vesync directory as a directory within custom_components
  3. Add switch.py to the vesync directory
  4. Add __init__.py to the vesync directory
  5. Add manifest.json to the vesync directory
  6. Add the following config to your Home Assistant configuration.yaml file:
vesync:
  username: VESYNC_USERNAME
  password: VESYNC_PASSWORD
  1. Restart Home Assistant

The custom_components directory should include the following files:

custom_components/vesync/__init__.py
custom_components/vesync/switch.py
custom_components/vesync/manifest.json

The version of the library defined in manifest.json should now get loaded within Home Assistant.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyvesync-1.0.11.tar.gz (22.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pyvesync-1.0.11-py2.py3-none-any.whl (28.9 kB view details)

Uploaded Python 2Python 3

File details

Details for the file pyvesync-1.0.11.tar.gz.

File metadata

  • Download URL: pyvesync-1.0.11.tar.gz
  • Upload date:
  • Size: 22.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.3

File hashes

Hashes for pyvesync-1.0.11.tar.gz
Algorithm Hash digest
SHA256 08ace404f86ed565339fa4cda7a5709a0cd52212c3759055d374e4537a96f73b
MD5 52e8f1cc498aedfc2802fb6a42033136
BLAKE2b-256 74482f85286c52482b572250983d75d5fb8ac9d9e48b92aac8bb47f35ccf27cb

See more details on using hashes here.

File details

Details for the file pyvesync-1.0.11-py2.py3-none-any.whl.

File metadata

  • Download URL: pyvesync-1.0.11-py2.py3-none-any.whl
  • Upload date:
  • Size: 28.9 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.3

File hashes

Hashes for pyvesync-1.0.11-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 05cf0c374f75ee1213f99f88a585e17d0d6db763abc8d194503c8a8a88515607
MD5 a1a0055f6834b3137de44e6f80ea3e6a
BLAKE2b-256 b949062f87f2c14ebe71defedd75e1190bc16d6b5ab96d7fd4d58d7b8a51b4e7

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page