Waqi State unknown if value is string (#97617)

This commit is contained in:
Joost Lekkerkerker 2023-08-04 08:45:36 +02:00 committed by GitHub
parent 615d7f0da7
commit 1587ac2137
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -2,6 +2,7 @@
from __future__ import annotations from __future__ import annotations
import asyncio import asyncio
from contextlib import suppress
from datetime import timedelta from datetime import timedelta
import logging import logging
@ -141,8 +142,9 @@ class WaqiSensor(SensorEntity):
@property @property
def native_value(self): def native_value(self):
"""Return the state of the device.""" """Return the state of the device."""
if self._data is not None: if value := self._data.get("aqi"):
return self._data.get("aqi") with suppress(ValueError):
return float(value)
return None return None
@property @property