Open shred86 opened 2 years ago
The basic idea is that when you call the VEHICLE_SUMMARY API you get the same basic information as returned by PRODUCT_LIST and when you call VEHICLE_DATA, you get detailed info. I decided to put this in a single dict, because you probably need the basic and the detailed information and then its available in a single dict. I don't want to create a method for each API call, so the code is easier to maintain. Some time later I improved the vehicle dict to automatically call the VEHICLE_DATA API, but I didn't do that for other products. I wanted to keep the powerwall and solar panel interface similar to the vehicle interface and that's why both JSON responses are combined.
Ahh, I see. That definitely threw me for a loop as I thought I was going crazy. 😄 At a minimum, that may be worth documenting just in a sentence somewhere. Personally, I'd prefer to see the responses broken out into two separate dictionaries so it's clear which response came from which endpoint, but I can understand that you're trying to simplify it. I also kind of like just having only the response for the endpoint you're hitting display since it's easy to combine multiple CLI arguments, but I suppose it depends on the use case. For me, I'm trying to have folks with different Tesla solar system setups provide their JSON response which this tool you created to be the easiest to do that, but obviously having responses combined makes that a bit more difficult. It's easy enough to just fork and make some minor changes though. I appreciate you creating and maintaining this tool as it's been very helpful.
I noticed when I get a JSON response from the
SITE_DATA
endpoint in the CLI using the--site
argument, the data from thePRODUCT_LIST
endpoint is also being included.This is what the
SITE_DATA
endpoint return should look like:This is what's showing up when using
--site
from the CLI:You can see the additional information is coming from what's contained in
PRODUCT_LIST
, which is:I noticed when
get_site_data()
is being called, it's returningself
, which if I print outself
prior toget_site_data()
being called, it is the JSON response toPRODUCT_LIST
. So it just appears it's combining the two JSON responses.If I change the
get_site_data()
method to simply returnself.api('SITE_DATA')['response']
, it fixes the issue. However, I'm sure there's a reasonself.update
was used andreturn self
, but I can't figure it out. 😄