Closed aviadoffer closed 2 years ago
They did, I'm working on a fix as we speak. The way the "device usage" info comes back is totally different so that's the biggest change that I'm trying to deal with. Fixed the customers call pretty easily (don't need to provide the gid manually, they pull it off the auth token) but the usage call provides all the data nested now which is super handy for some things but also completely different from before.
I'm going to try to be better about checking after app updates because I could have caught this a week ago and prepped for it.
You the man! thank you.
Thank you! This just hit me too!
First, I tested interactively (python command-line) and I was able to load my devices. Then I turned those same Python statements into a little .py script, tried to run it, and suddenly hit this Bad Request for url
error and was very confused. But it turns out the API changed in between me testing interactively and writing/running a standalone Python script!
So I came here and was really happy to see that 1) this issue was just opened (so it's not me) and 2) @magico13 is already working on a fix!
Any more indication that they might be making/releasing an official public API soon?
Any more indication that they might be making/releasing an official public API soon?
Hard to say. If they are the app likely won't use it. Biggest indication in the past to me was when they swapped to using "AppAPI" in the url implying there might be some "PublicAPI" or similar endpoint in the future. Or it's just so they can have separate APIs for their different products (like a "BatteryAPI" or something)
They did, I'm working on a fix as we speak. The way the "device usage" info comes back is totally different so that's the biggest change that I'm trying to deal with. Fixed the customers call pretty easily (don't need to provide the gid manually, they pull it off the auth token) but the usage call provides all the data nested now which is super handy for some things but also completely different from before.
Thanks for already being on that and I am so looking forward for a fix as my system relying on your library broke an hour ago due to their API change (https://github.com/jeremy-compostella/home-manager). I was trying to see what changed. What is your reverse engineering process ? Let me know if I can help.
Code updated in master but not deployed to PyPI yet. Need to update the readme and api docs. Replaced get_devices_usage
with get_device_list_usage
which has a very different return. Here's an example method that will print the usage from all the channels if you pass in the return from that method:
def print_recursive(usage_dict, depth=0):
for gid, device in usage_dict.items():
for channelnum, channel in device.channels.items():
name = channel.name
print('-'*depth, f'{gid} {channelnum} {name} {channel.usage} kwh')
if channel.nested_devices:
print_recursive(channel.nested_devices, depth+1)
Updated on PyPI with 0.14.0, let me know if there are any additional issues, I did rush it a bit. Closing this.
I get devices now but:
channel_usage_list = vue.get_devices_usage(deviceGids, None, scale=pyemvue.enums.Scale.SECOND.value, unit=pyemvue.enums.Unit.KWH.value) Traceback (most recent call last): File "
", line 1, in AttributeError: 'PyEmVue' object has no attribute 'get_devices_usage'
Correct, that method changed pretty substantially, see this message: https://github.com/magico13/PyEmVue/issues/25#issuecomment-901309335
I missed that sorry. thanks
OK looks like TotalUsage doesn't always work and for AMPS it shows zero.
channel_usage_list = vue.get_device_list_usage(deviceGids, None, scale=pyemvue.enums.Scale.SECOND.value, unit=pyemvue.enums.Unit.AMPHOURS.value)
<pyemvue.device.VueDeviceChannelUsage object at 0x000000146B3B3CA0>
channel_usage_list[deviceGids[0]].channels["Mains_A"].usage -0.002654653647917231 channel_usage_list[deviceGids[0]].channels["Mains_B"].usage -0.0026299228329355823 channel_usage_list[deviceGids[0]].channels["TotalUsage"].usage 0.0
Thanks for the prompt resolution.
I didn't check it with amps and unfortunately I need to get back to work. After work I can look into that if that's alright, it seems to be working ok with kilowatt hours which was my main focus.
yes, no worry. I can sum up manually for now. thanks again for your quick resolution
@aviadoffer Make sure you're not accidentally grabbing the new "Balance" channel. It has a name and channel_num of "Balance" and can have positive or negative values. I ran into this when upgrading the Vuegraf project and those negative usage values caught my eye.
Something else that I noticed is that the usage for a channel is now the usage with nested devices excluded. So if you have an Emporia plug drawing 100 watts on a circuit drawing 250 watts (total) the plug will say 100 watts and the circuit will say 150 watts like you see in the app. It used to report as 100 and 250.
Where that can get interesting is if you have a plug drawing 1000 watts and the circuit is doing 1200 watts total, it'll report 1000 for the plug and 200 for the circuit. In theory this applies for nested vues as well, say if you have one on a subpanel.
That's screwed up. Anyway seems like Main_A and Main_B works for me for amphours and for KWh/KW I use [1,2,3]. I am sure it will change soon again , so it is what it is.
Looks like TotalUsage might only populate at the Day and higher scale and only shows up if you have solar.