2024.8 Tesla Fleet Integration (still) only one way

Control features have arrived in 10.0. Just installed and so far so good. For me, being able to stop and start charging is a much desired feature. Thank you @Brett_Adams and those assisting!

2 Likes

@Brett_Adams I just reloaded the integration (Iā€™m running it with my own Fleet Developer account oAuth credential by the way - great decision to support BYO credentials) and I noticed that it now supports setting Storm watch, Allow export, Operation mode, and Allow charging from grid.

Do you have any plans to also allow setting reserve (shown as VPP backup reserve as a Diagnostic)?

If not, would you consider a PR to add this? This would make this (maybe almost - never say complete) feature complete, IMO.

Does the Fleet API allow you to do that? I thought I had implemented every command for energy products. Point me to the documentation and Iā€™ll do it.

1 Like

Iā€™ll go one better: Sample code!

Iā€™m setting it in two calls (because this is legacy code that used to run locally against the Powerwall local API, then the old customer API, and what I used to find is that unless you set the reserve percentage and then the operation mode, the reserve percentage didnā€™t stick, but you might be able get away with doing it with just one call).

In any case, since youā€™ve already exposed the operation mode Select, it would just be a matter of exposing the backup_reserve_percent number. It would then be up to the user to make sure that they set both themselves, if necessary.

The api path is /backup: https://developer.tesla.com/docs/fleet-api/endpoints/energy#backup

Ignore the translation of return code to 202, again, thatā€™s just legacy wrapping of old return codes from owner API and internal powerwall API so that the code that was calling this gets what it expects.

Apologies for VB.Net, but this is legacy code :rofl::

    Private Function DoSetPWModeCloudAPICalls(ChargeSettings As Operation) As Integer
        Dim BackupSetting As New CloudBackup With {.backup_reserve_percent = ChargeSettings.backup_reserve_percent}
        Dim OperationSetting As New CloudOperation With {.default_real_mode = ChargeSettings.real_mode}
        Dim ModeResponse As CloudAPIResponse = PostPWCloudAPISettings("energy_sites/" & PWCloudEnergyID.ToString.Trim & "/backup", BackupSetting)
        Dim PercentageResponse As CloudAPIResponse = PostPWCloudAPISettings("energy_sites/" & PWCloudEnergyID.ToString.Trim & "/operation", OperationSetting)
        If ModeResponse.response.code >= 200 And ModeResponse.response.code <= 202 And PercentageResponse.response.code >= 200 And PercentageResponse.response.code <= 202 Then
            DoSetPWModeCloudAPICalls = 202
        Else
            DoSetPWModeCloudAPICalls = 500
        End If
    End Function

    Public Class CloudBackup
        Public Property backup_reserve_percent As Decimal
    End Class

    Public Class CloudOperation
        Public Property default_real_mode As String
    End Class

    Public Class Operation
        Public Property backup_reserve_percent As Decimal
        Public Property real_mode As String
    End Class

How are your installation set up? Are you using Nebu Casa or reversed proxy? Here I have installed ver. 2024.10, but still no joy with Tesla Fleet (only one way). My set up is with two proxies, one external and one internal that Home Assistant is using with lets encrypt certificate.

Hey @BJReplay, its already implemented in the integration, but due to a mistake the entire number platform doesnt get loaded. Will be fixed by Add missing number platform to init of Tesla Fleet by Bre77 Ā· Pull Request #127406 Ā· home-assistant/core Ā· GitHub so should be in 2024.10.1

1 Like

Your network setup has nothing to do with it, the Fleet API is all outbound API calls. When you say one way, is that because your getting errors when calling commands? If so its because your vehicle requries command signing and I havent implemented that yet.

2 Likes

Hi @Brett_Adams, so it is :slight_smile:

image

I had to re-learn vi to get the patch in.

1 Like

Do you have any idea how long it will take you to implement command signing?

I honestly donā€™t know.

Iā€™ve tried in the past to write an implementation in NodeJS and failed. I have found one project on GitHub that implements it in python for Bluetooth so I am hopeful I can leverage that knowledge.

The other half is putting the public key on your vehicle. For people creating their own application registrations they can do it over the internet (like https://tesla.com/_ak/teslemetry.com) but everyone else they have to do it over Bluetooth, and so thatā€™s where I need to completely implement the Tesla Bluetooth integration.

1 Like

Okei, thanks for the answer. Got confused since mark_f made a comment that he was able to stop and start charging with ver. 24.10.

Apologies for the confusion. I was saying the ability to do so is a high priority for me. No, I cannot do it yet.

Thanks for the great work on the Tesla Fleet API.

I set it up in my home assistant and it is getting the vehicle data. Awesome!

To send commands you still need a public domain with the key right?

Now I have two questions:

  1. My home assistant is on my private network and is not opened up to the public I only remotely connect via VPN.
    Now I have a public domain where I host my website. Would this be possible to put the key on my public website (like for example: www.my-website-example.com/.well-known/appspecific/com.tesla.3p.public-key.pem) and call that from my local home assistant (like for example: http://local-ip:8123/)?
    If so ā€¦ is there a step-by-step tutorial for dummies? x)

  2. Will the Tesla Fleet Integration somehow be able to simplify that command sending in the future? I loved the old and ā€œsimpleā€ way with the OAuth key ā€¦ not those domain/key shenanigans.

1 Like