|
8 | 8 | from pyomnilogic_local.decorators import control_method |
9 | 9 | from pyomnilogic_local.models.mspconfig import MSPChlorinator |
10 | 10 | from pyomnilogic_local.models.telemetry import TelemetryChlorinator |
11 | | -from pyomnilogic_local.omnitypes import ChlorinatorStatus |
| 11 | +from pyomnilogic_local.omnitypes import ChlorinatorMSPConfigMode, ChlorinatorStatus |
12 | 12 | from pyomnilogic_local.util import OmniEquipmentNotInitializedError |
13 | 13 |
|
14 | 14 | if TYPE_CHECKING: |
@@ -98,10 +98,29 @@ def operating_state(self) -> int: |
98 | 98 | """Current operational state of the chlorinator (raw value).""" |
99 | 99 | return self.telemetry.operating_state |
100 | 100 |
|
| 101 | + @property |
| 102 | + def mode(self) -> ChlorinatorMSPConfigMode: |
| 103 | + """Current operating mode from MSP Config (NOT_CONFIGURED, TIMED, ORP_AUTO). |
| 104 | +
|
| 105 | + TThis data appears to have some discrepancies with the mode reported in the Telemetry. |
| 106 | + The assumption is that the MSP Config mode represents the intended/configured mode, while the |
| 107 | + Telemetry operating mode represents the actual/current mode of operation. The reasons for |
| 108 | + discrepancies are not fully understood. |
| 109 | +
|
| 110 | + Returns: |
| 111 | + ChlorinatorMSPConfigMode: The operating mode enum value |
| 112 | + """ |
| 113 | + return self.mspconfig.mode |
| 114 | + |
101 | 115 | @property |
102 | 116 | def operating_mode(self) -> ChlorinatorOperatingMode: |
103 | 117 | """Current operating mode (DISABLED, TIMED, ORP_AUTO, or ORP_TIMED_RW). |
104 | 118 |
|
| 119 | + This data appears to have some discrepancies with the mode reported in the MSP Config. |
| 120 | + The assumption is that the MSP Config mode represents the intended/configured mode, while the |
| 121 | + Telemetry operating mode represents the actual/current mode of operation. The reasons for |
| 122 | + discrepancies are not fully understood. |
| 123 | +
|
105 | 124 | Returns: |
106 | 125 | ChlorinatorOperatingMode: The operating mode enum value |
107 | 126 | """ |
@@ -402,7 +421,7 @@ async def set_timed_percent(self, percent: int) -> None: |
402 | 421 | ) |
403 | 422 |
|
404 | 423 | @control_method |
405 | | - async def set_op_mode(self, op_mode: ChlorinatorOperatingMode) -> None: |
| 424 | + async def set_op_mode(self, op_mode: ChlorinatorMSPConfigMode) -> None: |
406 | 425 | """Set the operating mode for chlorine generation. |
407 | 426 |
|
408 | 427 | Args: |
@@ -432,12 +451,22 @@ async def set_op_mode(self, op_mode: ChlorinatorOperatingMode) -> None: |
432 | 451 |
|
433 | 452 | bow_type = 0 if bow.equip_type == "BOW_POOL" else 1 |
434 | 453 |
|
| 454 | + new_op_mode: int |
| 455 | + match op_mode: |
| 456 | + case ChlorinatorMSPConfigMode.TIMED: |
| 457 | + new_op_mode = 1 |
| 458 | + case ChlorinatorMSPConfigMode.ORP_AUTO: |
| 459 | + new_op_mode = 2 |
| 460 | + case _: |
| 461 | + msg = f"Unsupported operating mode: {op_mode}" |
| 462 | + raise ValueError(msg) |
| 463 | + |
435 | 464 | await self._api.async_set_chlorinator_params( |
436 | 465 | pool_id=self.bow_id, |
437 | 466 | equipment_id=self.system_id, |
438 | 467 | timed_percent=self.timed_percent_telemetry, |
439 | 468 | cell_type=self.mspconfig.cell_type.value, |
440 | | - op_mode=op_mode.value, |
| 469 | + op_mode=new_op_mode, |
441 | 470 | sc_timeout=self.superchlor_timeout, |
442 | 471 | bow_type=bow_type, |
443 | 472 | orp_timeout=self.orp_timeout, |
|
0 commit comments