israndy / tessense Goto Github PK
View Code? Open in Web Editor NEWCharge your Tesla with surplus solar generation as detected by your Sense Energy Monitor
Charge your Tesla with surplus solar generation as detected by your Sense Energy Monitor
Occasionally I get the following error and have to retry later in the day.
Traceback (most recent call last):
File "/data/projects/TesSense-new/TesSenseTes.py", line 543, in
asyncio.run(main())
File "/usr/lib/python3.9/asyncio/runners.py", line 44, in run
return loop.run_until_complete(main)
File "/usr/lib/python3.9/asyncio/base_events.py", line 642, in run_until_complete
return future.result()
File "/data/projects/TesSense-new/TesSenseTes.py", line 538, in main
await asyncio.gather(*tasks)
File "/data/projects/TesSense-new/TesSenseTes.py", line 248, in TesSense
print(' last seen ' + vehicles[CAR].last_seen(), end='')
File "/home/brypi/.local/lib/python3.9/site-packages/teslapy/init.py", line 626, in last_seen
raise ValueError('Timestamp is in the future')
First off, thanks for all the work on this. This thing is awesome and works great out of the box. I did have one issue:
I'm using the 120v mobile charger so on a 15a circuit I get 12A*120V = 1440 Watts of power for Tesla Charging.
The Tesla side of the code seems correct on voltage.
Level: 53 %, Limit 80 %, 5.0 MPH 114 Volts 2.74 kWh added,
But then the Tesla bubble in Sense is 1440*2 = ~2880 Watts
My short term hack was to divide the value on line 136 by 2
volts = int(sense.active_voltage[0] + sense.active_voltage[1])/2
I'm pretty sure the voltage issue is only on the sense side but I'll see what it does as the sun goes down this evening. If I come up with a reasonable fix (likely using the Tesla voltage number is it seems like it's half of the sense number), I'll send it to you.
Hi Randy,
great project, thanks for sharing!
I noticed that on my M3 (2019) the minimum charge rate request that it will actually acknowledge is 5A, whereas in your code it is 2A.
Note, that it doesn't give an error when I issue car.command('CHARGING_AMPS', charging_amps = 3), however the car.get_vehicle_data()['charge_state']['charge_current_request'] will only return 5 (or higher).
Do you know if this is car specific, or location specific? I'm in EU, so a 3 phase on board charger installed.
Hi israndy,
First of all thank you very much for developing this script. However, I have just noticed that the script cannot log into tesla account anymore. I get the following error:
_```
File "E:\py\Lib\site-packages\requests\models.py", line 1021, in raise_for_status
raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 412 Client Error: Endpoint is only available on fleetapi. Visit https://developer.tesla.com/docs for more info for url: https://owner-api.teslamotors.com/api/1/vehicles
Could you please advise how to resolve it?
Thank you so much for sharing this!
I have noticed one issue though, which is an error message of "Window_Control Failed unsupported_command", which happens when calling the (vent? close?) window commands as of March 2023 (*possibly as early as January 2023?).
I found a few references online that suggested this is due to Tesla removing the function: https://www.notateslaapp.com/news/1136/tesla-to-remove-window-auto-close-features-due-to-new-regulations
Background:
I don't have any of the Sense or TPLink stuff, but I have a Tesla Powerwall 2/Gateway, and am running the jasonacox/pypowerwall (https://github.com/jasonacox/pypowerwall/) to easily access the instant grid/solar/home/battery power usage from the Powerwall Gateway over the local network (and make that data accessible to SmartThings home automation).
I was able to modify your code and get it working with the local gateway data instead of the Sense monitor, and set it to automatically stop charging the car at 4pm (to avoid draining the Powerwall or using peak grid power from 4-9PM). (After I clean it up, I would like to get it posted to GitHub- pypowerwall runs as a docker container, and I was thinking that it would be really useful to figure out how to package my updated script to run in the pypowerwall docker, and accept the email/lat/long/night-time hours, and teslapy token as environmental variables, with a web api route to turn on and off the auto-solar-charging in case someone wanted to disable or turn it on it with a simple GET call to an endpoint on the pypowerwall webserver ).
US/Central 3.12.2 (main, Mar 5 2024, 10:50:29) [GCC 8.3.0]
Initating connection to Sense...
Traceback (most recent call last):
File "/home/pi/Downloads/TesSense.py", line 454, in
asyncio.run(main())
File "/usr/lib/python3.12/asyncio/runners.py", line 194, in run
return runner.run(main)
^^^^^^^^^^^^^^^^
File "/usr/lib/python3.12/asyncio/runners.py", line 118, in run
return self._loop.run_until_complete(task)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.12/asyncio/base_events.py", line 685, in run_until_complete
return future.result()
^^^^^^^^^^^^^^^
File "/home/pi/Downloads/TesSense.py", line 450, in main
await asyncio.gather(*tasks)
File "/home/pi/Downloads/TesSense.py", line 154, in TesSense
mycar = tesla.vehicle_list()[1]
~~~~~~~~~~~~~~~~~~~~^^^
IndexError: list index out of range
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.