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
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