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

Stopped loading #23

Closed
davelegg83 opened this issue May 16, 2024 · 12 comments
Closed

Stopped loading #23

davelegg83 opened this issue May 16, 2024 · 12 comments
Assignees
Labels
bug Something isn't working

Comments

@davelegg83
Copy link

What happened?
Restarted HA and got the error that Nissan Connect was unable to setup. Had been working fine prior to this.

Log Output

Logger: homeassistant.config_entries
Source: config_entries.py:575
First occurred: 09:01:00 (2 occurrences)
Last logged: 09:29:47

Error setting up entry NissanConnect Account for nissan_connect
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 575, in async_setup
    result = await component.async_setup_entry(hass, self)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/nissan_connect/__init__.py", line 47, in async_setup_entry
    await hass.async_add_executor_job(kamereon_session.login,
  File "/usr/local/lib/python3.12/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/nissan_connect/kamereon.py", line 698, in login
    oauth_authorize_url = resp.headers['location']
                          ~~~~~~~~~~~~^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/requests/structures.py", line 52, in __getitem__
    return self._store[key.lower()][1]
           ~~~~~~~~~~~^^^^^^^^^^^^^
KeyError: 'location'

Home Assistant Version
2024.5.3

Integration Version
1.0.0

@davelegg83 davelegg83 added the bug Something isn't working label May 16, 2024
@f-zappa
Copy link
Contributor

f-zappa commented May 16, 2024

Good morning, also just wanted to open a ticket for the same reason. I stumbled upon incorrect data (car location was still 'home' but in fact my wife is using it).
My log output is identical to the above. The Nissan App continues working normal, but maybe they changed something in the API?

@dan-r
Copy link
Owner

dan-r commented May 16, 2024

Looks like the API has changed. Just having a look to see if its something simple. For reference the response that comes back includes:

error: {
                    description: "Client authentication failed",
                    message: "invalid_client"
                }

Makes me think its just the client ID thats changed

@dan-r
Copy link
Owner

dan-r commented May 16, 2024

I've had a play around with it but haven't got anywhere yet. Looks like I'll need to decompile the APK rather than just changing some constants. I won't have any time today but should get a chance to look at it tomorrow/over the weekend.

@Tobiaswk looks like this is affecting the My Leaf app too (I did base the API client here on dartnissanconnect after all). Have you had any luck with these API changes yet?

@wralb
Copy link

wralb commented May 16, 2024

May be coincidence, but my Ohme android app hasn't been able to get my Nissan's soc for eight hours. I tried reconnecting my Ohme app to the Nissan system and the login to Nissan now fails. Perhaps Nissan didn't tell other suppliers of an API change or this is an 'unexpected event'.

@macflyhub
Copy link

Same here. Ariya not updating! Arggg

@Tobiaswk
Copy link

Tobiaswk commented May 16, 2024

@dan-r Yes, I've been looking at it. They've changed the client_id which is now a-ncb-nc-android-prod and the client_secret which is now 6GKIax7fGT5yPHuNmWNVOc4q5POBw1WRSW39ubRA8WPBmQ7MOxhm75EsmKMKENem.

I've just pushed the changes to dartnissanconnect; Tobiaswk/dartnissanconnect@e030199

I'm not sure if other changes have been made. I haven't had time to look at it all but authentication works again.

@Tobiaswk
Copy link

Interestingly it seems that whoever is responsible for the NissanConnect app on Android has changed quite a lot in app. They've obfuscated some of the "secrets" so they cannot as easily be decompiled and read directly any longer. It's still fairly easy though ;)

@dan-r
Copy link
Owner

dan-r commented May 16, 2024

Thanks @Tobiaswk I appreciate you sharing that - had a brief look at the strings from the apk earlier but couldn't get anything working.

I'll give it a go later on - I must admit my decompilation skills are a bit rusty! 🤣

@ClassicGOD
Copy link

For what it's worth I can confirm that changing the values in settings_map in kamereon.py to the ones provided by @Tobiaswk and restarting HA fixes the integration.

@f-zappa
Copy link
Contributor

f-zappa commented May 16, 2024

For what it's worth I can confirm that changing the values in settings_map in kamereon.py to the ones provided by @Tobiaswk and restarting HA fixes the integration.

Great idea, I did the same and it is also working for me.

@macflyhub
Copy link

And working now - this is the section I updated.
In HA file editor - /homeassistant/custom_components/nissan_connect/kamereon.py
Line 33...
settings_map = {
'nissan': {
'EU': {
'client_id': 'a-ncb-nc-android-prod',
'client_secret': '6GKIax7fGT5yPHuNmWNVOc4q5POBw1WRSW39ubRA8WPBmQ7MOxhm75EsmKMKENem',
'scope': 'openid profile vehicles',
'auth_base_url': 'https://prod.eu2.auth.kamereon.org/kauth/',
'realm': 'a-ncb-prod',
'redirect_uri': 'org.kamereon.service.nci:/oauth2redirect',
'car_adapter_base_url': 'https://alliance-platform-caradapter-prod.apps.eu2.kamereon.io/car-adapter/',
'notifications_base_url': 'https://alliance-platform-notifications-prod.apps.eu2.kamereon.io/notifications/',
'user_adapter_base_url': 'https://alliance-platform-usersadapter-prod.apps.eu2.kamereon.io/user-adapter/',
'user_base_url': 'https://nci-bff-web-prod.apps.eu2.kamereon.io/bff-web/',
},

@dan-r
Copy link
Owner

dan-r commented May 17, 2024

Thanks all for the testing - I've just released v0.5.1 with these changes and everything is working again for me now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

7 participants