During the hours of 4-9pm I'd like to run my home off solar, send the excess to the grid, have my home run off the Powerwalls when there isn't enough solar, and NEVER draw power from the grid.
The only way to do that would be to set your PW2 to be in self-consumption mode with 0% reserve for outages during 4-9pm. Even then, whenever solar production is low and house has exhausted the battery, you will start using the grid. No way to avoid that.
During the hours of 9-4pm I'd like my home to run off solar if available, run off the grid if enough solar isn't available, use excess solar to recharge the Powerwalls, and NEVER run the home off the Powerwalls (unless there is an outage).
To do that, set the PW2 reserve for outages to 100% from 9-4pm.
If it looks like there isn't going to be enough solar to recharge the Powerwalls before 4pm then prioritize recharging the Powerwalls over the home. If that still can't recharge the Powerwalls in time then charge the Powerwalls from the grid.
There is no way to prioritise PW2 charging over home consumption via commands that I know of. Consumption is higher than charging in the hierarchy. TBC / stormwatch might do this occasionally, but that appears to be an internal algorithm in the PW2 software that is triggered, and is not triggered by API commands.
If anyone has figured out a way to do this it would be nice to know.
Assuming you don’t want to sit on the Tesla App and manually change PW2 settings at various times during the day like a human cron job, the only way is to learn the Tesla API and write a script to change the PW2 settings to whatever you want at whatever times of the day and run that script as a cron job.