-
Notifications
You must be signed in to change notification settings - Fork 37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Documentation examples, I need more instructions... #80
Comments
Hello, you're primarily running into issues with python imports and its syntax. For If you do Your last error refers to code that looks like import pyemvue
from pyemvue.enums import Scale, Unit
import datetime
# Crea l'oggetto "vue" (?)
vue = pyemvue.PyEmVue()
vue.login(username='MIAMAIL', password='MIAPASSWORD', token_storage_file='keys.json')
#
### Get usage over time
## # ```python
## 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,
)
print("Usage for the last seven days starting", start_time.isoformat())
for usage in usage_over_time:
print(usage, "kwh")
# ```
# Gets the usage in the scale and unit provided over the given time range. Returns a tuple with the first element the usage list and the second the datetime that the range starts.
#### Arguments
# - **channel**: A VueDeviceChannel object, typically pulled from a VueDevice.
# - **start**: The start time for the time period. Defaults to now if None.
# - **end**: The end time for the time period. Default to now if None.
# - **scale**: The time scale to check the usage over.
# - **unit**: The unit of measurement. If you want the last hour of one-second data, it might look something like this. You'll have to iterate over all of the devices and/or channels, this is just checking the first channel on the first device. I also got an error if I requested more than 4000 data points, or 1 hour, 6 minutes, and 40 seconds worth of data. import pyemvue
from pyemvue.enums import Scale, Unit
import datetime
vue = pyemvue.PyEmVue()
# Note, once you've logged in with your email and password once, you can just use the token file to log in.
vue.login(token_storage_file="keys.json")
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(hours=1),
datetime.datetime.now(datetime.timezone.utc),
scale=Scale.SECOND.value,
unit=Unit.KWH.value,
)
print("Watts each second for the last hour starting at", start_time.isoformat())
for usage in usage_over_time:
print(usage * 3600 * 1000, "W")
# Note, the usage is always in kilowatt-hour regardless of the scale
# so you must scale it yourself if you want kilowatts, by multiplying by 3600 seconds per 1 hour
# if you want watts, multiply again by 1000 watts per 1 kilowatt |
Thanks for your support! I have two devices, with 6 and 10 channels. If I change the "channels" zero to, for example, 1, 3, 6, I obtain, always, the error "list index out of range". And, please, I need to print the channel number and name in the firs row to identify what data are them.
I tried the underlying code too, and verified this behaviour: Defining "device0 to 4" I can get and print all these. How is it possible to extract the channel names too?
|
Mmhh. I tried the underlying code
Results from the code. (I inserted commas to check).
|
Dear magico13,
I open a new issue because to comment an old one (#32) don't generate a notice, I think.
Using your example(s) I obtained correct results only with the one you shown results in the "readme.md" file.
I'm aware to need learnig on Python, Java and more other things, like a lot of people...
For a programmer like you it's easy and fast to complete coding of your examples, but a lot of us dont'know too much things.
During my training I made various trite errors, (syntax and others), after I founded Spyder, it's a great help to have a correct Python syntax.
Then, in the first example of readme.md file we obtain the list of instant data of all devices matched with our Emporia's account. It's correct, I have two devices and I obtain both's data. (Not always, and sometimes not all, I think it depend from the instant conection quality)
During last year I red a lot of news, forum etc on Emporia vue, like the Emporia's staff criticism on the enormous quantity of requests to them servers originated by your software, and it's normal, because if you need to obtain high resolution data you'll ask continuosly to servers...
So I'd like to ask only when I need, for example for a second resolution every less than three hours, because three hours are the limit of seconds interval on Emporia servers. (or three days for the minute, and so on).
It is the readme.md section I thought to use.
It is the code I wrote the first time, adding the first two rows from the other code.
Obtaining the next message on the console.
It is the code I wrote the second time (replacing the "vue =" rows with the other proven for my account access).
Obtaining the next message on the console.
It is the code I wrote the third time (inserting datatime call).
Obtaining the next message on the console.
Today, reading all other issues (open and not) I found the #42 code. Tried it and under the result
Here the issue #42 code
Obtaining the next message on the console.
So I need to ask to you.
I think you could write some code rows more than actual readme file...
I hope it.
The text was updated successfully, but these errors were encountered: