Skip to content

Commit

Permalink
Fix pm25 is aqi value for Pure device
Browse files Browse the repository at this point in the history
  • Loading branch information
gjohansson-ST committed Aug 18, 2024
1 parent e99f08b commit 33763ef
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
10 changes: 5 additions & 5 deletions pysensibo/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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"]
Expand Down
14 changes: 13 additions & 1 deletion pysensibo/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

from dataclasses import dataclass
from datetime import datetime
from enum import IntEnum
from typing import Any


Expand All @@ -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
Expand Down Expand Up @@ -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

0 comments on commit 33763ef

Please sign in to comment.