Pulling data out Tesla Powerwall

Lmao! Need :cookie:

looks like needs the same oauth2 that the car api is now using.. havent found an implementation yet in groovy and my attempts locked out my account so gave up for now.

Tesla Powerwall Manager also fails to auth to the remote site, and it breaks functionality like turning things off during outage and back on when the grid is back online. :neutral_face:

I'm hoping there will be some updates coming! :crossed_fingers:

1 Like

Just re-reading that and it might come off a bit too complain-ey, I should also mention how much I appreciate the functionality that's not been hampered by Tesla auth changes too.

As a fully off-grid (except 4G terrestrial wireless Internet) installation, I use this app to turn on secondary 12v battery chargers whenever the generator runs. The 12v system actually runs my Hubitat and the Internet connection and 2 of the 3 mesh Wi-Fi APs, along with my drinking water pressure pump - so as the days get shorter down under, the 12v system needs a bit more touching up from the mains batteries, and this little automation provided a bit extra to my scheduled boosts alone. So I appreciated that function in the app. :+1:

Side question, anyone have a good solution for taking a 12v input and driving a (10v) Fibaro implant, or something else to give proper telemetry on the 12v power and react more directly?

Chris

I’ve committed an update to the Powerwall Manager app to now allow you to paste in an access token directly into the app to allow authorization with the Tesla server. Unfortunately, the app no longer supports direct access to the local gateway. You will need to generate and paste in a new token at least every 45 days.

There are several approaches for generating new Tesla tokens, including python scripts and the ‘Auth App for Tesla’ for IOS and Android.

Due to what appears to be limitations in the current way Hubitat handles URL redirection and HTTP headers, I’m not sure the app will ever directly support authorization with the Tesla server by entering in your account and password information alone. The issue with local gateway access also appears to be related to limitations in the Hubitat HTTP map header interface (that currently does not allow multiple Set-Cookie headers). I would love to be proven wrong, so if anyone here has a solution, it would be greatly appreciated.

The app does now allow you to generate and serve the access token posted via a script running on a local server for those wanting a hands-off approach for refreshing the token periodically. Thanks @kahn-hubitat for outlining the approach.

Only limited testing, so please let me know of any issues.

1 Like

The Powerwall Manager has been updated to add the local gateway polling option back in. Thank you @snell for helping work through the new gateway auth cookie API changes.

This update also overhauls the scheduling infrastructure to allow an unlimited number of schedules, schedule naming, and adds optional month restrictions – so those of us with seasonal time-of-use utility plans or other seasonal requirements should hopefully not need to manually update schedules in the app as often.

The scheduling update was a fairly major infrastructure change, so if you update, please verify that your prior schedules have remained intact.

1 Like

Thank you! It is working for me.

1 Like

FYI, the local polling connection is working for me as well. FWIW, using the Tesla OAuth method requiring an updated token every 45 days or so also worked for me but given that I am only interested in local monitoring from Hubitat to Powerwall, the gateway authentication method is ideal for me. Hopefully Tesla will keep this in place.

1 Like

Powerwall Manager version v0.3.30 is now available. This update includes the option to specify a refresh token instead of an access token, eliminating the need to enter a token every 45 days. The update also includes the ability to command and schedule off-grid operation. Both app and driver should be updated for this change. Thank you @x10send.

1 Like

I've got the Tesla server logon working with the refresh token but am having trouble with the local access setup. From a browser I can log onto the gateway with the last 5 of the password on the gateway sticker. On the local access setup I'm getting a timeout error.

For the dashboard setup I get this error.

I am using the same IP and last 5 password that works from a browser and the Hubitat and gateway are on the same network. I also have the latest version of app and driver.

