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