Skip to content

Commit

Permalink
Complete the API calls (#115)
Browse files Browse the repository at this point in the history
  • Loading branch information
joostlek authored Jun 18, 2024
1 parent c5bd413 commit c2619a2
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 0 deletions.
24 changes: 24 additions & 0 deletions src/airgradient/airgradient.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,30 @@ async def request_led_bar_test(self) -> None:
"""Request LED bar test on AirGradient device."""
await self._set_config("ledBarTestRequested", value=True)

async def set_display_brightness(self, brightness: int) -> None:
"""Set display brightness on AirGradient device."""
await self._set_config("displayBrightness", brightness)

async def set_led_bar_brightness(self, brightness: int) -> None:
"""Set LED bar brightness on AirGradient device."""
await self._set_config("ledBarBrightness", brightness)

async def enable_sharing_data(self, *, enable: bool) -> None:
"""Enable or disable sharing data on AirGradient device."""
await self._set_config("postDataToAirGradient", value=enable)

async def set_co2_automatic_baseline_calibration(self, days: int) -> None:
"""Set CO2 automatic baseline calibration on AirGradient device."""
await self._set_config("abcDays", days)

async def set_nox_learning_offset(self, offset: int) -> None:
"""Set NOx learning offset on AirGradient device."""
await self._set_config("noxLearningOffset", offset)

async def set_tvoc_learning_offset(self, offset: int) -> None:
"""Set TVOC learning offset on AirGradient device."""
await self._set_config("tvocLearningOffset", offset)

async def close(self) -> None:
"""Close open client session."""
if self.session and self._close_session:
Expand Down
24 changes: 24 additions & 0 deletions tests/test_airgradient.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,30 @@ async def test_config(
lambda client: client.request_led_bar_test(),
{"ledBarTestRequested": True},
),
(
lambda client: client.set_display_brightness(50),
{"displayBrightness": 50},
),
(
lambda client: client.set_led_bar_brightness(50),
{"ledBarBrightness": 50},
),
(
lambda client: client.enable_sharing_data(enable=True),
{"postDataToAirGradient": True},
),
(
lambda client: client.set_co2_automatic_baseline_calibration(50),
{"abcDays": 50},
),
(
lambda client: client.set_nox_learning_offset(50),
{"noxLearningOffset": 50},
),
(
lambda client: client.set_tvoc_learning_offset(50),
{"tvocLearningOffset": 50},
),
],
)
async def test_setting_config(
Expand Down

0 comments on commit c2619a2

Please sign in to comment.