mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 11:17:21 +00:00
Fix unknown Pure AQI in Sensibo (#144924)
* Fix unknown Pure AQI in Sensibo * Fix mypy
This commit is contained in:
parent
c7cf9585ae
commit
9c4733595a
@ -252,7 +252,7 @@ class SensiboClimate(SensiboDeviceBaseEntity, ClimateEntity):
|
|||||||
return features
|
return features
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def current_humidity(self) -> int | None:
|
def current_humidity(self) -> float | None:
|
||||||
"""Return the current humidity."""
|
"""Return the current humidity."""
|
||||||
return self.device_data.humidity
|
return self.device_data.humidity
|
||||||
|
|
||||||
|
@ -15,5 +15,5 @@
|
|||||||
"iot_class": "cloud_polling",
|
"iot_class": "cloud_polling",
|
||||||
"loggers": ["pysensibo"],
|
"loggers": ["pysensibo"],
|
||||||
"quality_scale": "platinum",
|
"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,
|
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, ...] = (
|
PURE_SENSOR_TYPES: tuple[SensiboDeviceSensorEntityDescription, ...] = (
|
||||||
SensiboDeviceSensorEntityDescription(
|
SensiboDeviceSensorEntityDescription(
|
||||||
key="pm25",
|
key="pm25",
|
||||||
translation_key="pm25_pure",
|
translation_key="pm25_pure",
|
||||||
device_class=SensorDeviceClass.ENUM,
|
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,
|
extra_fn=None,
|
||||||
options=[aqi.name.lower() for aqi in PureAQI],
|
options=[aqi.name.lower() for aqi in PureAQI if aqi.name != "UNKNOWN"],
|
||||||
),
|
),
|
||||||
SensiboDeviceSensorEntityDescription(
|
SensiboDeviceSensorEntityDescription(
|
||||||
key="pure_sensitivity",
|
key="pure_sensitivity",
|
||||||
@ -119,6 +130,7 @@ PURE_SENSOR_TYPES: tuple[SensiboDeviceSensorEntityDescription, ...] = (
|
|||||||
FILTER_LAST_RESET_DESCRIPTION,
|
FILTER_LAST_RESET_DESCRIPTION,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
DEVICE_SENSOR_TYPES: tuple[SensiboDeviceSensorEntityDescription, ...] = (
|
DEVICE_SENSOR_TYPES: tuple[SensiboDeviceSensorEntityDescription, ...] = (
|
||||||
SensiboDeviceSensorEntityDescription(
|
SensiboDeviceSensorEntityDescription(
|
||||||
key="timer_time",
|
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
|
pyschlage==2025.4.0
|
||||||
|
|
||||||
# homeassistant.components.sensibo
|
# homeassistant.components.sensibo
|
||||||
pysensibo==1.1.0
|
pysensibo==1.2.1
|
||||||
|
|
||||||
# homeassistant.components.serial
|
# homeassistant.components.serial
|
||||||
pyserial-asyncio-fast==0.16
|
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
|
pyschlage==2025.4.0
|
||||||
|
|
||||||
# homeassistant.components.sensibo
|
# homeassistant.components.sensibo
|
||||||
pysensibo==1.1.0
|
pysensibo==1.2.1
|
||||||
|
|
||||||
# homeassistant.components.acer_projector
|
# homeassistant.components.acer_projector
|
||||||
# homeassistant.components.crownstone
|
# homeassistant.components.crownstone
|
||||||
|
@ -11,7 +11,7 @@ import pytest
|
|||||||
from syrupy.assertion import SnapshotAssertion
|
from syrupy.assertion import SnapshotAssertion
|
||||||
|
|
||||||
from homeassistant.config_entries import ConfigEntry
|
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.core import HomeAssistant
|
||||||
from homeassistant.helpers import entity_registry as er
|
from homeassistant.helpers import entity_registry as er
|
||||||
|
|
||||||
@ -45,3 +45,14 @@ async def test_sensor(
|
|||||||
|
|
||||||
state = hass.states.get("sensor.kitchen_pure_aqi")
|
state = hass.states.get("sensor.kitchen_pure_aqi")
|
||||||
assert state.state == "moderate"
|
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
|
||||||
|
Loading…
x
Reference in New Issue
Block a user