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' #139

Open mikecardwell opened 4 months ago

mikecardwell commented 4 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.