Closed ifuchs closed 1 year ago
I realize this response is way late and you might have already figured this out, but here is a script that I use in testing and is working fine to give me the current hour's data.
from datetime import datetime
import json
import pyemvue
from pyemvue.enums import Scale, Unit
with open('keys.json') as f:
tokens = json.load(f)
vue = pyemvue.PyEmVue()
vue.login(id_token=tokens['idToken'], access_token=tokens['accessToken'], refresh_token=tokens['refreshToken'], token_storage_file='keys.json')
devices = vue.get_devices()
device_gids = []
device_information = {}
for device in devices:
if not device.device_gid in device_gids:
device_gids.append(device.device_gid)
device_information[device.device_gid] = device
else:
device_information[device.device_gid].channels += device.channels
channel_usage_list = vue.get_devices_usage(device_gids, datetime.utcnow(), scale=Scale.HOUR.value,unit=Unit.KWH.value)
for channel in channel_usage_list:
device = device_information[channel.device_gid]
name = None
for dev_channel in device.channels:
if dev_channel.channel_num == channel.channel_num:
name = dev_channel.name or device.device_name
break
print(f"{name} ({channel.channel_num}) - ", "%.3f" % (channel.usage), 'kwh')
This example is out-dated and no longer works.
I put a newer example in #42 but realize I need to update the examples in the readme per #32
I am trying to play around with pyemvue and the first thing I tried to do was print the device names and their usage. However, I seem to get the names of 5 devices of the 10 that the Emporia app shows. Also, this script takes >30 seconds to run which seems rather excessive.
My script looks like this: