somm15 / PyViCare

Python Library to access Viessmann ViCare API
Apache License 2.0
130 stars 84 forks source link

Weird Errors in PyViCare.py #343

Closed E-niek closed 6 months ago

E-niek commented 6 months ago

I have the PyViCare API Plugin in Domoticz (in Docker). I works fine, but if I disable the plugin, and then enable it again, I see weird errors, like this:

2023-12-04 19:03:55.167 Viessmann API: Failed to initialize pyViCare: 'NoneType' object is not callable
2023-12-04 19:04:00.809 Error: Traceback (most recent call last):
2023-12-04 19:04:00.809 Error: File "Viessmann2", line 19, in <module>
2023-12-04 19:04:00.809 Error: File "/home/karels/.local/lib/python3.9/site-packages/PyViCare/PyViCare.py", line 26, in initWithCredentials
2023-12-04 19:04:00.809 Error: self.initWithExternalOAuth(ViCareOAuthManager(
2023-12-04 19:04:00.809 Error: File "/home/karels/.local/lib/python3.9/site-packages/PyViCare/PyViCare.py", line 31, in initWithExternalOAuth
2023-12-04 19:04:00.809 Error: self.__loadInstallations()
2023-12-04 19:04:00.809 Error: File "/home/karels/.local/lib/python3.9/site-packages/PyViCare/PyViCare.py", line 50, in __loadInstallations
2023-12-04 19:04:00.809 Error: self.installations = Wrap(data)
2023-12-04 19:04:00.809 Error: File "/home/karels/.local/lib/python3.9/site-packages/PyViCare/PyViCare.py", line 80, in Wrap
2023-12-04 19:04:00.809 Error: return [Wrap(x) for x in v]
2023-12-04 19:04:00.809 Error: File "/home/karels/.local/lib/python3.9/site-packages/PyViCare/PyViCare.py", line 80, in <listcomp>
2023-12-04 19:04:00.809 Error: return [Wrap(x) for x in v]
2023-12-04 19:04:00.809 Error: File "/home/karels/.local/lib/python3.9/site-packages/PyViCare/PyViCare.py", line 82, in Wrap
2023-12-04 19:04:00.809 Error: return DictWrap(v)
2023-12-04 19:04:00.809 Error: File "/home/karels/.local/lib/python3.9/site-packages/PyViCare/PyViCare.py", line 75, in __init__
2023-12-04 19:04:00.809 Error: setattr(self, k, Wrap(v))
2023-12-04 19:04:00.809 Error: File "/home/karels/.local/lib/python3.9/site-packages/PyViCare/PyViCare.py", line 80, in Wrap
2023-12-04 19:04:00.809 Error: return [Wrap(x) for x in v]
2023-12-04 19:04:00.809 Error: File "/home/karels/.local/lib/python3.9/site-packages/PyViCare/PyViCare.py", line 80, in <listcomp>
2023-12-04 19:04:00.809 Error: return [Wrap(x) for x in v]
2023-12-04 19:04:00.809 Error: File "/home/karels/.local/lib/python3.9/site-packages/PyViCare/PyViCare.py", line 82, in Wrap
2023-12-04 19:04:00.809 Error: return DictWrap(v)
2023-12-04 19:04:00.809 Error: File "/home/karels/.local/lib/python3.9/site-packages/PyViCare/PyViCare.py", line 75, in __init__
2023-12-04 19:04:00.809 Error: setattr(self, k, Wrap(v))
2023-12-04 19:04:00.809 Error: File "/home/karels/.local/lib/python3.9/site-packages/PyViCare/PyViCare.py", line 84, in Wrap
2023-12-04 19:04:00.809 Error: return datetime.strptime(v, '%Y-%m-%dT%H:%M:%S.%f%z')
2023-12-04 19:04:00.809 Error: TypeError: 'NoneType' object is not callable
2023-12-04 19:04:04.081 Viessmann API: Error fetching data from Viessmann API: 'PyViCare' object has no attribute 'devices' 

if I, after seeing this, restart domoticz, from docker, it works fine with no errors. But this isn't nice, because now I can't disable the plugin, and enable it back on, without having to restart domoticz.

Hope you can help me.

woehrl01 commented 6 months ago

@E-niek I'm not aware how domoticz is using PyViCare. PyViCare itself does not have a globale state, that means the issue is in domoticz not cleaning up everything correctly. I currently don't see anything we can do here.