jesserizzo / envoy_reader

MIT License
37 stars 26 forks source link

Cleanup detection and avoid calling endpoints that are not present #64

Closed bdraco closed 3 years ago

bdraco commented 3 years ago

Your code has been rated at 10.00/10 (previous run: 10.00/10, +0.00)

bdraco commented 3 years ago

@gtdiehl I remember from https://github.com/home-assistant/core/pull/42857 that you have write access to this repo so hopefully you can take a look.

Thanks!

gtdiehl commented 3 years ago

@bdraco I know I've been silent for a bit. COVID, family issues, death, and other stuff have side-lined me. I will take a look this tomorrow I promise! I'll see about testing this against the various platforms. I should be able to get access to Envoys running <3.9, >=3.9, and >=4.x.

bdraco commented 3 years ago

@bdraco I know I've been silent for a bit. COVID, family issues, death, and other stuff have side-lined me. I will take a look this tomorrow I promise! I'll see about testing this against the various platforms. I should be able to get access to Envoys running <3.9, >=3.9, and >=4.x.

Sorry man that sucks that the world hasn't been kind lately. Hope it gets better for you soon.

Thanks for taking a look 👍

gtdiehl commented 3 years ago

@bdraco Thank you!

I was able to test this on my Envoy running 3.15 and another running 4.x. I still want to run it against <3.9 as these don't have the same pages. I wasn't able to find one today. Hopefully I can find one tomorrow.

gtdiehl commented 3 years ago

@bdraco I tested on several Enphase Envoys, R3.7.31, R3.17.3, D4.2.27, and D5.0.49. Everything looks good! I want to run a couple more tests but need the sun shining. I just want to test when the Envoy is and is not using a Production CT.

If everything looks good tomorrow and I merge the code into the master branch, do you need a new release on PyPi as well?

bdraco commented 3 years ago

@bdraco I tested on several Enphase Envoys, R3.7.31, R3.17.3, D4.2.27, and D5.0.49. Everything looks good! I want to run a couple more tests but need the sun shining. I just want to test when the Envoy is and is not using a Production CT.

If everything looks good tomorrow and I merge the code into the master branch, do you need a new release on PyPi as well?

Excellent. Thanks for testing.

A new release would be great as I would like to get https://github.com/home-assistant/core/pull/48709 moved forward

gtdiehl commented 3 years ago

@bdraco I'm sorry but I found a problem. I found an Evoy running D4.x firmware that does not have a Production CT (eim activeCount = 0), and I'm not getting back Daily, Weekly, or Lifetime production values.

I'll try and debug it a bit more later tonight.

Here is the output from the envoy_reader.py and JSON

Reading...
production:              5891
consumption:             5806
daily_production:        'NoneType' object has no attribute 'json'
daily_consumption:       0
seven_days_production:   'NoneType' object has no attribute 'json'
seven_days_consumption:  0
lifetime_production:     'NoneType' object has no attribute 'json'
lifetime_consumption:    0
inverters_production:    {...}

/production.json

{"production":[{"type":"inverters","activeCount":34,"readingTime":1618005986,"wNow":5891,"whLifetime":10279087},{"type":"eim","activeCount":0,"measurementType":"production","readingTime":1618006624,"wNow":5814.869,"whLifetime":0.0,"varhLeadLifetime":0.0,"varhLagLifetime":0.0,"vahLifetime":0.0,"rmsCurrent":47.811,"rmsVoltage":243.277,"reactPwr":465.213,"apprntPwr":5816.157,"pwrFactor":1.0,"whToday":0.0,"whLastSevenDays":0.0,"vahToday":0.0,"varhLeadToday":0.0,"varhLagToday":0.0}],"consumption":[{"type":"eim","activeCount":0,"measurementType":"total-consumption","readingTime":1618006624,"wNow":5811.099,"whLifetime":0.0,"varhLeadLifetime":0.0,"varhLagLifetime":0.0,"vahLifetime":0.0,"rmsCurrent":47.534,"rmsVoltage":243.146,"reactPwr":-465.213,"apprntPwr":11557.595,"pwrFactor":0.5,"whToday":0.0,"whLastSevenDays":0.0,"vahToday":0.0,"varhLeadToday":0.0,"varhLagToday":0.0},{"type":"eim","activeCount":0,"measurementType":"net-consumption","readingTime":1618006624,"wNow":-3.769,"whLifetime":0.0,"varhLeadLifetime":0.0,"varhLagLifetime":0.0,"vahLifetime":0.0,"rmsCurrent":0.278,"rmsVoltage":243.015,"reactPwr":-0.0,"apprntPwr":33.697,"pwrFactor":0.0,"whToday":0,"whLastSevenDays":0,"vahToday":0,"varhLeadToday":0,"varhLagToday":0}],"storage":[{"type":"acb","activeCount":0,"readingTime":0,"wNow":0,"whNow":0,"state":"idle"}]}

/api/v1/production

{
  "wattHoursToday": 17920,
  "wattHoursSevenDays": 276614,
  "wattHoursLifetime": 10279087,
  "wattsNow": 5894
}
bdraco commented 3 years ago

Does that one work with the current master or is that a regression with this PR?

gtdiehl commented 3 years ago

It's a regression with this PR.

This is the ouput using the same Envoy with the current master code

Reading...
production:              5680
consumption:             5292
daily_production:        29477
daily_consumption:       0
seven_days_production:   279353
seven_days_consumption:  0
lifetime_production:     10290644
lifetime_consumption:    0
inverters_production:    {...}
bdraco commented 3 years ago

Thanks. I'll start some tests tomorrow with the data dump you provided

gtdiehl commented 3 years ago

From what I can tell, when the Envoy type is PC the endpoint_production_v1_results never gets populated, during getData().

We would still need to retrieve the endpoint_production_v1_results when Production Metering is disabled as the JSON data for Daily, Weekly, and Lifetime Production is not available from /production.json but from /api/v1/production

Hope this helps! 😃

bdraco commented 3 years ago

Working on adding test fixtures for 3.17.3 3.9.36 4.2.27 5.0.49

I'll push something later today

bdraco commented 3 years ago

@gtdiehl Should be fixed now

gtdiehl commented 3 years ago

I've tested against different firmware and configurations. Looks good to me!

bdraco commented 3 years ago

Thanks!