Tesla Backup Gateway Smart Home Integration Project

Part of my smart home solar installation project includes a Tesla Powerwall. This project summarises my work to integrate the gateway into our contextual smart home, so that it can perform intelligent energy management for us using whole home context and the Gateway's API.

Objectives

The objective with this project is to be able to query and control my Tesla Powerwall so that I can fully automate my smart energy management, by giving my contextual smart home all the information it needs to make the best decisions, resulting in improved whole home context and a zero touch user experience. The data set required to achieve this is covered under my smart home solar energy modelling project.

Installation

It's worth having a quick look at how the Backup Gateway is installed in a home that must still work in the event of a power outage. Credit for this image from StackExchange. Our installation is slightly different, as we are using panels with micro-inverters.

The Backup Gateway will disconnect our home from the network in the event of a network power outage. It will then run our whole home from the available solar power and the Powerwall battery storage. It is monitoring all of the energy flows and exposing them via its API. It also communicates directly with the Powerwall.

The Tesla Backup Gateway requires an IP network connection. It can use Wi-Fi but, I ran Cat5e cables into my garage years ago.

To use the API, you need to create a password. You can do that from the initial screen using the 'forgot password' option. It tells you how to do this with the last five characters from the password on the inside of the Backup Gateway cover. I used this interface to set a fixed IP address for the Backup Gateway.

Application Programming Interface (API)

The API can be used via a number of languages as it is basically a REST interface with session-based authentication.

Query End Points

Note: The Tesla API has to be polled and this means we are not getting real-time updates from it. Currently, I am making calls every 90 seconds. I am still relying on my smart home connected AC current transformers for real-time data but, this API is still providing more useful context.

The API supports a number of 'end points' to query and control the various features of the Tesla Powerwall. I've covered them here in order of importance to me.

/api/system_status

This query returns a lot of system status information. Interestingly, it shows my Powerwall can briefly discharge up to 8860W. It also shows how much energy has been used to charge the Powerwall and the energy delivered. Over time, this will give a good view of the round-trip efficiency.

/api/system_status/soe

This query returns the Powerwall battery SoC as a percentage. Interestingly, the app rounds this value down to the nearest integer value when displaying it. My contextual smart home also models charge/discharge rates, which the API also provides.

/api/system_status/grid_status

This query tells you the status of the grid connection. It can be used to let my Home Control System know when a power cut has occurred.

/api/meters/aggregates

This query shows how much is being exported, the house load, the solar generation and all the CT clamp readings. The key objects I model from this call are:

/api/site_info

Not particularly useful but, this query gives your site information.

Control End Points

The Tesla Powerwall does an amazing job of managing my energy out of the box and when configured to use a tariff like the Octopus Flux tariff, it will intelligently manage charging and discharging to maximise your Return On Investment (ROI). But my contextual smart home has all of the information and context to do an even better job and so I will be testing and documenting the control features very soon.

Summary

Having interfaced my Tesla Powerwall to my contextual smart home using the API, I can now fully populate my smarthome energy dashboard.

Buy Me A Coffee

If you found this page useful you can buy me a coffee. This helps me maintain this website and add more content.

Further Reading

My Projects

My Reviews