Tesla Powerwall Automate TOU / Self Consumption

I had a moment of boredom today and thought I’d hit up Chat GPT for the best way to automate a PW2 to switch between TOU and Self Consumption modes taking into the account the following

PW2, 13kW of solar, 2 x Tesla model 3’s and the weather.

Below is what it spat out, will try it over the next month or so and see how it goes.

Happy to take any feedback on any errors or things that could improve the rule.

I'm once again not very impressed with ChapGPT's ability to actually come up with a correct answer rather than just something that sounds like it makes sense. This rule is fundamentally broken. It does not make sense on its face.

If I understand what you want to do, you want to set a base mode at 0600 each day of the week, and then potentially switch to the other mode if the solar panels are producing above 4500 or less than 1500. Between 1500 and 4500 it will stay in whatever mode it is already in. The cloud cover condition complicates the logic a bit, but is that fundamentally what you're trying to achieve?

The first thing I noticed is that your rule is going to trigger on every new report for Solar Power above 4500. Depending on the device refresh rate, that might clutter up the logs a bit and is making the hub potentially work harder than it needs to. The if/then/else if statements also have to be evaluated every time the power reports above 4500. That's not ideal.

Then I noticed that your last ELSE IF seems to show you want to go back to time-based control when the weather becomes 'overcast clouds' or the solar power is below 1500. However with your current triggers, there is nothing to cause the rule to run and evaluate that conditional when the power drops or the weather changes. The rule only triggers under 3 conditions: time is 0600, power reports > 4500, and weather reports 'clear sky'.

So if at noon solar power reports 4800 and the weather is 'clear sky', the rule is triggered by the solar power value and goes to self-powered. If at 1230 the weather report becomes ''overcast clouds" then nothing happens. The rule is not triggered by that change.

Likewise, when the weather changes or the sun goes down and the solar power drops below 1500, the rule does not trigger.

Then I realized another issue that I probably should have seen sooner. No matter which trigger fires, the rule first evaluates if it is a weekday. If it is, then it sets time-based control AND EXITS because everything else is an "ELSE IF".

ELSE IFs aren't checked if a prior IF (or ELSE IF) is true.

On the weekends, it will get to the first ELSE IF. it will set self-powered AND EXIT. It will not evaluate the other two ELSE IFs.

This might be simpler as multiple rules.

Rule 1: Weekdays at 0600: Switch to Time Based Control
Rule 2: Weekends at 0600: Switch to Self Powered

Rule 3: Required condition: Powerwall self-powered = off
Triggers: Solar > 4500
Action: Turn on self-powered

This removes the weather check... are you able to get >4500 solar when it is 'overcast clouds'? If not, the weather condition is redundant. Due to the required condition, once the PW is in self-powered mode, this rule will not continue to fire.

Rule 4: Required condition: Powerwall time-based = off
Triggers: solar power < 1500
Action: Turn on time-based

This removes the weather condition. Do you really want to switch back to time-based if the weather reports overcast clouds but the solar panels are still above 1500? Due to the required condition, this rule will only fire when the PW is not already in time-based control.

It also might be better to use "and stays" on the solar power value to avoid switching due to passing clouds. So "solar power < 1500 and stays for x minutes" or "> 4500 and stays for x minutes" as the triggers)

Thanks for the information, I’m always greatful for the pros fact checking the rules, really appreciate your time.

I easily get over the 4500w of solar when not overcast, I’ll take the advice and create the rules as suggested and see how that pans out.

Thanks again

Okay, so I'm doing this same thing. I set an 0500 hrs rule that asks if the weather forecast for the current day will be inclement or nice. It ignores the Powerwall SoC in the beginning since that wasn't necessary; at the end, I added a Powerwall SoC check:

This seems to do what I want it to do. @ 0700, rates double, so I added a rule in Powerwall Manager to cut off battery charging @ 0655 (the extra 5 min is necessary because I have observed that battery charging will continue for 1 - 3 min after the command is issued).

Yesterday, I noticed that battery charging had not commenced @ 0500; the system did switch from Self-Powered mode to Time-Based-Control, but it was only drawing enough energy to run the house. Upon further exam, I noticed that if I set Backup Reserve to 100%, battery charging would commence. Normally, Backup Reserve is set to 10%. Thus, I added some Actions near the end: "Dim: Powerwall: 100 --> fade: 0", etc. Those were necessary to get battery charging going...wasn't necessary until yesterday. Not a big deal, but it has worked (all of the one time I tested it. I will know tomorrow morning if it does because the forecast is rain. N = One!!).

Happy to entertain criticisms, suggestions for improvement, thoughts, etc! I have some skills, but mostly learn by setting things on fire...

*Edit: a few words of explanation: Powerwalls charge max rate from the grid @ 10.8 kW in Time-Based-Control mode, and 3.9 kW in Self-Powered mode. Most of the time, the system is in Self-Powered mode. Most of the time, the Powerwalls don't need more than 2 hrs to fully charge or reach a reasonable SoC, thus the 0500 time point.

My objective was to make sure there is enough energy in the Powerwalls to get us through at least one 24 - 36 hr period with no grid power and very little solar. This is quite uncommon, of course, as our grid is very stable. However, it is perhaps the worst case scenario. Hope for the best, plan for the worst. I've seen rare mornings where the Powerwalls are run down to 11% just as solar begins to produce enough to charge them, and an even fewer number of times when they run down to 10%, so I've set about tweaking the settings to compensate, thus the Rule above (in its current form...there's always room for improvement). We now have Powershare, which changes everything (and I've created a "BackFeed Solar Project", which takes energy from a few el cheapo solar panels, run through a couple of grid-tie inverters and fed directly to my house. The Powerwall system sees this as a reduction of house load. This also changes everything!).