It's certainly possible that I'm not robustly handling this particular network configuration properly in the code, but the ConnectTimeoutException makes me wonder if maybe Hubitat can't reach the Powerwall Gateway's subnet. (Otherwise, if the subnet was valid to Hubitat, but the IP wasn't, it would likely result in a "no route to host/unreachable" error, and a simple password authorization error should give you a "401 unauthorized" error).

Do you have any other pinger or Powerwall apps or drivers installed on Hubitat that you can use to verify that your Hubitat can see the gateway's address?

As far as the Dashboard Tile iFrame issue, I'm now seeing this same dashboard error you have captured above when running on Chrome. Safari now also has a different problem, although Firefox and Fully Kiosk Browser both still seem to work for me when displaying this as a tile on a Dashboard. All my dashboards run on FullyKiosk, so I hadn't noticed any issues. I'm wondering if Chrome and Safari have added additional protection against iFrame access - or at least the way I'm implementing this. I'll investigate further. There may be a way to permit this for certain browsers.

@Darwin I'm using your app/driver pair. I find that it fails to automatically refresh the Powerwall values. It only updates if I manually click poll and refresh - but when I do, it successfully gets updated values. However, it never updates on the polling interval. I've updated to the latest (Jan 19) version and that hasn't made a difference.

I'm using the local gateway connection - no Tesla token is configured. I turned on debug logging and I see this in the logs:
[debug] Input Access Token Valid: false
and looking at the code, that looks like a path to validate the Tesla token (which I said is not configured in the app).

I'm using Snell's driver pair, also, and it doesn't have an issue talking to the local gateway connection. But I like the notifications in your app better.

Any ideas on how I can debug this?

.
UPDATE: I uninstalled and re-installed the app and reinitialized it. It did one query, then it logged this on the time for the 2nd query:
image
but it proceeded to query the device, so at the moment it is working.

I typically run with both server and gateway polling enabled and admittedly don't do too much testing with just the gateway. I was going to suggest re-entering the gateway data to re-initialize the polling, but your clean install certainly takes care of that. It's very possible I failed to migrate one of the updates properly and your set up needed a full-initialization to get things properly working again. Let me know if this rears its ugly head again. I'll toss in a few more debug or trace statements in this area for future reference.

1 Like

The network is all on 192.168.1.x. I don't have any other apps on the Hubitat connecting to the gateway, but the Hubitat does connect via IP to some Lifx bulbs and the Envoy gateway for the solar panels. I can't think of anything network wise that would get in the way. The Powerwall gateway is hardwired to the router.

This is a new Powerwall. Is there anything that should be done on its setup? I have not logged in as installer yet to check what the contractors set up in there.

I don't use this app (I use Node-RED to access my Powerwall) but I have possibly been having a similar issue with my Powerwall+ (installed late December). I cannot reach (either through a browser or ping) the Powerwall+ from any of my local machines EXCEPT one RPi that is connected directly to my router. I haven't been able to figure out what the root cause is, but since my Node-RED is running on that RPi, I can at least grab the data.

Have you tried configuring the wifi on the Powerwall to connect to your router and seeing if that works?

Yes, on the off chance it might work I did set up the WiFi connection on the gateway, confirmed it worked by accessing the IP on a PC browser, then tried that IP instead of the wired one in the local setup for the app. Same error.

I added a gateway ping test option on the Powerwall Manager app local gateway account page and also added some additional Hubitat Log debug and trace statements (general preferences page to enable) on the pre-release line here. It doesn't fix anything yet, but maybe it can help narrow down issues.

This is what I get on the Ping and below that the logs with it set to Trace. It just looks like the gateway is not responding to it. Still can't think of anything network wise that would block it. Do you think the user not authorized for GET error on the dashboard setup has anything to do with it?

09:55:49 [rttAvg:0.0, rttMin:0.0, rttMax:0.0, packetLoss:100, packetsReceived:0, packetsTransmitted:3]

TRACE

search

app:4962022-01-29 09:59:23.627 am warnError getting local gateway status: org.apache.http.conn.ConnectTimeoutException: Connect to 129.168.1.23:443 [/129.168.1.23] failed: connect timed out

app:4962022-01-29 09:59:13.590 am tracePosting to gateway URI: https://129.168.1.23/api/login/Basic

app:4962022-01-29 09:59:13.588 am debugConnecting to local gateway...

app:4962022-01-29 09:59:05.676 am debugbattery found: STE20220124-00121 site_name: Nicholls&Fenton energy_site_id: 283389897812

app:4962022-01-29 09:59:05.094 am debugInput Access Token Valid: true

app:4962022-01-29 09:57:11.115 am warnError getting local gateway status: org.apache.http.conn.ConnectTimeoutException: Connect to 129.168.1.23:443 [/129.168.1.23] failed: connect timed out

app:4962022-01-29 09:57:01.092 am debugConnecting to local gateway...

app:4962022-01-29 09:56:48.742 am debugprocessing server site data response

app:4962022-01-29 09:56:39.785 am debugprocessing server powerwall response

app:4962022-01-29 09:55:49.396 am warnError getting local gateway status: org.apache.http.conn.ConnectTimeoutException: Connect to 129.168.1.23:443 [/129.168.1.23] failed: connect timed out

app:4962022-01-29 09:55:39.377 am debugConnecting to local gateway...

app:4962022-01-29 09:55:39.293 am debugGateway ping results: PingData(rttAvg: 0.0, rttMin: 0.0, rttMax: 0.0, packetsTransmitted: 3, packetsReceived: 0, packetLoss: 100)

app:4962022-01-29 09:53:47.241 am warnError getting local gateway status: org.apache.http.conn.ConnectTimeoutException: Connect to 129.168.1.23:443 [/129.168.1.23] failed: connect timed out

app:4962022-01-29 09:53:37.218 am debugConnecting to local gateway...

app:4962022-01-29 09:50:28.177 am warnError getting local gateway status: org.apache.http.conn.ConnectTimeoutException: Connect to 129.168.1.23:443 [/129.168.1.23] failed: connect timed out

app:4962022-01-29 09:49:35.549 am warnError getting local gateway status: org.apache.http.conn.ConnectTimeoutException: Connect to 129.168.1.23:443 [/129.168.1.23] failed: connect timed out

app:4962022-01-29 09:49:08.465 am warnError getting local gateway status: org.apache.http.conn.ConnectTimeoutException: Connect to 129.168.1.23:443 [/129.168.1.23] failed: connect timed out

app:4962022-01-29 09:47:11.159 am warnError getting local gateway status: org.apache.http.conn.ConnectTimeoutException: Connect to 129.168.1.23:443 [/129.168.1.23] failed: connect timed out

The user not authorized issue on the dashboard I believe is an unrelated problem with some browsers with enhanced security not wanting to handle the gateway login via an iFrame. This happens with Chrome and Safari on my system as well. The fact that this page shows at all is a good sign that your computer can see the gateway OK.

On the Hubitat->Settings->Network Setup->Network Test page, do the gateway pings and trace route tests look OK? I can't imagine issues there though, or you would likely be seeing other issues besides this app, but I thought I'd ask.

At least your outside Tesla server connection appears to be working, but I'm at a loss for what else to try aside from re-booting Hubitat and/or your network equipment. But that would make me sound like a Cox support tech. You could try reconnecting your Powerwall networks and renewing leases by logging into the gateway webpage as customer and clicking on "Connect" on the Network->Ethernet page - or try a Static IP on that page vs DHCP. Or try re-selecting your wireless network on the gateway Wi-Fi page to renew that lease..

Well it ended up being a stupid reason for the local not connecting. If you notice in the log I had 129 instead of 192 in the IP. Came down to a typo. Works now that I have the correct IP.

Dashboard still has the get error, but that's a different thing. Had the IP correct on that screen which is why that did no time out.

2 Likes