-
Notifications
You must be signed in to change notification settings - Fork 61
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update to support Tesla Custom Integration re-write and add battery site support #341
Conversation
Makes sense to address #348 |
I just noticed the endpoint Anyone happen to know the difference between these two? If the note is accurate, it seems like to me we could simply just poll this endpoint without having to worry about waking up the vehicle. If it's asleep, it should just return the cached data. |
That seems new. We could use that to start but do we lose the info on whether a car is sleeping? I guess the online sensor may be enough to figure that out. This may also solve the issue of alandtse/tesla#251. I know you've been basically working yourself on this for like a month without my help. Are we getting to a point where we should consider taking it live? |
It appears to have the car state as well I've been running it 24/7 on a separate HA install and it's been working well so far. I think it's ready for use. If we could also release a beta version of the HA Tesla integration, that would be good to get some more folks to maybe test it out. There's a couple things I'd like to clean up on the integration though first but I'll continue to update that PR. |
Once it's in Dev it's basically beta, but you'll need to recruit people willing to test it.
This sounds fine. It can be the backup source when sleeping. |
Ah bummer, it looks like |
Just so it's tracked, please ensure conflicts are resolved so it merges cleanly. I can review and provide comments then. This should also make sure we don't obliterate any fixes that have been submitted by others. You can just look at closed PRs as there haven't been too many. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assume the tests we had for the HA components will be migrated to the /tesla app right? After you add the headers in and confirm the documentation state, I'll do a breaking change release based on your first post. We can then integrate your PR into dev
and let it run for a week or two. We'll want to do the official release to master when you are available to handle any major bugs so let me know what your preferred schedule is. I'm based in California and we can target a weekend.
Thanks again for all your hard work on this. I can't adjust your status on this repo, but I can make you a maintainer on tesla if you'd like to help out more actively.
That sounds good. I'm in the same time zone so that should work. I'm happy to continue helping out when I can so more than happy to be a maintainer on the Tesla integration. |
feat!: add support for solar systems and powerwall (#341)
Overview
This update includes support for the Tesla Custom Integration re-write and adds support for Tesla solar systems with Powerwall. The general design I'm following is what I see from other libraries like simplisafe-python and Home Assistant documentation. I'm not a developer by any means, so please provide feedback/recommendations. The general flow for using teslajsonpy is:
teslajsonpy.Controller
.Controller.connect
to get a list of products from Tesla to createself._vehicle_list
andself._energysite_list
. Two new arguments available,include_vehicles
andinclude_energysites
which defaults True.Controller.generate_car_objects
which returns a dictionary of car objects by VIN number.Controller.generate_energysite_objects
which returns a dictionary of energysite objects by energy site ID.The car and energy site objects are the primary means to get car and energy site data and send commands.
Changes
car.py
that contains aTeslaCar
class.energy.py
that contains energy site classes.Controller.generate_car_objects
that generatesTeslaCar
objects and stores them intoself.cars
by vin.Controller.generate_energysite_objects
that generatesSolarSite
,PowerwallSite
orSolarPowerwallSite
objects and stores them in theself.energysites
dictionary byenergysite_id
.Controller.update
to now just send a single request to thePRODUCT_LIST
endpoint (instead of bothPRODUCT_LIST
andVEHICLE_LIST
to get all products on a Tesla account. From there, create a list of carsself._vehicle_list
and energy sitesself._energysite_list
.TeslaCar
andEnergySite
when instantiated.include_vehicles
andinclude_energysites
arguments toController.connect
which default to True. This provides the option to completely ignore vehicles or energysites.Controller.command
,Controller.get
andController.post
methods. OnlyController._wake_up
was usingpost
which now usesController.api
.Fixes
Energy sites
For energy sites, there's a few variations that a user could have and we still need to get more JSON response examples from as many different setups as possible. My guess is the gateway is what determines how the data is published, whether it's a Tesla inverter, home energy gateway, Powerwall 2, etc. What I can tell right now is:
SITE_DATA
endpoint.BATTERY_DATA
andBATTERY_SUMMARY
There's a couple variations on solar setups but in general, I'm treating it as essentially three from a Class design perspective:
As you can see in the changes, I created a base
EnergySite
class and three child classes,SolarSite
,PowerwallSite
andSolarPowerwallSite
. The first two inherit fromEnergySite
andSolarPowerwallSite
inherit fromSolarSite
andPowerwallSite
. There's probably a better way to do this, but this is what I came up with so far.Notes
Controller
(self) when callingController._generate_car_objects
so we have access to all methods on the Controller compared to energysites, I'm only passing inself.api
, the specific energysite inself.energysites
andself.__power_data[energysite_id]
.To Do / Request Help
is None
since they don't return anything. I'm assuming we probably want to do something like check ifController.api
is being called, butunittest.mock.patch
doesn't work with async functions..rst
in/docs/teslajsonpy
based on my understanding of skimming over the sphinx documentation but I haven't figured out how to build and update everything.