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.
- 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 MPTT 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.
