[RELEASE] Tesla Powerwall Manager Smart App and Device Handler

This is a beta release smart app and device handler for the Tesla Powerwall II home battery.

For documentation and more information on this smart app and device handler, see: https://darwinsden.com/powerwall

Thank you to @RLS and @trentfoley for your earlier work interfacing Tesla and Powerwall features. I believe this app and handler fill a current gap, but apologize if there is overlap.

The Smart app currently must interface directly with the Tesla Servers, and so unfortunately requires your Tesla credentials.

This software was developed for my personal use and is provided here in the hopes that it will be useful to others, however, it is beta software and use of this software may result in unforeseen side effects to your equipment and related accounts. Use at your own risk!

Features:

  • Monitor and View Status:

    • Battery % level & Reserve % Level, Power status of Solar, Grid, Home, & Powerwall
    • Operational Mode Status (Backup-Only/Self Powered/Advanced Time Controls)
    • Optimization Strategy (Cost-Saving/Balanced)
    • Stormwatch Enabled Status
    • Grid/Power Outage Status (added 13-Aug-2019)
  • Control:

    • Set Reserve % Level
    • Set Operational Mode Status (Backup-Only/Self Powered/Advanced Time Controls)
    • Set Optimization Strategy (Cost-Saving/Balanced)
  • Define Schedules & Automations:

    • Schedule Operational Mode and/or reserve percentage changes to occur at specified times and days of the week
    • Select smart devices to automatically turn off in the event of a grid outage (added 13-Aug-2019)
  • Customize built in notification options to receive push and/or text notifications when:

    • Powerwall battery level approaches the reserve level
    • Powerwall battery level reaches a user-defined notification % value
    • Modes change
    • Firmware version changes
    • Grid/Power outage status changes (added 13-Aug-2019)
  • Monitored values and mode and level controls are exposed to SmartThings allowing integration with other smart apps such as WebCoRE.

5 Likes

Looks good. Nice to get it back into native groovy. I wish there was a method to directly control the amount of off peak charge, the Tesla algorithm is bizarre.

1 Like

Thanks, and I agree. Tesla’s time-based control mode never seems to do exactly what I would expect. I recognize the benefit of the ‘smarts’ they have added for some users and use cases, but for my needs, I would much rather have simple controls for scheduling basic modes and parameters. This app allows for some of that, but for whatever reason, it can take several hours for the Powerwall to change modes after being commanded. Hopefully Tesla will address some of this in future software updates.

Installed. Now I just need a Tesla.

2 Likes

no worry… this is alteady in the chapter 7 of the Apache license 2.0 you included in your code.

“You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License.”

I hardly think anyone in this forum would bring anyone in court for a DTH or a smartapp even though after few years in the US I still have hard time understanding the mindset.

If we start freaking out our devs can mess up things then this forum can close so let’s keep it simple and enjoyable.

Funny. Test drove a performance model 3 last week. Still outta my $$ range, but good to dream.

Installed and working, thanks! Tying this in with automation over Webcore. Is there a way to detect when the utility power grid is out? (black out)

Great suggestion. I updated the app and device handler to indicate the grid status from the Powerwall. The device attribute “gridStatus” will now be either “onGrid” or “offGrid”. To make things easier if you want to use Smart Lighting or other standard apps, I also added a switch capability to the device type so that “on” indicates the Powerwall is connected to the grid and “off” indicates a disconnect/power outage.

Since it only added a few more lines of code, I added grid status push/text notification option as well as an option to select devices to turn off during an outage in the Powerwall manager app itself. I configured my app to turn off the bar fridge in the event of a power outage, but now that I think about it, an operational bar fridge in an extended outage might be critical…

I did a quick run-through with a simulated outage, but won’t be able to give it a thorough test until tomorrow, when I can shut off grid power without disturbing the family.

Let me know if this will work and/or if you have other thoughts on implementation.

Awesome! Can’t wait to try this out once I get my Powerwall (still waiting on two referral red ones).

Great! I only have one, so I’m curious how well this works with multiple Powerwalls.

I’ve completed a quick test of the updates to add grid/outage status. If you’ve already installed the prior version, you’ll need to update both the smart app and device handler for all the changes to work properly.

As a side note, the Powerwall performed flawlessly when I cut off grid power to test the update. This is the first test I’ve done on the latest V1.37.1 software version. The Powerwall immediately cut over to power my home, and solar continued charging the battery. I think with a little care and forethought (and unfortunately no air conditioning considering I’m only using a single Powerwall), my home power could be indefinitely sustainable without grid-power. The Powerwall is just plain awesome.

1 Like

How have I been missing this all this time? Was delving into the API via WebCore with the hopes of eventually creating some sort of “low power mode” where I could turn off portions of the house when on backup power. Will have to pull this and play around a bit to see if it will do everything I envision. Now, if someone could come up with a Electrical Code legal smart circuit breaker…

1 Like

Just had the ability to test the off-grid functionality due to a quick power outage. App identified the outage and turned off the devices I had selected at install. However, when power came back on, instead of restoring state of the devices, it turned everything on.

It’s a super simple implementation right now. The app does provide an option to not turn the devices on after the grid outage is over, but it does not currently store the state of all the devices prior to the outage and restore them to their prior condition once the outage is over. I can look at adding that as an enhancement.

