diff --git a/pysensibo/__init__.py b/pysensibo/__init__.py index 263dd22..42919ca 100644 --- a/pysensibo/__init__.py +++ b/pysensibo/__init__.py @@ -11,7 +11,7 @@ from aiohttp import ClientResponse, ClientSession, ClientTimeout from .exceptions import AuthenticationError, SensiboError -from .model import MotionSensor, Schedules, SensiboData, SensiboDevice +from .model import MotionSensor, PureAQI, Schedules, SensiboData, SensiboDevice APIV1 = "https://home.sensibo.com/api/v1" APIV2 = "https://home.sensibo.com/api/v2" @@ -249,12 +249,12 @@ async def async_get_devices_data(self) -> SensiboData: # noqa: C901 "measurements_integration", False ) pure_prime_integration = pure_conf.get("prime_integration", False) - if dev["productModel"] != "pure": - pm25 = measure.get("pm25") - pm25_pure = measure.get("pm25") + if dev["productModel"] == "pure" and (pm25 := measure.get("pm25")): + pm25 = None + pm25_pure = PureAQI(pm25) else: pm25 = measure.get("pm25") - pm25_pure = measure.get("pm25") + pm25_pure = None # Binary sensors for main device room_occupied = dev["roomIsOccupied"] diff --git a/pysensibo/model.py b/pysensibo/model.py index 534d1a5..82a6a49 100644 --- a/pysensibo/model.py +++ b/pysensibo/model.py @@ -4,6 +4,7 @@ from dataclasses import dataclass from datetime import datetime +from enum import IntEnum from typing import Any @@ -28,7 +29,7 @@ class SensiboDevice: feelslike: float | None humidity: int | None pm25: float | None - pm25_pure: int | None + pm25_pure: PureAQI | None tvoc: int | None co2: int | None etoh: float | None @@ -145,3 +146,14 @@ class Schedules: days: list[str] time: str next_utc: datetime + + +class PureAQI(IntEnum): + """Pure AQI value. + + PM2.5 values in Pure devices are AQI values. + """ + + GOOD = 1 + MODERATE = 2 + BAD = 3