Skip to content

Commit

Permalink
✨ Implement on/off for water heater
Browse files Browse the repository at this point in the history
This is not visible in the UI but can be used as an action. This can be
especially useful for power shedding
  • Loading branch information
kamaradclimber committed Dec 14, 2024
1 parent 768c391 commit fdebb82
Showing 1 changed file with 36 additions and 1 deletion.
37 changes: 36 additions & 1 deletion custom_components/aquarea/water_heater.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
from __future__ import annotations
import logging

from typing import Any

from homeassistant.config_entries import ConfigEntry
from homeassistant.core import HomeAssistant, callback
from homeassistant.helpers.entity_platform import AddEntitiesCallback
Expand All @@ -16,7 +18,7 @@
STATE_PERFORMANCE,
)

from .definitions import lookup_by_value, OperatingMode
from .definitions import OperatingMode
from . import build_device_info
from .const import DeviceType

Expand Down Expand Up @@ -164,6 +166,39 @@ def heat_delta_received(message):
1,
)

@callback
def operating_mode_received(message):
self._operating_mode = OperatingMode.from_mqtt(message.payload)
self.async_write_ha_state()

await mqtt.async_subscribe(
self.hass,
f"{self.discovery_prefix}main/Operating_Mode_State",
operating_mode_received,
1,
)

async def async_turn_on(self, **kwargs: Any) -> None:
new_operating_mode = self._operating_mode | OperatingMode.DHW
await async_publish(
self.hass,
f"{self.discovery_prefix}commands/SetOperationMode",
new_operating_mode.to_mqtt(),
0,
False,
"utf-8",
)
async def async_turn_off(self, **kwargs: Any) -> None:
new_operating_mode = self._operating_mode & ~OperatingMode.DHW
await async_publish(
self.hass,
f"{self.discovery_prefix}commands/SetOperationMode",
new_operating_mode.to_mqtt(),
0,
False,
"utf-8",
)

@property
def device_info(self):
return build_device_info(DeviceType.HEATPUMP, self.discovery_prefix)

0 comments on commit fdebb82

Please sign in to comment.