TWCManager icon indicating copy to clipboard operation
TWCManager copied to clipboard

Vehicle Module Priority - Preference local BLE over API

Open ngardiner opened this issue 1 year ago • 1 comments

The idea of this branch is to introduce module priorities, which would allow us to overlap the TeslaBLE module over the top of the TeslaAPI module, so that commands like start/stop charging, wake, set charge limit etc would first be sent out via BT, and we'd look for indications in the response that confirm that the command was sent.

If this fails, it would fall back to the next priority module, the API. It's possible we could slot another module in-between these for the Tesla Fleet API - eventually the owner-api will go away and it will just be a no-op, this is my view of how we can untangle / stack technologies as Tesla deprecates the API we've depended on for a while now.

  • [x] Implement prototype static module priorities to create initial priority order
  • [x] Implement prototype fallback code for calling start/stop charging via this logic
  • [x] Track the performance of modules to allow us to visualise how this is operating
  • [x] Implement a better way of showing the statistics
  • [ ] Consider if instead of just falling back to the next priority down, we might be able to do something like assign a multiple for retry logic - eg every 10 priority = 1 retry in the event of failure.
  • [x] Find a more appropriate way to implement this - perhaps a proxy Class which automatically routes methods in priority order
  • [x] Replace functions outside of start/stop charge

Regressions:

  • [ ] Changes to car_api_available to replace charge argument with task needs to be updated in other locations

Tests:

  • [ ] Backwards compatibility (what happens if BLE is not loaded?)

ngardiner avatar Dec 12 '24 03:12 ngardiner

Not necessarily in this PR, but I created something that might be helpful in installing the BLE binaries. Since Tesla doesn't publish the armv6 binaries that would be needed on a Pi 0W and building from code is a pain, I put together https://github.com/MikeBishop/tesla-vehicle-command-arm-binaries/ which does a daily check to see whether Tesla has released a new version and if so, builds and posts ARM binaries for it. The latest can always be fetched from https://github.com/MikeBishop/tesla-vehicle-command-arm-binaries/releases/latest/download/vehicle-command-binaries-linux-armv6.tar.gz.

MikeBishop avatar Apr 25 '25 20:04 MikeBishop