Waqi State unknown if value is string (#97617)

This commit is contained in:
Joost Lekkerkerker
2023-08-04 13:06:40 +02:00
committed by Franck Nijhof
parent 20bddec328
commit c5747dffbc
+4 -2
View File
@@ -2,6 +2,7 @@
from __future__ import annotations
import asyncio
from contextlib import suppress
from datetime import timedelta
import logging
@@ -141,8 +142,9 @@ class WaqiSensor(SensorEntity):
@property
def native_value(self):
"""Return the state of the device."""
if self._data is not None:
return self._data.get("aqi")
if value := self._data.get("aqi"):
with suppress(ValueError):
return float(value)
return None
@property