Skip to content

Commit

Permalink
fix: add raw info debug field to non-aws devices too
Browse files Browse the repository at this point in the history
  • Loading branch information
dahlb committed Jan 12, 2025
1 parent dc455c2 commit bcc6639
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions src/blueair_api/device.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
import dataclasses
import logging

from .callbacks import CallbacksMixin
from .http_blueair import HttpBlueair
from .util import transform_data_points, safely_get_json_value
from dataclasses import dataclass, field
from logging import getLogger

_LOGGER = logging.getLogger(__name__)
_LOGGER = getLogger(__name__)


@dataclasses.dataclass(slots=True)
@dataclass(slots=True)
class Device(CallbacksMixin):
@classmethod
async def create_device(cls, api, uuid, name, mac, refresh=False):
Expand All @@ -33,6 +32,8 @@ async def create_device(cls, api, uuid, name, mac, refresh=False):
return device

api: HttpBlueair
raw_info : dict[str: any] = field(repr=False, init=False)

uuid: str | None = None
name: str | None = None
timezone: str | None = None
Expand Down Expand Up @@ -63,7 +64,9 @@ async def create_device(cls, api, uuid, name, mac, refresh=False):

async def refresh(self):
_LOGGER.debug("Requesting current attributes...")
self.raw_info = {}
attributes = await self.api.get_attributes(self.uuid)
self.raw_info["attributes"] = attributes
_LOGGER.debug(f"result: {attributes}")
if "brightness" in attributes:
self.brightness = int(attributes["brightness"])
Expand Down Expand Up @@ -94,7 +97,9 @@ async def refresh(self):
else:
self.wifi_working = False
if self.compatibility != "sense+":
for data_point in transform_data_points(await self.api.get_data_points_since(self.uuid)):
datapoints = transform_data_points(await self.api.get_data_points_since(self.uuid))
self.raw_info["datapoints"] = datapoints
for data_point in datapoints:
_LOGGER.debug(data_point)
self.pm25 = safely_get_json_value(data_point, "pm25", int)
self.pm10 = safely_get_json_value(data_point, "pm10", int)
Expand Down

0 comments on commit bcc6639

Please sign in to comment.