bogosj / tesla

Provides a wrapper around the API to easily query and command a Telsa car.
Other
23 stars 18 forks source link

Support for reading and writing Powerwall 'Energy Exports' and 'Grid Charging' #137

Closed mikecardwell closed 4 months ago

mikecardwell commented 5 months ago

The following two options may exist in the Tesla app, for Powerwall, if those features are enabled for your Powerwall:

image

This PR provides the capability to read and write those values:

energySite, err := client.EnergySite(product.EnergySiteId)

// Read the values
gridChargingEnabled := !energySite.Components.DisallowChargeFromGridWithSolarInstalled
energyExports := energySite.Components.CustomerPreferredExportRule

// Write them
err = energySite.SetGridCharging(false)
err = energySite.SetExportRule(tesla.PvOnly)
err = energySite.SetExportRule(tesla.BatteryOk)

Happy to make any changes you want, if this PR isn't consistent with the rest of your library. Just let me know what needs changing, or feel free to change yourself.

mikecardwell commented 4 months ago

I'm going to close this PR as I foolishly made it from my main branch, and it's getting in the way of some stuff I'm trying to do. I will re-open it from a different branch