Teslemetry + PowerWall - control "Energy Exports" selection?

Tesla support have now set up my PowerWall to allow me to Export energy from my batteries to grid. There’s an option in settings that’s now appeared called “Energy Exports” that allows me to either export from “Solar” or export from “Everything”. I’ve set up a custom utility profile for export that “forces” the batteries to export during morning and evening peak periods.

So far so good except that now the PW is prioritising filling up the batteries with solar rather than exporting the solar to grid. That’s worse for me - the batteries get to 100% then PW exports to grid. I have a 5kW limit to grid, so any solar in excess of 5kW plus what the home needs is clipped i.e. thrown away.

I naturally turned to Home Assistant to sort it out - I’m already using Teslemetry to monitor and manage the PW. I would like to have HA change the “Energy Exports” option to “Solar” if the batteries have got to say 80%. This should mean the PW will send 5kW of solar to grid and any excess solar above that will power the home and charge the batteries.

However, I can’t find a Teslemetry Switch that controls “Energy Exports” - any ideas?

Solved:

I’m using Node-RED to create my HA automations. I’d missed that there is a set of Node-RED nodes built to work with Teslemetry. Found them here:

@teslemetry/node-red-contrib-teslemetry

There are separate commands available for setting the Energy Exports options - I’ve just added a test node and tried setting the PW to Solar only and to Battery (which seems to be the Everything option). Works a treat. Now just need to write the logic to let the PW export from battery in the morning and evening peaks, then set the PW to solar only during the day if there’s enough charge in the batteries. Hopefully this will mean I send solar to the grid during the day, top up the batteries if there’s more than 5kW of solar during the day, then let the PW work out if there’s enough charge in the battery to send 5kW to grid over the evening peak period. What could possibly go wrong with this approach?