widewing/ha-toyota-na

"Not Logged In" message

Closed this issue · 102 comments

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

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.

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.

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?

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.

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

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

I have the same problem here. 2022 RAV4

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

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

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...

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

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

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.

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

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.

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.

Thanks! This also worked for me as well!

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

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.

@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

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

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

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.

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!

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?

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
      }
      {
        "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.

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

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

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.

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.

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.

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!

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

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

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.

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.

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

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.

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

idk how to simplify it more than the comment above that lays out basically step by step: #52 (comment)

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.

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.

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?

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

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

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

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.

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

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

layuso commented

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

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.

I just wanted to say thanks to everyone posting on how to make this work again. Especially @brylee123 for the excellent write up. After screwing up my config entries file numerous times I finally made this work.

jgdf42 commented

Can anyone help me get this working? Got my json and replaced the contents, reboot HA, but HA throws an error in log. My integration was installed via HACS.

My HAS log:

Error setting up entry Toyota Corolla for toyota_na

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 390, in async_setup
    result = await component.async_setup_entry(hass, self)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/toyota_na/__init__.py", line 38, in async_setup_entry
    client.auth.set_tokens(entry.data["tokens"])
  File "/usr/local/lib/python3.11/site-packages/toyota_na/auth.py", line 187, in set_tokens
    self._id_token = tokens["id_token"]
                     ~~~~~~^^^^^^^^^^^^
KeyError: 'id_token'

My core.config_entries snippet (redacted credentials, included another entry above it to show how indentation is spaced;)

      {
        "entry_id": "96e69890d09d2a2bb5cfe91b89307227",
        "version": 1,
        "domain": "homekit_controller",
        "title": "Roku 4670RW 51A1 (None)",
        "data": {
          "AccessoryIP": "192.168.1.185",
          "AccessoryPort": 45830
        },
        "options": {},
        "pref_disable_new_entities": false,
        "pref_disable_polling": false,
        "source": "ignore",
        "unique_id": "19:d8:e5:b6:03:e3",
        "disabled_by": null
      },
      {
        "entry_id": "f38a8263a9434c598bfc9f7b6cb9e25d",
        "version": 1,
        "domain": "toyota_na",
        "title": "Toyota Corolla",
        "data": {
          "tokens": {
            "access_token": "copy and pasted my access token from my json",
            "refresh_token": "copy and pasted my refresh token from my json",
            "expires_at": 1692638805.182473,
            "updated_at": 1692637006.182488,
            "guid": "copy and pasted my guid from my json"
          },
          "email": "email my account is under",
          "username": "email my account is under (also tried phone number)",
          "password": "password for my account"
        },
        "options": {},
        "pref_disable_new_entities": false,
        "pref_disable_polling": false,
        "source": "user",
        "unique_id": "toyota_na:email my account is under",
        "disabled_by": null
      },

Also, the syntax of @brylee123 core.config_entries example here; #52 (comment) is a different syntax from the one posted by @dannycohn here; #52 (comment) ??

tokens["id_token"]

your config file only has access_token and refresh_token...

jgdf42 commented

tokens["id_token"]

your config file only has access_token and refresh_token...

There is also no id_token in the above examples, so I overlooked this. Thank you.

Now I get this error in my logs;

Source: config_entries.py:432
First occurred: 10:49:09 PM (1 occurrences)
Last logged: 10:49:09 PM

Config entry 'Toyota Corolla' for toyota_na integration not ready yet: 500, message='Internal Server Error', url=URL('https://oneapi.telematicsct.com/v1/global/remote/status'); Retrying in background```

same 500 error as @jgdf42

edit: just to add some info, when I use the command line with app.py I can get vehicle status, vin and all, but some pages such as "get_engine_status" give a 500 error on the URL. not sure if its because my vehicle doesn't have advanced options (Base model) but it shouldn't error.

Thanks @brylee123 for the writeup and @layuso for the auth.py - managed to get this working from never having installed the integration before.

Does anyone know if the Integration works in Canada as it appears the website, logins, and app (registration) might be different? I can't use the Toyota.com website to add my VIN, which is, I suspect why the vehicle added to my app (registered as Canada) isn't showing on the Toyota.com website, and why I get the error below (logs) and the integration is giving me "Failed setup, will retry" as there is no vehicle to pull information for?

Can anyone confirm?

`This error originated from a custom integration.

Logger: custom_components.toyota_na
Source: custom_components/toyota_na/init.py:104
Integration: Toyota (North America) (documentation, issues)
First occurred: 9:32:53 PM (3 occurrences)
Last logged: 9:33:24 PM

Error fetching data
Traceback (most recent call last):
File "/config/custom_components/toyota_na/init.py", line 104, in update_vehicles_status
raw_vehicles = await get_vehicles(client)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/toyota_na/vehicle/vehicle.py", line 36, in get_vehicles
await vehicle.update()
File "/usr/local/lib/python3.11/site-packages/toyota_na/vehicle/vehicle_generations/seventeen_cy_plus.py", line 77, in update
vehicle_status = await self._client.get_vehicle_status(self._vin)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/toyota_na/client.py", line 67, in get_vehicle_status
return await self.get_vehicle_status_17cyplus(vin)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/toyota_na/client.py", line 80, in get_vehicle_status_17cyplus
return await self.api_get("v1/global/remote/status", {"VIN": vin})
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/toyota_na/client.py", line 41, in api_get
return await self.api_request("GET", endpoint, header_params)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/toyota_na/client.py", line 31, in api_request
resp.raise_for_status()
File "/usr/local/lib/python3.11/site-packages/aiohttp/client_reqrep.py", line 1005, in raise_for_status
raise ClientResponseError(
aiohttp.client_exceptions.ClientResponseError: 500, message='Internal Server Error', url=URL('https://oneapi.telematicsct.com/v1/global/remote/status')
`

I have read through the thread and seen the solutions folks have for the Code authentication but it looks a bit beyond my knowledge level. Is there any chance this will ever make it into the integration natively?

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.

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!

Can confirm this solution still works. Did it today without ever having used the integration before.

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.
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!

Can confirm this solution still works. Did it today without ever having used the integration before.

Which solution? The long thread and/or the YAML above? I just updated my auth.py with the #53 solution, but get syntax error with all of the elif(s). I'm using VSCode and running using the python client built in.

Does anyone have any advice for getting plugin with 2FA? I don't have an auth.py file when installed through HACS.

Thanks,

I have tried this fix from May 8 several times and am able to generate a token, but whenever I update /config/.storage/core.config_entries and then restart HA it crashes and I am unable to load the UI. If I unplug my server and plug it back then HA will start but ALL data in core.config_entries is deleted and a file called core.config_entries.corruputed (which is empty) is generated. Nothing is saved in the logs when I do this. I am also being very careful to ensure that all the syntax and indentation is correct. Any ideas?

I have tried this fix from May 8 several times and am able to generate a token, but whenever I update /config/.storage/core.config_entries and then restart HA it crashes and I am unable to load the UI. If I unplug my server and plug it back then HA will start but ALL data in core.config_entries is deleted and a file called core.config_entries.corruputed (which is empty) is generated. Nothing is saved in the logs when I do this. I am also being very careful to ensure that all the syntax and indentation is correct. Any ideas?

I just had the same happen to me yesterday! Basically reset my whole HA system. I was able to generate all the needed data, but can't add the config to the core.config entries manually... that seems to be where the issue is for me. And with not being able to add the integration, can't get an entry there correctly.

      {
        "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.

Is the Entity ID the GUID or the ID_TOKEN? yesterday when I manually added this to my core.config file its killed my HA. I know I was missing this attribute but need to know which is the correct ID to insert there...

Is the Entity ID the GUID or the ID_TOKEN? yesterday when I manually added this to my core.config file its killed my HA. I know I was missing this attribute but need to know which is the correct ID to insert there...

I used the GUID as the "entry_id" and it worked. I don't think it even matters, only needs to be unique.

Is the Entity ID the GUID or the ID_TOKEN? yesterday when I manually added this to my core.config file its killed my HA. I know I was missing this attribute but need to know which is the correct ID to insert there...

I used the GUID as the "entry_id" and it worked. I don't think it even matters, only needs to be unique.

Did you already have the integration added or just added the entry manually and restarted?

I never had the integration working until adding it manually with the method above.

The code block you have is also missing a 3rd token, id_token, that also showed up in the generated token file.

I never had the integration working until adding it manually with the method above.

The code block you have is also missing a 3rd token, id_token, that also showed up in the generated token file.

Thanks! I seemed to have killed my HA again when adding this manually... The copy/paste of the code block seemed to match the other entries in there, so I don't think it is formatting. I did have the ID_Token included in the clipboard... Not sure why this seems to be killing HA upon a restart... Guess I'll be recovering this afternoon and giving it another go around.

Let me know if you have had any success. I made another attempt last night and ran into the same issue. I have given up for now.

No success for me either... every time I edit that core config entries file, my HA crashes and I have to restore from backup. I'm holding out as well... not sure if it's formatting or something different.

When I initially tried this I had the same corrupt config errors. I was trying to insert the config at the top of the list and got repeated errors. I then added it to the bottom of the config list and it worked first try. I don't know if that'll help anyone else but it worked for me.

I was trying to add it second entry from the end, so that could've been my issue as well. I'll give it a shot at the bottom and see what happens. Couldn't hurt🤪🤪 I have a good full backup available

I tried adding it to the end of the file, making sure the formatting matched the entry above. It killed my HA system, so had to restore... Not sure where to go from here...

@tmorris0221

I added the JSON code that I was pasting into the core config entries file to an online JSON editor and discovered that it did not like the "//" comments (which I was not removing). This fixed my issue and I was able to get the integration running. Hope this helps!

As someone who has just uncovered this issue, what is the current state of the project? Do we need to manually install the other plugin and modify files locally in order to get everything working? Is there a guide that someone would be kind enough to compile?

Worked for me, the only thing I needed to do differently was to use a phone number rather than an email for the OTA

python3 -m toyota_na.app authorize <phone#>
format for the phone number was no dash or space. 5555551234

jgdf42 commented

same 500 error as @jgdf42

edit: just to add some info, when I use the command line with app.py I can get vehicle status, vin and all, but some pages such as "get_engine_status" give a 500 error on the URL. not sure if its because my vehicle doesn't have advanced options (Base model) but it shouldn't error.

Did you ever get this resolved?

image

Debug log if anyone can make sense of this. Maybe I didn't update something? I'm just downloading newest version of integration from integration store via search in Home Assistant and adding my auth token contents to my config file. The python commands about my vehicle work on Windows when I run the commands for the script, just not in Home Assistant.

2023-10-28 00:22:54.284 DEBUG (MainThread) [custom_components.toyota_na] Updating vehicle status
2023-10-28 00:23:02.845 ERROR (MainThread) [custom_components.toyota_na] Error fetching data
Traceback (most recent call last):
File "/config/custom_components/toyota_na/init.py", line 104, in update_vehicles_status
raw_vehicles = await get_vehicles(client)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/toyota_na/vehicle/vehicle.py", line 36, in get_vehicles
await vehicle.update()
File "/usr/local/lib/python3.11/site-packages/toyota_na/vehicle/vehicle_generations/seventeen_cy_plus.py", line 77, in update
vehicle_status = await self._client.get_vehicle_status(self._vin)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/toyota_na/client.py", line 67, in get_vehicle_status
return await self.get_vehicle_status_17cyplus(vin)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/toyota_na/client.py", line 80, in get_vehicle_status_17cyplus
return await self.api_get("v1/global/remote/status", {"VIN": vin})
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/toyota_na/client.py", line 41, in api_get
return await self.api_request("GET", endpoint, header_params)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/toyota_na/client.py", line 31, in api_request
resp.raise_for_status()
File "/usr/local/lib/python3.11/site-packages/aiohttp/client_reqrep.py", line 1005, in raise_for_status
raise ClientResponseError(
aiohttp.client_exceptions.ClientResponseError: 500, message='Internal Server Error', url=URL('https://oneapi.telematicsct.com/v1/global/remote/status')
2023-10-28 00:23:02.860 DEBUG (MainThread) [custom_components.toyota_na] Finished fetching toyota_na data in 8.576 seconds (success: False)

As someone who has just uncovered this issue, what is the current state of the project? Do we need to manually install the other plugin and modify files locally in order to get everything working? Is there a guide that someone would be kind enough to compile?

I would also be appreciative of some kind of guide to get this working inside go HA. I'm not advanced enough to go through Ubuntu so anything that is doable with studio-code-server or the HA terminal would be awesome

As someone who has just uncovered this issue, what is the current state of the project? Do we need to manually install the other plugin and modify files locally in order to get everything working? Is there a guide that someone would be kind enough to compile?

I would also be appreciative of some kind of guide to get this working inside go HA. I'm not advanced enough to go through Ubuntu so anything that is doable with studio-code-server or the HA terminal would be awesome

I would be appreciative of something like this as well... I've quit trying as every time I make manual changes trying to get this working, I lose my HA and have to restore.

Update to all: I have managed to automate the process of getting OTP and it's been working for me for several days. I'll do more verification and share the setup in this repo.


gist created: https://gist.github.com/t0ny-peng/f85b0a0dc3d46246ae17a9d7215e39da

@lunar-studio Do you mind add this gist to the description of this issue to help other people?

The method posted by @t0ny-peng is working for me too. I don't love the IMAP solution, but understand why it's necessary. It's just too bad we cannot get a developer key for the Toyota API to avoid this workaround.

@willheineman Well, you can't hope a 20th century company to embrace new technology. With that being said, the AWS solution is more reliable to can even work with all other services where a email verification code is needed.

@t0ny-peng Thank you and please let me know if this is what you wanted me to add. There’s so many admittedly unexpected replies to this issue that I’ve only loosely followed my original post. I might have to give this another shot now.

same 500 error as @jgdf42

edit: just to add some info, when I use the command line with app.py I can get vehicle status, vin and all, but some pages such as "get_engine_status" give a 500 error on the URL. not sure if its because my vehicle doesn't have advanced options (Base model) but it shouldn't error.

@yankees5963 I finally fixed this today..by signing up for the Toyota trial. Why this isn't mentioned in any of the instructions? I don't know. Huge oversight. If you don't activate the trial, the car doesn't communicate any of the data into Toyota's cloud. Turns out you get the trial for free from the day you bought the car (if brand new and you never activate it then you just lose your trial time).

      {
        "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.

Can confirm that adding the above to the middle of config_entries crashed my HAS but adding it to the end did not. Also needed to add "id_token" for the integration to work

Hmm, I am unable to generate a token. I have canceled my Toyota connection for the last 6 months and I just reactivated it last week. I made the changes to my auth.py file but I am unable to generate a token. Am I missing a step?

      {
        "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.

Can confirm that adding the above to the middle of config_entries crashed my HAS but adding it to the end did not. Also needed to add "id_token" for the integration to work

Getting this error today. Had everything working fine for months. Integration will not load.

image

I see the DMCA takedown notice now. sad days

Getting this error today. Had everything working fine for months. Integration will not load.

image

I think this is caused by @t0ny-peng taking down toyota-na-custom from pypi

image

Hmm, I am unable to generate a token. I have canceled my Toyota connection for the last 6 months and I just reactivated it last week. I made the changes to my auth.py file but I am unable to generate a token. Am I missing a step?

      {
        "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.

Can confirm that adding the above to the middle of config_entries crashed my HAS but adding it to the end did not. Also needed to add "id_token" for the integration to work

Share a screenshot of the section of auth.py you modified

So this is completely dead? Still working for anyone?

So this is completely dead? Still working for anyone?

Yes, still works fine. Once in a while I have to simply reload the integration; maybe because Toyota web services momentarily went poof. Still using the token generated from over a year ago.

Finally got it working. But I don't see an option for Remote Start. I could have sworn I had this before the 2FA / Token setup? Anyone. Thanks for all the posts & help, it was a pain. I checked the issues section and saw someone else said something about the library. Can remote start it from the Toyota App.

2022 Toyota Tundra for reference

Thanks,

Finally got it working. But I don't see an option for Remote Start. I could have sworn I had this before the 2FA / Token setup? Anyone. Thanks for all the posts & help, it was a pain. I checked the issues section and saw someone else said something about the library. Can remote start it from the Toyota App.

2022 Toyota Tundra for reference

Thanks,

Bump please. I thought the same thing but I never used the function. I originally thought I might've mistaken that function for the lock and unlock feature

So this is completely dead? Still working for anyone?

Yes, still works fine. Once in a while I have to simply reload the integration; maybe because Toyota web services momentarily went poof. Still using the token generated from over a year ago.

Could you share your setup? my integration stopped working with the DMCA takedown

Anyone have a distro of toyota-na-custom? Where can it be found?

Has something else changed with their API? When I make the changes to auth.py and run it, I get an error mentioning:

"output": [{"name": "value", "value": "3"}, {"name": "id", "value": "USER_BLOCKED_REMAIN_MINUTES"}], "input": [{"name": "IDToken1", "value": "USER_BLOCKED_REMAIN_MINUTES"}]}, {"type": "HiddenValueCallback", "output": [{"name": "value", "value": "5"}, {"name": "id", "value": "USER_BLOCKED_TIME"}], "input": [{"name": "IDToken2", "value": "USER_BLOCKED_TIME"}]

I seem to get blocked for 5 minutes and once the remaining time runs out, it starts back up to 5. Is this happening to anyone else?

Update: Found the problem. Had to use my phone number instead of my email as mentioned in #52 (comment) . I also had to disable the biometrics on the phone app.

Had anyone tried the 2.2 update released on HACS? Especially for the ones that got it working by manually adding the 2 factor auth.

Had anyone tried the 2.2 update released on HACS? Especially for the ones that got it working by manually adding the 2 factor auth.

It's working on my already logged in install. Not going to try logging out

Had anyone tried the 2.2 update released on HACS? Especially for the ones that got it working by manually adding the 2 factor auth.

It works for me, so I built the new release.

Finally got it working. But I don't see an option for Remote Start. I could have sworn I had this before the 2FA / Token setup? Anyone. Thanks for all the posts & help, it was a pain. I checked the issues section and saw someone else said something about the library. Can remote start it from the Toyota App.

2022 Toyota Tundra for reference

Thanks,

Not sure if you found this or not. Took me a little digging to find it. Use the "Service" Toyota (North America): engine_start.
Just got mine up and going after feeling defeated for about a week, took another stab at it and got it going today.