Site icon Shutdown Hook

Dog Mode

Elon Musk is a weird dude. I say this never having met the guy, but I don’t think I’m going out on a limb there. He is also a once-in-a-generation innovation powerhouse, of a very specific type. He is repeatedly able to:

  1. Recognize an important problem;
  2. Educate himself enough to become a legitimate expert;
  3. Identify the key barriers to progress; and
  4. Push past them, seemingly through sheer force of will.

I think #2 and #4 together are the keys. He sincerely respects existing knowledge, but isn’t cowed by conventional wisdom. Somehow it seems (and I fall into this trap too) that most folks miss one or the other (ask me about all the wonderful people who keep pitching me HealthVault clone startups).

Anyway. I’ve been thinking about this because a couple of weeks ago I did a quick round trip drive between Seattle and Los Angeles in our Tesla X. Even having done this a few times, the car was once again notably awesome. I am not a “car guy,” but the thing is a freaking delight. Just being electric certainly isn’t driving that experience, so what is? The magic is that it’s an electric, connected, software car.

It comes down to that #2/#4 combo. The big automakers know cars, but they frame the problem as simply swapping out one energy source for another, and they can’t get over the issue of gas station ubiquity — so you end up with Frankenstein hybrids or just lame imitations of gas cars. On the other hand, most of the electric-first folks haven’t understood the realities of the market and build consumer-unfriendly products on top of a guilt-based selling proposition.

Tesla has threaded this needle — delivering a no-compromise vehicle that is awesome because of, not in spite of, it’s 21st century foundation. A few examples:

Dog Mode

As it turns out, this feature was the tipping point for buying our Tesla. We spend a lot of time waiting for the Whidbey ferry. Obviously when you’re in the ferry lot with 200 other cars you can’t idle to keep the interior comfortable — but with the electrics we keep it a sweet 72 degrees all year (and watch TV on the big screen to boot). More importantly, our old guy Charlie is always with us — he grew up in the mom taxi and expects to be along on most trips. Flip on “dog mode” when we leave the car and it keeps the temperature steady and indicates to outside folks that the animals are safe. We can check the temp from our phones at any time and adjust as needed. So obvious and simple once all the pieces are in place — but Tesla figured it out.

Routing and Navigation

Most of the time, we just plug into 120 volts in the garage and rarely drop below a 200 mile charge. But on a road trip like Seattle/LA, charging stops are obviously a big part of the journey. The on-board Tesla route planner adjusts for this, identifying supercharger stops along the way, ensuring a buffer to make it to each safely and optimized charging time spent at each. And because it’s software, this capability continually improves — for example, charging becomes less efficient as you near 100% so the software often tells you to leave “early” for the next leg, rather than wasting time. It knows not just how many stalls are installed at each station, but how many are open as you approach, in real time. If driving conditions drain the battery faster than expected, it automatically re-routes to another charger.

And just the fact that “another charger” always exists is industry-changing. Lack of charging infrastructure has been the “why not” for years, and of course it’s not the traditional responsibility of automakers to provide the gas. While they hemmed and hawed, Musk just built his own network — last count I saw was 25,000 chargers at 2,700 stations worldwide. It is frankly stunning how ubiquitous they are. This dominance was on amusing display in Car & Driver’s recent long-distance EV race. The Teslas killed it.

Autodrive

Two hours over fifteen miles in Portland, OR I-5 rush hour traffic is a heck of a lot nicer when you’re able to sit back and let the car do the driving. Honestly, the Tesla pretty much drove itself the whole way to Los Angeles, and back. Sure I had a hand hung over the wheel and once in while the car asked me to help out, but largely I was free to watch the scenery and safely snack or change up the audiobook while cruising a sweet speed-limit-plus-5 the whole time. Bottom line — in most situations, the car drives itself better than I do, and it never nods off in the middle of a lecture about English Medieval history. It does get confused on twisty roads lined with jersey barriers, but even that was better this trip than it was on the last one.

Acceleration

I threw this one in there for my wife, who never tires of freaking out new passengers by flooring the Tesla. The car has shocking pick-up. And sure, electric motors just generate a lot of torque, so there are other EVs that show up here (love the Biden F150 video). But Telsa did it first — no compromises.

Software is magic, DIY edition

All of this innovation is possible because of an always-connected, software-powered electric platform. Being able to talk to the car in real time and make updates continually just changes the game. And while unfortunately Tesla hasn’t opened up that platform officially for development yet, enterprising folks like Tim Dorr have reverse-engineered the API used by the mobile app to do some amazing things. It was impossible not to jump in and check that out. I threw together “tview” as a simple command-line app that lets you interrogate your Tesla and send it some simple commands — the code is on the shutdownhook github. Tim’s API covers a lot more than just what I’ve played with here … definitely worth checking out and sending some love his way.

Tesla.java wraps up the API into a relatively usable package. Instantiate the class with a config file that most importantly contains the owner’s login email and password, then call methods to retrieve JSON objects describing the car’s state, or send commands like “honk the horn”. Remember to close() the object when you’re done to clean up resources.

The authentication here is just a classic OAuth2 deal — as an unofficial API you have to pretend to be a browser client, but it’s not too bad. Current client id and secret values can be found at https://pastebin.com/pS7Z6yyP. Hopefully they will make this official soon! Anyways, the end result is a bearer token that you can use to make requests such as getVehicles, which returns metadata and identifiers for all cars associated with the provided credentials:

Because it’s an unofficial API, you have to be a little careful about the data that comes back in these calls. Apparently since late 2019 the “option_codes” above are just wrong, so heads up. Also, typically for a class like this, I’d define objects to parse out the JSON, but this is just an experiment so I’ve left it raw. I am a huge fan of using jq to make JSON usable from the command line. For example; ./run.sh vehicles | jq -r '.response[]|.display_name + " " + .id_s' will return the vehicle ID for each car in a much more readable way.

Late-breaking annoyance … just as I was going to post this, Tesla re-introduced CAPTCHA to their login which they apparently do every once in awhile. I added a simple callback for the user to provide a CAPTCHA solve if needed; since the token lasts for 45 days (and is cached by default in /tmp/.tesla) this isn’t that bad. But really, what the hell Elon?

Another gotcha is that for the car to respond it has to be “awake” — an idle car will enter an offline state to save power. Tesla.java manages this under the covers in the ensureAwake() method. Once that’s taken care of and you’re armed with a vehicle ID, you can interact with the car in a ton of cool ways. A few examples:

It’s pretty easy to imagine some pretty sweet innovation that could be built around all of this — even just the map option wired up to SMS would make a nice modern-day Lojack. Maybe an app that compares battery efficiency across locations or times of year; or a nanny app that makes sure the windows are closed and the car is within a geofence overnight. Third-party competition around route planning apps optimized using real-time car stats would be fantastic. Software is magic.

End of the day, I’m glad that we have folks like Elon Musk tackling the big problems of our age. Tesla has changed the transportation game and shown a ton of people what is possible … the next few years should be insanely fun to watch.

Code for this article is at https://github.com/seanno/shutdownhook/tree/main/tview

Exit mobile version