Just FYI this is how I do it:
https://community.home-assistant.io/t/optimizing-use-of-unused-solar-power-to-charge-a-tesla/340818/2?u=tom_l
There are more details in the following posts.