Sense app controlling Tesla charging with excess solar

Recently the Tesla API (as seen in the Tesla App) became able to change the car’s charge rate remotely. This means that the Sense App now knows how much excess solar production there is AND it could send signals to our Teslas to absorb that excess instead of letting it got back to the grid where we lose it’s value.

My Sense is NEVER going to be able to detect my Tesla as I don’t charge full speed all the way to full (which you shouldn’t do), so I have put a TP-Link on it and turn it on during the day. But if Sense really wanted to help those of us with Teslas they should add this charging integration to maximize our Tesla/Solar/Sense investment.


It sounds like you are using a TP-Link to turn on/off your tesla charger. You should be able to setup a IFTTT applet to turn the TP-Link/KASA plug on when solar > usage and off when <.

I agree, “You SHOULD be able to setup an IFTTT applet” too bad the only things IFTTT can do in relation to Sense is to react to devices turning off and on, kinda useless for discovering my surplus solar.

I did end up taking someone’s code from here and making an app that will turn off and on the Tesla charging by talking directly to the car and sending requests based on any surplus. It’s ~working~ but needs to experience many more corner cases. I got it to the point where it will react correctly to the charging being turned on some other way than thru the Python script, and correctly reading the charging amps from the car.

I am currently adding the ability to up the charge rate using the new ability to set the charge current remotely. Just waiting for the sun to come out to see if I got the code right, stupid fog.

You’ll have to share the code with everyone once you have it all worked out. I’m sure a lot of users would like the TOU rates figured into this. I assume if the NEM 3.0 passes in CA, we will be seeing a lot of off grid systems running in conjunction with the grid systems. All of those will be needing a device to communicate / control devices between the grid system and off grid systems to maximize their usage.

In the past, we’ve refrained from developing anything dependent on unofficial/unsupported API’s due to the implications if something changes in terms of access for 3rd parties. I have to check-in on this, but that’s been one significant roadblock for us in the past when a Tesla integration has been suggested.

Unofficial/unsupported API’s like the one for Sense?

That’s correct. It might seem counter-intuitive, but we obviously have more control/understanding over changes that could impact usability of some of the user-created tools leveraging our unofficial API.

1 Like

OK, it’s very preliminary, but it runs for 24 hours and I THINK I got all the bugs out today, but then the sun went down, so I’ll test more tomorrow.

In the mean time, you can check it out and any bugs that I find I’ll update the code at my GitHub archive:

Just download the code, edit it and change the usernames and the Sense password to your own and launch it at the command line with python3, I am sure there are some packages that will need to be installed on your system and I’ll update the ReadMe as I figure it all out.

I would love any feedback or issues you have trying to get it to work.