Skip to content

oznetmaster/TeslaPowerwallCrestronDriver

Repository files navigation

TeslaPowerwallCrestronDriver

A Crestron Home Entity V2 driver that integrates a Tesla Powerwall energy site via the Tesla Owner API or the official Tesla Fleet API, providing live power flow, battery status, energy history, and site control from the Crestron Home app.

Tesla and Powerwall are trademarks of Tesla, Inc. This project is an independent, unofficial driver and is not affiliated with, endorsed by, or sponsored by Tesla, Inc. Crestron and Crestron Home are trademarks or registered trademarks of Crestron Electronics, Inc. This project is not affiliated with, endorsed by, or sponsored by Crestron Electronics, Inc.

License: MIT + Commons Clause


Driver Architecture

This driver is a Crestron Home energy-automation Entity V2 driver implemented on the Crestron Home SDK Entity V2 Model. It derives directly from ReflectedAttributeDriverEntity and exposes all configuration items, properties, commands, and extension UI bindings through SDK attributes and the entity model.

The driver connects to a single Tesla Powerwall energy site through the TeslaPowerwallLibrary NuGet package, using either its Tesla Owner API (cloud) support or its official Tesla Fleet API support. Only an OAuth refresh token is required for either mode — the library automatically derives and renews the access token from it on every connection.


Supported Connection Modes

This driver connects to Tesla using one of two modes, via TeslaPowerwallLibrary. Which mode is used is selected entirely by configuration: leave Tesla Fleet API Client ID blank to use the Tesla Owner API, or set it to use the Tesla Fleet API (see Configuration below).

Tesla Owner API (Cloud)

Uses Tesla's unofficial, undocumented Owner API. Requires a one-time login via the companion TeslaPowerwallLibrary.Setup tool (see Obtaining a Tesla Refresh Token below), using your own Tesla account credentials via Tesla's own login page — this driver never sees or stores your password.

