ha-emporia-vue icon indicating copy to clipboard operation
ha-emporia-vue copied to clipboard

Adding credentials doesn't work

Open GChan21 opened this issue 1 year ago • 11 comments

Hi, thanks for creating this, videos online look great! My installation seemed to go fine until i add my email and password i use for Emporia. I then get a spinning wheel and it never completes the install. Eventually it times out with "Unexpected Error". Any ideas?
Thanks!

GChan21 avatar Jan 20 '24 23:01 GChan21

I have similar problem. After upgrading to the latest version of plugin it started failing to authorize. The logs show

Unexpected exception

Traceback (most recent call last):
  File "/config/custom_components/emporia_vue/config_flow.py", line 76, in async_step_user
    info = await validate_input(self.hass, user_input)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/emporia_vue/config_flow.py", line 47, in validate_input
    if not await hub.authenticate(data[CONF_EMAIL], data[CONF_PASSWORD]):
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/emporia_vue/config_flow.py", line 37, in authenticate
    result = await loop.run_in_executor(None, self.vue.login, username, password)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/pyemvue/pyemvue.py", line 355, in login
    self.auth = Auth(
                ^^^^^
  File "/usr/local/lib/python3.12/site-packages/pyemvue/auth.py", line 57, in __init__
    self.cognito.authenticate(password=password)
  File "/usr/local/lib/python3.12/site-packages/pycognito/__init__.py", line 495, in authenticate
    self._set_tokens(tokens)
  File "/usr/local/lib/python3.12/site-packages/pycognito/__init__.py", line 767, in _set_tokens
    self.verify_token(
  File "/usr/local/lib/python3.12/site-packages/pycognito/__init__.py", line 266, in verify_token
    raise TokenVerificationException(
pycognito.exceptions.TokenVerificationException: Your 'access_token' token could not be verified (The token is not yet valid (iat)).

Rollback to 0.8.3 did not help. It looks like something has changed on API side.

yuri-tceretian avatar Mar 12 '24 04:03 yuri-tceretian

@yuri-tceretian your issue is from your server time drifting too far from reality, see #260. The original error for this issue was likely an outage on the Emporia/AWS side or invalid credentials, @GChan21 did you ever get logged in?

magico13 avatar Mar 13 '24 14:03 magico13

@magico13 , thanks for the reply. I haven't managed to log in yet, but I've not tried for a while. I'll give it another go and keep you posted. Cheers!

GChan21 avatar Mar 13 '24 16:03 GChan21

I'm getting same error, cant connect anymore

`This error originated from a custom integration.

Logger: custom_components.emporia_vue.config_flow Source: custom_components/emporia_vue/config_flow.py:76 integration: Emporia Vue (documentation, issues) First occurred: 23:24:56 (2 occurrences) Last logged: 23:45:05

Unexpected exception Traceback (most recent call last): File "/config/custom_components/emporia_vue/config_flow.py", line 76, in async_step_user info = await validate_input(self.hass, user_input) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/emporia_vue/config_flow.py", line 47, in validate_input if not await hub.authenticate(data[CONF_EMAIL], data[CONF_PASSWORD]): ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/emporia_vue/config_flow.py", line 37, in authenticate result = await loop.run_in_executor(None, self.vue.login, username, password) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/concurrent/futures/thread.py", line 58, in run result = self.fn(*self.args, **self.kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/pyemvue/pyemvue.py", line 355, in login self.auth = Auth( ^^^^^ File "/usr/local/lib/python3.12/site-packages/pyemvue/auth.py", line 59, in init self.tokens = self.refresh_tokens() ^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/pyemvue/auth.py", line 63, in refresh_tokens self.cognito.renew_access_token() File "/usr/local/lib/python3.12/site-packages/pycognito/init.py", line 695, in renew_access_token self._set_tokens(refresh_response) File "/usr/local/lib/python3.12/site-packages/pycognito/init.py", line 767, in _set_tokens self.verify_token( File "/usr/local/lib/python3.12/site-packages/pycognito/init.py", line 266, in verify_token raise TokenVerificationException( pycognito.exceptions.TokenVerificationException: Your 'access_token' token could not be verified (The token is not yet valid (iat)). `

RageInvader avatar Apr 06 '24 22:04 RageInvader

Token not yet valid typically means your time on your ha instance or docker containers is wrong.

DabblerIOT avatar Apr 06 '24 23:04 DabblerIOT

yeah i have checked and made sure time is correct, could it be daylight savings in the uk?

RageInvader avatar Apr 06 '24 23:04 RageInvader

Don't know, your os and all that up to date? Servers are in iad... us east for auth.. time changed here a couple weeks ago.

Where are you trying to authenticate from?

DabblerIOT avatar Apr 06 '24 23:04 DabblerIOT

reboot host and see how it pans out? Hopefully time sync sorts it all out?

DabblerIOT avatar Apr 06 '24 23:04 DabblerIOT

I'm running in a docker on unraid. tried all the reboots nothing helping.

RageInvader avatar Apr 07 '24 02:04 RageInvader

okay, i tried changing timezone on unraid to UTC which takes my clock 1 hour back, and it works now.

RageInvader avatar Apr 07 '24 02:04 RageInvader

I'm seeing this issue and unfortunately an NTP sync doesn't fix it.

That is, after running:

home:~# ntpd -d -q -n -p pool.ntp.org
ntpd: 'pool.ntp.org' is 198.60.22.240
ntpd: sending query to 198.60.22.240
ntpd: reply from 198.60.22.240: offset:+0.976274 delay:0.026299 status:0x24 strat:2 refid:0x0260a384 rootdelay:0.014282 reach:0x01
ntpd: sending query to 198.60.22.240
ntpd: reply from 198.60.22.240: offset:+0.976367 delay:0.026415 status:0x24 strat:2 refid:0x0260a384 rootdelay:0.014282 reach:0x03

I'm still seeing this error:

pycognito.exceptions.TokenVerificationException: Your 'access_token' token could not be verified (The token is not yet valid (iat)).

My HA container is configured to use PDT:

home:/config# env | grep TZ
TZ=America/Los_Angeles
home:/config# date
Tue Apr  9 23:11:28 PDT 2024

sushain97 avatar Apr 10 '24 06:04 sushain97