teslamotors / vehicle-command

Apache License 2.0
415 stars 94 forks source link

Feature request: IsChargerConnected and IsSOCbelowChargingLimit via BLE #229

Open osimmert opened 5 months ago

osimmert commented 5 months ago

To implement solar charger logic using BLE, it would be helpful to know if a charging cable is plugged in and if the battery currently needs charge. (Reading the SOC via BLE also would be nice to implement a display)

sftman18 commented 4 months ago

I believe this is covered in #52

osimmert commented 3 months ago

It would be important that the two infos could be obtained without waking up the car. If a solar charger want's to charge, it needs to wake up the car and try start charging. The charging-start command may fail due to several issues:

sethterashima commented 2 months ago

Partially addressed by: https://github.com/teslamotors/vehicle-command/pull/263

I believe infotainment stays awake while charging, but I'll need to confirm that internally. This would mean that if the above method indicates the car is asleep or the charge port is closed, then the car is not plugged in. The reverse is heuristic; it's possible for the car to be awake with an open charge port but not plugged in.

osimmert commented 2 months ago

Most important thing is: If the solar system gets the info that the charge port is currently closed, it has to poll the car to find out if it became plugged in. This polling (either for the charge port or for plugged in) must be possible without waking the car. Otherwise the car would be waked by every poll.

sethterashima commented 2 months ago

This change allows you to determine if the charge port is open without waking up the car.

Most important thing is: If the solar system gets the info that the charge port is currently closed, it has to poll the car to find out if it became plugged in.

I'm not sure what you're saying here. If the charge port is closed, the car is not plugged in.

tzoratto commented 2 months ago

Partially addressed by: #263

I believe infotainment stays awake while charging, but I'll need to confirm that internally. This would mean that if the above method indicates the car is asleep or the charge port is closed, then the car is not plugged in. The reverse is heuristic; it's possible for the car to be awake with an open charge port but not plugged in.

hi @sethterashima, thanks for your answers.

Have you confirmed that infotainment is awake when charging ?

If this is the case, then we can implement solar charging more easily, but there are still some corner cases that would need dirty workarounds without access to the current SOC and charging limit:

To sum it up, the risk here is either to:

Using the Fleet API only to fetch data, and then use the BLE one to send commands (so that we don't hit the super low Fleet API rate limits) is technically possible, but fetching data from the Fleet API also comes with low rate limits, using the Fleet API also is a pain in the neck for individuals, and it will eventually be charged. Don't get me wrong, I understand why the Fleet API needs to be charged in the end, handling millions of calls is not cheap in terms of infrastructure, but that's why having a local BLE option in addition to the Fleet API is all for the best.

Are there any plans to make the SOC + charging limit available from BLE ?

Bonus question: instead of implementing this by communicating with the car, could we use an official local API for the Tesla Wall Connector Gen 3 ? It would probably make the all thing way simpler, without having to take care about not waking up the car when not needed. We could leave the car do whatever it wants, and only set the Wall Connector amps continuously. I was under the impression that the legacy local API for the Wall Connector was also being deprecated and replaced by the Fleet API. It this the case ? And is there any local official alternative just like we have with BLE for the car ?

Thanks

osimmert commented 2 months ago

Just to clarify: It is already possible to continuously change the charging amps while charging.

For the Wall Connector: There are countries where 3 phases are not common (e.g Spain). In that countries the Wall Connector has no advantage over the charging brick. For that reason a 'wall-box-only' solution is not sufficient for many customers. (But may be nice for the 3 phase guys. 8-)

tzoratto commented 2 months ago

Just to clarify: It is already possible to continuously change the charging amps while charging.

Interesting, could you expand on that please ? From my understanding, all we can do for now is either send "charging amps settings" blindly, that will wake the car up if it doesn't need charging, or we can use #263 to see if the car is (only) likely to be currently charging and send commands only if this is the case, but there are many corner cases, such as the one that I mentioned above (and many more). Am I missing something ?

For the Wall Connector, yes it would only be a solution for customers that have one of them, but still, if we could talk to it locally (officially), it would still be nice.

osimmert commented 2 months ago

With #263, IsChargerConnected is well covered (charge port will not be open otherwise) For IsSOCbelowChargingLimit or the current SOC there is still a solution required. But for this information it is OK to wake the car. If the charger has seen that the battery is full there is no need to ask again (at least that day).

tzoratto commented 1 month ago

For IsSOCbelowChargingLimit or the current SOC there is still a solution required

Ok, then we are aligned, we still need IsSOCbelowChargingLimit (or current SOC + charging limit) to implement solar charging properly using BLE. #263 helps, but is not enough to cover edge cases