Getting Serious on power automation with Tesla Powerwall

So I am based in Australia, and use AGL for electricity supply.

They have changed the way they are now charging me for power.

A base rate throughout the day and then a demand surcharge.

They take the highest use in the calendar month between 5-9pm then multiply that by the number of days in the month by the demand surcharge and then add that to my base usage.

I have solar and a Tesla Powerwall so it’s time to really put the automation power of HA to work here.

The normal controls in Powerwall App don’t allow me to make the best use of the battery.

I want to run the house entirely on battery between 5-9pm. Pretty simple when the sun shines all day. A little harder when the sun doesn’t shine all day. The idea here is if there is no sun to ensure 100% battery is available at 5pm each day to change the settings on the Tesla to force it to charge from the grid before 5pm.

There are various references to the reverse engineered Tesla REST API on the web.

Before I start the journey has anyone done something similar already?

Does anyone want to join me on the journey to see if we can make it happen?

I have a tesla powerwall as well as a very large solar array (15.9 kW past the inverter). My utility charges me a surcharge of 2.00/kW for peak usage for the month between 16:00 and 21:00. So if I use 5kW anytime between 16:00 and 21:00 during the month I get $10.00 added to my bill. So I have tried to avoid this. Mostly I have enough power to power batteries and run both A/C and fans without using power. Because of the size of my system I am not net metered (Colorado USA law). I pay 2.5x more for power than I get in return.

I use schedule on my thermostats to give me a hope of not hitting the peak. I over cool in the morning to put less load on the A/C in the afternoon. I have not written automations to power the batteries during non-peak rates. I have generation capacity when I don’t get monsoon rain clouds.

I am interested and will help where I can. Not a CS person but am an engineer. The biggest issue I see is turning on and off the battery charge in the Tesla app. It does not have an equivalent entity in HA.

Here is my energy balance on a very overcast afternoon when my scheme failed me. The blue is energy from the grid.

1 Like

Thanks J, like you I am an engineer.

The first question we need to resolve is can we change the configuration of the Powerwall using the API. Search begins :grinning:

Jase

1 Like

Hello all. I’m new the community as I’m heading down this HA journey coming from a SmartThings ecosystem. All my SmartThings still going, but it doesn’t support the things I want to do with my Powerwalls that I’m seeing mentioned here. Looks like HA may be an additional solution just for my Powerwalls and maybe eventually a full migration over here to centralize my home automation.

The discussion above is several months old so I’m checking in if a solution has been found to force the battery to charge at nights via the grid or some trigger event. ie. predicted lower solar generation the following day. Thanks! I love the dashboard @AllHailJ @meremortal

I have not found one. I have peak usage charges of $2.00 per month per maximum KW used from 4-9 and I have not found a way to access the API. I have to do it on the app on my phone. Painful

1 Like

Bummer. I find myself manually going into the Tesla app most nights to “top off” my PW batteries manually. That’s why this thread got interesting as I was hoping to trigger the top off.

If nothing else, the HA dashboard is cool looking. Debating now if that alone is enough motivation to move to the HA since the PW trigger isn’t available.

Has anyone looked at the below?

and the related dashboard:

The proxy seems to allow API calls to the gateway which allows it to query metrics populate the dashboard. I’m wondering if it’ll allow commands to trigger charge functions.

I made the jump off Hubitat over to HA. Seriously one of the best decisions for my home in a long time. It does have a learning curve and definitely not plug-and-play, but rewarding because of the robustness of the features and of course community.

I now have much more control of my PWs in my home automation eco system. Heck the Powerflow card is super cool and has replaced the native Telsa app along with my custom dashboard. FYI for those on the fence and to update my own hesitation above. =)

my powerwall has not yet been installed, but I have been running a gateway for a little while.
The custom tesla integration seems to allow control of the battery - can anyone confirm?

This post suggests it does. Sorry for the noise.

1 Like

The Tesla custom integration in HACS basically gives you the same controls as the app, the advantage is you can use these controls in your automations.

The thing is, it is missing the function to adjust set time of use. If you have the option to set time of use settings you can dynamically adjust the tariffs and peak/off peak based on live rates.

Not that simple, but it is possible to set the time of use windows via the API.

I have this script to retrive the TOU settings:

#!/usr/bin/env python3
import teslapy
with teslapy.Tesla("[email protected]") as tesla:
        tesla.fetch_token()
        battery = tesla.battery_list()[0]
#        tariff = battery.api('SITE_TARIFF')
#        battery.set_backup_reserve_percent(100)
#        battery.set_operation(backup)

#        print(battery) # should print battery status once successfully authenticated
#        print('----')
        print(battery.api('SITE_TARIFF'))

You can set the TOU windows using this API call, I just haven’t gotten around to integrating with Home Assistant.

https://github.com/tdorssers/TeslaPy/blob/ccd0eb894927e148a163477ea9492b3affb419e6/teslapy/init.py#L850

1 Like