Skip to content

Commit

Permalink
Add foot warmer support for Climate360 beds
Browse files Browse the repository at this point in the history
Add foot warmer support for Climate360 beds
  • Loading branch information
kbickar committed Jan 14, 2024
2 parents 0ec0eca + 14bc4c1 commit d852c11
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 2 deletions.
5 changes: 5 additions & 0 deletions asyncsleepiq/consts.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,14 @@

BED_LIGHTS = [RIGHT_NIGHT_STAND, LEFT_NIGHT_STAND, RIGHT_NIGHT_LIGHT, LEFT_NIGHT_LIGHT]


class FootWarmingTemps(int, enum.Enum):
OFF = 0
LOW = 31
MEDIUM = 57
HIGH = 72


FAVORITE = 1
READ = 2
WATCH_TV = 3
Expand Down Expand Up @@ -101,4 +103,7 @@ class End(str, enum.Enum):
"SetActuatorTargetPosition": "ACTS",
"SetTargetPresetWithoutTimer": "ASTP",
"GetCurrentPreset": "AGCP",
"GetFootwarmingPresence": "FWPG",
"SetFootwarmingSettings": "FWTS",
"GetFootwarmingSettings": "FWTG",
}
25 changes: 25 additions & 0 deletions asyncsleepiq/fuzion/foot_warmer.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
"""Foundation foor warmer for Fuzion SleepIQ API."""
from __future__ import annotations

from typing import Any

from ..consts import SIDES_FULL, FootWarmingTemps
from ..foot_warmer import SleepIQFootWarmer


class SleepIQFuzionFootWarmer(SleepIQFootWarmer):
"""Foot warmer representation for SleepIQ API."""

async def set_foot_warming(self, temperature: FootWarmingTemps, time: int) -> None:
"""Set foot warmer state through API."""
if time <= 0 or time > 360:
raise ValueError("Invalid Time, must be between 0 and 360")

args = [SIDES_FULL[self.side].lower(), temperature.name.lower(), str(time)]
await self._api.bamkey(self.bed_id, "SetFootwarmingSettings", args)
await self.update({})

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)
14 changes: 12 additions & 2 deletions asyncsleepiq/fuzion/foundation.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,20 @@
PRESET_SNORE,
PRESET_TV,
PRESET_ZERO_G,
SIDES_FULL,
End,
Mode,
Side,
Speed,
)
from ..foundation import SleepIQFoundation
from .preset import SleepIQFuzionPreset
from .actuator import SleepIQFuzionActuator
from .foot_warmer import SleepIQFuzionFootWarmer
from .light import SleepIQFuzionLight
from .preset import SleepIQFuzionPreset

FEATURE_NAMES = [
"bedType", # Not sure what best to call this, but there's one flag at the start of the list that's (from testing) always "dual".
"bedType", # Not sure what best to call this, but there's one flag at the start of the list that's (from testing) always "dual".
"pressureControlEnabledFlag",
"articulationEnableFlag",
"underbedLightEnableFlag",
Expand Down Expand Up @@ -51,6 +53,7 @@ async def init_features(self) -> None:
if self.features["articulationEnableFlag"]:
await self.init_actuators()
await self.init_presets({})
await self.init_foot_warmers()

async def update_foundation_status(self) -> None:
"""Update all foundation data from API."""
Expand Down Expand Up @@ -101,6 +104,13 @@ async def init_presets(self, data: dict[str, Any]) -> None:

await self.update_presets({})

async def init_foot_warmers(self) -> None:
"""Initialize list of foot warmers available on foundation."""
for side in [Side.LEFT, Side.RIGHT]:
result = await self._api.bamkey(self.bed_id, "GetFootwarmingPresence", args=[SIDES_FULL[side].lower()])
if result == "1":
self.foot_warmers.append(SleepIQFuzionFootWarmer(self._api, self.bed_id, side, 0, 0))

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 d852c11

Please sign in to comment.