ha-toyota-na
ha-toyota-na copied to clipboard
"Not Logged In" message
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.
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.
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 theauthorize()
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 tologin()
withclient.auth.set_tokens
inasync_get_entry_data()
. For safe measure, also callset_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
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 theauthorize()
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 tologin()
withclient.auth.set_tokens
inasync_get_entry_data()
. For safe measure, also callset_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 :(
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 modifyha-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.
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: 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!
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 runcat .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 runpip3 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 runcat .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.