Tesla Powerwall 3 Integration using pypowerwall-server & MQTT Binding

This is a new thread to cover the setup of the Tesla Powerwall 3 integration using pypowerwall-server and MQTT.

The pypowerwall-server has recently become available, and is probably an easier way to integrate a Powerwall 3 with OpenHAB, vs. using pypowerwall-proxy and the HTTP binding. See my previous thread for details on the latter: Tesla Powerwall 3 Integration using PyPowerwall Proxy & HTTP Binding

Remember, whilst the above also supports older versions such as the Powerwall 2, you still have the native OH Powerwall Binding which can support that, so you probably don’t need to worry about reading this tutorial.

My requirements don’t include controlling the PW3 - Happy to let it do its own thing there, but arguably you could use the same approach for the controllable values, only thing then, is that requires the cloud API connection to be configured for the pypowerwall-server.

For others who are looking to do the same, this is a rough how-to guide I have collated from various sources, to get PW3 values back into OpenHAB, with the following high-level steps:

  • Install/Configure WIFI connection on OH server, as client to PW3 WiFi AP
  • Install Docker & Run pypowerwall-server container
  • Add MQTT Things & Items, to handle values sent from pypowerwall server
  • This assumes you already have a MQTT broker running, and the OH MQTT binding installed.

For those who already had the original pypowerwall proxy installed, make sure you disable/remove the pypowerwall docker container first. The pypowerwall-server also works with the HTTP binding, so provides a easy mechanism to progressively migrate from HTTP->MQTT. I only found one endpoint that didn’t exist from the previous setup (‘soe’).

I have done this all on my local openHAB server, running Ubuntu, but arguably the first 3 steps could be done on a separate device such as a PI Zero 2W (with Ethernet HAT), giving you a dedicated server device. You may need to do this, if you are already using, or don’t have a WiFi adapter in your OpenHAB server, and don’t want to add another one in there.

Obviously you will need to interpret and apply your own site/device-specific commands/config.

First things first, you are going to need the WIFI SSID and Wifi Password for the TEDAPI access - There is no access via the local LAN ports to the PW3 API, which was taken away in a recent release (25.10). Take a picture of the WiFi sticker in the main PW3 unit (Not the Gateway Unit), while your installer is connecting things up…

1) Setup WiFi Network Adapter

#install network manager (if not already installed)
sudo apt install network-manager

#list wifi interfaces - In my example below, the wlan interface is wlp3s0
sudo nmcli d

#turn on WiFi
sudo nmcli r wifi on

#List Wifi Networks (Just to check its working, however noting the Powerwall 3 Wifi Network is hidden, so you will not see it in the list)
sudo nmcli d wifi list

#replace <ssid> below with SSID from Powerwall 3 - Will be something like TealsaPW_XXXX, and also replace the ifname with the actual wifi interface name on your system
sudo nmcli c add type wifi con-name powerwall ifname wlp3s0 ssid <ssid>

#replace <password> with password from Powerwall 3
sudo nmcli c modify powerwall wifi-sec.key-mgmt wpa-psk wifi-sec.psk <password>

# The following is optional, to set a fixed IP address, as the PW3 will provide a DCHP IP Address
sudo nmcli con mod "powerwall" \
  ipv4.addresses "192.168.91.50/24" \
  ipv4.gateway "" \
  ipv4.dns "" \
  ipv4.dns-search "" \
  ipv4.method "manual"

#bring up the network
sudo nmcli c up powerwall

#Ping the powerwall - If it responds, you are ready to move onto the next steps
ping 192.168.91.1


2) Install and run pypowerwall-server in Docker

#If docker is not already installed, execute the following command:
sudo apt install docker.io docker-compose-v2 docker-doc

#'Install' & run the pypowerwall-server container. Replace the gateway_password with the ones from your PW, and the MQTT user/pass/host for the connection to your broker. Also set the timezone with that appropriate to your location

sudo docker run \
        -d \
        -p 8675:8675 \
        -e PW_HOST='192.168.91.1' \
        -e PW_TIMEZONE='Pacific/Auckland' \
        -e PW_PORT='8675' \
        -e PROXY_BASE_URL='/pypowerwall' \
        -e MQTT_HOST='192.168.1.10' \
        -e MQTT_PORT='1883' \
        -e MQTT_USERNAME='mqtt_username' \
        -e MQTT_TOPIC_PREFIX='powerwall' \
        -e MQTT_HA_DISCOVERY='false' \
        -e MQTT_CLIENT_ID='pypowerwall-server' \
        -e TZ='Pacific/Auckland' \
        -e PW_CACHE_EXPIRE='10' \
        -e PW_GW_PWD='Gateway_Password' \
        -e MQTT_PASSWORD='MQTT Password' \
        --name pypowerwall-server \
        --restart unless-stopped \
        jasonacox/pypowerwall-server


