Skip to content
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

Adding integration stuck on menu #95

Closed
fasavard opened this issue Dec 29, 2021 · 28 comments
Closed

Adding integration stuck on menu #95

fasavard opened this issue Dec 29, 2021 · 28 comments

Comments

@fasavard
Copy link

fasavard commented Dec 29, 2021

image

When adding the integration, i get stuck on the looping animation of the lower right in the menu. Nothing else happend.

I have put the home assistant log on debug but nothing gets logs, should i look somewhere else ?

@fasavard
Copy link
Author

Have have been debugging for a while. Right now i have found that any username or password (even a bad one) will not work

Also, i got a very weird behavior where i already had my account, but after i let the process hang for a while, i got an email from emporia to congratulate me aboute creating my new account

@fasavard
Copy link
Author

Adding the integration from my phone finally five my an error,
`Logger: custom_components.emporia_vue.config_flow
Source: custom_components/emporia_vue/config_flow.py:38
Integration: Emporia Vue (documentation)
First occurred: 08:10:16 (1 occurrences)
Last logged: 08:10:16

Unexpected exception
Traceback (most recent call last):
File "/config/custom_components/emporia_vue/config_flow.py", line 77, in async_step_user
info = await validate_input(self.hass, user_input)
File "/config/custom_components/emporia_vue/config_flow.py", line 48, in validate_input
if not await hub.authenticate(data[CONF_EMAIL], data[CONF_PASSWORD]):
File "/config/custom_components/emporia_vue/config_flow.py", line 38, in authenticate
result = await loop.run_in_executor(None, self.vue.login, username, password)
File "/usr/local/lib/python3.9/concurrent/futures/thread.py", line 52, in run
result = self.fn(*self.args, **self.kwargs)
File "/usr/local/lib/python3.9/site-packages/pyemvue/pyemvue.py", line 184, in login
self.auth = Auth(
File "/usr/local/lib/python3.9/site-packages/pyemvue/auth.py", line 45, in init
self.cognito.authenticate(password=password)
File "/usr/local/lib/python3.9/site-packages/pycognito/init.py", line 447, in authenticate
tokens = aws.authenticate_user()
File "/usr/local/lib/python3.9/site-packages/pycognito/aws_srp.py", line 249, in authenticate_user
response = boto_client.initiate_auth(
File "/usr/local/lib/python3.9/site-packages/botocore/client.py", line 357, in _api_call
return self._make_api_call(operation_name, kwargs)
File "/usr/local/lib/python3.9/site-packages/botocore/client.py", line 676, in _make_api_call
raise error_class(parsed_response, operation_name)
botocore.errorfactory.UserNotFoundException: An error occurred (UserNotFoundException) when calling the InitiateAuth operation: User does not exist.`

I can confirm the user does exist. Could it be some caracter support problem ? The email have dots in it ie: sss.jfhd.sjdsfh@gmail.com

@magico13
Copy link
Owner

I wouldn't expect the dots to be a problem. What region are you in? Right now it only tries to authenticate against the east us cognito user pool but I don't know if they have added additional ones for different regions or if everyone uses the same pool. If you're outside of the US then that could be the problem.

@fasavard
Copy link
Author

Hi, yes im in quebec Canada so that might explain the issue

@magico13
Copy link
Owner

magico13 commented Dec 30, 2021

Ok, I wonder if they have a separate user pool then. If so then your user wouldn't exist in the one it's trying to authenticate against. I'm not as familiar with the AWS data centers outside of the US. If you want to try to figure out where your account is, capture the network traffic in your browser when logging into the Emporia web view and look for requests with cognito in the url. https://web.emporiaenergy.com/#/

I can get you more specific steps later if you want/need them.

@fasavard
Copy link
Author

image
I am on east-2, is it the same as the one you are using ?

@magico13
Copy link
Owner

Hmm, yes that's the same so that's not the issue. On one hand that's good because there's quite a bit of work to make it support different regions but on the other hand that means I'm not sure what the issue is. Would you be willing to run a python script that uses the library that this integration is based on? That would let us remove the Home Assistant layer to hopefully see whether it's an issue with the library or the integration, you'd just need to use pip to get the required dependencies.

@magico13
Copy link
Owner

