Skip to content

Commit

Permalink
Get some sensors from Mr.Steam units
Browse files Browse the repository at this point in the history
  • Loading branch information
gazoodle committed Feb 27, 2025
1 parent 3897e86 commit 973a016
Show file tree
Hide file tree
Showing 7 changed files with 89 additions and 46 deletions.
36 changes: 30 additions & 6 deletions src/geckolib/automation/async_facade.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,12 +172,13 @@ async def _facade_update(self) -> None:
if not self._spa.is_responding_to_pings:
wait_time = GeckoConfig.PING_FREQUENCY_IN_SECONDS
else:
self._water_care.change_watercare_mode(
await self._spa.async_get_watercare()
)
self._reminders_manager.change_reminders(
await self._spa.async_get_reminders()
)
if self._water_care.is_available:
self._water_care.change_watercare_mode(
await self._spa.async_get_watercare()
)
self._reminders_manager.change_reminders(
await self._spa.async_get_reminders()
)
self._on_config_device_change()

# After we've been round here at least once, we're ready
Expand Down Expand Up @@ -229,6 +230,29 @@ def _scan_outputs(self) -> None:
if sensor[1] in self._spa.accessors
]

if self._spa.struct.is_mr_steam:
self._sensors.extend(
[
GeckoSensor(
self, "Mr.Steam On/Off", self._spa.accessors["UserMode"]
),
GeckoSensor(
self, "Mr.Steam Aroma", self._spa.accessors["UserAroma"]
),
GeckoSensor(
self,
"Mr.Steam Temperature",
self._spa.accessors["UserSetpointG"],
self._spa.accessors["TempUnits"],
),
GeckoSensor(
self,
"Mr.Steam Runtime",
self._spa.accessors["RemainingRuntime"],
),
]
)

