widewing / ha-toyota-na

Home Assistant integration for Toyota Motor (North America) connected services
75 stars 17 forks source link

"Not Logged In" message #52

Closed lunar-studio closed 2 months ago

lunar-studio commented 2 years ago

I don't know if I need an "active subscription" in order to at least be able to log in and get past this message or if something else might be incorrect.

I'm new to HA and just installed HACS - excited to actually see a smart integration for my car.

I used to have the Entune App (with username and pass) then upgraded to their newer plain "Toyota" app. Then Toyota pulled a switch and bait on my 2019 Prius Prime Advanced with Connected Services. Key FOB works still for remote start, but this actually seems much handier. I realize in order for it to work that I'd probably have to pay their ransom fees. I was able to log into their App just now, albeit I don't have a subscription (yet.)

Thanks!

Edit: If it is related to not having an Active Subscription, please consider adding a notice which states "Active Subscription Required" next to the "Not Logged In" message. My initial thought (just like the app) is at the very least I might be able to get past this log in screen but unable to see data until a subscription is purchased.

_Edit #2: Might be something actually wrong on Toyota's end with Connected Services suddenly not being shown on my account. Will be on the phone with them. Used to work but apparently doesn't even show up on their end now. Was told to call Toyota's "Brand Services" at 1-800-331-4331.

Update: @t0ny-peng may have found a HA solution: https://gist.github.com/t0ny-peng/f85b0a0dc3d46246ae17a9d7215e39da

lunar-studio commented 1 year ago

Update: signed up for a Safety Connect Subscription and am receiving a “not logged in” error message. Can log in with the app itself. Only trying to test this out to see if I can get voice integration working.

lunar-studio commented 1 year ago

Managed to finally get past the username and password entry but now I’m receiving the same error as others regarding the server error 500 retrying message.

gmsantosti commented 1 year ago

I´m getting the same error "Not logged in" and then I receive an email from toyota with a 6 digit code to validate my login.

Email from toyota: Your Toyota app account sign up is almost complete, but you need to verify your email address. Please enter the verification code in the Toyota app or provide it to the agent when prompted. This code will be valid for five minutes.

Ideas?

barnett commented 1 year ago

Any tips here? Have an active account (with an email address) for the Toyota iOS app and can login with their website fine but keep getting this error message.

antasp3136 commented 1 year ago

I am also having issues signing into the integration with my account. I have a active subscription as well.

potts-mike commented 1 year ago

Having the same issue here. Worked with the temporary VIN while the vehicle was built but not now with the actual VIN.

fzambroni commented 1 year ago

I have the same problem here. 2022 RAV4

brylee123 commented 1 year ago

I am also having this problem too. My subscription ends on Aug 2023. I have uninstalled and reinstalled the integration. Still no luck. I believe it might be a change in the Toyota API.


Home Assistant Logs

First Error: `Logger: custom_components.toyota_na Source: custom_components/toyota_na/init.py:39 Integration: Toyota (North America) (documentation, issues) First occurred: 8:23:55 PM (2 occurrences) Last logged: 8:30:50 PM

Traceback (most recent call last): File "/usr/local/lib/python3.10/site-packages/toyota_na/auth.py", line 116, in check_tokens await self.refresh_tokens() File "/usr/local/lib/python3.10/site-packages/toyota_na/auth.py", line 94, in refresh_tokens raise LoginError() toyota_na.exceptions.LoginError

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/config/custom_components/toyota_na/init.py", line 39, in async_setup_entry await client.auth.check_tokens() File "/usr/local/lib/python3.10/site-packages/toyota_na/auth.py", line 118, in check_tokens raise TokenExpired() toyota_na.exceptions.TokenExpired`

Second Error: `Logger: homeassistant.config_entries Source: config_entries.py:1242 First occurred: 8:30:50 PM (1 occurrences) Last logged: 8:30:50 PM

Config entry 'Prius Prime LE' for toyota_na integration could not authenticate`

Third Error: `Logger: root Source: custom_components/toyota_na/config_flow.py:34 Integration: Toyota (North America) (documentation, issues) First occurred: 8:24:46 PM (3 occurrences) Last logged: 9:01:41 PM

{"authId": "xxxxxxxxx", "callbacks": [{"type": "TextOutputCallback", "output": [{"name": "message", "value": "Invalid UI Locale provided"}, {"name": "messageType", "value": "2"}]}]} {"authId": "yyyyyyyyy", "callbacks": [{"type": "TextOutputCallback", "output": [{"name": "message", "value": "Invalid UI Locale provided"}, {"name": "messageType", "value": "2"}]}]} {"authId": "zzzzzzzzz", "callbacks": [{"type": "TextOutputCallback", "output": [{"name": "message", "value": "Invalid UI Locale provided"}, {"name": "messageType", "value": "2"}]}]}`


