StephanJoubert / home_assistant_solarman

Home Assistant component for Solarman collectors used with a variety of inverters.
Apache License 2.0
544 stars 199 forks source link

Support for other Modbus Function Codes #8

Closed jmccrohan closed 2 years ago

jmccrohan commented 2 years ago

Hi Stephan,

Thanks for this integration; I'm just after discovering it.

Like yourself, I have also been trying to reverse engineer the Solarman V5 protocol and have developed pysolarmanv5. It might be an easier way to implement support for other Modbus function codes. Access to the holding registers would be particularly useful for hybrid inverters to set SOC etc.

Let me know what you think.

Regards, Jon

StephanJoubert commented 2 years ago

Hi Jon,

I have looked at setting parameters - especially in my case controlling grid-export so it may be very useful. Will have a look and experiment a bit to see the possibilities.

Regards

jmccrohan commented 2 years ago

Hi Stephan,

I took some time this evening to go through your code and to try to get it working with my Solis inverter. I got it working, but I need to make some changes.

On a Solis inverter, the realtime information is stored in input (read-only) registers (Modbus Function Code 04), rather than holding registers. Also my inverter stores 32 bit values as big endian, where as your inverter seems to store them as little endian.

Register 1001: 0x1234
Register 1002: 0x5678
vs
Register 1001: 0x5678
Register 1002: 0x1234

Rather than trying to retrofit this into your existing code, would you be open to using pysolarmanv5? If you are, I will work on a PR and add additional configuration options such as word swap etc.

Let me know your thoughts.

StephanJoubert commented 2 years ago

@jmccrohan . I had a look at pysolarmanv5, but not yet had the opportunity to experiment with it. I am certainly open to integrating it so if you work on a PR it would be appreciated.

TheAnt1dot3 commented 2 years ago

hey guys,

I'm also an owner of a v5 compatible data logger stick. I've already tested with your pysolarmanV5 (thanks alot for that @jmccrohan) and i am able to read out my registers. I won't mind trying to help out with integrating pysolarmanV5 with hass solarman since i believe this would benefit a growing amount of people.

Give me a shout if you need some hands :)

Thanks !

jmccrohan commented 2 years ago

Hi @StephanJoubert,

I've been working away on this as time allows, and would like to get your views on a few things before I submit the PR.

Thanks for the great work.

Jon

StephanJoubert commented 2 years ago

Hi Jon,

I like the suggestions and agree that it will make the component easier to use. I have already merged a PR that replaced the configuration in the yaml file with the config flow, so the next update will be rather large and probably the ideal place for the changes.

  1. Agree
  2. We can add it in the parameters.yaml file - I would suggest the top portion not per-parameter if that makes sense. I would actually like to trim the yaml file slightly.

    requests:
    - start: 0x0003
    end: 0x0070
    function: 1 <-- inserted here?
    - start: 0x0096  
    end: 0x00f8
    function: 2 <-- inserted here?
  3. Sounds great, I was not aware of that option.
  4. Agree
  5. The rule parser has a bit more than only the data type since the field (ex Uint32) may consist of registers that are not contagious. Found that on the deye specifically. I may not fully understand what you have in mind?
  6. Yes we can so away with the "lastUpdate" once the debug messages are there. However I found the status_connection quite useful since HA gives me a graph to see the history of the connection which is quite useful.
  7. Yes absolutely. I used the "sunsynk" name in the start and it stuck. It has no meaning at all (I don't even have a synsynk inverter). solarman makes much more sense.

Looking forward to the PR.

Stephan