Welcome to Tesla Motors Club
Discuss Tesla's Model S, Model 3, Model X, Model Y, Cybertruck, Roadster and More.
Register
  • The latest TMC Podcast (#14) is now available on YouTube and all major podcast networks. We covered FSD Beta's exciting v11 update, Enhanced Autopilot coming to the U.S. and Canada, and more!

TesSense - Control your Tesla charging from your Sense Energy Monitor

Randy Spencer

Supercharger Hunter
Mar 31, 2016
4,460
5,058
Alameda, CA
I have a Sense Energy Monitor that shows me how much solar power I am generating and how much energy my home is using every microsecond. It is nice for logging and realizing I have left the oven on but I would REALLY love if I could have it calculate any free solar and instead of sending it back to the grid, dump it into my Tesla instead.

I don't know how to program much, but after a few years of following both Sense and Tesla there have been unofficial APIs emerged and now support for them are in almost any language. So I checked out TeslaPy and the Sense_API on GitHub and using a couple of quick cut and pastes from their examples I came up with TeslaSense.

Check it out at GitHub:


Charge your Tesla with surplus solar generation as detected by your Sense Energy Monitor - First Release

TeslaSense logs into your Sense Energy Monitor and your Tesla account and tracks the amount of surplus energy your solar system is generating and asks your Tesla to start or stop charging and adjusts the amps used for charging, based on the amount of free solar and updates every minute.

If you have this app running and plug your Tesla in you can charge using ANY model of EVSE and the Python3 script will get information from your car about what capabilities your connection has and then will track the energy usage in your location, allocating any spare power to charging, up to the limits of your wall connector.

It plays nicely with the Tesla App allowing you to see the changes as they happen and gives feedback about what is happening with the app on the standard output.

You will need to edit this app, placing your Username and Password for your Sense Energy Monitor account, and your login for your Tesla account in the appropriate locations. The first time this python script is run you will be prompted for your password by Tesla and you will receive a confirmation code, paste that back into the app and you will be logged in securely and you can watch as the app detects your surplus solar and uses that to set the charging rate on your car. Before sunrise and after the sun starts going down or anytime there are too many power draws in your location the app will ask your Tesla to turn off charging. When the surplus solar returns, the charging will start again.
I haven't gotten a chance to do a TON of edge cases, but I'll update any fixes at the GitHub site. Would love everyone's feedback and I am sure it could easily be modified to talk to other energy monitors, perhaps even Tesla's for those of you with Tesla Solar too
 
I also have a (small, 3.8kW) solar install and a Sense monitor, so will definitely give this a go - thanks for writing it.

We have net metering so I guess there’s no financial saving, but I do like the idea of charging the car using home-grown power. There’s not much excess generation at this time of year, given the short days, but OTOH we’re not using the a/c either.
 

Randy Spencer

Supercharger Hunter
Mar 31, 2016
4,460
5,058
Alameda, CA
I have NO trouble charging the car in the summer, so I don't think about it, the reason I wrote this app is because I have great difficulty charging the car in winter (and I put up my solar too late to get Net Metering, although I have heard some horror stories, so probably just as happy). With this app I don't have any time of the day that I am not max charging my car with the energy I have, so nothing is going back to the grid (for the paltry return they give me) until I have used as much as I can.

Screen Shot 2022-02-03 at 1.46.56 PM.png

This is before, when I did the charging by hand, I would not notice for minutes or hours that it was over or under charging

Screen Shot 2022-02-03 at 1.48.24 PM.png

This is after writing the app, you can see how often it changes and hugs the generation. I did take the car while the hot tub was heating before noon, so you can see when I got back and you can see I have times when I get more power than the charger can take.
 

Randy Spencer

Supercharger Hunter
Mar 31, 2016
4,460
5,058
Alameda, CA
OK, updates available to my python script that controls your Tesla and only uses extra solar generation to charge your car.
Lots of bugs fixed and functionality that wasn't really there on the first release, I crossed my fingers that you guys wouldn't look at it initially, so check it out now.

Also, thinking how Tesla doesn't like their name in apps I changed the repository to be called TesSense, incase anyone ever wants to make this a real thing it has a name no one else is apparently using that doesn't have the word Tesla in it.


Much more in code documentation too, so hopefully it's easy to figure out
 
I’m new to this and also do not have net metering. I do not want to send electricity back unnecessarily . I’m looking at enphase w/ batteries vs Tesla panels w/ powerwalls. I have two teslas, and we just have the mobile connectors. Could this be an option for me or does it require the wall connector(s)?
 

Randy Spencer

Supercharger Hunter
Mar 31, 2016
4,460
5,058
Alameda, CA
Works with any EVSE, it keeps you from charging your car when there isn't any sun but it does require owning a Sense Energy Monitor.

Tesla Panels and PowerWalls are the best, and priced that way. If you get either solution they will charge from the sun during the day and you can use that power to charge your car and run your home at night, but that will wear down the batteries. Since I already have non-Tesla panels I cannot get PWs here so I put my spare solar into my cars and motorcycle, but I am home during the sunny part of the day, many have to work then.

If you need to charge *right now* so you can travel you can always just quit the app and set the charging amps to max in the Tesla app, or hit up a Supercharger, off-peak it's cheaper to charge at those here than it is to charge at home (barely).

edit: I continue to update the code as I find bugs so look for updates on GitHub. I have posted three versions and I found a fatal bug just now in the code there, so there is bound to be more updates
 
  • Like
Reactions: Stampee

Sporty

Member
Supporting Member
Apr 20, 2019
550
595
Seattle
Works with any EVSE, it keeps you from charging your car when there isn't any sun but it does require owning a Sense Energy Monitor.

Tesla Panels and PowerWalls are the best, and priced that way. If you get either solution they will charge from the sun during the day and you can use that power to charge your car and run your home at night, but that will wear down the batteries. Since I already have non-Tesla panels I cannot get PWs here so I put my spare solar into my cars and motorcycle, but I am home during the sunny part of the day, many have to work then.

If you need to charge *right now* so you can travel you can always just quit the app and set the charging amps to max in the Tesla app, or hit up a Supercharger, off-peak it's cheaper to charge at those here than it is to charge at home (barely).

edit: I continue to update the code as I find bugs so look for updates on GitHub. I have posted three versions and I found a fatal bug just now in the code there, so there is bound to be more updates

What motorcycle do you have? I’ve see a couple of news articles but haven’t been following then too closely. How far does it go on a charge?
 

Randy Spencer

Supercharger Hunter
Mar 31, 2016
4,460
5,058
Alameda, CA
I have a couple of 2007 Vectrix Maxiscooters. They come with NiMH batteries out of the box. Similar tech to gel lead acid batts, but opposite chemistry. The guy who designed them also designed the Li Ion batt for the Leaf so he made them compatible sizes. You can drop 18-20 Leaf cells in a Vectrix and you have converted it to Lithium. Just did one last summer. Doubled the range to maybe 80-100 miles city, I see less than 60 highway. But it's a nice big bike with room for me and my wife, full fairing looks just like a Honda Silverwing. So I can go anywhere in the Bay Area now, I could probably hit Sacramento, but I would have to charge to get back. I also added a J1772 port, but it still only charges at 2kW or so.

Cleaning up the code for TesSense, so I'll have another release this weekend. No longer exits on full batt or driving or disconnected, so you can come home and plug in and it will regain control. Now I need to fix it if I am traveling and plug into an L2 charger away from home.
 
Aloha Randy,
Sorry if my questions are stupid. I think this might be the answer to charging our soon to be delivered model 3. We are off grid solar in Hawaii, 6.1kw(max) possible 24amps(max) . Concern is the Tesla stopping charge when refrigerator or some appliance kicks on. if this solutions allocates the surplus power being fed to the batteries that would be great. I presently have an outback Mate3 energy monitor that uses Optics RE to tell me on the web what my production/output is. Does that take the place of "Sense energy monitor" if not, which one would I need.
Mahalo Nui Loa
Jim Ward
 

Randy Spencer

Supercharger Hunter
Mar 31, 2016
4,460
5,058
Alameda, CA
I can answer questions about the program but I no nothing about your hardware. The app reads from sense and every two minutes changes the charge rate based on conditions like solar generation and home usage. If you can get that info and your off grid setup can handle the car continuing to charge for two minutes before changing. Might work.

It could be modified to do all sorts of things. But not by me.
 
I can answer questions about the program but I no nothing about your hardware. The app reads from sense and every two minutes changes the charge rate based on conditions like solar generation and home usage. If you can get that info and your off grid setup can handle the car continuing to charge for two minutes before changing. Might work.

It could be modified to do all sorts of things. But not by me.
Mahalo!
 
I have a Sense Energy Monitor that shows me how much solar power I am generating and how much energy my home is using every microsecond. It is nice for logging and realizing I have left the oven on but I would REALLY love if I could have it calculate any free solar and instead of sending it back to the grid, dump it into my Tesla instead.

I don't know how to program much, but after a few years of following both Sense and Tesla there have been unofficial APIs emerged and now support for them are in almost any language. So I checked out TeslaPy and the Sense_API on GitHub and using a couple of quick cut and pastes from their examples I came up with TeslaSense.

Check it out at GitHub:



I haven't gotten a chance to do a TON of edge cases, but I'll update any fixes at the GitHub site. Would love everyone's feedback and I am sure it could easily be modified to talk to other energy monitors, perhaps even Tesla's for those of you with Tesla Solar too
How does one install this? I have an iPhone and Mac.
 

Randy Spencer

Supercharger Hunter
Mar 31, 2016
4,460
5,058
Alameda, CA
This is a command line application so launch the Terminal app.

You need to have Python 3 (not the default 2.7) installed on the Mac you use and you need to have the support packages installed (as documented in the source) and you need to modify the source with your passwords and preferences. I just installed Xcode, it's a great source editor. Then you simply issue the command from the terminal: python3 tessense.py

It will connect to your Sense monitor if you put in the correct password. It will connect to your car (if you have more than one you need to edit the source code to specify which car). Then it will check for free power and if it finds some it will start your car charging. If you plug in after the app is going the car starts charging on it's own and the app will limit it to use just free solar. Since it only checks every two minutes it will allow a bit of grid power thru as things change, so it's not super specific at the edge. It may let 250 watts from the grid charge your car but if it goes over that it'll slow the charging. It can only tell your car to change in one amp increments and:
1 amp * 240ish volts = 240ish watts.

Glad to help with any questions
 

Products we're discussing on TMC...

About Us

Formed in 2006, Tesla Motors Club (TMC) was the first independent online Tesla community. Today it remains the largest and most dynamic community of Tesla enthusiasts. Learn more.

Do you value your experience at TMC? Consider becoming a Supporting Member of Tesla Motors Club. As a thank you for your contribution, you'll get nearly no ads in the Community and Groups sections. Additional perks are available depending on the level of contribution. Please visit the Account Upgrades page for more details.


SUPPORT TMC
Top