Tesla Powerwall 2 Integration

I am still getting these communication errors as:

2023-09-28 01:23:53.499 [INFO ] [ab.event.ThingStatusInfoChangedEvent] - Thing 'teslapowerwall:teslapowerwall:pw1' changed from OFFLINE (COMMUNICATION_ERROR): Tesla Powerwall returned error while invoking https://powerwall/api/system_status/grid_status to OFFLINE (COMMUNICATION_ERROR): Tesla Powerwall returned error while invoking https://powerwall/api/login/Basic

I am using the 4.0.0-SNAPSHOT.jar and have the thing looks like

   Thing teslapowerwall:teslapowerwall:pw1 "Tesla Powerwall 2" [
        hostname="powerwall",
        email="david@itbeyond.com.au",
        password="RBHTV",
        refresh=30
    ]

Tried refresh=10 but I just get more errors. There are periods when I do not get errors and the data comes in and updates the items but these errors appear frequently and seemingly randomly. Here is a successful update only mins after the error above:

2023-09-28 01:28:28.755 [INFO ] [ab.event.ThingStatusInfoChangedEvent] - Thing 'teslapowerwall:teslapowerwall:pw1' changed from OFFLINE (COMMUNICATION_ERROR): Tesla Powerwall returned error while invoking https://powerwall/api/login/Basic to ONLINE
2023-09-28 01:28:28.757 [INFO ] [openhab.event.ItemStateUpdatedEvent ] - Item 'Battery_SOE' updated to 14.253124380083317
2023-09-28 01:28:28.758 [INFO ] [openhab.event.ItemStateUpdatedEvent ] - Item 'Grid_Status' updated to SystemGridConnected
2023-09-28 01:28:28.758 [INFO ] [openhab.event.ItemStateUpdatedEvent ] - Item 'PW_InstPower_Site' updated to 0.922
2023-09-28 01:28:28.759 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'PW_InstPower_Site' changed from 0.912 to 0.922
2023-09-28 01:28:28.763 [INFO ] [openhab.event.ItemStateUpdatedEvent ] - Item 'PW_EnergyExported_Site' updated to 34789.54253116237 kWh
2023-09-28 01:28:28.768 [INFO ] [openhab.event.ItemStateUpdatedEvent ] - Item 'PW_EnergyImported_Site' updated to 13405.737218008067 kWh
2023-09-28 01:28:28.770 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'PW_EnergyImported_Site' changed from 13405.722968008067 kWh to 13405.737218008067 kWh
2023-09-28 01:28:28.771 [INFO ] [openhab.event.ItemStateUpdatedEvent ] - Item 'PW_InstPower_Battery' updated to 0
2023-09-28 01:28:28.773 [INFO ] [openhab.event.ItemStateUpdatedEvent ] - Item 'PW_EnergyExported_Battery' updated to 12558.62 kWh
2023-09-28 01:28:28.776 [INFO ] [openhab.event.ItemStateUpdatedEvent ] - Item 'PW_EnergyImported_Battery' updated to 14045.08 kWh
2023-09-28 01:28:28.777 [INFO ] [openhab.event.ItemStateUpdatedEvent ] - Item 'PW_InstPower_Load' updated to 0.943
2023-09-28 01:28:28.778 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'PW_InstPower_Load' changed from 0.92675 to 0.943
2023-09-28 01:28:28.780 [INFO ] [openhab.event.ItemStateUpdatedEvent ] - Item 'PW_EnergyExported_Load' updated to 0 kWh
2023-09-28 01:28:28.784 [INFO ] [openhab.event.ItemStateUpdatedEvent ] - Item 'PW_EnergyImported_Load' updated to 51688.21442990559 kWh
2023-09-28 01:28:28.785 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'PW_EnergyImported_Load' changed from 51688.20023068684 kWh to 51688.21442990559 kWh
2023-09-28 01:28:28.786 [INFO ] [openhab.event.ItemStateUpdatedEvent ] - Item 'PW_InstPower_Solar' updated to 0
2023-09-28 01:28:28.788 [INFO ] [openhab.event.ItemStateUpdatedEvent ] - Item 'PW_EnergyExported_Solar' updated to 74584.04570392401 kWh
2023-09-28 01:28:28.792 [INFO ] [openhab.event.ItemStateUpdatedEvent ] - Item 'PW_EnergyImported_Solar' updated to 25.56596086412336 kWh
2023-09-28 01:28:28.794 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'PW_EnergyImported_Solar' changed from 25.56591008287336 kWh to 25.56596086412336 kWh

Nope that field is a cumulative since the PW2 was installed. The daily amount isn’t available through the Tesla API.

1 Like

No real ideas but I have no issues and use refresh=60. Enabling debug logging might give some clues…

Hello

is it possible to send values with this binding?
I want to edit the power reserve (to charge the PW when the price is low).

Regards
Jonas

The cloud version can update/change reserve, the one that uses the local API can’t.

Hi
Many thanks for this binding @Paul_Smedley .
I’m running the local version. The various instantaneous values appeared immediately and work a treat. Two questions:

  1. The Battery SOE and Battery reserve items showed values when I fixed the %.1f %% pattern, but the values seem to bear no relation to the values in Tesla app. Any idea why not?
  2. All the other fields just show NULL. Do I need to set specific patterns for those or something? I tried %1.f but that just shows UNDEF.

Apologies if these are silly questions.

Thanks!

Example values shown attached

Sorry - problem solved for the energy fields! Item > Metadata > Dimension > Energy (kWh).

Still don’t know why the battery values don’t match the app.

Battery values via the local API have always been different to what’s in the app. I have no idea why Tesla made this decision.

