funzie19 / hubitat-solaredge

Hubitat driver to query the Solaredge API for inverter metrics
GNU General Public License v3.0
3 stars 4 forks source link

Site Power Flow Fails When Unsupported #4

Open xcguy opened 2 years ago

xcguy commented 2 years ago

Some SolarEdge installations do not support Site Power Flow, so the API call for currentPowerFlow returns empty/null object for siteCurrentPowerFlow (documented top of page 25 API manual). The code doesn't expect this scenario, throws a null pointer exception in querySitePowerFlowEndpoint() when it attempts to access the power flow data (like currentPower). Generic exception handler expects HttpResponseException and thus throws another exception when it tries to process the null exception. Recommend code add check for site power flow data: if (r.data.siteCurrentPowerFlow) { And log a warning that the site doesn't support that data. Also recommend changing generic exception handler to specific HttpResponseException: } catch (groovyx.net.http.HttpResponseException e) {

jvcaloen commented 1 month ago

Hello @funzie19 and @xcguy

I was experiencing the same issue, I applied @xcguy proposed changes to the latest version and they work correctly. No longer have the error messages about siteCurrentPowerFlow @funzie19 Could you reconsider merging the proposed changes?

Thanks a lot for providing this driver !

Thanks Jean.