Skip to content

Commit

Permalink
[ENH] Update Summary mode repository
Browse files Browse the repository at this point in the history
  • Loading branch information
dragarthPl committed May 14, 2024
1 parent ff8b48a commit e79bb98
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/main/summer_mode/summer_mode_repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ class ISummerModeRepository(ABC):
async def get_summer_mode(self) -> SummerMode:
pass

@abstractmethod
async def set_summer_mode(self, summer_mode: SummerMode) -> bool:
pass


class SummerModeRepository(ISummerModeRepository):
stream_ip: str
Expand All @@ -32,3 +36,15 @@ def __init__(self, configuration: Configuration, redis: Redis):
async def get_summer_mode(self) -> SummerMode:
stove_data = self.__redis.hgetall("stove_data")
return SummerMode(int(stove_data.get("summer_mode", 0)))

async def set_summer_mode(self, summer_mode: SummerMode) -> bool:
command = {
"component": "ecomax",
"parameter": "summer_mode",
"value": summer_mode.get_mode(),
}
try:
self.__redis.publish("command-channel", command)
except Exception:
return False
return True

0 comments on commit e79bb98

Please sign in to comment.