Skip to main content

Library for interacting with the Emporia Vue energy monitor.

Project description

PyEmVue

A Python Library for reading data from the Emporia Vue energy monitoring system.

The library can be invoked directly to pull back some basic info but requires your email and password to be added to a keys.json file, which is then replaced with the access tokens.

API documentation can be accessed here

keys.json

{
    "email": "you@email.com",
    "password": "password"
}

Usage

Log in with username/password

vue = PyEmVue()
vue.login(username='you@email.com', password='password', token_storage_file='keys.json')

token_storage_file is an optional file path where the access tokens will be written for reuse in later invocations. It will be updated whenever the tokens are automatically refreshed.

Log in with access tokens

with open('keys.json') as f:
    data = json.load(f)

vue = PyEmVue()
vue.login(id_token=data['id_token'],
    access_token=data['access_token'],
    refresh_token=data['refresh_token'],
    token_storage_file='keys.json')

Get customer details

vue = PyEmVue()
vue.login(id_token='id_token',
    access_token='access_token',
    refresh_token='refresh_token')

customer = vue.get_customer_details()

Returns a Customer object with email address, name, customer_gid, and creation date

Get devices

vue = PyEmVue()
vue.login(id_token='id_token',
    access_token='access_token',
    refresh_token='refresh_token')

vue.get_devices()

Returns a list of VueDevices with device information, including device_gid and list of VueDeviceChannels associated with the device. VueDeviceChannels are passed to other methods to get information for the specific channel.

Get additional device properties

vue = PyEmVue()
vue.login(id_token='id_token',
    access_token='access_token',
    refresh_token='refresh_token')

device1 = vue.get_devices()[0]
print(device1.device_name) # prints ""
device1 = vue.populate_device_properties(device1)
print(device1.device_name) # prints "Home"

Updates and returns the passed VueDevice with additional information about the device such as the device name (as set in the app), zip code, timezone, electricity costs, etc.

Arguments

  • device: A VueDevice as returned by get_devices. Will be updated and returned.

Get total usage

vue = PyEmVue()
vue.login(id_token='id_token',
    access_token='access_token',
    refresh_token='refresh_token')

energy_usage = vue.get_total_usage(channel, timeFrame=TotalTimeFrame.ALL.value, unit=TotalUnit.WATTHOURS.value)

Returns the total usage over the time frame for the specified channel as a single float number. Generally energy over all time or month to date.

Arguments

  • channel: A VueDeviceChannel from the get_devices call. Key parts are the device_gid and channel_num.
  • timeFrame: Any value from the TotalTimeFrame enum. Either all time or month to date.
  • unit: Any value from the TotalUnit enum. Currently only watthours.

Get recent usage

vue = PyEmVue()
vue.login(id_token='id_token',
    access_token='access_token',
    refresh_token='refresh_token')

channel_usage_list = vue.get_recent_usage(scale=Scale.HOUR.value, unit=Unit.WATTS.value)
for channel in channel_usage_list:
    print(channel.usage)

Returns list of ViewDeviceChannelUsage objects giving usage over the scale timeframe in the unit specified. For a scale of under 1 hour this will give the average usage over the time frame (ie kW), for an hour or more it gives the total usage (ie kWh).

Arguments

  • scale: Any value from the Scale enum. From 1 second to 1 year.
  • unit: Any value from the Unit enum. Generally watts but there are options for dollars or trees or miles driven, etc.

Get usage over time

vue = PyEmVue()
vue.login(id_token='id_token',
    access_token='access_token',
    refresh_token='refresh_token')

usage_time = vue.get_usage_over_time(channel, start, end, scale=Scale.SECOND.value, unit=Unit.WATTS.value)

# Throw into matplotlib for plotting

Returns the energy used by the VueDeviceChannel between the start and end datetimes for each scale timeframe. In other words, if scale is seconds and there's a minute between start and end, you'll get 60 data points in the output.

Arguments

  • channel: A VueDeviceChannel from the get_devices call. Key parts are the device_gid and channel_num.
  • start: Starting datetime given in UTC.
  • end: Ending datetime given in UTC.
  • scale: Any value of Scale enum at HOUR or finer, DAY and higher is not supported. For 1 hour between start and end you'd get 3600 data points at SECOND, 60 at MINUTE, or 4 at MINUTE_15.
  • unit: Any value of Unit enum, generally watts.

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

pyemvue-0.9.5.tar.gz (8.6 kB view details)

Uploaded Source

Built Distribution

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

pyemvue-0.9.5-py3-none-any.whl (9.3 kB view details)

Uploaded Python 3

File details

Details for the file pyemvue-0.9.5.tar.gz.

File metadata

  • Download URL: pyemvue-0.9.5.tar.gz
  • Upload date:
  • Size: 8.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.0.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.8.1

File hashes

Hashes for pyemvue-0.9.5.tar.gz
Algorithm Hash digest
SHA256 6bfa8a1c3bf847ecd9956592ac251c4a7a9762791d2bd5ad954be41c7d28058d
MD5 618dff93664487d83913b9354d0be6aa
BLAKE2b-256 df3990f0c9d216b53ec859be3d0f2ec14e6a9c788e0a3f9a9e8b82b1e9f37043

See more details on using hashes here.

File details

Details for the file pyemvue-0.9.5-py3-none-any.whl.

File metadata

  • Download URL: pyemvue-0.9.5-py3-none-any.whl
  • Upload date:
  • Size: 9.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.0.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.8.1

File hashes

Hashes for pyemvue-0.9.5-py3-none-any.whl
Algorithm Hash digest
SHA256 0943c7b63208b25172c10c9759b468d0dd44cf2ac4ce5f2d838dd88c726bb25f
MD5 90682ccccb2705a1fbd7644c012a3ff6
BLAKE2b-256 6be792fe6244b2a78b4f6077f438eb2053f251287dbceda40fa4a9c251c971de

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