Improve error handing in kaiterra data retrieval when no aqi data is present (#112885)

* Update api_data.py

change log level on typeerror on line 103 from error to debug, it occurs too often to be useful as an error

* Update api_data.py

restore error level and add a type check instead

* Update homeassistant/components/kaiterra/api_data.py

actually filter for aqi being None rather than None or 0

Co-authored-by: Erik Montnemery <erik@montnemery.com>

---------

Co-authored-by: Erik Montnemery <erik@montnemery.com>
This commit is contained in:
Anil Daoud 2024-05-15 22:22:58 +08:00 committed by GitHub
parent fd8dbe0367
commit 8eaf471dd2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -87,6 +87,7 @@ class KaiterraApiData:
main_pollutant = POLLUTANTS.get(sensor_name) main_pollutant = POLLUTANTS.get(sensor_name)
level = None level = None
if aqi is not None:
for j in range(1, len(self._scale)): for j in range(1, len(self._scale)):
if aqi <= self._scale[j]: if aqi <= self._scale[j]:
level = self._level[j - 1] level = self._level[j - 1]