I tried logging using toyota-na 2.1.1 and also had an error. ERROR 2023-04-05 21:00:20,998 - {"authId": "xxxxxxxxxxxxxxxxxxxxxxxxxxxx", "callbacks": [{"type": "TextOutputCallback", "output": [{"name": "message", "value": "Invalid UI Locale provided"}, {"name": "messageType", "value": "2"}]}]} Traceback (most recent call last): File "/usr/lib/python3.8/runpy.py", line 194, in _run_module_as_main return _run_code(code, main_globals, None, File "/usr/lib/python3.8/runpy.py", line 87, in _run_code exec(code, run_globals) File "/home/bryle/.local/lib/python3.8/site-packages/toyota_na/app.py", line 93, in <module> main() File "/home/bryle/.local/lib/python3.8/site-packages/toyota_na/app.py", line 51, in main run_async(cli.auth.login(args.username, args.password)) File "/home/bryle/.local/lib/python3.8/site-packages/toyota_na/app.py", line 89, in run_async return loop.run_until_complete(future) File "/usr/lib/python3.8/asyncio/base_events.py", line 616, in run_until_complete return future.result() File "/home/bryle/.local/lib/python3.8/site-packages/toyota_na/auth.py", line 116, in login authorization_code = await self.authorize(username, password) File "/home/bryle/.local/lib/python3.8/site-packages/toyota_na/auth.py", line 53, in authorize raise LoginError() toyota_na.exceptions.LoginError

SeanPM5 commented 1 year ago

Same issue here with a 2020 RAV4 XLE Premium and Connected Services subscription that is good through Jan 2024.

Integration was working flawlessly without issues for over a year until it randomly logged me out a couple days ago after restarting HA. I attempted to log back in without success, and get the following errors in logs:

This error originated from a custom integration.

Logger: custom_components.toyota_na.config_flow
Source: custom_components/toyota_na/config_flow.py:20
Integration: Toyota (North America) (documentation, issues)
First occurred: 11:15:54 PM (1 occurrences)
Last logged: 11:15:54 PM

Not logged in
This error originated from a custom integration.

Logger: root
Source: custom_components/toyota_na/config_flow.py:34
Integration: Toyota (North America) (documentation, issues)
First occurred: 11:15:54 PM (1 occurrences)
Last logged: 11:15:54 PM

{"authId": "censored", "callbacks": [{"type": "TextOutputCallback", "output": [{"name": "message", "value": "Invalid UI Locale provided"}, {"name": "messageType", "value": "2"}]}]}

I didn't make any password/account changes on the Toyota side of things and still remained logged into the Toyota iOS app the whole time. I was able to log out and back into the Toyota iOS app without any issue, it's only the Home Assistant integration that is failing to connect.

JiDoan commented 1 year ago

It looks like there is a a new requirement in the login flow that requires that the user's locale is passed in along with the requirement of an one time passcode. I managed to get it to work locally but it requires making changes in the toyota-na repo that was taken down, so not sure how we can make the fix work for everyone...

woejillis commented 1 year ago

I'd love to get this working for my newly purchased Toyota Prius Prime. Any direction would be appreciated.

ACiDGRiM commented 1 year ago

It looks like there is a a new requirement in the login flow that requires that the user's locale is passed in along with the requirement of an one time passcode. I managed to get it to work locally but it requires making changes in the toyota-na repo that was taken down, so not sure how we can make the fix work for everyone...

Can you please share the local changes? I assume I can just update the files locally in homeassistant. I really need this to work because I rely on it to make sure my car is locked in a high crime area.

JiDoan commented 1 year ago

It looks like there is a a new requirement in the login flow that requires that the user's locale is passed in along with the requirement of an one time passcode. I managed to get it to work locally but it requires making changes in the toyota-na repo that was taken down, so not sure how we can make the fix work for everyone...

Can you please share the local changes? I assume I can just update the files locally in homeassistant. I really need this to work because I rely on it to make sure my car is locked in a high crime area.

I can give you the steps that I took but it is not production ready since I didn't have time to figure out how to hook it into Home Assistant UI asynchronously when the OTP prompt comes up.


In auth.py of the library, replace the callbacks to the authorize() function with these:

if (
    cb["type"] == "NameCallback"
    and cb["output"][0]["value"] == "User Name"
):
    cb["input"][0]["value"] = username
elif (
    cb["type"] == "NameCallback"
    and cb["output"][0]["value"] == "ui_locales"
):
    cb["input"][0]["value"] = "en-US"
elif (
    cb["type"] == "PasswordCallback"
    and cb["output"][0]["value"] == "One Time Password"
):
    otp = input('Please enter your app verification code: ')
    cb["input"][0]["value"] = otp
elif (
    cb["type"] == "PasswordCallback"
    and cb["output"][0]["value"] == "Password"
):
    cb["input"][0]["value"] = password

Then, login with the command line interface using python app.py authorize <email> <password>.

Once you log in, use the tokens saved in .toyota_na_tokens.json to replace the call to login() with client.auth.set_tokens in async_get_entry_data(). For safe measure, also call set_device_id() with the ID in .toyota_na_device_id.

ACiDGRiM commented 1 year ago

It looks like there is a a new requirement in the login flow that requires that the user's locale is passed in along with the requirement of an one time passcode. I managed to get it to work locally but it requires making changes in the toyota-na repo that was taken down, so not sure how we can make the fix work for everyone...

Can you please share the local changes? I assume I can just update the files locally in homeassistant. I really need this to work because I rely on it to make sure my car is locked in a high crime area.

I can give you the steps that I took but it is not production ready since I didn't have time to figure out how to hook it into Home Assistant UI asynchronously when the OTP prompt comes up.

In auth.py of the library, replace the callbacks to the authorize() function with these:

if (
    cb["type"] == "NameCallback"
    and cb["output"][0]["value"] == "User Name"
):
    cb["input"][0]["value"] = username
elif (
    cb["type"] == "NameCallback"
    and cb["output"][0]["value"] == "ui_locales"
):
    cb["input"][0]["value"] = "en-US"
elif (
    cb["type"] == "PasswordCallback"
    and cb["output"][0]["value"] == "One Time Password"
):
    otp = input('Please enter your app verification code: ')
    cb["input"][0]["value"] = otp
elif (
    cb["type"] == "PasswordCallback"
    and cb["output"][0]["value"] == "Password"
):
    cb["input"][0]["value"] = password

Then, login with the command line interface using python app.py authorize <email> <password>.

Once you log in, use the tokens saved in .toyota_na_tokens.json to replace the call to login() with client.auth.set_tokens in async_get_entry_data(). For safe measure, also call set_device_id() with the ID in .toyota_na_device_id.

Thanks, now I just have to figureout where the pip libraries are accessed from hassio

JiDoan commented 1 year ago

It looks like there is a a new requirement in the login flow that requires that the user's locale is passed in along with the requirement of an one time passcode. I managed to get it to work locally but it requires making changes in the toyota-na repo that was taken down, so not sure how we can make the fix work for everyone...

Can you please share the local changes? I assume I can just update the files locally in homeassistant. I really need this to work because I rely on it to make sure my car is locked in a high crime area.

I can give you the steps that I took but it is not production ready since I didn't have time to figure out how to hook it into Home Assistant UI asynchronously when the OTP prompt comes up. In auth.py of the library, replace the callbacks to the authorize() function with these:

if (
    cb["type"] == "NameCallback"
    and cb["output"][0]["value"] == "User Name"
):
    cb["input"][0]["value"] = username
elif (
    cb["type"] == "NameCallback"
    and cb["output"][0]["value"] == "ui_locales"
):
    cb["input"][0]["value"] = "en-US"
elif (
    cb["type"] == "PasswordCallback"
    and cb["output"][0]["value"] == "One Time Password"
):
    otp = input('Please enter your app verification code: ')
    cb["input"][0]["value"] = otp
elif (
    cb["type"] == "PasswordCallback"
    and cb["output"][0]["value"] == "Password"
):
    cb["input"][0]["value"] = password

Then, login with the command line interface using python app.py authorize <email> <password>. Once you log in, use the tokens saved in .toyota_na_tokens.json to replace the call to login() with client.auth.set_tokens in async_get_entry_data(). For safe measure, also call set_device_id() with the ID in .toyota_na_device_id.

Thanks, now I just have to figureout where the pip libraries are accessed from hassio

This helped me get what I needed before.

ACiDGRiM commented 1 year ago

Thanks, I just did the auth on my computer and copied the token to the .storage folder on my hassio.

I highly appreciate the modifications needed to interact with the API. I may try to kludge into the HA UI setup flow, but as a python nonce I don't expect any sucess.

brylee123 commented 1 year ago

Thanks! This also worked for me as well!

t0ny-peng commented 1 year ago

Hi @JiDoan Thanks for your exploration! With the following harc-coded tokens I did manage to get it to work.

Just one quick question. I managed to modify auth.py locally and get the tokens, but looks like it has expiration which is pretty soon. If we modify ha-toyora-na/config_flow.py like this:

    async def async_get_entry_data(self, user_input, errors):
        try:
            client = ToyotaOneClient()
            await client.auth.login(user_input["username"], user_input["password"])
            id_info = await client.auth.get_id_info()
            return {
                "tokens":  <hard coded dict of tokens>
                ...

How does it manage to refresh the token? I guess a complete logic would be to use user-provided .toyota_na_tokens.json for the first time and automatically refresh this file.


As a proof of concept, I pushed a very hacky working version to https://github.com/t0ny-peng/ha-toyota-na and Pypi https://pypi.org/project/toyota-na-custom/

After 2 hours it's still working well. Seems that my car doesn't support start the engine remotely :(

JiDoan commented 1 year ago

Hi @JiDoan Thanks for your exploration! With the following harc-coded tokens I did manage to get it to work.

Just one quick question. I managed to modify auth.py locally and get the tokens, but looks like it has expiration which is pretty soon. If we modify ha-toyora-na/config_flow.py like this:

    async def async_get_entry_data(self, user_input, errors):
        try:
            client = ToyotaOneClient()
            await client.auth.login(user_input["username"], user_input["password"])
            id_info = await client.auth.get_id_info()
            return {
                "tokens":  <hard coded dict of tokens>
                ...

How does it manage to refresh the token? I guess a complete logic would be to use user-provided .toyota_na_tokens.json for the first time and automatically refresh this file.

As a proof of concept, I pushed a very hacky working version to https://github.com/t0ny-peng/ha-toyota-na and Pypi https://pypi.org/project/toyota-na-custom/

After 2 hours it's still working well. Seems that my car doesn't support start the engine remotely :(

I'm not sure of the refresh frequency but the original library already had refreshing built in. You may be able to play around with the library to see if you can add remote start, it should work if you can remote start on the official app but I'm not sure how to be able to check without the car.

t0ny-peng commented 1 year ago

@JiDoan I tried to manually start the car via toyota-na(not the HA wrapper) and my phone app shows an error that the action failed because it isn't initiated from mobile phone.

JiDoan commented 1 year ago

Interesting, I wonder which field is missing. I haven't seen that error before for my 2022 car.

buzzshaw commented 1 year ago

Any luck on a fix for this? I am newer to HA and can't figure out how to implement the above suggested code.

brylee123 commented 1 year ago

Any luck on a fix for this? I am newer to HA and can't figure out how to implement the above suggested code.

I believe you are able to do this all inside of Home Assistant but that was not the route I went with. I am using Ubuntu (WSL) Terminal. I installed toyota-na from PyPI linked here: https://pypi.org/project/toyota-na/

In my Ubuntu Terminal I ran: pip3 install toyota-na

Then you need to do the edits that JiDoan mentioned above. To find out where the toyota-na library lives, you can run pip3 show -f toyota-na

It'll show you where the Python scripts are stored. For reference, it was here: Location: /home/brylee123/.local/lib/python3.10/site-packages/toyota-na

Inside that directory, there is a file called auth.py. Inside auth.py on approximately line 40, there is this for-loop. for cb in data["callbacks"]:

You will need to replace the contents of this for-loop with the code snippet mentioned above (linked here: https://github.com/widewing/ha-toyota-na/issues/52#issuecomment-1519291342)

Make sure you save and close auth.py. Now you may run this command which will now prompt you for a OTP sent to your email/phone. python3 -m toyota_na.app authorize <username> <passworde>

Type in your OTP and then it should finish.

Remember the location of auth.py? There is now a hidden file there called .toyota_na_tokens.json If you're in the terminal and in the directory where auth.py lives, you can run cat .toyota_na_tokens.json and it'll display all the values you need to copy over to .storage/core.config_entries in Home Assistant. NOTE: I believe if you try to run this twice, .toyota_na_tokens.json does not overwrite itself. So make sure you delete the file if you plan on re-authorizing.

Back to Home Assistant: Copy the contents of .toyota_na_tokens.json to .storage/core.config_entries in Home Assistant. If you do not see .storage in the File Editor, go here and change the setting: Addons > FIle Editor > Configuration > Press X on .storage You may need to reboot File Editor.

EDIT: Within /config/.storage/core.config_entries, you should have a Toyota entry for your vehicle if you installed this integration before, otherwise, I believe you can manually fill it out like so.

      {
        "entry_id": "[ENTITY_ID]",
        "version": 1,
        "domain": "toyota_na",
        "title": "Prius Prime LE",
        "data": {
          "tokens": {                    // Begin paste-block .toyota_na_token.json contents here
            "access_token": "[ACCESS_TOKEN]", 
            "refresh_token": "[REFRESH_TOKEN]",
            "expires_at": [EXPIRES_AT], 
            "updated_at": [UPDATED_AT], 
            "guid": "[GUID]"                                               
          },                             // End paste-block (make sure there is a comma after JSON content)
          "email": "[EMAIL]",
          "username": "[EMAIL]",
          "password": "[PASSWORD]"
        },
        "options": {},
        "pref_disable_new_entities": false,
        "pref_disable_polling": false,
        "source": "user",
        "unique_id": "toyota_na:[EMAIL]",
        "disabled_by": null
      },

Make sure you have the YAML indentation spacing correct. Save in the File Editor. Dev Tools > YAML > Check Configuration & Restart.

This should solve the problem!

dannycohn commented 1 year ago

Any luck on a fix for this? I am newer to HA and can't figure out how to implement the above suggested code.

I believe you are able to do this all inside of Home Assistant but that was not the route I went with. I am using Ubuntu (WSL) Terminal. I installed toyota-na from PyPI linked here: https://pypi.org/project/toyota-na/

In my Ubuntu Terminal I ran: pip3 install toyota-na

Then you need to do the edits that JiDoan mentioned above. To find out where the toyota-na library lives, you can run pip3 show -f toyota-na

It'll show you where the Python scripts are stored. For reference, it was here: Location: /home/brylee123/.local/lib/python3.10/site-packages/toyota-na

Inside that directory, there is a file called auth.py. Inside auth.py on approximately line 40, there is this for-loop. for cb in data["callbacks"]:

You will need to replace the contents of this for-loop with the code snippet mentioned above (linked here: #52 (comment))

Make sure you save and close auth.py. Now you may run this command which will now prompt you for a OTP sent to your email/phone. python3 -m toyota_na.app authorize <username> <passworde>

Type in your OTP and then it should finish.

Remember the location of auth.py? There is now a hidden file there called .toyota_na_tokens.json If you're in the terminal and in the directory where auth.py lives, you can run cat .toyota_na_tokens.json and it'll display all the values you need to copy over to .storage/core.config_entries in Home Assistant. NOTE: I believe if you try to run this twice, .toyota_na_tokens.json does not overwrite itself. So make sure you delete the file if you plan on re-authorizing.

Back to Home Assistant: Copy the contents of .toyota_na_tokens.json to .storage/core.config_entries in Home Assistant. If you do not see .storage in the File Editor, go here and change the setting: Addons > FIle Editor > Configuration > Press X on .storage You may need to reboot File Editor.

Make sure you have the YAML indentation spacing correct. Save in the File Editor. Dev Tools > YAML > Check Configuration & Restart.

This should solve the problem!

@brylee123 thanks for this great writeup! One quick question: When copying the access token into core.config_entries, what is the format? Specifically, it would seem that the JSON entry needs a domain, title, and some other fields. Do you have an example that you can share?

dannycohn commented 1 year ago

Any luck on a fix for this? I am newer to HA and can't figure out how to implement the above suggested code.

I believe you are able to do this all inside of Home Assistant but that was not the route I went with. I am using Ubuntu (WSL) Terminal. I installed toyota-na from PyPI linked here: https://pypi.org/project/toyota-na/ In my Ubuntu Terminal I ran: pip3 install toyota-na Then you need to do the edits that JiDoan mentioned above. To find out where the toyota-na library lives, you can run pip3 show -f toyota-na It'll show you where the Python scripts are stored. For reference, it was here: Location: /home/brylee123/.local/lib/python3.10/site-packages/toyota-na Inside that directory, there is a file called auth.py. Inside auth.py on approximately line 40, there is this for-loop. for cb in data["callbacks"]: You will need to replace the contents of this for-loop with the code snippet mentioned above (linked here: #52 (comment)) Make sure you save and close auth.py. Now you may run this command which will now prompt you for a OTP sent to your email/phone. python3 -m toyota_na.app authorize <username> <passworde> Type in your OTP and then it should finish. Remember the location of auth.py? There is now a hidden file there called .toyota_na_tokens.json If you're in the terminal and in the directory where auth.py lives, you can run cat .toyota_na_tokens.json and it'll display all the values you need to copy over to .storage/core.config_entries in Home Assistant. NOTE: I believe if you try to run this twice, .toyota_na_tokens.json does not overwrite itself. So make sure you delete the file if you plan on re-authorizing. Back to Home Assistant: Copy the contents of .toyota_na_tokens.json to .storage/core.config_entries in Home Assistant. If you do not see .storage in the File Editor, go here and change the setting: Addons > FIle Editor > Configuration > Press X on .storage You may need to reboot File Editor. Make sure you have the YAML indentation spacing correct. Save in the File Editor. Dev Tools > YAML > Check Configuration & Restart. This should solve the problem!

@brylee123 thanks for this great writeup! One quick question: When copying the access token into core.config_entries, what is the format? Specifically, it would seem that the JSON entry needs a domain, title, and some other fields. Do you have an example that you can share?

For anyone looking for the answer to this, this seemed to work for me:

{
        "entry_id": "GUID, I used the one from .toyota_na_tokens.json",
        "version": 1,
        "domain": "toyota_na",
        "title": "YOUR TOYOTA USERNAME",
        "data": {
          "tokens": JSON OBJECT FROM .toyota_na_tokens.json,
          "email": "YOUR EMAIL ADDRESS",
          "username": "YOUR TOYOTA USERNAME",
          "password": "YOUR TOYOTA PASSWOD"
        },
        "options": {},
        "pref_disable_new_entities": false,
        "pref_disable_polling": false,
        "source": "user",
        "unique_id": "YOUR TOYOTA USERNAME",
        "disabled_by": null
      }
brylee123 commented 1 year ago
      {
        "entry_id": "[ENTITY_ID]",
        "version": 1,
        "domain": "toyota_na",
        "title": "Prius Prime LE",
        "data": {
          "tokens": {                    // Begin PASTE .toyota_na_token.json contents here
            "access_token": "[ACCESS_TOKEN]", 
            "refresh_token": "[REFRESH_TOKEN]",
            "expires_at": [EXPIRES_AT], 
            "updated_at": [UPDATED_AT], 
            "guid": "[GUID]"                                               
          },                             // End paste-block (make sure there is a comma after JSON content)
          "email": "[EMAIL]",
          "username": "[EMAIL]",
          "password": "[PASSWORD]"
        },
        "options": {},
        "pref_disable_new_entities": false,
        "pref_disable_polling": false,
        "source": "user",
        "unique_id": "toyota_na:[EMAIL]",
        "disabled_by": null
      },

It looks like you found a solution already. I've bolded the portion of the code that should be copied over from .toyota_na_token.json. I will also update my previous post to include this snippet too.

thegpfury commented 1 year ago

Is this going to be updated in the main repository so HA can be updated, or is this going to be a manual fix?

widewing commented 1 year ago

Is this going to be updated in the main repository so HA can be updated, or is this going to be a manual fix?

I think I can not update it in the repo, as the affected library has been DMCA taken down

ACiDGRiM commented 1 year ago

Is this going to be updated in the main repository so HA can be updated, or is this going to be a manual fix?

I think I can not update it in the repo, as the affected library has been DMCA taken down

Any chance the configuration ui could be updated to ask for the Auth token in json format? It would be nice to renew without editing the .storage configuration entries and restarting

I'm still able to install from hacs and pip because while the library github was taken down, the pip repo still has this available.

thegpfury commented 1 year ago

Ok, is there a simple guide for manually fixing then? There's a few different solutions in the thread and I'm not sure which is the correct one.

saulpatinojr commented 1 year ago

Follow the walkthrough from May 9th, it worked for me. A few things, I used the the Ubuntu subsystem within Windows and installed python and the toyota-na components found https://pypi.org/project/toyota-na/

I then exported the needed files and uploaded them to my supervised home assistant install. I needed to use the File Share addon to see the invisible folders to upload and I just need to add one vehicle in the yaml file but when the addon started working it popped up both vehicles in my account.

thegpfury commented 1 year ago

Follow the walkthrough from May 9th, it worked for me. A few things, I used the the Ubuntu subsystem within Windows and installed python and the toyota-na components found https://pypi.org/project/toyota-na/

I then exported the needed files and uploaded them to my supervised home assistant install. I needed to use the File Share addon to see the invisible folders to upload and I just need to add one vehicle in the yaml file but when the addon started working it popped up both vehicles in my account.

That did it, thank you so much!

jtaseff commented 1 year ago

Also managed to get it working with the guide from May 9, and sticking the token data in. Hadn't ever installed the integration or gotten it working before, but putting that into config worked and showed up after restarting HA.

Took me a minute to figure out running it from bash - turns out had to use toyota_na instead of toyota-na for whatever reason. I tried in a few places before figuring this out, and ended up getting it working by editing the actual module within my HA install, which I'm sure will get deleted when I update and may cause issues because it doesn't know how to ask the UI for the code, only the cli... but it's working.

jgdf42 commented 1 year ago

How often do I need to reauth if I use the manual fix in this thread?

danepowell commented 1 year ago

I think I can not update it in the repo, as the affected library has been DMCA taken down

If anyone is feeling a little bold, I would suggest recreating the toyota-na repo from the PyPi package, making sure to omit any API keys, sample responses, and other sensitive info that probably prompted the takedown. The API client itself is quite clearly fair use.

ACiDGRiM commented 1 year ago

It honestly seems like the long term solution for these damn car companies is to tap directly into the CANBUS with an onboard RPI and just control the car directly.

cwwilson08 commented 1 year ago

Could anyone explain this for those of us less in the know?

What exactly is missing now that causes this integration to fail? Would reverting to older releases allow it to work? Would anyone be willing to put together a for dummies version of the fix above to help me out getting this fixed?

Feel free to message me direct. Apologies if this is the wrong place, however it is the only place I really see it being discussed

jtaseff commented 1 year ago

From what I've gathered, there was a recent change on the Toyota server side that requires an OTP to log in, and the current version of this custom integration doesn't support that in the login process. It could be updated to prompt this within the HA UI by someone who knows how that works. The comment above on May 9th everyone mentions is still working to login. It involves modifying one of the python files, running it manually, giving it the OTP that Toyota emails you, then copying the contents of the file it creates into your HA storage. You can either modify the python file directly in the custom_components file that hacs has and run it from within the HA docker container, but it will get overwritten with any update, or can install python and the toyota-na module elsewhere and run it there, which was giving me some difficulty getting the module to actually run with the right version and naming. So far I've only had to do this twice, the latest being after my remote connect expired and I renewed and reauthorized just today.

omar10wahab commented 1 year ago

From what I've gathered, there was a recent change on the Toyota server side that requires an OTP to log in, and the current version of this custom integration doesn't support that in the login process. It could be updated to prompt this within the HA UI by someone who knows how that works. The comment above on May 9th everyone mentions is still working to login. It involves modifying one of the python files, running it manually, giving it the OTP that Toyota emails you, then copying the contents of the file it creates into your HA storage. You can either modify the python file directly in the custom_components file that hacs has and run it from within the HA docker container, but it will get overwritten with any update, or can install python and the toyota-na module elsewhere and run it there, which was giving me some difficulty getting the module to actually run with the right version and naming. So far I've only had to do this twice, the latest being after my remote connect expired and I renewed and reauthorized just today.

Is there any way someone can explain the steps in lame man terms? I have tried running from ha docker and get error message and I'm sure the login and password is correct. I don't require MFA so I'm not sure what your comment is referring to. Or maybe I need to enable it to get it to work. I do have an active Toyota subscription.

Even if I were to attempt to try running the commands from another computer and transferring files I have no idea what I would transfer over or do. If anyone can provide anymore insight on the solution please let me know

jtaseff commented 1 year ago

idk how to simplify it more than the comment above that lays out basically step by step: https://github.com/widewing/ha-toyota-na/issues/52#issuecomment-1540831221

I have tried running

What did you try to run?

get error message

What error did you get?

I don't require MFA

If you're in north america, which is the only place this issue and workaround apply to, Toyota did recently require adding MFA via email TOTP when logging into a device for the first time. Try deleting the Toyota app from your phone, adding it again, and it will require a code. It's possible that the first time you newly log in after this was added is the first time it gets set up.

no idea what I would transfer over

The same comment above lays out what file you need to edit in HA storage, the data to add. There are sections like "your token" that you will copy out of the file created when you go through the login process via the terminal, it gives a few tokens which are very long strings of characters.

omar10wahab commented 1 year ago

image

i redownloaded the app like you said and it now asks for an authorization code to my email.

When typing the user and password into the code (python -m toyota_na.app authorize ), i replace the user and pass as such

python -m toyota_na.app authorize myuser pass1234

and then i get that error code attached. I tried with single and double quotes around the user and pass but still same error. It doesnt trigger any email code to be distributed either so im not sure what im doing wrong.

jtaseff commented 1 year ago

and then i get that error code attached. I tried with single and double quotes around the user and pass but still same error. It doesnt trigger any email code to be distributed either so im not sure what im doing wrong.

This "invalid UI locale provided" error looks like the same that people were getting originally, then the fix to auth.py in that comment above resolved it.

Can you post the contents of your "auth.py" file in the toyota-na package, at least the async def authorize(... block from line 34 down to 96ish?

omar10wahab commented 1 year ago

okay after reading through some of the above comments that you suggested was the same problem im having im now stuck at trying to access the file. Im using an ssh program with web interface in HA. Not official app im using "Advanced SSH & Web Terminal" which doesnt require me to do any protection setup to access and run these commands. I am just starting it an stopping it each session im on so i know im potentially compramised but im just trying to get this shit to work at this point.

So new problem is i dont know how to access and edit the auth.py file. I cant access it through FTP and when i try typing the file path into my system its telling me access denied. I tried the command login and then using my main HA account details to login but it says incorrect login. Not sure if the issue is the SSH add on is the issue or what. Im not sure if i just type the file path and it will then open the file or is there a command i need to tag along with the file path. I have used sudo nano before to mess with static ip and writing in files but that doesnt work in the docker ssh when i type it.

image

jtaseff commented 1 year ago

Sorry I've tried to help, but you've come back saying you followed the instructions but completely skipped some steps. I'm not sure on HA OS install the best way to edit files as needed, I would assume doing sudo nano would let you edit this, but the screenshot here is showing just trying to call the file directly instead of opening it in an editor. Please research on your own to get to the point of being able to edit this file as the instructions show, and then do cat auth.py to confirm the contents match what's required above

omar10wahab commented 1 year ago

Sorry I've tried to help, but you've come back saying you followed the instructions but completely skipped some steps. I'm not sure on HA OS install the best way to edit files as needed, I would assume doing sudo nano would let you edit this, but the screenshot here is showing just trying to call the file directly instead of opening it in an editor. Please research on your own to get to the point of being able to edit this file as the instructions show, and then do cat auth.py to confirm the contents match what's required above

I do appreciate the assistance and I understand half of what I'm doing I don't have much knowledge on. I am not someone who codes on the regular. I will attempt to complete the steps not on home assistant as it seems the people who have done it that way are not being as responsive so I'll try to get it to work the way you did it so I'm not conflicting with the steps you took. I do appreciate the help and I will be attempting more at this over the weekend. As you mentioned and this forum does, the changes made in home assistant docker get rewritten after an update so I would prefer the more permanent solution anyways. Thanks again

ACiDGRiM commented 1 year ago

It's easy

Install the Toyota python module with pip on your computer. Run it as I suggested above

Open the file it creates and copy the whole json

Edit the config registry file in HA .storage folder and replace the json token for this integration with What you copied. Then restart HA

At something you can either figure it out or you cant. I can't program a ui configuration for this, so I just do what I can or accept that the features I want aren't available. Please stop filling our inbox up with tutorials, I want to watch this issue for developments on the issue.

omar10wahab commented 1 year ago

It's easy

Install the Toyota python module with pip on your computer. Run it as I suggested above

Open the file it creates and copy the whole json

Edit the config registry file in HA .storage folder and replace the json token for this integration with What you copied. Then restart HA

At something you can either figure it out or you cant. I can't program a ui configuration for this, so I just do what I can or accept that the features I want aren't available. Please stop filling our inbox up with tutorials, I want to watch this issue for developments on the issue.

When i get this shit working i promise ill STFU. So i was able to get to the part of authentication but im using a windows computer and my .json file is not located where the auth.py file is. Does anyone know where i can find it? Using the "show" command does not help either on where the location of that file would be.

I tried the windows command "type" as well instead of "cat"

Nevermind i found it in the main folder python310 C:\Users\wahab\AppData\Local\Programs\Python\Python310

dkornahrens commented 1 year ago

If someone could post their auth.py file, that would be great.

layuso commented 1 year ago

Here is a copy of the auth.py file.

For anyone more inclined to use tabs instead of spaces... using tabs to adjust the for loop content will cause an error about tabs and indentiation not being the same. Make sure to use 4 spaces with this instead of tabs.

Using the file listed below, I was able to run 'python3 -m toyota_na.app authorize [user] [pass]' successfully and receive a one time passcode via email.

Attaching the auth.py as a text file here. Download and change the extension back to .py to use. File to download: auth.txt

TiddlyWiddly commented 1 year ago

The auth.txt posted above worked for me. Copy pasted the tokens into HA and rebooted HA and it came right up. Hope I don't have to do this again soon. Very annoying.