meltaxa / solariot

Leverage your IoT enabled Solar PV Inverter to stream your solar energy usage data to a real time dashboard.
https://solariot.live
MIT License
207 stars 70 forks source link

Implementing some weird-ass multi-register logic around positive/negative values #39

Closed michael-robbins closed 3 years ago

michael-robbins commented 3 years ago

Currently in my SG5K-D inverter registers 5083 & 5084 are used for the amount and direction of power flowing through the Sungrow S100 smart meter.

If 5084 is 65535, then 5083 is treated as negative, and power is being exported to the grid. If 5084 is 0, then 5083 is treated as positive, and power is being imported from the grid.

I just kinda kept poking around with dumping all hundred or so registers and kept turning the oven on and off until I narrowed down what registers were telling me importing vs exporting from the grid.

My logic around using the 'indicator' register and reading from it is potentially a bit flaky once the indicator register is not really close to the other register, but it works for me? /shrug

But I feel it's better than seeing if the register > 60,000 and then treating it as negative (seemed a bit too hacky for me)

Thoughts? Feelings?

Edit #1: Another thing this PR does is allows multiple 'transformations' on the register value

So you can have this 'overflow' modifier as well as a 'divide by' modifier, as well as future modifiers if we introduce any!

michael-robbins commented 3 years ago

So tl;dr, this allows (me at least) to track the 'am I importing or exporting, and how much' question I've been unable to as of yet!

michael-robbins commented 3 years ago

Mad props to https://solarclarity.co.uk/wp-content/uploads//2018/12/TI_20180301_String-Inverters_Communication-Protocol_V10_EN.pdf

I used that to validate what I had currently set up as well as any possible extras I could add!

Note: The registers I'm using above are 'Reserved' but I'm guessing Sungrow are using them to expose the S100 Power Meter

bdog720 commented 3 years ago

@meltaxa could we merge this with master? I've tested the changes and they work for me