kellerza / pysma

Async library for SMA Solar's WebConnect interface
MIT License
59 stars 51 forks source link

Add Insulation Resistance Sensor #104

Closed peteraclausen closed 2 years ago

peteraclausen commented 2 years ago

I have a SMA inverter that sometimes shuts down due to the Insulation resistance dropping below 500 kOhm. Can this sensor be added to the integration please?

The new entry in the definitions.py would look something like this:

`

: PV Isolation Resistance

pv_isolation_resistance = Sensor(“6102_00254F00_0”, “pv_isolation_resistance”, unit=”kOhm”, factor=100, enabled=False)`

Thanks!

kellerza commented 2 years ago

Hi @peteraclausen can you please create a PR on definitions.py? for an example see #103

peteraclausen commented 2 years ago

Hi @kellerza

I'm not actually a developer, but I did know to look at the html code for the Insulation Resistance value from the SMA web interface:

https://i.imgur.com/OXf2CPr.jpg

And from looking at other entries in definitions.py, I surmised that adding the following entry would expose the Insulation Resistance value:

#: PV Isolation Resistance pv_isolation_resistance = Sensor( “6102_00254F00_0”, “pv_isolation_resistance”, unit=”kOhm”, factor=100, enabled=False )

I have never created a PR before and I'm not sure I would feel comfortable doing so.

Thanks

rklomp commented 2 years ago

@peteraclausen could you checkout my branch https://github.com/rklomp/pysma/tree/isolation_resistance and test with example.py if this works?

peteraclausen commented 2 years ago

@rklomp thank you so much for creating a branch with the isolation_resistance sensor added. I see where you made the update to definitions.py, but I'm unsure how exactly to drop that into my install. I asked around but I haven't gotten anything back yet.

So where do I drop the updated definitions.py (renamed as example.py) and how to I point my existing SMA integration to it?

Thanks and sorry for being such a noob when it comes to python.

rklomp commented 2 years ago

You can use the following commands on any linux host:

# git clone -b isolation_resistance https://github.com/rklomp/pysma.git
# cd pysma
# python3 example.py

The example.py script needs some command line parameters. Then if that runs successfully, see if the isolation resistance value is shown in the output.

peteraclausen commented 2 years ago

@rklomp Thanks, that did the trick. I tested it on all 8 of my inverters and they all returned the proper value.

Here's the output from one of them:

      status             Ok
               pv_power_a            381 W
               pv_power_b            580 W
               pv_power_c            579 W
             pv_voltage_a         240.77 V
             pv_voltage_b         356.31 V
             pv_voltage_c         358.57 V
             pv_current_a          1.585 A
             pv_current_b          1.629 A
             pv_current_c          1.617 A
  pv_isolation_resistance       17202.77 kOhm
               grid_power           1511 W
                frequency          60.02 Hz
               current_l1          6.078 A
               current_l2          6.078 A
               current_l3
               voltage_l1          124.8 V
               voltage_l2         125.36 V
               voltage_l3
                 power_l1            754 W
                 power_l2            757 W
                 power_l3              0 W
              sps_voltage
              sps_current
                sps_power              0 W
              total_yield      38010.486 kWh
              daily_yield
             pv_gen_meter      38010.486 kWh
INFO:__main__:Closing Session...

I have a SB 7.7 US40 and various SB 6.0 US41, SB7.0 US41 and SB 7.7 US41.

kellerza commented 2 years ago

Nice! Is this the expected value? Or should it be 1700kOhm only?

peteraclausen commented 2 years ago

That is the expected value and matches what I see in the SMA web GUI. By default, there is a safety cutoff at 500 kOhm, meaning that if the value drops below that, the inverter won't come online. When I deployed my inverters, I had one that would not come online initially because the value was around 400 kOhm, so I reduced the threshold to 350 kOhm to bring it up.

A few weeks later, I had another inverter that did not come online, and it had a value of 380 kOhm, so I dropped the trigger down to 300 kOhm. I'm finding this issue only seem to occur in early mornings when its very humid and once the sun comes out and dries everything up, all my inverters report values above 1,000 kOhm.

The measured value for this attribute is from around 100 kOhm to 3,000 kOhm.

Being able to track this attribute in Grafana for all 8 of my inverters will allow me to set the proper threshold on each inverter to ensure I don't dip below it.

rklomp commented 2 years ago

So the value now shown (17,202) is a factor 10 to high?

peteraclausen commented 2 years ago

Yes. I should have caught that.

Insulation Resistance

Actual reading:

maxedout

rklomp commented 2 years ago

If you do a git pull it will update and should have the correct factor. Can you test?

peteraclausen commented 2 years ago

Yep it now has the correct factor.

Example:

pv_isolation_resistance 2162.324 kOhm

And the web GUI:

2,162.32 kOhm

rklomp commented 2 years ago

See also https://github.com/home-assistant/core/pull/76937

I expect it to be available in the next major release of HA