Closed sillygoose closed 3 years ago
Thanks for the tip on using 'yield from', changes made and tested on my three inverter system. I changed the code in _read_body() to return None or result_body, read() and the new read_logging() still return True/False, the rest of the changes is just the code moved to read() and read_logging().
Since I only picked up Python a few weeks ago, I can start with the new-style async coding for the future. There is still so much to learn, thanks for setting me straight on everything to date.
Best regards.
Rick
I installed pylint since flake8 didn't seem to complain about the unused variable sensors in _read_body(). I also removed the warnings so the read() will behave as before (read_logger() returns an empty dict if you give it a bad key or a date before it was commissioned).
Hi @sillygoose,
I am failing to understand the int(sensors[0].key)
in read_logger
Are you still using read_logger
and extract_logger
?
If so, is it still working in the latest version? Would you be able to add some tests to cover your usecase?
On May 31, 2021, at 7:21 AM, René Klomp @.***> wrote: Hi @sillygoose, I am failing to understand the int(sensors[0].key) in read_logger
Are you still using read_logger and extract_logger? If so, is it still working in the latest version? Would you be able to add some tests to cover your usecase? If you are not using it anymore. Can it be removed?
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe.
These are how I pull the production history from the Sunny Boy web interface, it looks like René has expanded read_logger() and added extract_logger().
As for 'int(sensors[0].key)’, that is because the original code was copied from read() but only has a single value passed in the sensor list, I use 28672 to get the fine history and 28704 to collect daily history. These permit calculation of the day, month, year, and lifetime production and the code could be updated to pass just the history type:
async def read_logger(self, key=None, start=None, end=None):
"""Read a logging key and return the results."""
if self._new_session_data is None:
payload = {"destDev": [], "key": []}
result_body = await self._read_body(URL_DASH_LOGGER, payload)
else:
payload = {
"destDev": [],
"key": key,
"tStart": start,
"tEnd": end,
}
…
If you wish to remove it I can just use the current SMA class as a base class and add it in my code, especially now that René has separated the Sensor class which is something I don’t use.
Best regards.
Rick
Hi Rick,
I have refactored the read_logger
method in #70
Could you review this change?
I have multiple inverters and used pysma to access them and report individual and aggregate results using Sensor as a base class (no changes necessary at this point). While looking at the page sources from a browser session with an inverter I was able to see how to access the inverter data logs used to graph production using the path 'dyn/getLogger.json' and sending a json request with start and end times:
The results are a list of times and total production values:
I used this to request the values for calculating the production for the day, month, and year in my application and avoid having Home Assistant do this. I am new to all of this but the changes are simple additions so I hope you find them suitable to add.
Rick