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.
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.
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.
The API can be used via a number of languages as it is basically a REST interface with session-based authentication.
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.
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.
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.
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.
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:
Not particularly useful but, this query gives your site information.
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.
Having interfaced my Tesla Powerwall to my contextual smart home using the API, I can now fully populate my smarthome energy dashboard.
If you found this page useful you can buy me a coffee. This helps me maintain this website and add more content.