For now, unfortunately, the only options are to choose to have them turned on after the outage is over - or choose to do nothing at all with them once the outage is over. I’m currently doing the latter with my setup.

Got it. May be something I will try to hack into my system. Been meaning to learn Groovy and this seems like a good get-my-feet-wet type of thing.

1 Like

Excellent! Thanks.
I’ve tested this with my Powerwall a few times and it’s worked perfectly.
I rely on low cost TOU electricity during the winter and i had a terrible experience with the unpredictable, Tesla TOU algorithm which predicts tomorrows weather based on yesterdays!
Your app will really enhance the usability of the powerwall.

2 Likes

These exist for most US jurisdictions (but as always check with your own township as codes do differ from place to place)— But I don’t know of any that integrate with smartthings.

Leviton has a nice system. However, in order to meet the national safety code, it can only turn off the breakers, not turn them on. They still have to be manually turned on because you are supposed to be inspecting the condition of the box each time you restore power. Also it can’t turn off the main breaker. So that may be the limits of what you can do under the national code.

https://www.leviton.com/en/products/residential/load-centers/the-leviton-smart-load-center

1 Like

Big thank you for your work, I’ve been using successfully now for 6 months and your app automates charge/discharge scheduling way better than the native Tesla app. Some suggestions as follows:

1 - allow multiple TBC schedules with individual TBC sub-settings. At the moment I can only switch on a single TBC configuration.
2 - allow scheduling a mode to turn off as well as on. At the moment I have to switch to another mode to ‘end’ the first mode. An optional ‘end time’ for each schedule would be perfect!
3 - this is a long shot but would be my nirvana: allow wholesale tracker tariff imports and auto-schedule the optimum cost from it. In the UK we have the Octopus Agile wholesale tracker tariff which changes the charge every 30 mins and is forward published each day for the following day.

Keep up the good work!

1 Like

Thanks. I’ll give these some thought as I work additional updates.

#3 is intriguing. I would very much like to be able to automate Powerwall states dynamically based on utility rates. I wish there was a common API for all utilities.

Most of the Powerwall Manager commands can also be called from WebCore, so that is at least an option for #3 for now. I see there has been some WebCore work done with Octopus Agile: https://community.webcore.co/t/parse-get-json-data-into-a-variable/16251/24, but not sure how easy this would be to leverage.

2 Likes

@RudyK @Darwin
Linking this app to the Octopus Agile tariff should be possible by using Octopus’ API to retrieve their next days rates. However this approach clearly will have to be coded to each energy provider and api.

We will for the moment ignore the fact that the overwhelming majority of providers are still not offering such intelligent and flexible tariffs and indeed many still don’t even support the ancient Economy7 type tariff on new smart meters.

There are indications Tesla themselves plan to enter this arena directly. They have a system called Autobidder whereby they act on behalf of customers to negotiate the best rates. The impression I get is that this would cover both grid to customer cost and customer to grid (feed in) cost with the Powerwall automatically switching between export and import modes but keeping a power ‘reserve’. I also get the impression this is not yet available in the UK.

In the meantime a potentially flexible approach would be to (somehow) query a smart meter. UK and I believe other countries smart meters have the ability to locally let a customer access consumption data but at least here in the UK allegedly can also provide tariff information. The smart meter sends consumption data to the DCC which in turns sends it to your provider and in return allegedly downloads tariff information.

https://www.smartdcc.co.uk/

Smart meters use Zigbee but a special version. Customers can however connect IHD - In Home Displays and CAD - Consumer Access Devices. CADs are a way to not merely display the information but to directly access and process it.

The later i.e. CADs is what is relevant here. With this a CAD could then send information to Smartthings or similar.

Unfortunately whilst energy providers have to allow certified IHD and CAD devices to be connected by customers they have (of course) made this as difficult as possible. Firstly for some insane reason only one manufacturer sells direct to end users - the rest only to energy providers. Secondly every such CAD device currently on sale in the UK that I have identified sends the data to their own cloud system from which you then have to use their API to retrieve the data. This is instead of allowing local access.

The strong likelihood is that because the only access is via their cloud systems you do not have access to all the data especially tariff information as their focus is purely on consumption data. If you could directly talk to the CAD which in turn directly talks to the smart meter then nothing should limit your view.

There is a US product which works locally as well as again via their cloud.


Unfortunately it is not certified for the UK and needs some updating. I know they have had several contacts from the UK but like too many US firms are sitting on their ass and ignoring the UK/EU market.

It is ironic. I am impressed with the foresighted ideas behind the UK smart meters. Whilst the expectation that IHDs would by themselves lead to energy savings is naive the ability to use a CAD to then also use the information retrieved to automate turning off and on high energy using appliances so they operate during cheap rate periods and other ideas is something one does not expect from a government originated scheme. Sadly as mentioned too many energy providers and manufacturers are holding this back.

Octopus Energy is one of the smarter and more exciting providers but even they do not provide CADs and even if they did as mentioned they would force you to work via someone else’s cloud system.

Note: Smartthings has done a link up with Bulb a UK energy provider.


The referred to Chameleon IHD is actually a combined IHD and CAD in a single device. This as I mentioned before sends the data to Chamleon’s own cloud.

As far as I can see this does little more than give you a pretty display on your phone and has no ‘smarts’ for controlling things.

1 Like