vincentwolsink / home_assistant_enphase_envoy_installer

This is a HACS custom integration for Enphase Envoys with firmware version 7 and up.
Apache License 2.0
61 stars 12 forks source link

Prevent recursive calls for EnvoyData #62

Closed mnederlof closed 1 year ago

mnederlof commented 1 year ago

Hopefully this will prevent recursive calls more definitively, if they occur, we'd know sooner anyway.

mnederlof commented 1 year ago

Somehow None.get resolves to __main__.EnvoyMeteredWithCT No clue why this happens though

mnederlof commented 1 year ago

Just removed the __getattr__ method completely and updated appropriate calls. Please verify though 😇

mnederlof commented 1 year ago

One thing to remember, is that whenever a AttributeError is raised in a class, which has a __getattr__ method defined in the class, python will call that method to see if it resolves to anything...

Have not verified in python how/where, it is just a observation. If we catch the AttributeError ourselves, we can do something else with it.

vincentwolsink commented 1 year ago

It is pretty hard to see now which calls used the magic getattr and which are regular class variables. There is also a magic getattr in EnvoyReader. Should we remove it there too?

(Btw, if you create a PR from your own fork I cannot contribute to it without merging first.)

mnederlof commented 1 year ago

It is pretty hard to see now which calls used the magic getattr and which are regular class variables. There is also a magic getattr in EnvoyReader. Should we remove it there too?

No not yet, i'm working on another PR that will remove that requirement as well, but that also implies some changes to the __init__.py file and how updates are handled.

mnederlof commented 1 year ago

(Btw, if you create a PR from your own fork I cannot contribute to it without merging first.)

I'll start committing branches to your repo then 😄