The container will restart following reboots. Documentation for the server can be found at GitHub - jasonacox/pypowerwall-server: A pypowerwall based FastAPI server for monitoring and managing Tesla Solar and Powerwall systems with multi-gateway support, real-time data streaming, MQTT, and a web based console. · GitHub

Note the default cache expiry is 5 seconds (how often it will fetch data from the Powerwall - I have upped this to 10 seconds in the above example).

Browse to your Openhab server (assuming you are running the Docker container on there), on port 8675 (http://openhabserveraddress:8675/ ), and you should then see a page similar to the following:

If the powerwall is showing as copnnected, and also the MQTT connection (bottom of the screen) this means you should be ready to move onto the next step, of setting up OpenHAB itself.

  1. Setup OpenHAB Thing (MQTT)

I’ll add further details here later, but to be honest, from this step onwards its very straightforward, as compared to the HTTP integration using pypowerwall proxy:

  • We don’t need to worry about transforming JSON, as we receive scalar values via MQTT
  • You can use basetopic/default/online (true|false) as your LWT topic for the MQTT thing
  • pypowerwall-server now handles string summing for those of us at the bottom of the world (NZ/Aus):
    • This is where the PW3 ships with only 3 physical MPPT inputs, but still supplies 6 string values in the interface.
    • These summed values are supplied via MQTT under basetopic/default/strings/AB (and CD/EF)
    • No post calculations/rules, or summing groups are therefore needed in OH to handle this as a result
    • Note this may now affect and be useful for North American units, as it looks like you may be able jumper 2 pairs of MPPT inputs (but not all 3 pairs).

Documentation on the core MQTT topics can be found here pypowerwall-server/mqtt-tools/README.md at main · jasonacox/pypowerwall-server · GitHub , but noting that this doesn’t cover ‘strings’ as yet. But using something like MQTT Explorer, you should be able to follow your nose, and see all the topics that are published.

You may still have issues with the Powerwall dropping connections after a firmware update, or similar, so the same advice in this comment, can be used for managing a transient connection: Tesla Powerwall 3 Integration using PyPowerwall Proxy & HTTP Binding - #6 by glen_m

I will add details to this thread as I go, but hopefully this should be enough to get you started anyway.

Hello,

in one week I’ll receive my Powerwall3, and I’m preparing the infrastructure. I would like to use the ethernet connection, and I’ve perhaps found a solution to accesse TEDAPI via ethernet:

I’m creating a vlan for the Powerwall 3 on 10.42.1.0/24. The I would like to set up a docker for pypowerwall-server on another vlan, and make the connection possible. The question is: it seems it works with pypowerwall, do you think it will work also with this solution with MQTT Binding?

thanks

Andrea

Hi Andrea,

Whilst I don’t personally use this mode (I use TEDapi via WLAN), I can’t really see any reason why it shouldn’t work…

  • I believe this is what is referred to as ‘v1r’ in the pypowerwall-server documentation
  • When looking at the documentation you have linked above, this appears analogous to the method for pypowerwall (proxy) as described here
  • pypowerwall-server is in essence seems to be becoming the replacement for pypowerwall
  • Which ever method(s) you use to connect pypowerwall-server to your powerwall, you should still get the same data out the other side, with the only caveats being (as I understand it) :
    • You will get less detailed information when using Cloud mode (I dont think they have individual srings etc)
    • You dont get control, unless you are using cloud mode (I only use local, and this is fine for my situation)

If you run into issues with connecting the pypowerwall to the PW3, probably best to ask over on the pypowerwall-server issues page.

I would however recommend checking posts in the original pypowerall page before youlook to do that - many have raised issues/questions when setting up v1r, and given this is mostly related to networking, it will probably be relatable to both.

Once you have your connection running to the PW3, and you can bring up the overview page from pypowerwall-server, everything else should be fairly straightforward (Data should already be flowing out via MQTT etc).

And last tip - Just remember to take photos of the inside of the Backup Gateway Box, and also the PW3 itself, while your installer has them apart… The wifi information and passwords are on stickers inside there.

Good luck

Hi Glen,

small update from my side, now that the Powerwall 3 has been installed and I have the integration running.

I ended up using Ethernet, but not through TEDAPI/v1r as I originally expected.

My PW3 is running firmware 26.18.3 184289b9 and is connected to my network via Ethernet on 10.42.1.44.

While working on the setup I found that pypowerwall 0.17.0 can access the PW3 using the Basic LAN API with just:

PW_HOST=10.42.1.44

PW_PASSWORD=<last 5 characters of the Powerwall password>

This gives local access to the basic real-time values I need: solar, load, battery power, grid power, battery SoC and grid status.

Initially pypowerwall-server 0.5.0 did not properly support this mode. It rejected PW_HOST + PW_PASSWORD as a valid local configuration and its connection test used /api/status, which returns 404 on my PW3 even though the Basic LAN endpoints work correctly.

I reported this upstream and Jason’s team produced PR #80:

I tested the PR on the actual Powerwall and it now works end-to-end:

Powerwall 3 → Ethernet Basic LAN → pypowerwall-server → MQTT → Mosquitto → openHAB

The server correctly detects Basic LAN mode, the web Console receives live data, MQTT publishing works, and the unsupported TEDAPI endpoints are no longer continuously queried.

The Basic LAN mode is read-only, so advanced telemetry and local control are not available. For my use case this is actually a very good fit: monitoring stays completely local and does not depend on Tesla Cloud. Hybrid cloud control for reserve/mode/grid charging/export has also been discussed upstream as a possible future enhancement.

So for anyone with a recent PW3 who already has Ethernet available, this may be a considerably simpler alternative to adding a second Wi-Fi interface or setting up v1r/RSA.

My installer has confirmed that my current Ethernet cable is connected to ETH A. At some point I will have it moved to ETH B so I can also test v1r/TEDAPI and compare the additional telemetry, but for now Basic LAN is working very well.

Now that the Powerwall side is stable, I would like to reuse/adapt your MQTT/openHAB configuration. If you have your current Thing/Items definitions available, I would be very interested in comparing them with the MQTT topics I am receiving.

Thanks again for the original guide — it was extremely useful in getting the whole chain set up.

Andrea

Fantastic - Good work - That’s much easier for someone who only needs the basic info without all the extra admin of the r1r or WLAN setup.

I need to stick with the current WLAN setup however, as I require individual string input details - I have 3 strings, each with different panels, and all different ages, so want to monitor/understand whats going on with each of these.

As far as my things definitions go, I am only using a limited set (similar to the original post) :

Thing mqtt:topic:fnlctlmqtt:powerwall "Powerwall 3" (mqtt:broker:fnlctlmqtt) [availabilityTopic="powerwall/default/online", payloadAvailable="true", payloadNotAvailable="false"] {
	Channels:
		Type number : powerwall_battery_level "Powerwall Battery Level" [stateTopic="powerwall/default/battery"]
		Type number : powerwall_solar_total_power "Powerwall Total Solar Power" [stateTopic="powerwall/default/solar"]
		Type number : powerwall_load_power "Powerwall Load Power" [stateTopic="powerwall/default/home"]
		Type number : powerwall_site_power "Powerwall Site Power" [stateTopic="powerwall/default/grid"]
		Type number : powerwall_battery_power "Powerwall Battery Power" [stateTopic="powerwall/default/powerwall"]
		Type switch : powerwall_grid_status "Powerwall Grid Status" [stateTopic="powerwall/default/grid_status", on="UP", off="DOWN"]
		Type number : powerwall_strings_AB_power "Powerwall String AB Power" [stateTopic="powerwall/default/strings/AB/power"]
		Type number : powerwall_strings_CD_power "Powerwall Strings CD Power" [stateTopic="powerwall/default/strings/CD/power"]
		Type number : powerwall_strings_EF_power "Powerwall Strings EF Power" [stateTopic="powerwall/default/strings/EF/power"]
		Type switch : powerwall_online_status "Powerwall Online (via pypowerwall-server)" [stateTopic="powerwall/default/online", on="true", off="false"]
		Type number : powerwall_strings_AB_voltage "Powerwall Strings AB Voltage" [stateTopic="powerwall/default/strings/AB/voltage"]
		Type number : powerwall_strings_AB_current "Powerwall Strings AB Current" [stateTopic="powerwall/default/strings/AB/current"]
		Type number : powerwall_strings_CD_voltage "Powerwall Strings CD Voltage" [stateTopic="powerwall/default/strings/CD/voltage"]
		Type number : powerwall_strings_CD_current "Powerwall Strings CD Current" [stateTopic="powerwall/default/strings/CD/current"]
		Type number : powerwall_strings_EF_voltage "Powerwall Strings EF Voltage" [stateTopic="powerwall/default/strings/EF/voltage"]
		Type number : powerwall_strings_EF_current "Powerwall Strings EF Current" [stateTopic="powerwall/default/strings/EF/current"]
}

Hope that helps.