CharlesGillanders / alphaess

This Python library logs in to www.alphaess.com and retrieves data on your Alpha ESS inverter, photovoltaic panels, and battery if you have one.
MIT License
22 stars 9 forks source link

Added second_data from api/ESS/GetSecondDataBySn to enable reading of… #1

Closed xenomorpheus closed 1 year ago

xenomorpheus commented 2 years ago

… near real-time data from the battery.

Tested on Smile-5. Values look to match Alpha ESS Monitoring portal.

xenomorpheus commented 2 years ago

Fixes in error checking. Code simplification by removing "else" statement after terminal statement.

CharlesGillanders commented 2 years ago

Thanks for this - I'm currently (very slowly) working on a request to add the AlphaESS integration into core home assistant. As I'm far from a python expert I'd prefer to get that completed before accepting any code that I'm not personally familiar with.

I'm going to leave this pull request open until then.

xenomorpheus commented 2 years ago

Hi Charles.

A huge thank you for your explanation and your extremely useful code. I didn't even know it was possible to get data from AlphaEss. You have certainly helped me a great deal.

Today I am attempting to use derived code to optimally charge my electric car.

I've done a few code clean-ups, and refactors. I will be pushing a few updates in my fork.

A couple of code pointers.

I feel that there is a bug in the error checking used in about 4 places.

    if "info" in json_response and json_response["info"] != "Success": 

I feel it should be ...

  if "info" not in json_response or json_response["info"] != "Success": 

Another pointer, is code can be simplified by removing the "else" statement when following a "terminal statement" such as "return" or "throw". Also saves indenting the code.

Again thank you for your git repo. Massive help to me.

CharlesGillanders commented 1 year ago

Closing as no longer required, this data is now in the main library

eviltabouleh commented 1 year ago

Thanks for the added functionality @CharlesGillanders . I (we) really appreciate your efforts. I've been able to use python to run an edited version of the apitest.py to set/adjust my charge periods. Now to make it work from homeassistant . Then automate based on solar forecast Many thanks