Skip to content

Commit

Permalink
Feature to turn on/off boilers
Browse files Browse the repository at this point in the history
  • Loading branch information
danielgospodinow committed Nov 18, 2024
1 parent c2246ce commit 419cf7f
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 1 deletion.
24 changes: 24 additions & 0 deletions custom_components/eldom/eldom_boiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,14 @@ def saved_energy(self) -> float:
def current_operation(self) -> str:
"""Return current operation ie. Off, Heating, Smart, or Study."""

@abstractmethod
async def turn_on(self) -> None:
"""Turn the boiler on."""

@abstractmethod
async def turn_off(self) -> None:
"""Turn the boiler off."""

@abstractmethod
async def set_operation_mode(self, operation_mode: str) -> None:
"""Set the operation mode of the boiler."""
Expand Down Expand Up @@ -200,6 +208,14 @@ def current_operation(self) -> str:
"""Return current operation ie. Off, Heating, Smart, or Study."""
return OPERATION_MODES.get(self._flat_boiler_details.State, "Unknown")

async def turn_on(self) -> None:
"""Turn the boiler on."""
await self.set_operation_mode(STATE_ECO)

async def turn_off(self) -> None:
"""Turn the boiler off."""
await self.set_operation_mode(STATE_OFF)

async def set_operation_mode(self, operation_mode: str) -> None:
"""Set new target operation mode."""
if operation_mode not in OPERATION_MODES.values():
Expand Down Expand Up @@ -322,6 +338,14 @@ def current_operation(self) -> str:
"""Return current operation ie. Off, Heating, Smart, or Study."""
return OPERATION_MODES.get(self._smart_boiler_details.State, "Unknown")

async def turn_on(self) -> None:
"""Turn the boiler on."""
await self.set_operation_mode(STATE_ECO)

async def turn_off(self) -> None:
"""Turn the boiler off."""
await self.set_operation_mode(STATE_OFF)

async def set_operation_mode(self, operation_mode: str) -> None:
"""Set new target operation mode."""
if operation_mode not in OPERATION_MODES.values():
Expand Down
2 changes: 1 addition & 1 deletion custom_components/eldom/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@
"requirements": ["pyeldom==0.3.0"],
"ssdp": [],
"zeroconf": [],
"version": "2.0.1"
"version": "2.1.0"
}
13 changes: 13 additions & 0 deletions custom_components/eldom/water_heater.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
SUPPORT_FLAGS_HEATER = (
WaterHeaterEntityFeature.TARGET_TEMPERATURE
| WaterHeaterEntityFeature.OPERATION_MODE
| WaterHeaterEntityFeature.ON_OFF
)

TEMP_UNIT = UnitOfTemperature.CELSIUS
Expand Down Expand Up @@ -140,6 +141,18 @@ def operation_list(self) -> list[str] | None:
"""Return the list of available operation modes."""
return self._eldom_boiler.operation_modes

async def async_turn_on(self, **kwargs: Any) -> None:
"""Turn the water heater on."""
await self._eldom_boiler.turn_on()
self.schedule_update_ha_state()
await self.coordinator.async_request_refresh()

async def async_turn_off(self, **kwargs: Any) -> None:
"""Turn the water heater off."""
await self._eldom_boiler.turn_off()
self.schedule_update_ha_state()
await self.coordinator.async_request_refresh()

async def async_set_operation_mode(self, operation_mode: str) -> None:
"""Set new target operation mode."""
try:
Expand Down

0 comments on commit 419cf7f

Please sign in to comment.