Welcome to Tesla Motors Club
Discuss Tesla's Model S, Model 3, Model X, Model Y, Cybertruck, Roadster and More.
Register

TesSense - Control your Tesla charging from your Sense Energy Monitor

This site may earn commission on affiliate links.
If you comment out the "controllist =" line (I believe it's that way by default) that TP section of the code is not called at all.

Looks like one of the libraries I call crapped out, client.py is not anything I wrote. I often have the app choke overnight, so I added code to sleep it from 8pm to 8am. It's a work in progress.
 
My poor coding skills are in full effect. I tried commenting out the entire CheckTPLink() section as well as the tp_task = CheckTPLink() line, although the script failed to run after the edits.

I can't seem to find a "controllist =" line. Did you mean "tasks = controller.tasks"? Or maybe "controller = SenseLink(None)"?

This morning the script failed around 8am just like yesterday. What you put together seems to work reliably until the morning, and I don't really need the charge data to be sent to Sense. If I could get the script to automatically run in the morning I would be in good shape. I tried setting up a crontab job to automatically run the script in the morning, although I haven't been able to get it to work yet. I'll try another way and see what happens.
 
Good stuff !

My to-do list of future projects includes this type of optimized home PV usage. My only step in this direction so far is to swap out my clipper creek EVSE for an internet enabled Grizzl-E. My thought at the moment is to monitor excess current and set the Grizzl-E to the same Amps (or close enough).

The more advanced project will be to add heat pumps and temperature readings to the mix. I want to operate them when needed, and when the COP is high.
 
My poor coding skills are in full effect. I tried commenting out the entire CheckTPLink() section as well as the tp_task = CheckTPLink() line, although the script failed to run after the edits.

I can't seem to find a "controllist =" line. Did you mean "tasks = controller.tasks"? Or maybe "controller = SenseLink(None)"?

This morning the script failed around 8am just like yesterday. What you put together seems to work reliably until the morning, and I don't really need the charge data to be sent to Sense. If I could get the script to automatically run in the morning I would be in good shape. I tried setting up a crontab job to automatically run the script in the morning, although I haven't been able to get it to work yet. I'll try another way and see what happens.
The controllist= line is actually devicelist= in your version that was on GitHub. If it's NOT assigned then that whole TPLink section of the code is ignored, I hadn't actually tried it before, I changed the code now to assign it to null so I don't get an unassigned variable error.

I have a newer stable version that I uploaded to GitHub. That way if you broke your copy you can just start again with a few new features. I now track the temps of the car when its awake and open the windows if it gets too hot in the car, then close them when they cool down. My assumption being that if it's gonna rain the clouds will cool the car interior, tracking the feature to see if it ever sleeps with the windows open, we'll see.
 
My to-do list of future projects includes this type of optimized home PV usage. My only step in this direction so far is to swap out my clipper creek EVSE for an internet enabled Grizzl-E. My thought at the moment is to monitor excess current and set the Grizzl-E to the same Amps (or close enough).

The more advanced project will be to add heat pumps and temperature readings to the mix. I want to operate them when needed, and when the COP is high.
You don't need fancy hardware, the Tesla allows you to remotely control the amps it's charging with and my Python script reads the free solar at your location and then sets the Tesla to charge with that excess only (it's right on the line and only updates every two minutes, so some power might be pulled from the grid.

You don't need an internet enabled EVSE, and I have added features to control TPLink Smartplugs so when the sun goes behind a cloud or the hot tub kicks in it can turn off named Smartplugs until the free solar returns. I have an Electric Motorcycle and my wife has an smaller EV that both charge on 120v so I use the Smartplugs to control them and space heaters (next project will be the hot tub itself).

It wasn't so important to have such an app now, in the summertime, I get so much sun my car is always topped up, but in the winter it's a struggle to charge the car w/o a ton of the power coming from the grid which shows up in my monthly bill.
 
Last edited:
Despite my best efforts I wasn't able to figure out how to prevent the 8am failure. I've "phoned a friend" so there might be a solution coming.

I changed logging to INFO and this is what it outputs on startup
Initating connection to Sense...
INFO:root:Spoofed Device ID: ae93b6c9681dd9264da950e7f345df138ad956d3
INFO:root:Starting SenseLink controller
=============================
Looking for TPLink smartplugs
-----------------------------
======================================
No TPLink (KASA) E-Meter devices found
--------------------------------------
INFO:root:Starting UDP server
ERROR:root:Error creating endpoint [Errno 48] Address already in use
Starting connection to Carla... ( **.** -***.*** )

Wed 10:18 AM Away from home, wait two minutes
* The car was actually away from home in this instance. If it was home it charges as you would expect.
I thought the ERROR:root might be because either the name Tesla or the mac address in the code was already used within Sense, although after changing both, the error still pops up. Randy, do you see this error on your side?
 
Despite my best efforts I wasn't able to figure out how to prevent the 8am failure. I've "phoned a friend" so there might be a solution coming.

I changed logging to INFO and this is what it outputs on startup

* The car was actually away from home in this instance. If it was home it charges as you would expect.
I thought the ERROR:root might be because either the name Tesla or the mac address in the code was already used within Sense, although after changing both, the error still pops up. Randy, do you see this error on your side?
Yikes, OK, sending you a PM
 
The address already in use error seems to have been related to a python process ID. I entered a ps -a command and it appears I had multiple old TesSense threads running. To kill the old processes I entered "kill -9 (process ID#)" one by one. Now that all of the other processes have been killed, Sense is able to see the spoofed TP-Link smart plug and should able to receive usage data.

We'll see if the 8am failure is fixed now as well.
 
This is working great!!! One question. If I wanted to ensure that the car is charged up to 80% by the next morning and the solar was not able to achieve that during the day, is there a command that could be entered to determine if car <MAX CHARGE and just turn on full charging for the night?
 
I have not written any such code, it seems it would be possible, if this is something that you do all the time you might easily modify the code I wrote in order to add that feature. If it's just a rare event the car can do that by itself by turning on scheduled charging, you can even set it up from the Tesla app