This will set up a Raspberry Pi to connect to a Tesla Powerwall Gateway (TEG) and bridge that connection to the ethernet connected LAN.
___________________ __________________________ _______________
[ Powerwall Gateway ] [ Raspberry Pi ] [ Host ]
[ TEG ] WiFi [__________________________] LAN [ Linux/Mac/Win ]
[ WiFi: TEG-xxx ] <---- [ 192.168.91.x | 10.0.1.55 ] <-----> [ 10.0.1.65 ]
[ 192.168.91.1 ] [ WiFi (dhcp) | Ethernet ] [ LAN ]
‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾ ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾ ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾
- Create or edit
/etc/wpa_supplicant/wpa_supplicant.conf
:
network={
ssid="TEG-xxx"
psk="password"
}
- Restart Networking and Test
sudo systemctl restart networking
# Test
ifconfig wlan0
ping -c 1 192.168.91.1
- Set up IPv4 Routing and Reboot
# Add IP Forwarding - Uncomment net.ipv4.ip_forward=1
sudo sed -i -e '/^#net\.ipv4\.ip_forward=1/s/^#//' /etc/sysctl.conf
sudo sysctl -w net.ipv4.ip_forward=1
# Restart
sudo reboot
On the host, you need to add a route to use the Raspberry Pi as a gateway to get to the Powerwall Gateway.
# Linux
sudo ip r add 192.168.91.0/24 via 10.0.1.55
# MacOS
sudo route add -host 192.168.91.1 10.0.1.55
# Test
ping -c 1 192.168.91.1
curl -ik https://192.168.91.1
@jasonacox I have a fix for this.
Status
The script is still a bit rough/immature. I'm working on figuring out how to make it better and/or integrate it into the server. I also have other variations that work using network namespaces and virtual interfaces, but those seem unnecessary.
Summary
Essentially: Instead of calling
192.168.91.1
directly, set the host in pypowerwall to one of [192.168.92.100
,192.168.92.101
] (Subnet choice is arbitrary). Currently my inverters are at [192.168.1.67
,192.168.92.250
] and my raspberry pi is at192.168.1.225
Steps
This is the reason for this fix that I posted earlier today. Most of TEDAPI worked except firmware version retrieval!
I will update my other PR with this.
Code
Routing Configuration