Noltari / aioairzone-cloud

Python library to control Airzone via Cloud API
Apache License 2.0
3 stars 0 forks source link

Convert Error when humidity value is None #1

Closed niko34 closed 1 year ago

niko34 commented 1 year ago

hile setting up Airzone Cloud Integration, I can select my home (so credentials are ok), I then get an error in the logs : `Logger: homeassistant.components.airzone_cloud.coordinator Source: components/airzone_cloud/coordinator.py:40 Integration: Airzone Cloud (documentation, issues) First occurred: 26 juin 2023 à 19:12:08 (50 occurrences) Last logged: 26 juin 2023 à 20:10:12

Unexpected error fetching airzone_cloud data: int() argument must be a string, a bytes-like object or a real number, not 'NoneType' Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 283, in _async_refresh self.data = await self._async_update_data() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/components/airzone_cloud/coordinator.py", line 40, in _async_update_data await self.airzone.update() File "/usr/local/lib/python3.11/site-packages/aioairzone_cloud/cloudapi.py", line 530, in update await self._update() File "/usr/local/lib/python3.11/site-packages/aioairzone_cloud/cloudapi.py", line 516, in _update await asyncio.gather(tasks) File "/usr/local/lib/python3.11/site-packages/aioairzone_cloud/cloudapi.py", line 503, in update_zones await asyncio.gather(tasks) File "/usr/local/lib/python3.11/site-packages/aioairzone_cloud/cloudapi.py", line 488, in update_zone zone.update(device_data) File "/usr/local/lib/python3.11/site-packages/aioairzone_cloud/zone.py", line 80, in update super().update(data) File "/usr/local/lib/python3.11/site-packages/aioairzone_cloud/hvac.py", line 344, in update self.humidity = int(data[API_HUMIDITY]) ^^^^^^^^^^^^^^^^^^^^^^^ TypeError: int() argument must be a string, a bytes-like object or a real number, not 'NoneType'`

If I check what is coming from Airzone Cloud API, I have this :

...ent_air_min': {'fah': 59, 'celsius': 15}, 'range_sp_stop_air_min': {'fah': 59, 'celsius': 15}, 'zone_sched_available': True, 'humidity': None, 'setpoint_air_cool': {'celsius': 23.5, 'fah': 74}, 'setpoint_air_dry': {'celsius': 23.5, 'fah': 74}, 'setpoint_air_vent'

You can see humidity is None. This None value cannot be convert to int. I just modified the source code on my homeassistant install to check the None value before converting to int and the integration work as expected. If the author see this message, the solution to avoid this issue is easy.

Noltari commented 1 year ago

hile setting up Airzone Cloud Integration, I can select my home (so credentials are ok), I then get an error in the logs : `Logger: homeassistant.components.airzone_cloud.coordinator Source: components/airzone_cloud/coordinator.py:40 Integration: Airzone Cloud (documentation, issues) First occurred: 26 juin 2023 à 19:12:08 (50 occurrences) Last logged: 26 juin 2023 à 20:10:12

Unexpected error fetching airzone_cloud data: int() argument must be a string, a bytes-like object or a real number, not 'NoneType' Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 283, in _async_refresh self.data = await self._async_update_data() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/components/airzone_cloud/coordinator.py", line 40, in _async_update_data await self.airzone.update() File "/usr/local/lib/python3.11/site-packages/aioairzone_cloud/cloudapi.py", line 530, in update await self._update() File "/usr/local/lib/python3.11/site-packages/aioairzone_cloud/cloudapi.py", line 516, in _update await asyncio.gather(tasks) File "/usr/local/lib/python3.11/site-packages/aioairzone_cloud/cloudapi.py", line 503, in update_zones await asyncio.gather(tasks) File "/usr/local/lib/python3.11/site-packages/aioairzone_cloud/cloudapi.py", line 488, in update_zone zone.update(device_data) File "/usr/local/lib/python3.11/site-packages/aioairzone_cloud/zone.py", line 80, in update super().update(data) File "/usr/local/lib/python3.11/site-packages/aioairzone_cloud/hvac.py", line 344, in update self.humidity = int(data[API_HUMIDITY]) ^^^^^^^^^^^^^^^^^^^^^^^ TypeError: int() argument must be a string, a bytes-like object or a real number, not 'NoneType'`

If I check what is coming from Airzone Cloud API, I have this :

...ent_air_min': {'fah': 59, 'celsius': 15}, 'range_sp_stop_air_min': {'fah': 59, 'celsius': 15}, 'zone_sched_available': True, 'humidity': None, 'setpoint_air_cool': {'celsius': 23.5, 'fah': 74}, 'setpoint_air_dry': {'celsius': 23.5, 'fah': 74}, 'setpoint_air_vent'

You can see humidity is None. This None value cannot be convert to int. I just modified the source code on my homeassistant install to check the None value before converting to int and the integration work as expected. If the author see this message, the solution to avoid this issue is easy.

Fixed in 8d40862a4bb2989782e83f2f31d3259082741ab1

niko34 commented 1 year ago

Thank you !