Skip to content

Commit

Permalink
Merge pull request #23 from jmwaldrip/main
Browse files Browse the repository at this point in the history
Fixing update bug for fuzion foot warmers and core climates
  • Loading branch information
kbickar committed Jan 18, 2024
2 parents a30d661 + 3028930 commit 2742267
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 2 deletions.
6 changes: 5 additions & 1 deletion asyncsleepiq/fuzion/core_climate.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,9 @@ async def set_mode(self, temperature: CoreTemps, time: int) -> None:
async def update(self, data: dict[str, Any]) -> None:
"""Update the core climate data through the API."""
args = [SIDES_FULL[self.side].lower()]
self.preset = await self._api.bamkey(self.bed_id, "GetHeidiMode", args)
data = await self._api.bamkey(self.bed_id, "GetHeidiMode", args)
data = data.split()
self.temperature = CoreTemps[data[0].upper()]
self.is_on = self.temperature > 0
self.timer = data[1] if self.is_on else 0

7 changes: 6 additions & 1 deletion asyncsleepiq/fuzion/foot_warmer.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,9 @@ async def set_foot_warming(self, temperature: FootWarmingTemps, time: int) -> No
async def update(self, data: dict[str, Any]) -> None:
"""Update the foot warmer through the API."""
args = [SIDES_FULL[self.side].lower()]
self.preset = await self._api.bamkey(self.bed_id, "GetFootwarmingSettings", args)
data = await self._api.bamkey(self.bed_id, "GetFootwarmingSettings", args)
data = data.split()
self.temperature = FootWarmingTemps[data[0].upper()]
self.is_on = self.temperature > 0
self.timer = data[1] if self.is_on else 0

16 changes: 16 additions & 0 deletions asyncsleepiq/fuzion/foundation.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ async def update_foundation_status(self) -> None:
await self.update_lights()
await self.update_actuators({})
await self.update_presets({})
await self.update_foot_warmers()
await self.update_core_climates()

async def init_lights(self) -> None:
"""Initialize list of lights available on foundation."""
Expand Down Expand Up @@ -113,13 +115,27 @@ async def init_foot_warmers(self) -> None:
if result == "1":
self.foot_warmers.append(SleepIQFuzionFootWarmer(self._api, self.bed_id, side, 0, 0))

async def update_foot_warmers(self) -> None:
if not self.foot_warmers:
return

for foot_warmer in self.foot_warmers:
await foot_warmer.update({})

async def init_core_climates(self) -> None:
"""Initialize list of core climates available on foundation."""
for side in [Side.LEFT, Side.RIGHT]:
result = await self._api.bamkey(self.bed_id, "GetHeidiPresence", args=[SIDES_FULL[side].lower()])
if result == "true":
self.core_climates.append(SleepIQFuzionCoreClimate(self._api, self.bed_id, side, 0, 0))

async def update_core_climates(self) -> None:
if not self.core_climates:
return

for core_climate in self.core_climates:
await core_climate.update({})

async def fetch_features(self) -> None:
"""Update list of features available for foundation from API."""
vals = await self._api.bamkey(self.bed_id, "GetSystemConfiguration")
Expand Down

0 comments on commit 2742267

Please sign in to comment.