Skip to content

Commit

Permalink
updated multi coooker sensor properties and fixed ready_at property
Browse files Browse the repository at this point in the history
  • Loading branch information
sschirr committed Apr 22, 2024
1 parent fd16ea0 commit f4ae40e
Showing 1 changed file with 28 additions and 14 deletions.
42 changes: 28 additions & 14 deletions miio/integrations/chunmi/cooker_multi/cooker_multi.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ def stage(self) -> str:

@property
@sensor("Current temperature", unit="C")
def temperature(self) -> Optional[int]:
def temperature(self) -> int:
"""Current temperature, if idle.
Example values: 29
Expand All @@ -262,30 +262,44 @@ def temperature(self) -> Optional[int]:

@property
@sensor("Cooking finish time")
def ready_at(self) -> datetime.datetime:
def ready_at(self) -> Optional[datetime.datetime]:
"""Remaining minutes of the cooking process."""

if self.mode != OperationMode.PreCook and self.mode != OperationMode.Running:
return None

return (
datetime.datetime.now()
+ datetime.timedelta(
0, int(self.data["t_left"] + (self.data["t_pre"] * 60))
minutes=self.remaining
)
).replace(second=0, microsecond=0)

@property
@sensor("Cooking start delay")
def cooking_delayed(self) -> Optional[int]:
"""Wait n minutes before cooking / scheduled cooking."""
delay = int(self.data["t_pre"])
@sensor("Cooking process time remaining in minutes")
def remaining(self) -> int:
"""Remaining minutes of the cooking process. Includes optional precook phase."""

if delay >= 0:
return delay
if self.mode != OperationMode.PreCook and self.mode != OperationMode.Running:
return 0

remaining_minutes = int(self.data["t_left"]/60)
if self.mode == OperationMode.PreCook:
remaining_minutes = int(self.data["t_pre"])

return remaining_minutes

@property
@sensor("Cooking process delay time remaining in minutes (precook phase time remaining)")
def delay_remaining(self) -> int:
"""Remaining minutes of the cooking delay (precook phase)."""

return None
return max(0, self.remaining - self.duration)

@property
@sensor("Cooking duration")
@sensor("Cooking duration in minutes")
def duration(self) -> int:
"""Duration of the cooking process."""
"""Duration of the cooking process. Does not include optional precook phase."""
return int(self.data["t_cook"])

@property
Expand Down Expand Up @@ -316,7 +330,7 @@ def favorite(self) -> None:
class MultiCooker(Device):
"""Main class representing the multi cooker."""

_supported_models = [*MODEL_MULTI]
_supported_models = [MODEL_MULTI]

@command()
def status(self) -> CookerStatus:
Expand Down

0 comments on commit f4ae40e

Please sign in to comment.