mlowijs / tesla_api

Lightweight Python API client for the Tesla API.
MIT License
80 stars 31 forks source link

Endpoint for Meter Aggregates #12

Closed scienceintheshed closed 4 years ago

scienceintheshed commented 4 years ago

Would like to access the same endpoint through this API as is available via "Powerwall_ip_address/API/metres/aggregates"...cant' find it in energy.py nor have I been able to re-create.

mlowijs commented 4 years ago

I don't personally own a Powerwall but will see what I can do, thanks!

scienceintheshed commented 4 years ago

Just solved it about an hour ago but need to wait until tomorrow to verify readings...

mlowijs commented 4 years ago

Cool, is it something you can create a PR for?

scienceintheshed commented 4 years ago

New to github so I will have to work out how to do that...there are quite a few more endpoints that I have now found so I will look at including all of them.

swm11 commented 4 years ago

scienceintheshed: I wrote the energy API based on mlowjs code to access Tesla cars via the cloud. So the energy API goes via the cloud rather than access the powerwall directly since I was unable to change settings by accessing the powerwall directly. I have, however, been able to get access to aggregate meter data directly from a Powerwall 2 - see: https://github.com/swm11/homeautomationegs/blob/master/powerwall/dumpPowerwallDaemon.py

scienceintheshed commented 4 years ago

Thanks for that...I can see your fork now...

I have been able to access the meter aggregates directly from the Powerwall wlan address for some time using he endpoints at https://github.com/vloschiavo/powerwall2. Problem was it tended to lose connection on a regular basis and needs to be manually reconnected, that's why I'm wanting to do it from the cloud.

Modifying your energy.py code with;

Helper function added by scienceintheshed.

def get_solar_power(self):
    return int(self.get_energy_site_live_status()["solar_power"])

gives me exactly what I want. I have a few more endpoints that I've added to my local copy of the energy.py code. Happy to share once I understand github a bit better.

swm11 commented 4 years ago

That's interesting - I occasionally see my Powerwall 2 disconnect, but my logging script retries a few times and it always appears to succeed.

mlowijs commented 4 years ago

@scienceintheshed I added your helper method and will release 2.0.1 to PyPI soon! Be aware we migrated the package to be async, so you'll have to await that method.