self._binary_sensors = [
GeckoBinarySensor(
self, binary_sensor[0], self._spa.accessors[binary_sensor[1]]
Expand Down
2 changes: 2 additions & 0 deletions src/geckolib/automation/reminders.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ def __init__(self, facade: GeckoAsyncFacade) -> None:
self._all_reminders: list[GeckoReminders.Reminder] = []
self._reminders_handler = None
self._last_update = None
if not facade.spa.struct.is_mr_steam:
self.set_availability(is_available=True)

@property
def reminders(self) -> list[Reminder]:
Expand Down
24 changes: 9 additions & 15 deletions src/geckolib/automation/watercare.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ def __init__(self, facade: GeckoAsyncFacade) -> None:
super().__init__(facade, "WaterCare", "WATERCARE")
self.active_mode: int | None = None
self._water_care_handler: GeckoWatercareProtocolHandler | None = None
if not facade.spa.struct.is_mr_steam:
self.set_availability(is_available=True)

@property
def mode(self) -> int | None:
Expand All @@ -37,7 +39,9 @@ def modes(self) -> list[str]:

@property
def state(self) -> str:
"""Return all the current state."""
"""Return the current state."""
if self.mode is None:
return "Unknown"
return GeckoConstants.WATERCARE_MODE_STRING[self.mode]

@property
Expand Down Expand Up @@ -71,20 +75,6 @@ def _on_watercare(
self._on_change(self, old_mode, self.active_mode)
self._water_care_handler = None

def obsolete_update(self) -> None:
"""Update the state."""
if self._water_care_handler is not None:
return

assert self._spa is not None # noqa: S101
self._water_care_handler = GeckoWatercareProtocolHandler.request(
self._spa.get_and_increment_sequence_counter(),
on_handled=self._on_watercare,
parms=self._spa.sendparms,
)
self._spa.add_receive_handler(self._water_care_handler)
self._spa.queue_send(self._water_care_handler, self._spa.sendparms)

def change_watercare_mode(self, new_mode: int) -> None:
"""Change the watercare mode."""
if self.active_mode != new_mode:
Expand All @@ -94,6 +84,8 @@ def change_watercare_mode(self, new_mode: int) -> None:

def __str__(self) -> str:
"""Stringise the class."""
if not self.is_available:
return f"{self.name}: Unavailable"
if self.active_mode is None:
return f"{self.name}: Waiting..."
if self.active_mode < 0 or self.active_mode > len(
Expand All @@ -105,6 +97,8 @@ def __str__(self) -> str:
@property
def monitor(self) -> str:
"""Get monitor string."""
if not self.is_available:
return "WC: None"
if self.active_mode is None:
return "WC: ?"
return f"WC: {self.active_mode}"
4 changes: 4 additions & 0 deletions src/geckolib/driver/async_spastruct.py
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,10 @@ def build_connections(self) -> None:
#
# Accessory support

def is_mr_steam(self) -> bool:
"""Is this a MrSteam pack."""
return self.plateform_key == "mrsteam"

async def check_for_accessories(self) -> None:
"""After the initial pack has been loaded, check for accessories too."""
inmix_packtype = GeckoByteStructAccessor(self, "inMix-PackType", 628, None)
Expand Down
18 changes: 13 additions & 5 deletions src/geckolib/utils/cui/cui.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,15 +243,22 @@ def _build_facade_ui(self, _maxy: int, maxx: int) -> None:
for moveit in button_line:
moveit.move(moveit.y, moveit.x + delta)

if self.facade.spa.struct.is_mr_steam:
self._lines.append("We have a Mr Steam unit")
self._lines.append("")

self._lines.append(f"{self.facade.water_heater}")
if self.facade.inmix.is_available:
self._lines.extend(f"{zone}" for zone in self.facade.inmix.zones)
if self.facade.inmix.syncro.is_available:
self._lines.append(f"{self.facade.inmix.syncro}")
self._lines.extend(
f"{reminder}" for reminder in self.facade.reminders_manager.reminders
)
self._lines.append(f"{self.facade.water_care}")
if self.facade.reminders_manager.is_available:
self._lines.extend(
f"{reminder}" for reminder in self.facade.reminders_manager.reminders
)
# if self.facade.water_care.is_available:
if self.facade.water_care.is_available:
self._lines.append(f"{self.facade.water_care}")
if self.facade.heatpump.is_available:
self._lines.append(f"{self.facade.heatpump}")
if self.facade.ingrid.is_available:
Expand All @@ -267,7 +274,8 @@ def _build_facade_ui(self, _maxy: int, maxx: int) -> None:
*self.facade.binary_sensors,
]
)
self._lines.append(f"{self.facade.eco_mode}")
if self.facade.eco_mode is not None:
self._lines.append(f"{self.facade.eco_mode}")
self._lines.append(
f"{self.ping_sensor} (Responding: {self._spa.is_responding_to_pings})"
)
Expand Down
18 changes: 14 additions & 4 deletions src/geckolib/utils/shell.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

from geckolib import VERSION, GeckoConstants, GeckoPump
from geckolib.async_spa_manager import GeckoAsyncSpaMan
from geckolib.automation import inmix
from geckolib.automation.base import GeckoAutomationBase, GeckoAutomationFacadeBase
from geckolib.config import release_config_change_waiters
from geckolib.driver.accessor import GeckoStructAccessor
Expand Down Expand Up @@ -220,16 +221,25 @@ def do_state(self, _arg: str) -> None:
print(blower)
for light in self.facade.lights:
print(light)
for reminder in self.facade.reminders_manager.reminders:
print(reminder)
print(self.facade.water_care)
if self.facade.reminders_manager.is_available:
for reminder in self.facade.reminders_manager.reminders:
print(reminder)
if self.facade.water_care.is_available:
print(self.facade.water_care)
for sensor in [
*self.facade.sensors,
*self.facade.binary_sensors,
]:
print(sensor)
print(self.facade.eco_mode)
if self.facade.eco_mode is not None:
print(self.facade.eco_mode)
print(self.facade.error_sensor)
if self.facade.ingrid.is_available:
print(self.facade.ingrid)
if self.facade.heatpump.is_available:
print(self.facade.heatpump)
if self.facade.inmix.is_available:
print(self.facade.inmix)

def monitor_get_states(self) -> list[str]:
"""Get the monitor states as a string list."""
Expand Down
33 changes: 17 additions & 16 deletions src/geckolib/utils/simulator.py
Original file line number Diff line number Diff line change
Expand Up @@ -444,22 +444,23 @@ def _install_standard_handlers(self) -> None:
"Status block",
"SIM",
)
# Watercare
self.add_task(
GeckoWatercareProtocolHandler(
async_on_handled=self._async_on_watercare
).consume(self._protocol),
"Watercare",
"SIM",
)
# Reminders
self.add_task(
GeckoRemindersProtocolHandler(
async_on_handled=self._async_on_reminders
).consume(self._protocol),
"Reminders",
"SIM",
)
# Watercare if not MrSteam
if not self.structure.is_mr_steam:
self.add_task(
GeckoWatercareProtocolHandler(
async_on_handled=self._async_on_watercare
).consume(self._protocol),
"Watercare",
"SIM",
)
# Reminders
self.add_task(
GeckoRemindersProtocolHandler(
async_on_handled=self._async_on_reminders
).consume(self._protocol),
"Reminders",
"SIM",
)
# Update firmware fake
self.add_task(
GeckoUpdateFirmwareProtocolHandler(
Expand Down

0 comments on commit 973a016

Please sign in to comment.