TMC is an independent, primarily volunteer organization that relies on ad revenue to cover its operating costs. Please consider whitelisting TMC on your ad blocker and becoming a Supporting Member. For more info: Support TMC

Android phone key work around with Tasker?

Discussion in 'Model 3: User Interface' started by SDKoala, Apr 20, 2018.

  1. SDKoala

    SDKoala Model 3 LR RWD

    Joined:
    Apr 11, 2018
    Messages:
    827
    Location:
    San Diego
    Count me in the group of Android users that's having too many failures with the phone key concept that Tesla is trying shove down our throats. At least half of the time, my phone (Google Pixel) won't connect to the car and I have to pull it out and toggle the Bluetooth on-off to get it to connect. Thankfully, this reliably corrects the problem. I've resorted to just manually toggling on-off the Bluetooth on my phone while approaching the car so I won't be stuck fiddling around with my phone trying to get in the car.

    This got me thinking that there should be a way to use Tasker (https://play.google.com/store/apps/details?id=net.dinglisch.android.taskerm&hl=en_US) to automate this process. The learning curve with Tasker is extremely high and the interface is not intuitive at all. After putting hours into trying to figure it out, I can't make it do what I want.

    The task I want to perform is automatically toggling off-on the phone's Bluetooth when I approach the car. The problem I'm having is how to trigger the task. One way I thought to do it is to have Tasker store the GPS coordinates of the car and toggle the Bluetooth when the phone comes back to the location, but that seems like it would be a huge battery drain on the phone. Another way I tried was to use the "Bluetooth Near" state to detect the car's Bluetooth and then toggle the phone's Bluetooth on-off, but it doesn't always detect the car, which is the underlying problem.

    Maybe someone else with more experience with Tasker can come up with something? At this point, I'd settle for a Bluetooth toggle button on my phone's home screen to save a few taps.
     
    • Informative x 1
  2. ratsbew

    ratsbew Active Member

    Joined:
    Mar 3, 2012
    Messages:
    1,010
    Location:
    O'Fallon, IL
    Maybe have it switch Bluetooth off/on every hour?
     
  3. swaltner

    swaltner Active Member

    Joined:
    Oct 13, 2012
    Messages:
    1,539
    Location:
    Kansas, USA
    This would be my suggestion as well, but hopefully you can put an exception in to not toggle Bluetooth if you’re currently playing music or some other media on the phone. You don’t want Tasker to interrupt your normal phone usage.
     
  4. SDKoala

    SDKoala Model 3 LR RWD

    Joined:
    Apr 11, 2018
    Messages:
    827
    Location:
    San Diego
    That might be the best way. I just need to figure out how to disable the task if I'm already connected to a Bluetooth device
     
  5. Packetdancer

    Packetdancer Member

    Joined:
    Apr 17, 2018
    Messages:
    23
    Location:
    Seattle, WA
    It's been a while since I've used Tasker, I admit, but I believe you should be able to set up a profile for 'Connected to Car' and make it dependent on BT Connected <address of car's BT radio or name of car>, and similarly a 'Connected to Headset' and make it dependent on your headset.

    Sadly, last I remember there wasn't a generic 'Bluetooth is connected to something', so you'd need to do this and then make the reset task dependent on NOT being in one of those two profiles, but if you connected to something else you'd still run the risk of a reset. If you use a lot of Bluetooth Low Energy ad-hoc connection devices, that could cause problems.
     
  6. Coeus

    Coeus Member

    Joined:
    Apr 16, 2018
    Messages:
    18
    Location:
    Carmel, IN
    I combined Tasker with AutoWear and made a profile to simply toggle my BT via a quick tap on my watch. I'm now trying a version that opens the Tesla app instead of toggling BT to see if that works a little better. But, I haven't figured out a good automatic way to trigger the profile since I'm not convinced BT Near will work overly well.
     
  7. SDKoala

    SDKoala Model 3 LR RWD

    Joined:
    Apr 11, 2018
    Messages:
    827
    Location:
    San Diego
    Do you have any more specific advice on how to do it or where to go for help? I've literally put hours into trying to learn Tasker basics over the years and it's something that I just don't get. The way it works is so illogical to me and the UI is so incredibly unfriendly that I always eventually just give up.
     
  8. insaneoctane

    insaneoctane Active Member

    Joined:
    Apr 6, 2016
    Messages:
    3,191
    Location:
    Southern California
    I am a Tasker user and welcome solutions that use it. I don't have my car yet, but think needing Tasker is sad :(. Having said that I often found tasker limited without root permission. My current phone isn't rooted so I am hoping a good tasker profile can help with standard permissions ...
     
  9. garym3

    garym3 New Member

    Joined:
    Apr 21, 2018
    Messages:
    1
    Location:
    San Diego
  10. Coeus

    Coeus Member

    Joined:
    Apr 16, 2018
    Messages:
    18
    Location:
    Carmel, IN
    That still involves pulling out your phone (or possibly thrusting your pocket against the car), so I don't see that as any better, really. But, that's just my opinion, so if that's something you prefer, cool. Additionally, that plugin is using the remote API, so it will only work after waking up your car, which takes 10 or so seconds usually.
     
  11. Kcharwood

    Kcharwood Member

    Joined:
    Oct 22, 2016
    Messages:
    256
    Location:
    Austin, TX
    My iPhone X has worked flawlessly for 2 months. Literally never had a problem.

    Is it the Bluetooth stack on Android that flakey? Or maybe a specific hardware problem with specific phones?

    From a stack perspective, I’d assume there is firmware for the radio, Google has a generic SDK wrapper on top of the Bluetooth stack, then app developers build custom apps on top of that.

    In my experience as IOS developer, Bluetooth sucked until about 3 years ago, when Apple got serious and rewrote the whole stack specifically for the reliability of Apple Watch. Once Apple did that, Bluetooth has been a reliable foundation to build apps on top of that. Before that, you couldn’t count on it.

    Do we think this is a hardware problem, a google problem, or a Tesla problem on Android?
     
    • Informative x 1
  12. Packetdancer

    Packetdancer Member

    Joined:
    Apr 17, 2018
    Messages:
    23
    Location:
    Seattle, WA
    Speaking as someone who works with Bluetooth and Bluetooth Low Energy for her day job, different implementations of the Android Bluetooth stack haunt my nightmares. But yes, different Android phones have different Bluetooth quirks; I literally have a list I keep for work. Unsurprisingly, the Pixel is my gold standard for 'least headache-inducing Bluetooth implementation'.

    iOS's Bluetooth stack has always been more solid than Android's, I'm afraid, even in the iOS 7 era where you'd end up with weird invalidated CBPeripherals that would just silently fail to reconnect but still claimed to be valid. Android, for instance, spent a great deal of time where it would report support (down at the link layer) for connection interval negotiation, and then just refuse every connection interval it was asked for after the first.
     
    • Informative x 5
  13. SDKoala

    SDKoala Model 3 LR RWD

    Joined:
    Apr 11, 2018
    Messages:
    827
    Location:
    San Diego
    #13 SDKoala, Apr 22, 2018
    Last edited: Apr 22, 2018
    I think I figured it out and it was much simpler than I thought it would be, just difficult to implement because of the non-intuitive UI. What I want to do is toggle Bluetooth off/on automatically after a set amount of time because (at least for me) toggling the Bluetooth off/on reliably gets the phone key to work again if it's not connecting.

    Below I present the step-by-step directions a Tasker-naive person like me should be able to follow:

    (0) Download Tasker from the Play Store. It's like $3. I have no financial interest in Tasker and I happened to get it for free years ago.

    (1) Make sure you are on the "Profiles" tab, which should be the default when starting the app. Press the "+" button in the lower right corner to add the first context, a condition which Tasker is going to look for to run. Tap "Time." Tap "From" and "To" to deselect start and end times, which makes the profile run all day long. You can also specify the hours you want it to run. Tap "Every" to specify how often. The minimum is 2 minutes, which is what I've chosen for now. Tap the back arrow to get back to the "Profiles" screen.

    (2) A new window called "Enter Task" will pop up in the lower right. Tap "New Task," then the checkmark to come to the "Task Edit" screen.

    (3) Tap the "+" to create an action for Tasker to perform. The first action will be to turn Bluetooth off. Tap "Net" -> "Bluetooth" and make sure "Off" is selected under "Set." Tap the back arrow to get back to the "Task Edit" screen.

    (4) The next action will be to turn Bluetooth back on immediately after turning it off. Repeat the Step 3 but this time select "On" under "Set." Tap the back arrow again to get back to the "Profiles" screen.

    (5) You now have a Profile that will turn Bluetooth off then on at whatever interval you specified between whatever hours you specified. We don't want it do this if Bluetooth is already connected because you'll lose your connection. To keep it from doing that, we will create another context/condition that will look to see if Bluetooth is connected. Long press the first context you created under the profile (Every X hours/minutes). Tap "Add" -> "State" -> "Net" -> "BT Connected" and select the "Invert" checkbox. Click the back arrow to get to the previous screen. This makes the profile run the task only if Bluetooth is not already connected to a device.

    (6) There's one more context/condition to add, which is to keep the profile from running the task if Bluetooth is already off. With the above steps, Tasker will turn the Bluetooth on even if it's off. Frequently, I turn my Bluetooth radio off to keep my phone from stealing connections to other Bluetooth devices in our house or as a battery saving measure (though not anymore since needing to have it on basically all the time for the phone key). Long one of the existing contexts under the Profile, then Tap "Add" -> "State" -> "Net" -> "BT Status" and make sure "Off" is selected. Click the back arrow to get back to the home screen.

    (7) Make sure Tasker is enabled by clicking the menu button in the top right of the main screen and that the switch for the profile is active.

    I tested it and it works. If my Bluetooth is off, nothing happens. If my Bluetooth is on and not connected to a device, Tasker will turn the Bluetooth off/on to refresh the Bluetooth radio. If I'm already connected to a Bluetooth device, nothing happens. It's completely non-obtrusive and as long as Tasker is running in the background, the profile will run, even if you're using other apps.

    I can't do any real world testing because my car is at the service center. I really think this could squash the phone key bugs related to Bluetooth connectivity on Android devices. The only thing I could imagine would be annoying is if the profile runs exactly as you are trying to get into the car. It takes about 5 seconds for the Bluetooth to toggle on and off. I don't know what the minimum interval is needed to toggle the Bluetooth to eliminate phone key problems. Maybe every 2 minutes, maybe every hour, maybe just a couple times a day?

    If anyone can test this out and let us know, this may be the work around we need to get the phone key working.
     
    • Helpful x 6
    • Informative x 1
  14. SDKoala

    SDKoala Model 3 LR RWD

    Joined:
    Apr 11, 2018
    Messages:
    827
    Location:
    San Diego
    #14 SDKoala, Apr 30, 2018
    Last edited: Apr 30, 2018
    This thread hasn't gotten a lot of traction, which is too bad because it's made my Android nearly 100% reliable as the key. Maybe it's too much tinkering and people can't be bothered or are intimidated. Or maybe the skeptics are right and it isn't that pervasive of a problem.

    Regardless, here's an update. If this helps even just one other person, it will be worth it.

    I've been running Tasker with the profile above for a week with a toggle time of 1 hour and I haven't failed to connect to the car to unlock it when approaching it for the first time in many hours (like after a day at work or overnight). Phone battery drain is a non-issue on my Pixel 1.

    A new glitch became apparent when I noticed that sometimes if I exit the car and walk out of Bluetooth range, then back right away, it won't recognize the phone as the key. Instead, it asks for the keycard when I try to open the door, even though I was just driving it seconds earlier, but happened to walk out of Bluetooth range. The Bluetooth seems to have a hard time re-connecting with the car around the fringes of it's range. This is an issue for me because the door to my house happens to be almost the exact distance from where my car is parked for the Bluetooth connection to drop. This means if forget something in my car and have to go back to get it, a lot of times it won't unlock.

    To workaround this new issue, I set up a second Tasker profile to run in parallel with the first profile above that toggles Bluetooth off/on when the following two conditions are met: (1) phone goes from the state of connected to disconnected from Tesla Bluetooth, (2) phone goes from a state of charging to not charging. I did it this way because I always plug my phone into the USB when I'm driving, but it should work with just disconnecting from the car's Bluetooth. It has the additional benefit of toggling my Bluetooth off/on immediately in the morning after unplugging my phone from charging, which I always do overnight.

    Now when I walk away from the car and my phone loses the Bluetooth connection, it automatically toggles Bluetooth off/on. This refreshes Bluetooth immediately, so if I turn around to go back to the car, it unlocks reliably having re-established a new the Bluetooth connection.

    If you were able to follow the above instructions, you should be able to implement this pretty easily. If anyone is interested, though, I'm happy to type out the step-by-step instructions to get you started.
     
    • Informative x 4
    • Like x 2
    • Helpful x 1
    • Love x 1
  15. Butane

    Butane Member

    Joined:
    Apr 6, 2018
    Messages:
    79
    Location:
    Bloomington, IN
    I tried this and got "Error, you configured your car 23 days and 37 minutes ago, but have not yet received a VIN."

    But seriously, I have a Nexus 6P (and my wife a 5X) and as a (lapsed) Tasker user am thankful you put this together. I will revisit this thread if I have any issues and report how it goes. Just gotta get the car first... :)
     
  16. sajakh

    sajakh Member

    Joined:
    Jan 24, 2018
    Messages:
    35
    Location:
    GA
    I took your advice from your tasker workaround and my experience has been similar to yours as well with my Pixel 1. However If you could do another step by step instruction, it would be very much appreciated by me and the community:)
     
  17. David L

    David L Member

    Joined:
    Jun 26, 2016
    Messages:
    315
    Location:
    San Diego, CA
    Similar to what you're doing with Tasker, I'm toggling Bluetooth on my Nexus 6 (not 6P) off and on every 30 minutes by using Llama to run the Bluetooth Reboot app. Unfortunately, the phone key is still failing about half the time. At this point, I'm thinking about further reducing the BT toggle interval to see if it would help. If other Nexus 6 owners figure out something that works, please share!
     
  18. SDKoala

    SDKoala Model 3 LR RWD

    Joined:
    Apr 11, 2018
    Messages:
    827
    Location:
    San Diego
    I remember reading that Llama is considered abandon-ware and sure enough, the Play Store says it was last updated about 3.5 years ago. That could be a big reason why it's not working. I wonder if you'd have better success if you tried doing it through Tasker.
     
  19. SDKoala

    SDKoala Model 3 LR RWD

    Joined:
    Apr 11, 2018
    Messages:
    827
    Location:
    San Diego
    For anyone setting this up before getting your Model 3, this assumes that your phone is already paired to the car because it needs to make use of the Bluetooth's MAC address.

    (1) Create a new Profile by pressing (+) from the Profile tab. Go to State -> Net -> BT Connected. Tap the magnifying glass under Name and tap on your Model 3. Repeat for the magnifying glass under Address. Check the Invert box. Return the the Profiles screen.

    (2) In the pop-up window, tap New Task, then the checkmark to get to the Task Edit screen. Tap the (+) and Net -> Bluetooth, then confirm it is set to Off. Tap the back arrow. Repeat to create another action that turns Bluetooth On. Return to the Profiles screen. (Advanced note, this is an "Entry Task" as opposed to an "Exit Task." Creating it the way I've written defaults correctly to an Entry Task.)

    (3) Long press the State of "Not BT Connected" then tap Add -> State -> Power -> Power (again). Under Source, confirm it says Any then check the Invert box. (You can also set it to AC, which is how Tasker recognizes the phone as being plugged into the car. Selecting USB doesn't work because at the other end of the connection is just power, not a computer.)

    (4) Save changes by tapping the checkmark in the Tasker title bar. This should complete creation of the profile. You may want to disable and re-enable Tasker to get it to restart.

    What you are looking for is the two conditions you created ("Not BT Conected" and "Not Power") to be highlighted as green lettering when you aren't plugged into your car's USB with the Bluetooth connected. When you enter your car and plug it in, you will be connected by Bluetooth and getting Power, so the conditions will change to black lettering. After unplugging your phone, the "Not Power" state will become active and it will turn green. When you walk out of range, the "Not BT Connected" state will also become green, which will trigger the task of turning Bluetooth off/on. It should perform the task once and shouldn't happen again until the next time those two conditions are met.

    Like I mentioned above, if you don't want to tie it into the Power status, you could probably remove that condition and rely on just the Bluetooth connection status. I have it in there as an extra step so that my Bluetooth will also reset when I unplug it from its charger in the morning.
     
    • Love x 2
  20. sajakh

    sajakh Member

    Joined:
    Jan 24, 2018
    Messages:
    35
    Location:
    GA
    Thank you!
     

Share This Page

  • About Us

    Formed in 2006, Tesla Motors Club (TMC) was the first independent online Tesla community. Today it remains the largest and most dynamic community of Tesla enthusiasts. Learn more.
  • Do you value your experience at TMC? Consider becoming a Supporting Member of Tesla Motors Club. As a thank you for your contribution, you'll get nearly no ads in the Community and Groups sections. Additional perks are available depending on the level of contribution. Please visit the Account Upgrades page for more details.


    SUPPORT TMC