⚠️ Stability notice: The Owner API is unofficial and undocumented. As of July 2026, Tesla has begun deprecating Owner API access for vehicle endpoints (confirmed via multiple independent reports and Tesla's own error responses pointing to the official Fleet API). Energy/Powerwall endpoints appear unaffected at this time, but there is no guarantee this will remain the case. If Owner API access breaks for your site, please open an issue on this repository.

Tesla Fleet API (Official)

Uses Tesla's officially supported, documented Fleet API. Requires a Tesla Fleet API application (with its own Client ID) and a Fleet API refresh token for your Tesla account. Configuring a Tesla Fleet API Client ID switches the driver into this mode, and the Tesla Refresh Token field must then contain a Fleet API refresh token rather than an Owner API one.

The Fleet API covers everything this driver uses — live status, energy/impact history, backup reserve, operating mode, and grid export control — with one exception: Storm Watch is not available through the Fleet API. When a Client ID is configured, the Storm Watch toggle is hidden from the Settings page and the setStormWatchEnabled command is a no-op.

Not Yet Supported

  • Local Mode (Powerwall 2 / Powerwall+ only)TeslaPowerwallLibrary can connect directly to a Gateway 2's local REST API over your home LAN, but this driver does not yet expose it as a configuration option. Not supported on Powerwall 3 in any case, since PW3 replaces this local API with TEDAPI.
  • TEDAPI (Powerwall 3 local access) — Scaffolded in TeslaPowerwallLibrary but not yet complete; requires physical/network access to the Powerwall 3's isolated local interface.

See the TeslaPowerwallLibrary repository for the underlying library's full roadmap and known issues.


Features

  • Live house, solar, grid, and Powerwall power flow on the Main page
  • Battery level, backup reserve, operation mode, and grid export status
  • Energy page with Day/Week/Month/Year/Lifetime period selection, back/forward period navigation, and a per-sub-period breakdown (hourly/daily/weekly/monthly rows depending on the selected period)
  • Impact page showing self-powered percentage, home usage, and grid usage for the selected period
  • Settings page to adjust backup reserve, grid charging, Storm Watch, operation mode, and grid export mode directly from Crestron Home
  • Automatic background polling with a configurable refresh interval
  • Manual "Refresh Now" command
  • Programmable commands and events for the Crestron Home programming environment (grid status changed to backup, grid status restored, Storm Watch activated/deactivated, battery reserve low, battery fully charged)

Usage

The pages below roughly follow the layout of the Tesla mobile app, but everything shown is generated by this driver directly from the Tesla cloud data described here — no app access is required to use it.

Home tile and Main page

The device tile shows current home power consumption (with a BKUP suffix whenever the grid is down and the Powerwall is supplying the house) plus a compact summary of which sources are currently contributing. The Main page breaks that out into four rows — House, Solar, Grid, and Powerwall — each showing that source's live power, plus a status block showing a plain-language summary, the current operation mode, and the current grid export mode. From the Main page you can navigate to the Energy page, the Impact page, or the Settings page.

Energy page

Shows energy (kWh), not instantaneous power. Two selector rows control what's displayed:

  • Period — Day, Week, Month, Year, or Lifetime. Back/forward arrows step through prior instances of the selected period (for example, Day steps one calendar day at a time); the forward arrow disables once you're back at the current period. Lifetime has no history to step through, so the arrows are hidden for it.
  • Type — Solar, Powerwall, Grid, or House. Changes which totals are displayed for the selected period:
    • Solar: energy produced, home usage, and grid export (export line is hidden when grid export is set to Never)
    • Powerwall: energy discharged, energy charged, and the net of the two
    • Grid: energy imported, energy exported, and the net of the two
    • House: energy used, a Solar/Grid breakdown of where it came from, and how much the Powerwall contributed

Beneath the totals, a per-sub-period breakdown lists the same figures split into rows — Day shows up to 24 hourly rows, Week shows 7 daily rows, Month shows its weekly rows, and Year shows 12 monthly rows. Lifetime has no breakdown and hides this section entirely.

Impact page

Shows how self-sufficient the site was for the selected period: a gauge with the self-powered percentage, plus how much of that usage came from solar/Powerwall versus the grid. It uses the same Period selector and back/forward navigation as the Energy page.

Settings page

Lets you adjust the site directly from Crestron Home:

  • Backup Reserve — the minimum battery charge percentage reserved for outages
  • Charge From Grid — allow the battery to charge from the grid, not just from solar
  • Storm Watch — Tesla's predictive pre-charge ahead of severe weather forecasts (only shown when connected via the Tesla Owner API; not available on the Tesla Fleet API)
  • Operation Mode — Self Powered, Backup Only, or Autonomous
  • Grid Export — Battery OK, Solar Only, or Never
  • Refresh Now — forces an immediate refresh instead of waiting for the next scheduled poll

Programming

For Crestron Home programmers, every Settings control above is also exposed as a programmable command, and the driver raises programmable events for grid status changed to backup/restored, Storm Watch activated/deactivated, battery reserve low, and battery fully charged — see PowerwallDriver.Commands.cs for the full list.


Prerequisites

Requirement Details
Crestron Home processor Running a firmware version compatible with Entity V2 drivers
Tesla account Must have one or more Powerwalls linked to the account
Tesla OAuth refresh token Obtained using the TeslaPowerwallLibrary login tool — see Obtaining a Tesla Refresh Token below

Installation

The best way to download and install this driver on a Crestron Home system is to use the Crestron Home Driver Feed Installer repository and application.

If you prefer to install manually, use the attached .pkg asset from the relevant GitHub Release. The automatic GitHub Source code (zip) and Source code (tar.gz) assets are repository snapshots, not installable Crestron driver packages.

NuGet package availability: this driver is also published as the CrestronHomeDriver.Tesla.Powerwall NuGet package. This NuGet package conforms to the Crestron Home Driver NuGet Publishing Standard v1. It is a distribution wrapper for the final .pkg artifact, includes the required crestron-driver-package.json manifest, and is not intended as a direct DLL reference package.

Crestron Home Driver NuGet Publishing Standard v1 is not an official Crestron product or specification. It is an open source packaging standard created to facilitate community distribution and discovery of Crestron Home drivers through NuGet.

  1. Download the generated .pkg asset from the GitHub Release, or build it yourself using the instructions in Building from Source.
  2. Upload the .pkg file to your Crestron Home processor manually (for example via SFTP to /user/ThirdPartyDrivers/Import).
  3. In the Crestron Home configuration UI, add a new device and select the Tesla Powerwall driver.
  4. Configure the driver using the values below.

Configuration

Field Description
Tesla Fleet API Client ID Optional. Leave blank to use the Tesla Owner API. Set to a Tesla Fleet API application Client ID to use the Tesla Fleet API instead — when set, the refresh token below must be a Fleet API refresh token, and Storm Watch is unavailable.
Tesla Refresh Token Required. OAuth refresh token for the Tesla account — an Owner API refresh token if Client ID above is blank, or a Fleet API refresh token if it is set. See Obtaining a Tesla Refresh Token below.
Tesla Energy Site ID Optional. Numeric Tesla energy site ID, or the site's name exactly as shown in the Tesla app/account. Leave blank to use the account's first/default energy site.
Refresh Interval Seconds How often the driver refreshes Powerwall status and power data from Tesla. 30-3600 seconds; default 60.

⚠️ Changing the Client ID invalidates the cached refresh token. Owner API and Fleet API refresh tokens are not interchangeable, and Fleet API refresh tokens are themselves scoped to the application (Client ID) that requested them. Adding, removing, or changing the Client ID therefore requires entering a new, matching refresh token in the same configuration update — the driver will reject the update with a validation error on the Tesla Refresh Token field if one isn't supplied.

Obtaining a Tesla Refresh Token

This driver needs an OAuth refresh token for your Tesla account before it can connect, regardless of mode. Tesla's login flow requires an interactive browser sign-in, which isn't something a Crestron Home driver can perform on its own, so token retrieval is handled by a companion tool from the TeslaPowerwallLibrary repository:

  1. Go to the TeslaPowerwallLibrary releases page and download the latest TeslaPowerwallLibrary.Setup release asset.
  2. Run the tool and sign in with your Tesla account credentials in the interactive login window. For Fleet API mode, use the tool's Fleet API login option and supply your Fleet API application's Client ID.
  3. Copy the resulting refresh token shown by the tool.
  4. Paste it into the Tesla Refresh Token field when configuring this driver in Crestron Home (and, for Fleet API mode, paste the Client ID into the Tesla Fleet API Client ID field).

Full step-by-step instructions, including screenshots, are in the Tesla cloud login guide.

Tesla may periodically rotate the refresh token; this driver automatically persists an updated token if Tesla rotates it during normal use, so re-running the login tool should only be necessary if the stored token is lost or revoked.


Building from Source

Dependencies

Build

dotnet build TeslaPowerwallCrestronDriver.slnx -c Release

The build pipeline:

  1. Compiles the driver targeting net472
  2. Bumps DriverVersion and VersionDate in TeslaPowerwallCrestronDriver.json
  3. ILRepacks runtime dependencies into the driver assembly
  4. Runs PatchMergedAssembly.ps1 against the merged assembly
  5. Packages the driver into a .pkg using Crestron's ManifestUtil

GitHub Release Asset

This repository includes a GitHub Actions workflow that builds the Release package and attaches the generated .pkg to a GitHub Release.

The same release workflow also publishes the TeslaPowerwallCrestronDriver NuGet package, which wraps the final generated .pkg artifact.

Typical release flow:

  1. Push the release commit and tag
  2. Publish the GitHub Release for that tag
  3. Let the workflow build and attach the .pkg asset automatically

Repository Notes

  • XML documentation generation is enabled in the project build
  • The release workflow builds the package on windows-latest
  • The repository includes the driver package/build scripts needed for packaging and deployment

License

MIT + Commons Clause © 2026 Neil Colvin — see LICENSE.

Free to use and modify. You may not sell the Software as a standalone product or sublicense it. Commercial system integration work (for example, a Crestron installer commissioning a customer system) is explicitly permitted, even where a fee is charged for that service.

Tesla and Powerwall are trademarks of Tesla, Inc.

Note: This project references Crestron.DeviceDrivers.DevKit, which is subject to Crestron's SDK license agreement. That license governs the SDK libraries only; the source code in this repository is licensed independently under the terms above.

About

Crestron Home Entity V2 Driver for Tesla Powerwall

Resources

License

Stars

0 stars

Watchers

0 watching

Forks

Packages

 
 
 

Contributors