Closed Merca60 closed 4 months ago
Most likely you're just missing dependencies. If you install the PyEmVue module with pip then you shouldn't need anything extra. That can be done by python -m pip install pyemvue
and when installed that way you don't need to download the GitHub repo.
If you want to go off the GitHub repo instead then you can install the dependencies by running python -m pip install -r requirements.txt
from within the folder.
I'm seeing the same error in new Vuegraf builds. I dug into it and found pycognito
has migrated away from python-jose
:
https://github.com/pvizeli/pycognito/pull/220
The reason is that python-jose
is no longer maintained and has security vulnerabilities.
Forcing pycognito to version 2021.3.1 fixes the issue for me.
pip install pycognito==2021.3.1
import pyemvue
from pyemvue.enums import Scale, Unit
def print_recursive(usage_dict, info, depth=0):
for gid, device in usage_dict.items():
for channelnum, channel in device.channel.items():
name = channel.name
if name == 'Main':
name = info[gid].device_name
print('-'*depth,f'{gid}{channelnum}{name}{channel.usage}kwh')
if channel.nested_devices:
print_recursive(channel.nested_devices, info, depth+1)
vue = pyemvue.PyEmVue()
vue.login(username='myname', password='mypassword', token_storage_file='keys=json')
devices=vue.get_devices
device_gids=[]
device_info={}
for device in devices: **(It is 29 line)**
if not device.device_gid in device_gids:
device_gids.append(device.device_gid)
device_info[device.device_gid]=device
else:
device_info[device.device_gid].channels+=device.channels
device_usage_dict=vue.get_device_list_usage(deviceGids=device_gids, instant=None,scale=Scale.MINUTE.value, unit=Unit.KWH.value)
print('device_gid channel_num name usage unit')
print_recursive(device_usage_dict, device_info)
The` result is under
Traceback (most recent call last):
File "/home/ammi/PyEmVue-master/PyEmVue/PPyEmVue_02.py", line 29, in <module>
for device in devices:
TypeError: 'method' object is not iterable
What can I do?
Please, any other advice?
@Merca60 your issue is because of this line devices=vue.get_devices
where you are setting it to the method instead of calling the method and setting the variable to the result. Just swap it to devices=vue.get_devices()
.
Dear magico13, following your example(s) I obtain some result only with the first, the one where you show the results too. It is, (no, really it seems to me), the only one with you show the complete code, other are only a part of the code we need to write. I'm sure to need a lot of knowledge, and I ask to you to write more help row of code than now.
For example I'd like to obtain datas after the "X" instant in the selected time interval, and wrote this code:
import pyemvue
from pyemvue.enums import Scale, Unit
from datetime import datetime
vue = PyEmVue()
vue.login(id_token='id_token',
access_token='access_token',
refresh_token='refresh_token')
devices = vue.get_devices()
usage_over_time, start_time = vue.get_chart_usage(devices[0].channels[0], datetime.datetime.now(datetime.timezone.utc)-datetime.timedelta(days=7), datetime.datetime.now(datetime.timezone.utc), scale=Scale.DAY.value, unit=Unit.KWH.value)
## the previous is "line 20"
print('Usage for the last seven days starting', start_time.isoformat())
for usage in usage_over_time:
print(usage, 'kwh')
I received this message on the terminal, with an empty result.
Traceback (most recent call last):
File "/home/ammi/PyEmVue-master/PyEmVue/PPyEmVue_26.py", line 20, in
I can try to do some random change, but I'm not a programmer, like a lot of people to need to learn.
Can you help us?
Ehm.. I am a new user on Linux, Python etc... I tried the first code from the "readme" file about two months ago, having the results from my device. After hardware problems I needed to reinstall all, and now, I think with the same code, I obtain this error message.
I didn't found any issues on it, am I alone to have this problem?
Thank you for your useful work. Merca60