Updated version of the binding that uses the local API: https://smedley.id.au/tmp/org.openhab.binding.teslapowerwall-4.1.3-SNAPSHOT.jar Now has a channel showing battery degradation (based on a single PW2) and reports the full battery pack energy level reported by the API. Useful for seeing how your battery is degrading.

Existing installs will be upgraded to add these channels.

This is fixed in the latest release.

I switched from OH 3.4.2 to 4.1.2 yesterday and got the local powerwall binding from the Add-on Store. I cannot find the channel showing battery degradation. Maybe it will take some time for the new version to show up in the Add-on Store?

Then I copied the latest jar-Files from this thread to /usr/share/openhab/addons and restarted OH:

291 │ Active │  80 │ 4.1.3.202404192157     │ openHAB Add-ons :: Bundles :: TeslaPowerwall Binding
292 │ Active │  80 │ 4.0.0.202307251008     │ openHAB Add-ons :: Bundles :: TeslaPowerwallCloud Binding

I cannot find any channel showing battery degradation.

Btw: I was successfull generating the token for PWC with
[GitHub - adriankumpf/tesla_auth: Securely generate API tokens for third-party access to your Tesla.].
The Android app was not available any more in the play store.

Thank - I’ll fix the link in Marketplace - forgot to do that.

From your image above, it looks like you have the 4.0.0 and the 4.1.3 binding installed in /usr/share/openhab/addons - you should remove the 4.0.0 one

The 4.0.0 is the Cloud version you posted on July 1st last year here. I could not find it in the marketplace.

And the 4.1.3 was the local version you posted 5 days ago.

Now I deleted the jar for the local one in /usr/share/ … and got the one from the marketplace.
After restarting OH it shows Battery degradation and Battery Full Pack Energy :slight_smile:

Thank you!

Ahh sorry, I should have scrolled to the right :frowning:

My Powerwall, installed in 7/2017, shows
0,44% degradation (thats not too bad) and
13559 kWh Battery Full Pack Energy, off by a factor of 1k

Is it possible you didn’t specify the unit in the channel?

The app states 9,6 MWh went into the PW and 7,7 MWh out of the PW resulting in an efficency of 80%. Perhaps I should switch off my PW in the dark months of the year.

The PW2 reports the capacity in Wh - I was specifying the units as kWh.

Fixed in: https://smedley.id.au/tmp/org.openhab.binding.teslapowerwall-4.2.0-SNAPSHOT.jar & Fix units for Battery Capacity · psmedley/openhab-addons@c144810 · GitHub

FYI - I rebased the code for 4.2.0 and I’m trying to get this included in a future OH release - see [teslapowerwall] [WIP] Initial Contribution by psmedley · Pull Request #16667 · openhab/openhab-addons · GitHub

For me, the PW2 installed here in July 2019 was replaced a month or two ago as it had degraded to < 70%. The replacement has 14.045kWh of capacity. My second PW2 at a different property, installed in April 2020, is at 13.376kWh, so around 1% degradation.

1 Like

HI Paul

I tried to install local version of the binding and got this… any ideas where to start ?
Openhab v4.1.2 running on debian 12.5 (bookworm).

2024-04-28 13:12:46.671 [ERROR] [ore.thing.internal.ThingRegistryImpl] - Could not inform the ThingTracker 'org.openhab.core.thing.internal.ThingManagerImpl@cef3685' about the 'THING_ADDED' event!
java.lang.IllegalArgumentException: Duplicate channels teslapowerwall:teslapowerwall:pwtest:degradation
	at org.openhab.core.thing.util.ThingHelper.ensureUniqueChannels(ThingHelper.java:135) ~[?:?]
	at org.openhab.core.thing.util.ThingHelper.ensureUniqueChannels(ThingHelper.java:127) ~[?:?]
	at org.openhab.core.thing.util.ThingHelper.ensureUniqueChannels(ThingHelper.java:123) ~[?:?]
	at org.openhab.core.thing.binding.builder.ThingBuilder.withChannel(ThingBuilder.java:123) ~[?:?]
	at org.openhab.core.thing.internal.update.UpdateChannelInstructionImpl.doChannel(UpdateChannelInstructionImpl.java:140) ~[?:?]
	at org.openhab.core.thing.internal.update.UpdateChannelInstructionImpl.perform(UpdateChannelInstructionImpl.java:99) ~[?:?]
	at org.openhab.core.thing.internal.ThingManagerImpl.lambda$17(ThingManagerImpl.java:1095) ~[?:?]
	at java.lang.Iterable.forEach(Iterable.java:75) ~[?:?]
	at org.openhab.core.thing.internal.ThingManagerImpl.checkAndPerformUpdate(ThingManagerImpl.java:1095) ~[?:?]
	at org.openhab.core.thing.internal.ThingManagerImpl.registerAndInitializeHandler(ThingManagerImpl.java:918) ~[?:?]
	at org.openhab.core.thing.internal.ThingManagerImpl.thingAdded(ThingManagerImpl.java:359) ~[?:?]

Is this a brand new install, or an upgrade from an older version of the binding? It seems to be something to do with the feature to ‘upgrade’ to add the new channels…

Hi Paul,

Its an existing openhab install… started life as 3.x.
This binding was tried a few years ago, but at that point didn’t work as it didn’t renew the auth token automatically.
All things related to it were removed, as was the binding itself.
I can see no trace of it in karaf, paperui or jsondb files when this is done.
I then install from addon store (or manually to addon folder, makes no difference) and get the error.

I do have teslapowerwallcloud:powerwallcloud binding installed and working, but i can’t see how that would conflict… it doesn’t have a degradation channel.