-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Climate fails to turn on when vehicle is asleep #39
Comments
Sorry for the delay.. We have been trying to account for that here, and handling it by sending the wake command:
But it looks like the TeslaFi response has changed:
This means the json data is not returned properly, and instead TeslaFi is reporting the error with plain text prepended, and that plaintext string has changed. Looks like we can fix this by changing the startwith check to a contains/substring check. Ultimately TeslaFi is wrong to return non-json here 🤦♂️ they should instead be encapsulating the upstream error and embedding that into the json error response. |
Just adding a +1 to this, I'm seeing the same error when attempting to start a charge while the car is asleep.
|
I have a workaround that's functional:
Unfortunately, It seems that polling takes quite a while to update the state. Is there a way to increase the polling frequency? Or perhaps trigger a poll manually within the automation? |
@jhansche I spend some time looking into your suggestion and changed the startswith to contains, but it still does not work. I'm not a python developer, but as far as I can tell this check just throws a Do you have the time to take a look or point me in the right direction here? I might find some time to look into it again if you help me understand the problem. |
You're right - that would only surface the error in a more user-friendly way. In coordinator.execute_command(), we are automatically adding
Can you tell if the error is raised immediately, or does it hang for 10 seconds before the error? If you don't do anything -- that is, you try the command, get the "offline or asleep" error -- does the car eventually perform the requested action? Like, maybe after a minute or two? If not, does it at least wake up on its own? If the car eventually responds to the command despite the TeslaFi API error, then we might just need to suppress the error while we wait for the car to wake up. If the car does not respond, and the request waits for those ~10 seconds before responding with an error, then maybe the |
When toggling charge / setting charge target with the car asleep, the error is returned immediately. The car does wake from sleep, but the intended action doesn't ever run. I've noticed that the wake time can vary quite a bit - everything from a couple of seconds to well beyond 1 minute. Setting a timeout feels a bit fragile with that in mind, might be better to wake the car, wait for confirmation, then set the desired actions. |
Right, that should be the intent behind TeslaFi's We could work around it in the integration, but I wonder if this should be a bug report to TeslaFi instead... Possibly even a feature request to replace the wake-delay parameter with a simple "wake if needed and send the command whenever it wakes up", so that we don't have to guess how long a typical wake should take. Even if the TeslaFi wake parameter worked correctly, it sounds like it would impose the requested delay regardless of how long it actually takes for it to wake up |
@jhansche I looked into the "api documentation" over at teslafi.com and it does indeed seem like the wake command is currently broken. Sending a I think that this is a TeslaFi issue. Will try to contact them and see what they say. I'll keep you posted here. |
It was indeed a problem over at teslafi and it seems like they fixed it now. It's working as intended for me at least. Response from James:
As he points out there might be a case where some firmware versions report the vehicle as offline instead of asleep. In this case the command will not be able to wake the car. Might be something we should handle somewhere or at the very least document. What's your view on this @jhansche? |
Awesome, thanks for checking on that. My view is we shouldn't go out of our way to work around issues with TeslaFi or Fleet API or specific car models and versions. If there is some intricacy with how Home Assistant works with certain scenarios, then I can make a case for handling that in the integration -- example being how we need to wait for TeslaFi to reflect the new status for an unlock command or climate command. In those cases, I schedule a refresh after a short delay, and try to suppress the state flapping in the meantime. Without that, you would send the unlock command, it would show unlocked, and then a few seconds later switch back to locked again because TeslaFi hasn't updated its status yet, and then a minute or two later switch to unlocked once it is reflected. So, with that in mind, I don't think we should work around the exception that James described. |
That makes sense. Well, seems like we can close this one. Thanks for the assistance 😄 |
Unfortunately, this issue seems to have returned, and the API is responding with |
Still works fine on my end. Could be your vehicle reporting as offline rather than asleep depending on model/firmware. |
Interesting that it's still working for you, I already had the offline / sleep toggle enabled. It's been failing for roughly 5 days (looking at the logs when the automations began failing) I haven't changed anything in the setup during this time. This seems to be the case for every change requested (set charge level etc) while the car is asleep. |
Try to call the API manually to see what response you get. This error caused the API to return a 500 response when we tried to wake the vehicle with the request Since I can still wake my vehicle with this command i guess the problem you are experiencing is different. |
Thought I'd update here - this started working again not long after my last post, and hasn't happened since then, so I can only assume it was an issue on TeslaFi's side, or perhaps a timeout issue (e.g 10s wasn't long enough) - As the car is on cellular, this might be more variable in my situation. If it does happen again, I'll try the manual API call again with a longer timeout and see if this fixes the issue. |
The TeslaFi API supports adding a `wake=N` argument that instructs TeslaFi to wait for up to `N` seconds for the car to wake up before sending the requested command. In my testing, wake=10 was sufficient to allow the car to wake up, but that testing was performed at home on wifi. Issues #39 and #47 report that 10 seconds may not be enough time to car fully, but 30 seconds appears to be more reliable. If the car is already awake when a command is being sent, then the argument will have no effect. So this should be a safe change.
The TeslaFi API supports adding a `wake=N` argument that instructs TeslaFi to wait for up to `N` seconds for the car to wake up before sending the requested command. In my testing, wake=10 was sufficient to allow the car to wake up, but that testing was performed at home on wifi. Issues #39 and #47 report that 10 seconds may not be enough time to wake the car fully, but 30 seconds appears to be more reliable. If the car is already awake when a command is being sent, then the argument will have no effect. So this should be a safe change.
The TeslaFi API supports adding a `wake=N` argument that instructs TeslaFi to wait for up to `N` seconds for the car to wake up before sending the requested command. In my testing, wake=10 was sufficient to allow the car to wake up, but that testing was performed at home on wifi. Issues #39 and #47 report that 10 seconds may not be enough time to wake the car fully, but 30 seconds appears to be more reliable. If the car is already awake when a command is being sent, then the argument will have no effect. So this should be a safe change.
The TeslaFi API supports adding a `wake=N` argument that instructs TeslaFi to wait for up to `N` seconds for the car to wake up before sending the requested command. In my testing, wake=10 was sufficient to allow the car to wake up, but that testing was performed at home on wifi. Issues #39 and #47 report that 10 seconds may not be enough time to wake the car fully, but 30 seconds appears to be more reliable. If the car is already awake when a command is being sent, then the argument will have no effect. So this should be a safe change.
I'm having issues with turning on the climate when the vehicle is asleep. HA shows an error and usually I can just wait a few seconds (until the vehicle wakes up) and try it again successfully.
Expected behaviour should be to wake up the vehicle when it is asleep and then send the auto_conditioning_start command. It seems like we get a 500 error back with the message: "vehicle is offline or asleep".
Have you encountered this problem before?
Se attached log below:
The text was updated successfully, but these errors were encountered: