magico13 / PyEmVue

Python Library for the Emporia Vue Energy Monitor
MIT License
185 stars 36 forks source link

Looks like they again changed the API.. always around 4PM EST :) #31

Closed aviadoffer closed 1 year ago

aviadoffer commented 2 years ago

devices = vue.get_devices() Traceback (most recent call last): File "", line 1, in File "c:\Python38-64\lib\site-packages\pyemvue\pyemvue.py", line 59, in get_devices devices.append(VueDevice().from_json_dictionary(dev)) File "c:\Python38-64\lib\site-packages\pyemvue\device.py", line 68, in from_json_dictionary if 'offlineSince' in con: self.offline_since = parse(con['offlineSince']) File "c:\Python38-64\lib\site-packages\dateutil\parser_parser.py", line 1374, in parse return DEFAULTPARSER.parse(timestr, kwargs) File "c:\Python38-64\lib\site-packages\dateutil\parser_parser.py", line 646, in parse res, skipped_tokens = self._parse(timestr, kwargs) File "c:\Python38-64\lib\site-packages\dateutil\parser_parser.py", line 725, in _parse l = _timelex.split(timestr) # Splits the timestr into tokens File "c:\Python38-64\lib\site-packages\dateutil\parser_parser.py", line 207, in split return list(cls(s)) File "c:\Python38-64\lib\site-packages\dateutil\parser_parser.py", line 75, in init raise TypeError('Parser must be a string or character stream, not ' TypeError: Parser must be a string or character stream, not NoneType

magico13 commented 2 years ago

This looks like it might be #30 which I'm planning on fixing tonight

aviadoffer commented 2 years ago

Thanks

kpnobvious commented 2 years ago

thanks for fixing this again so quickly. I recently updated and must have missed some auth changes.

I was previously reading the keys.json and parsing the tokens out. if ('email' not in data or 'password' not in data) and ('idToken' not in data or 'accessToken' not in data or 'refreshToken' not in data):

It looks like the tokens are now stored as id_token, access_token etc. When did that happen to change?

magico13 commented 2 years ago

That was changed in this latest release. I'm in the process of refactoring the authentication process to align it better with what's expected by Home Assistant which allows for an application to manage the tokens themselves instead of pyemvue doing all of it. Take a look at the new Auth class and you'll see that you can override how tokens are refreshed and can pass in a callback method to be alerted when a refresh happens. https://github.com/magico13/PyEmVue/blob/master/pyemvue/auth.py