dlarrick / pykumo

Python library to interact with Mitsubishi KumoCloud devices via their local API
MIT License
33 stars 12 forks source link

resolves #18, mitigate variable referenced before assignment error if… #24

Closed cjkrolak closed 2 years ago

cjkrolak commented 2 years ago

… Timeout exception causes response to be undefined

cjkrolak commented 2 years ago

before fix: Timeout querying KumoCloud: HTTPSConnectionPool(host='geo-c.kumocloud.com', port=443): Read timed out. (read timeout=0.1) Traceback (most recent call last): File "C:\Users\cjkro\onedrive\documents\github\ThermostatSupervisor\kumolocal.py", line 571, in <module> Thermostat, Zone = tc.thermostat_basic_checkout( File "C:\Users\cjkro\onedrive\documents\github\ThermostatSupervisor\thermostat_common.py", line 953, in thermostat_basic_checkout Thermostat, Zone = create_thermostat_instance(api, thermostat_type, zone, File "C:\Users\cjkro\onedrive\documents\github\ThermostatSupervisor\thermostat_common.py", line 921, in create_thermostat_instance Thermostat = ThermostatClass(zone) File "C:\Users\cjkro\onedrive\documents\github\ThermostatSupervisor\kumolocal.py", line 53, in __init__ self.device_id = self.get_target_zone_id(self.zone_number) File "C:\Users\cjkro\onedrive\documents\github\ThermostatSupervisor\kumolocal.py", line 68, in get_target_zone_id kumos = self.make_pykumos() File "..\pykumo\pykumo\pykumo.py", line 625, in make_pykumos for iu in list(self.get_indoor_units()): File "..\pykumo\pykumo\pykumo.py", line 562, in get_indoor_units self._fetch_if_needed() File "..\pykumo\pykumo\pykumo.py", line 522, in _fetch_if_needed if response.ok: UnboundLocalError: local variable 'response' referenced before assignment

after fix: Timeout querying KumoCloud: HTTPSConnectionPool(host='geo-c.kumocloud.com', port=443): Read timed out. (read timeout=0.1) No JSON returned from KumoCloud; check credentials?

dlarrick commented 2 years ago

I've included the equivalent of this fix in https://github.com/dlarrick/pykumo/pull/25 and will close this PR and the issue when that's merged.

dlarrick commented 2 years ago

Thanks, I incorporated this change into 0.2.0