TeslaPowerwallLibrary 1.0.3
See the version list below for details.
dotnet add package TeslaPowerwallLibrary --version 1.0.3
NuGet\Install-Package TeslaPowerwallLibrary -Version 1.0.3
<PackageReference Include="TeslaPowerwallLibrary" Version="1.0.3" />
<PackageVersion Include="TeslaPowerwallLibrary" Version="1.0.3" />
<PackageReference Include="TeslaPowerwallLibrary" />
paket add TeslaPowerwallLibrary --version 1.0.3
#r "nuget: TeslaPowerwallLibrary, 1.0.3"
#:package TeslaPowerwallLibrary@1.0.3
#addin nuget:?package=TeslaPowerwallLibrary&version=1.0.3
#tool nuget:?package=TeslaPowerwallLibrary&version=1.0.3
TeslaPowerwallLibrary
A .NET client library for the Tesla™ Powerwall™ Energy Gateway, providing direct local-network access and Tesla Owners (cloud) API access to status, power flow, energy history, and control operations.
Tesla and Powerwall are trademarks of Tesla, Inc. This project is an independent, unofficial .NET library and is not affiliated with or endorsed by Tesla.
Supported Platforms
| Target Framework | Supported |
|---|---|
| .NET 10 | ✅ |
| .NET Framework 4.7.2 | ✅ |
Overview
TeslaPowerwallLibrary provides a strongly typed, async-first .NET wrapper around the Tesla Energy Gateway's local API and the Tesla Owners cloud API. It supports:
- Local network access to the Powerwall gateway (status, power flow, grid status, system status, and energy/calendar history)
- Tesla Owners (cloud) API access, including interactive OAuth login and automatic token persistence
- Control operations such as backup reserve level, operating mode, grid charging, grid export, and Storm Watch (cloud only)
- Response caching with configurable expiry to reduce load on the gateway
- Multi-target support for .NET Framework 4.7.2 and .NET 10
This .NET library is adapted from the Python pypowerwall project by Jason A. Cox. See the license for attribution details.
Connection modes
| Mode | Status | Notes |
|---|---|---|
| Local | ✅ Implemented | Direct HTTPS/JSON access to the gateway using the customer password. Targets the Gateway 2 / Powerwall+ local REST API (see hardware note below). |
| Cloud | ✅ Implemented | Tesla Owners API access using interactive OAuth login and cached tokens. Works regardless of gateway generation. |
| FleetAPI | 🚧 Not yet implemented | Scaffolded for a future milestone; currently throws a not-implemented exception. |
| TEDAPI | 🚧 Not yet implemented | Scaffolded protobuf-based local link-local access for a future milestone; currently throws a not-implemented exception. |
Gateway hardware compatibility: Local mode's plain HTTPS/JSON REST API (
/api/login/Basicplus endpoints such as/api/system_status/soeand/api/meters/aggregates) is the original Gateway 2 / Powerwall+ local interface and is well established on that hardware. On Powerwall 3, Tesla replaced this local REST API with TEDAPI (protobuf-encoded, RSA-signed); the plain REST endpoints return403 Unable to GET to resourceon a Powerwall 3 gateway. Powerwall 3 owners need TEDAPI support (not yet implemented — see the table above) for local access; Cloud mode works today regardless of gateway generation.
Installation
The library is available as the TeslaPowerwallLibrary NuGet package.
dotnet add package TeslaPowerwallLibrary
Quick Start
Connect to a local gateway
using TeslaPowerwallLibrary;
var options = new PowerwallOptions
{
Host = "10.0.1.99",
Password = "your-customer-password"
};
using var powerwall = new Powerwall(options);
await powerwall.ConnectAsync();
var status = await powerwall.StatusAsync();
Connect using the Tesla Owners cloud API
using TeslaPowerwallLibrary;
var options = new PowerwallOptions
{
Email = "you@example.com",
CloudMode = true,
AccessToken = "your-access-token",
RefreshToken = "your-refresh-token"
};
using var powerwall = new Powerwall(options);
await powerwall.ConnectAsync();
After the first successful cloud connect, the library persists the (possibly rotated) tokens internally, keyed by Email, so later runs can omit AccessToken and RefreshToken entirely. AccessToken is optional even on a first connect: when omitted (or stale), the library silently derives a new one from RefreshToken. When a non-empty AuthPath is supplied, that location is authoritative — no fallback is attempted, and an inaccessible path throws PowerwallCloudTokenCacheStorageException instead of silently continuing without persistence.
Cloud mode without library-owned token storage
Set NoCloudTokenPersistence when the host has no suitable place for the library to keep a file (for example a Mono-hosted embedded environment). No cache file is ever read or written; AuthPath is ignored, and Email is not validated since it is otherwise used only as the cache key. Only RefreshToken needs to be supplied on every run — AccessToken remains optional and is silently (re)derived from it when absent or stale. Because AccessToken was not supplied here, CloudTokensRefreshed only fires when Tesla rotates the refresh token itself, and e.AccessToken is null in that case:
using TeslaPowerwallLibrary;
var options = new PowerwallOptions
{
CloudMode = true,
RefreshToken = "your-refresh-token",
NoCloudTokenPersistence = true
};
using var powerwall = new Powerwall(options);
powerwall.CloudTokensRefreshed += (sender, e) =>
{
// Only raised here because RefreshToken alone was supplied above: fires when Tesla rotates the
// refresh token itself (not on every access-token renewal), and e.AccessToken is null.
// Persist e.RefreshToken using your own storage so the next run can reuse it.
};
await powerwall.ConnectAsync();
Repository Contents
TeslaPowerwallLibrary— the main library project published to NuGetTeslaPowerwallLibrary.Login— shared Tesla cloud OAuth login library (interactive WebView2-based browser login), used by both the app and the test console; not published to NuGet, distributed as a DLL attached to each GitHub release — see the Tesla cloud login guideTeslaPowerwallLibrary.App— a WPF dashboard application with live energy charts, system status, and site/account managementTeslaPowerwallLibrary.TestConsole— a command-line and interactive test harness covering the library's read and control operationsTeslaPowerwallLibrary.Setup— a small WPF wrapper aroundTeslaPowerwallLibrary.Loginthat performs a standalone Tesla cloud login and displays the resulting tokensTeslaPowerwallLibrary.Tests— MSTest-based deterministic unit test coverage
Documentation
Public documentation for this repository is available on GitHub Pages:
Acknowledgements
This library is adapted from the Python pypowerwall project by Jason A. Cox.
License
MIT © 2026 Neil Colvin, © 2022 Jason Cox — see LICENSE.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
| .NET Framework | net472 is compatible. net48 was computed. net481 was computed. |
-
.NETFramework 4.7.2
- Google.Protobuf (>= 3.35.1)
- Hafner.Compatibility.MetaPackage (>= 1.9.0)
- log4net (>= 3.3.2)
- Microsoft.Bcl.AsyncInterfaces (>= 10.0.9)
- Microsoft.Bcl.HashCode (>= 6.0.0)
- Microsoft.Bcl.Memory (>= 10.0.9)
- Newtonsoft.Json (>= 13.0.4)
- System.Net.Http (>= 4.3.4)
- System.Runtime.CompilerServices.Unsafe (>= 6.1.2)
- System.Security.Cryptography.ProtectedData (>= 10.0.9)
- System.Threading.Tasks.Extensions (>= 4.6.3)
- YamlDotNet (>= 18.1.0)
-
net10.0
- Google.Protobuf (>= 3.35.1)
- log4net (>= 3.3.2)
- Newtonsoft.Json (>= 13.0.4)
- System.Security.Cryptography.ProtectedData (>= 10.0.9)
- YamlDotNet (>= 18.1.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Adds Storm Watch control (cloud only): Powerwall.GetStormWatchAsync/SetStormWatchAsync let callers read and toggle Storm Watch (predictive pre-charging ahead of severe weather) the same way the Tesla app does, via the Tesla Owners cloud API.