mirror of
https://github.com/home-assistant/core.git
synced 2025-06-25 01:21:51 +02:00
Fix unknown Pure AQI in Sensibo (#144924)
* Fix unknown Pure AQI in Sensibo * Fix mypy
This commit is contained in:
@ -252,7 +252,7 @@ class SensiboClimate(SensiboDeviceBaseEntity, ClimateEntity):
|
||||
return features
|
||||
|
||||
@property
|
||||
def current_humidity(self) -> int | None:
|
||||
def current_humidity(self) -> float | None:
|
||||
"""Return the current humidity."""
|
||||
return self.device_data.humidity
|
||||
|
||||
|
@ -15,5 +15,5 @@
|
||||
"iot_class": "cloud_polling",
|
||||
"loggers": ["pysensibo"],
|
||||
"quality_scale": "platinum",
|
||||
"requirements": ["pysensibo==1.1.0"]
|
||||
"requirements": ["pysensibo==1.2.1"]
|
||||
}
|
||||
|
@ -101,14 +101,25 @@ MOTION_SENSOR_TYPES: tuple[SensiboMotionSensorEntityDescription, ...] = (
|
||||
value_fn=lambda data: data.temperature,
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
def _pure_aqi(pm25_pure: PureAQI | None) -> str | None:
|
||||
"""Return the Pure aqi name or None if unknown."""
|
||||
if pm25_pure:
|
||||
aqi_name = pm25_pure.name.lower()
|
||||
if aqi_name != "unknown":
|
||||
return aqi_name
|
||||
return None
|
||||
|
||||
|
||||
PURE_SENSOR_TYPES: tuple[SensiboDeviceSensorEntityDescription, ...] = (
|
||||
SensiboDeviceSensorEntityDescription(
|
||||
key="pm25",
|
||||
translation_key="pm25_pure",
|
||||
device_class=SensorDeviceClass.ENUM,
|
||||
value_fn=lambda data: data.pm25_pure.name.lower() if data.pm25_pure else None,
|
||||
value_fn=lambda data: _pure_aqi(data.pm25_pure),
|
||||
extra_fn=None,
|
||||
options=[aqi.name.lower() for aqi in PureAQI],
|
||||
options=[aqi.name.lower() for aqi in PureAQI if aqi.name != "UNKNOWN"],
|
||||
),
|
||||
SensiboDeviceSensorEntityDescription(
|
||||
key="pure_sensitivity",
|
||||
@ -119,6 +130,7 @@ PURE_SENSOR_TYPES: tuple[SensiboDeviceSensorEntityDescription, ...] = (
|
||||
FILTER_LAST_RESET_DESCRIPTION,
|
||||
)
|
||||
|
||||
|
||||
DEVICE_SENSOR_TYPES: tuple[SensiboDeviceSensorEntityDescription, ...] = (
|
||||
SensiboDeviceSensorEntityDescription(
|
||||
key="timer_time",
|
||||
|
2
requirements_all.txt
generated
2
requirements_all.txt
generated
@ -2293,7 +2293,7 @@ pysaj==0.0.16
|
||||
pyschlage==2025.4.0
|
||||
|
||||
# homeassistant.components.sensibo
|
||||
pysensibo==1.1.0
|
||||
pysensibo==1.2.1
|
||||
|
||||
# homeassistant.components.serial
|
||||
pyserial-asyncio-fast==0.16
|
||||
|
2
requirements_test_all.txt
generated
2
requirements_test_all.txt
generated
@ -1875,7 +1875,7 @@ pysabnzbd==1.1.1
|
||||
pyschlage==2025.4.0
|
||||
|
||||
# homeassistant.components.sensibo
|
||||
pysensibo==1.1.0
|
||||
pysensibo==1.2.1
|
||||
|
||||
# homeassistant.components.acer_projector
|
||||
# homeassistant.components.crownstone
|
||||
|
@ -11,7 +11,7 @@ import pytest
|
||||
from syrupy.assertion import SnapshotAssertion
|
||||
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import Platform
|
||||
from homeassistant.const import STATE_UNKNOWN, Platform
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers import entity_registry as er
|
||||
|
||||
@ -45,3 +45,14 @@ async def test_sensor(
|
||||
|
||||
state = hass.states.get("sensor.kitchen_pure_aqi")
|
||||
assert state.state == "moderate"
|
||||
|
||||
mock_client.async_get_devices_data.return_value.parsed[
|
||||
"AAZZAAZZ"
|
||||
].pm25_pure = PureAQI(0)
|
||||
|
||||
freezer.tick(timedelta(minutes=5))
|
||||
async_fire_time_changed(hass)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
state = hass.states.get("sensor.kitchen_pure_aqi")
|
||||
assert state.state == STATE_UNKNOWN
|
||||
|
Reference in New Issue
Block a user