If you're willing to try running the script, I just tested this one with my own account. You'll need to pip install pyemvue to install the library (which is this one if you're interested: https://github.com/magico13/pyemvue) and then put the following into a new .py file and run it.

from pyemvue import PyEmVue

email = input('Enter email: ')
password = input('Enter password: ')

print('Attempting to log in...')
vue = PyEmVue()
vue.login(username=email, password=password)

details = vue.get_customer_details(email)
print(f'Successful. Your customer id is {details.customer_gid}')

If it can log in then it should print out your customer id, which is something that can only be requested from the server so we know it works. If it can't then it'll throw an exception and print out the whole stack trace. I tested with my own credentials and some made up ones and it worked for mine.

@fasavard
Copy link
Author

Yes of course,
Just a fyi on running on a blue if that changes anything
https://www.home-assistant.io/blue/

@fasavard
Copy link
Author

So im not sure yet how to run it on the blue but i runned it on my pc and got this:

vue.login(username=email, password=password)
Traceback (most recent call last):
File "", line 1, in
File "C:\Users\fasavard\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\pyemvue\pyemvue.py", line 184, in login
self.auth = Auth(
File "C:\Users\fasavard\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\pyemvue\auth.py", line 47, in init
self.tokens = self.refresh_tokens()
File "C:\Users\fasavard\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\pyemvue\auth.py", line 51, in refresh_tokens
self.cognito.renew_access_token()
AttributeError: 'Auth' object has no attribute 'cognito'

@magico13
Copy link
Owner

That's interesting and unexpected. I think the only way that could happen is if python didn't treat the username and/or password as "truthy". The section of code that defines the cognito variable in that class either requires existing tokens or the username and password to be set. We should be hitting this line of code here to set that: https://github.com/magico13/PyEmVue/blob/master/pyemvue/auth.py#L43

Since you posted your email earlier I can try to check if it doesn't like something about that. If it's something with your password then you might try changing it to something else?

@fasavard
Copy link
Author

yes of course, i will try a simple one right now

@fasavard
Copy link
Author

so i just try a very simple password and the error

@magico13
Copy link
Owner

so i just try a very simple password and the error

I think part of your reply might have been dropped. Did the error go away or is it still happening?

@fasavard
Copy link
Author

so i see in the class we have a user, passe, and email,
Are we suppose to provide an email aswell ?
image

ho yes sorry about the message before, the problem is still there

@magico13
Copy link
Owner

Oh, there might have been some confusion. Don't enter the email and password into the file, those are just prompts and you should enter them on the command line when it comes up. If you want to just hard code them into the file instead of entering them when running it then replace those lines with

email = 'youremail@gmail.com'
password = 'yourpassword'

I think the way you have it right now you're probably just pressing enter when those prompts come up so it isn't actually passing in the email or password, just empty strings.

@fasavard
Copy link
Author

ho right my bad ! it is working:
:/Users/fasavard/test.py Attempting to log in... Successful. Your customer id is 49506 PS C:\Users\fasavard>

@magico13
Copy link
Owner

Awesome, that's a good sign. You said that you tried making the password simpler? Does the Home Assistant integration log in correctly with that new password?

@fasavard
Copy link
Author

ok now i got this:

This error originated from a custom integration.

Logger: custom_components.emporia_vue
Source: custom_components/emporia_vue/init.py:263
Integration: Emporia Vue (documentation)
First occurred: 10:57:19 (2 occurrences)
Last logged: 10:58:19

Error communicating with Emporia API: No channels found during update for scale 1MIN

I will try a reset of my device just in case

@fasavard
Copy link
Author

AFter reboot, it still hang but got those 2 error that i havent seen:

Logger: homeassistant.components.hassio.handler
Source: components/hassio/handler.py:230
Integration: Home Assistant Supervisor (documentation, issues)
First occurred: 11:03:30 (4 occurrences)
Last logged: 11:03:30

/ingress/validate_session return code 401

Logger: homeassistant.components.hassio
Source: components/hassio/websocket_api.py:119
Integration: Home Assistant Supervisor (documentation, issues)
First occurred: 11:03:30 (4 occurrences)
Last logged: 11:03:30

Failed to to call /ingress/validate_session -

not sure how they would be related though

@magico13
Copy link
Owner

It looks like you were able to log in at least. Sometimes their API is finicky and doesn't return all the data when it's requested and if that happens during set up it can cause some issues. As long as the initial set up is ok you'll see an occasional issue during updates where data doesn't come back but the next update a minute later usually resolves that.

Do you see any of the different "channels" as separate devices with the minute, day, and month sensors on them?

image

image

@fasavard
Copy link
Author

no unfortunatly, still stuck on the menu where it ask for my email and password.
Would you like to do a google meet ? maybe it would help ?
https://meet.google.com/cke-hqzj-zkt?pli=1

@fasavard
Copy link
Author

image

After closing the infinit loop windows i got this with this log:
This error originated from a custom integration.

Logger: custom_components.emporia_vue.config_flow
Source: config_entries.py:1211
Integration: Emporia Vue (documentation)
First occurred: 11:19:06 (1 occurrences)
Last logged: 11:19:06

Unexpected exception
Traceback (most recent call last):
File "/config/custom_components/emporia_vue/config_flow.py", line 80, in async_step_user
self._abort_if_unique_id_configured()
File "/usr/src/homeassistant/homeassistant/config_entries.py", line 1211, in _abort_if_unique_id_configured
raise data_entry_flow.AbortFlow("already_configured")
homeassistant.data_entry_flow.AbortFlow: Flow aborted: already_configured

@magico13
Copy link
Owner

I can't hop on a call at the moment (technically am at work and already in a meeting) but I might be able to this afternoon/evening. My email is magico1313@gmail.com if you want to send me a meeting invite for some time after 2pm eastern.

@fasavard
Copy link
Author

awesome thanks will do and i will continu to debug

@fasavard
Copy link
Author

fasavard commented Dec 30, 2021

Sooo it started working out but i havent done anything :O

@magico13
Copy link
Owner

That last error message did say "already configured" so a reboot might have let it finish setup. I'm not sure if the initial problem was related to the password, I've seen special characters in passwords cause some problems in the past with other software, but hopefully it stays working now.

It will reauthenticate with the stored username and password each boot so if you change your password you'll have to remove and readd the integration with the new password, but all the devices and entities should repopulate in-place so you shouldn't mess up any custom displays by doing that.

Maybe monitor it for a day and if it stays working (especially through a reboot) then I think we should be safe to close this. Sound good?

@fasavard
Copy link
Author

fasavard commented Dec 5, 2022

Since this issue have been fixe i will close the issus

@fasavard fasavard closed this as completed Dec 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants