Kemmey / Kemmey-TeslaWatch-Public

40 stars 21 forks source link

Shortcuts failing #290

Open JGunner1970 opened 3 years ago

JGunner1970 commented 3 years ago

Hi Just started playing around with the new shortcuts support you have added. Can you recommend a workaround to stop the shortcut failing to run initially due to the time it takes for the car to wake up? Maybe a loop until a positive response is returned? I believe iOS allows only up to 20 seconds to get a response.

Kemmey commented 3 years ago

Hey,

That's actually a really good idea! I'll add a few new shortcuts shortly - and will include a "wake vehicle" shortcut, that should return a true/false - then you can loop that action until it's awake or too long time has passed.

But by default, the actions will spend all possible time allowed to try and wake the vehicle - with above, possibly that will circumvent the timeout.

Until that ships, maybe use close charge port instead? It shouldn't be able to do much so shouldn't interfere with your workflow.

Cheers,

Kim

JGunner1970 commented 3 years ago

Hi Kim

Thanks for coming back to me on this. A Wake Up short cut would be great.

Current I have setup an Automation triggered via an NFC tag to get the car ready to leave. The steps are:

1) turn on climate 2) unlock charge port 3) unlock doors and horn sounds to confirm

However if the car is in a deep sleep the routine fails and keeps failing until about the 5th attempt by which time the car has awoken.

Perhaps the Wake shortcut could keep trying with a 10 second wait in between and for up to a minute?

I will try reordering my routine with the open / close charge port first.

Thanks

Jonathan

Sent from my iPhone

On 4 Mar 2021, at 20:00, Kim Hansen notifications@github.com wrote:

 Hey,

That's actually a really good idea! I'll add a few new shortcuts shortly - and will include a "wake vehicle" shortcut, that should return a true/false - then you can loop that action until it's awake or too long time has passed.

But by default, the actions will spend all possible time allowed to try and wake the vehicle - with above, possibly that will circumvent the timeout.

Until that ships, maybe use close charge port instead? It shouldn't be able to do much so shouldn't interfere with your workflow.

Cheers,

Kim

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.

Cardo1 commented 3 years ago

I’ve just picked up my M3 and started using this app. It’s fantastic. However, I would like to add a +1 for a wake up action, as otherwise my shortcuts fail unless the car is already awake.

Kemmey commented 3 years ago

@Cardo1 @JGunner1970 The wake action is in current beta build of 1.1.6. I intended to ship that tonight, but found a last minute annoyance. Feel free to join the beta and test out the wake command straight away!

https://testflight.apple.com/join/FdzFOLZv

Cheers,

Kim

Cardo1 commented 3 years ago

Excellent, thanks. I’ve signed up to the beta.

Quick question - do the various pre-built shortcuts include the wake command, or do we need to manually add this command to the beginning of the shortcuts?

Kemmey commented 3 years ago

@Cardo1 when you add a given action to Siri from within the app in 1.1.6 behind the scenes a new shortcut will actually be added with the phrase you chose - this is entirely handled by the operating system and how Apple thinks it should work. However the created shortcut contains only one single action - the one you chose. But to answer your question - yes, they do contain the wake - but since there's a limit to how long a single shortcut action can run, it might time out before waking the car - which is why I added the wake action - you can put that in a loop and run it 5 times, to ensure the action runs more reliably - however, this cannot be done from with-in the app, and has to be done manually, which is rather unfortunate...

Cardo1 commented 3 years ago

Ok, thanks for the info. I shall add a looped wake action to the beginning of my shortcuts that are likely to be run when the car is asleep.

Cardo1 commented 3 years ago

I’ve just tried running one of my newly amended shortcuts with the wake function, however unfortunately this didn’t run smoothly. The car did wake up after a few seconds of the command running, however the action itself failed. I tried it a few times (Siri through the Watch, Siri through my phone and through the Shortcuts app directly), even after the car was awake, and the error I seemed to be getting was the shortcut was taking too long to run. Bizarrely, despite getting the error each time I tried the shortcut, the boot did eventually open. I don’t know which command eventually opened it! This is what the shortcut looks like... A0274B08-FE5E-45D2-8BB9-C9D3514D0577 Is it possible the shortcut is still working, despite the error?

JGunner1970 commented 3 years ago

Is this because the initial Wake request is taking longer to respond than the maximum time that shortcuts permits? I think this is 20 seconds.

Perhaps the Wake request could respond immediately and then process asynchronously in the background?

The shortcuts process could then loop polling for vehicle status until the vehicle is awake. Then we could send the next commands as required.

Just an idea.

Thanks.

Sent from my iPhone

On 16 Mar 2021, at 11:03, Cardo1 @.***> wrote:

 I’ve just tried running one of my newly amended shortcuts with the wake function, however unfortunately this didn’t run smoothly. The car did wake up after a few seconds of the command running, however the action itself failed. I tried it a few times (Siri through the Watch, Siri through my phone and through the Shortcuts app directly), even after the car was awake, and the error I seemed to be getting was the shortcut was taking too long to run. Bizarrely, despite getting the error each time I tried the shortcut, the boot did eventually open. I don’t know which command eventually opened it! This is what the shortcut looks like...

Is it possible the shortcut is still working, despite the error?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe.

Kemmey commented 3 years ago

I tried the exact same shortcut - just works:

https://share.icloud.com/photos/0cIs2JUQRsgGBTigw9XMQuMzQ

But yeah, @JGunner1970 is probably on to something, cause even though my car is currently outside WiFi range, it woke really fast, so couldn't verify the long wake time...

Kemmey commented 3 years ago

@Cardo1 I think I see where this went bad - if the wake command times out, the action will return as if it failed. That's not entirely true - the action was fine - the result was just false. I've changed that and scheduled a new build - then the wake action should always succeed, just with a result of false if unable to wake in allowed time of 40 seconds.

If shortcuts allowed proper while loops or just a break feature, the flow could be optimized immensely with that... Alas

Will ship to TestFlight when build has processed.

Cheers,

Kim

Cardo1 commented 3 years ago

Rather than repeating the wake command 5 times, are we able to only repeat if the result is false? That way it could keep trying until it works?

Edit - Probably needs some kind of eventual timeout, though. Don’t want the boot opening 5 minutes into a drive!

Cardo1 commented 3 years ago

I’ve got an odd one when trying to run the shortcuts through Siri on my Watch. When I try and run it the first time, it always fails after a few seconds of “Checking with app”. When I try again after a few more seconds, it then shows the various actions scrolling through, ie. Wake, Wake, Wake... Open charge port, and then it works. It’s a bit difficult to thoroughly test, as I have to keep waiting for the car to go back to sleep, again!

Cardo1 commented 3 years ago

And on and on I go... Build 534 shows two Wake commands in Shortcuts? DF86A70D-E2EC-49A7-A036-0CF2E015C307

Kemmey commented 3 years ago

@Cardo1 Try to set the actions to not show during execution - at least then it'll be less of a mess with messages.

Why it fails the first time I have no clue - when making the initial request through Siri, all I do is ensure the vehicle is reported as being online by the Tesla api - cause if not, there's no way the command could succeed. Maybe making that request fails because the watch was too slow to get the network up and running? Really weird.

The two wakes must be a temporary fluke - I can't reproduce. Probably some caching - but shouldn't matter much in the grand scheme of things. The action is there only once in the app itself.

Cardo1 commented 3 years ago

I’ve been testing a fair bit. I deleted all my shortcuts and recreated them, just in case. For whatever reason, whether I use Siri or the Shortcuts app directly, and whether I use the iPhone or Watch, the first time I try the command when the car is asleep the shortcut always fails stating it took too long. Running the shortcut moments later will generally work as expected. This is for shortcuts with a 5 times repeated wake command, however the error is thrown up whilst it attempts the first wake command.

Cardo1 commented 3 years ago

Here’s a screen recording of the first attempt failing and the second moments later working as expected...

https://user-images.githubusercontent.com/7265647/111443794-a2bdd900-8701-11eb-8f3e-b833cbcbdc55.MOV

Kemmey commented 3 years ago

@Cardo1 yeah - can definitely reproduce myself as well.

I'll try @JGunner1970 suggestion of having a 10 sec timeout - then you'll just have to run it a few more times to make sure.

I just shipped 1.1.6, so this will be for 1.1.7 - and getting TestFlight beta approval takes a day or two - so I'll work on it, but won't be able to share for a couple days...

JGunner1970 commented 3 years ago

Hi Kim,

Yes that sounds like it would be a good work around and the we can add multiple Wake attempts into our script.

Looking forward to testing your next version.

Thanks

Sent from my iPad

On 17 Mar 2021, at 09:20, Kim Hansen @.***> wrote:

 @Cardo1 yeah - can definitely reproduce myself as well.

I'll try @JGunner1970 suggestion of having a 10 sec timeout - then you'll just have to run it a few more times to make sure.

I just shipped 1.1.6, so this will be for 1.1.7 - and getting TestFlight beta approval takes a day or two - so I'll work on it, but won't be able to share for a couple days...

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe.

Cardo1 commented 3 years ago

1.1.7 (536) has appeared on TestFlight. Does this build have the tweaked wake command?

Kemmey commented 3 years ago

@Cardo1 not yet - but I'll release it in 30 mins along with re-added summon :-D

Kemmey commented 3 years ago

@Cardo1 out now :-D build 540

JGunner1970 commented 3 years ago

I just updated to the new build and it appeared to work the first time I tried.

I checked the vehicle status on TeslaMate before trying and it showed as being asleep.

I will give it another try after the car has gone back to sleep for a while.

Sent from my iPhone

On 17 Mar 2021, at 20:27, Kim Hansen @.***> wrote:

 @Cardo1 out now :-D build 540

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe.

JGunner1970 commented 3 years ago

Spoke too soon. The initial wake works but then subsequent commands fail.

Sent from my iPhone

On 17 Mar 2021, at 20:56, Jonathan Gunner @.***> wrote:

I just updated to the new build and it appeared to work the first time I tried.

I checked the vehicle status on TeslaMate before trying and it showed as being asleep.

I will give it another try after the car has gone back to sleep for a while.

Sent from my iPhone

On 17 Mar 2021, at 20:27, Kim Hansen @.***> wrote:

 @Cardo1 out now :-D build 540

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe.

Kemmey commented 3 years ago

Wow - really? As in the second command times out or just didn't do anything?!

Kemmey commented 3 years ago

Seems to work properly for me with the same shortcut as screenshotted above

Cardo1 commented 3 years ago

Seems to be working for me. Tried shortcut with 5x wake then unlock, worked correctly.

Does the wake command check to see if the car is awake, or does it merely confirm if the command itself was successful?

I’ll be trying with 3x wake commands next, so the shortcuts run quicker.

JGunner1970 commented 3 years ago

Ok I have updated the sequence now to just to send the Wake command 4 times in succession without checking the result and the follow up command to Get Vehicle Status and Unlock Charge Port now appear to work consistently.

I will keep testing.

Sent from my iPhone

On 17 Mar 2021, at 21:16, Cardo1 @.***> wrote:

 Seems to be working for me. Tried shortcut with 5x wake then unlock, worked correctly.

Does the wake command check to see if the car is awake, or does it merely confirm if the command itself was successful?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe.

Kemmey commented 3 years ago

It'll check each time if car is awake - if not, it'll wait max 9 sec. if already awake it'll return immediately. So at worst you're sending 5 - or 3 - unnecessary requests. If there was a way to break out of a loop, that could be immensely optimized

Cardo1 commented 3 years ago

If the wake command can return a result, we could use an If command. If negative, repeat, if positive, move to next command.

JGunner1970 commented 3 years ago

Ok that’s interesting. What Result is returned if it times out at 9 seconds?

Sent from my iPhone

On 17 Mar 2021, at 21:24, Kim Hansen @.***> wrote:

 It'll check each time if car is awake - if not, it'll wait max 9 sec. if already awake it'll return immediately. So at worst you're sending 5 - or 3 - unnecessary requests. If there was a way to break out of a loop, that could be immensely optimized

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe.

JGunner1970 commented 3 years ago

We were obviously thinking the same thing!

Sent from my iPhone

On 17 Mar 2021, at 21:29, Cardo1 @.***> wrote:

 If the wake command can return a result, we could use an If command. If negative, repeat, if positive, move to next command.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe.

Kemmey commented 3 years ago

You can do a pseudo while loop like this - but it sure is nasty:

https://www.icloud.com/shortcuts/fa8592f249bf49bd83ec972ef9a2c251

image image image

Kemmey commented 3 years ago

The wake action will always return success if car was online. The result property will be true if awake, false if asleep. Also false if timeout after 9 seconds.

Cardo1 commented 3 years ago

Bizarre, I just tested again and it failed running the wake command stating it took too long. 😩

Kemmey commented 3 years ago

Hmmm, so maybe 9 is too close - I'll turn it down to 8

JGunner1970 commented 3 years ago

Wow that’s a lot of steps to do a simple while loop! Frustrating there is no way to break out of a loop when the condition is met!

Anyway really appreciate your efforts to get this working. 👍

Sent from my iPad

On 17 Mar 2021, at 21:35, Kim Hansen @.***> wrote:

 You can do a pseudo while loop like this - but it sure is nasty:

https://www.icloud.com/shortcuts/fa8592f249bf49bd83ec972ef9a2c251

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe.

Kemmey commented 3 years ago

Yeah, must admit that's the reason I'm not using shortcuts for much myself - trying to do even the simplest of tasks requires an obscene amount of jumping through hoops and fighting it the entire time. I know people do crazy things with it, but it's just sooo cumbersome. If it let me execute a swift playground file, that would be another story! :-D

Cardo1 commented 3 years ago

I’ve been having a play around with the shortcuts and the wake command and it’s still a bit hit and miss. It seems the first time I try to run the shortcut through Siri it fails, without showing anything happening. Almost like the app isn’t responding quickly enough and Siri is giving up? Subsequent attempts are successful.

I wonder whether this may be linked to my scheduled commands failing. I’ve been trying to use a scheduled shortcut to preheat the car using a “Wake/Wake/Wake/Start climate” shortcut, however usually when it tries to run it will fail, or I get a notification pop up on my phone asking me to tap it for it to work. I have “Ask Before Running” disabled, so it shouldn’t need to ask for permission to run. I have noticed there is no entry for the app in the “Background App Refresh” settings on the phone. Could it be that the app is going dormant/closing and when shortcuts are running through the phone they are initially failing as the app doesn’t open quickly enough?

JGunner1970 commented 3 years ago

I am experiencing the same thing when trying to wake for the first when the car is in a deep sleep.

This happens whether I invoke the shortcut via Siri, the shortcuts app or via an NFC tag.

Sent from my iPhone

On 23 Mar 2021, at 10:38, Cardo1 @.***> wrote:

 I’ve been having a play around with the shortcuts and the wake command and it’s still a bit hit and miss. It seems the first time I try to run the shortcut through Siri it fails, without showing anything happening. Almost like the app isn’t responding quickly enough and Siri is giving up? Subsequent attempts are successful.

I wonder whether this may be linked to my scheduled commands failing. I’ve been trying to use a scheduled shortcut to preheat the car using a “Wake/Wake/Wake/Start climate” shortcut, however usually when it tries to run it will fail, or I get a notification pop up on my phone asking me to tap it for it to work. I have “Ask Before Running” disabled, so it shouldn’t need to ask for permission to run. I have noticed there is no entry for the app in the “Background App Refresh” settings on the phone. Could it be that the app is going dormant/closing and when shortcuts are running through the phone they are initially failing as the app doesn’t open quickly enough?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe.

Kemmey commented 3 years ago

Hmm - this is so frustrating :-(

The background app refresh is not involved with this at all. Currently the iOS version doesn't do background updates at all - this is handled entirely by the widgets themselves.

As for the wake - three wakes is only 3x8 seconds - which I don't think is enough to wake from deep sleep - so possibly add 7 wakes to be sure?

I also thought of another possibility - I'd add two more actions - "send wake command and don't wait" - and "is car awake?" - then the waiting part could be implemented in the shortcut with apple sleep/wait commands which might be able to remain dormant for longer? A proper while loop would. E really helpful here, but the hacky one from earlier would be needed for now.

I'll try to add those soon - then at least all logic responsibility will be removed from the app, and there's only shortcuts itself to blame for failure to wake...

Kemmey commented 3 years ago

I should probably then figure out how to ship such a composite shortcut that ensures awake with the app - so that shortcut could be run from other shortcuts to optimize reuse

JGunner1970 commented 3 years ago

For me in this instance, it appears to fail on the first Wake command saying it took too long.

On 23 Mar 2021, at 11:51, Kim Hansen @.***> wrote:

Hmm - this is so frustrating :-(

The background app refresh is not involved with this at all. Currently the iOS version doesn't do background updates at all - this is handled entirely by the widgets themselves.

As for the wake - three wakes is only 3x8 seconds - which I don't think is enough to wake from deep sleep - so possibly add 7 wakes to be sure?

I also thought of another possibility - I'd add two more actions - "send wake command and don't wait" - and "is car awake?" - then the waiting part could be implemented in the shortcut with apple sleep/wait commands which might be able to remain dormant for longer? A proper while loop would. E really helpful here, but the hacky one from earlier would be needed for now.

I'll try to add those soon - then at least all logic responsibility will be removed from the app, and there's only shortcuts itself to blame for failure to wake...

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/Kemmey/Kemmey-TeslaWatch-Public/issues/290#issuecomment-804839148, or unsubscribe https://github.com/notifications/unsubscribe-auth/AIAEEYIRHYK6AN5B4U7GFK3TFB6CNANCNFSM4YTPNUIA.

Kemmey commented 3 years ago

Is that with the beta version?

Cardo1 commented 3 years ago

For me in this instance, it appears to fail on the first Wake command saying it took too long.

Same here. It’s failng within 5-10 seconds of running the shortcut. It’s definitely not getting all the way through the shortcut before it fails. I don’t think this is a case of the car not waking up quick enough. If I rerun the shortcut immediately after it fails, it will usually work. In my case, beta build 550.

JGunner1970 commented 3 years ago

Yes. The latest beta via TestFlight. 1.1.7

I just tried it now and got this:

Sent from my iPhone

On 23 Mar 2021, at 11:54, Kim Hansen @.***> wrote:

 Is that with the beta version?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe.