Dymerz / SMA-SunnyBoy

A simple data retrieving from SMA SunnyBoy
https://sma-sunnyboy.readthedocs.io/en/latest/sma_sunnyboy.html
MIT License
39 stars 9 forks source link

Binary log parsing #9

Open RickMeasham opened 4 years ago

RickMeasham commented 4 years ago

The 5-minute logs are available at /dyn/genericLog.bin, however they're returned as binary data and script.xxxx.js decodes them and pushes them to the user as CSV.

This ticket isn't a bug report as these logs aren't yet implemented in the library. Instead it's a Feature ticket in case @Dymerz or anyone else has already done some work on rewriting the binary interpreter so we don't double up.

RickMeasham commented 4 years ago

getLogConfig is passed to getLogData which calls either getLogChunksByDate or getLogChunksByLastRowStamp with the log config. These functions then ultimately call convertRows which uses the log config to pull bytes from the row and convert them into values.

getLogConfig calls /dyn/genericLogCfg.bin to get the config. This too is a binary response that needs parsing. Sigh.

Dymerz commented 4 years ago

Ive tried to access to /dyn/genericLog.bin but without success so I've searched in the /scripts/vendor.xxxx.js and I've found the reference of functions you talk about, I haven't been deep into the script.

RickMeasham commented 4 years ago

I'm tempted to take the easy way out here and do what the graph endpoint appears to do: to get a 5 minute generation figure, subtract the total generation at the end of five minutes from the total generation at the end of the previous five minutes.

JSON Endpoint returns: Generation in period:
648511 -
648803 292
649612 809
650324 712
... ...

Heaps easier than parsing the binary data. Not as much fun though. But at the moment I need the numbers more than the fun.