Skip to content

Commit

Permalink
Mr.Steam basic support
Browse files Browse the repository at this point in the history
  • Loading branch information
gazoodle committed Mar 3, 2025
1 parent 9c4d892 commit 280196f
Show file tree
Hide file tree
Showing 6 changed files with 97 additions and 27 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

## v0.1.26
- Bump geckolib to 1.0.8
- Mr.Steam basic support

## v0.1.25
- Bump geckolib to 1.0.7
Expand Down
2 changes: 2 additions & 0 deletions custom_components/gecko/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
SELECT = "select"
WATER_HEATER = "water_heater"
DATE = "date"
NUMBER = "number"
PLATFORMS = [
BINARY_SENSOR,
BUTTON,
Expand All @@ -44,6 +45,7 @@
SELECT,
WATER_HEATER,
DATE,
NUMBER,
]

# Option keys
Expand Down
68 changes: 68 additions & 0 deletions custom_components/gecko/number.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
"""Number platform for Gecko."""

import logging
from typing import TYPE_CHECKING

from homeassistant.components.number import NumberEntity
from homeassistant.config_entries import ConfigEntry
from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity_platform import AddEntitiesCallback

from .const import DOMAIN, NUMBER
from .entity import GeckoEntity

if TYPE_CHECKING:
from .spa_manager import GeckoSpaManager

_LOGGER = logging.getLogger(__name__)


async def async_setup_entry(
hass: HomeAssistant, entry: ConfigEntry, async_add_entities: AddEntitiesCallback
) -> None:
"""Set up number platform."""
spaman: GeckoSpaManager = hass.data[DOMAIN][entry.entry_id]
numbers: list = []
if (
spaman.can_use_facade
and spaman.facade is not None
and spaman.facade.mrsteam.is_available
):
numbers.append(
GeckoNumber(spaman, entry, spaman.facade.mrsteam.user_runtime, None)
)
async_add_entities(numbers)
spaman.platform_loaded(NUMBER)


class GeckoNumber(GeckoEntity, NumberEntity):
"""Gecko Date class."""

@property
def native_value(self) -> float:
"""Return the native value of the sensor."""
return self._automation_entity.native_value

@property
def native_min_value(self) -> float:
"""Get the min value."""
return self._automation_entity.native_min_value

@property
def native_max_value(self) -> float:
"""Get the max value."""
return self._automation_entity.native_max_value

async def async_set_native_value(self, new_value: float) -> None:
"""Set the value of the number entity."""
await self._automation_entity.async_set_native_value(new_value)

@property
def native_unit_of_measurement(self) -> str:
"""Return the unit of measurement."""
return self._automation_entity.native_unit_of_measurement

@property
def device_class(self) -> str:
"""Return the device class of the sensor."""
return "" # self._automation_entity.device_class
4 changes: 4 additions & 0 deletions custom_components/gecko/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@ async def async_setup_entry(
for reminder in spaman.facade.reminders_manager.reminders
)
sensors.append(GeckoErrorTextSensor(spaman, entry, spaman.facade.error_sensor))
if spaman.facade.mrsteam.is_available:
sensors.append(
GeckoSensor(spaman, entry, spaman.facade.mrsteam.remaining_runtime)
)
async_add_entities(sensors)
spaman.platform_loaded(SENSOR)

Expand Down
7 changes: 7 additions & 0 deletions custom_components/gecko/switch.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,13 @@ async def async_setup_entry(
spaman, entry, spaman.facade.standby, EntityCategory.CONFIG
)
)
if spaman.facade.mrsteam.is_available:
entities.extend(
[
GeckoBinarySwitch(spaman, entry, switch, None)
for switch in spaman.facade.mrsteam.switches
]
)
async_add_entities(entities)
spaman.platform_loaded(SWITCH)

Expand Down
42 changes: 15 additions & 27 deletions custom_components/gecko/water_heater.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import logging
from typing import Any

from geckolib import GeckoAsyncFacade, GeckoWaterCare, GeckoWaterHeater
from geckolib import GeckoAsyncFacade, GeckoWaterHeaterAbstract
from homeassistant.components.water_heater import (
WaterHeaterEntity,
WaterHeaterEntityFeature,
Expand All @@ -24,18 +24,23 @@ async def async_setup_entry(
) -> None:
"""Set up climate platform."""
spaman: GeckoSpaManager = hass.data[DOMAIN][entry.entry_id]
if spaman.facade is not None and spaman.facade.water_heater.is_available:
if spaman.facade is not None:
facade: GeckoAsyncFacade = spaman.facade
async_add_entities(
[
water_heaters = []

if spaman.facade.water_heater.is_available:
water_heaters.append(
GeckoHAWaterHeater(
spaman,
entry,
facade.water_heater,
facade.water_care,
)
]
)
)
if spaman.facade.mrsteam.is_available:
water_heaters.append(GeckoHAWaterHeater(spaman, entry, facade.mrsteam))

async_add_entities(water_heaters)

spaman.platform_loaded(WATER_HEATER)


Expand All @@ -46,41 +51,24 @@ def __init__(
self,
spaman: GeckoSpaManager,
config_entry: ConfigEntry,
automation_entity: GeckoWaterHeater,
water_care: GeckoWaterCare,
automation_entity: GeckoWaterHeaterAbstract,
) -> None:
"""Initialize Gecko climate entity."""
self._attr_supported_features = WaterHeaterEntityFeature.TARGET_TEMPERATURE
super().__init__(spaman, config_entry, automation_entity)
self._water_care = water_care
self._water_care.watch(self._on_change)

@property
def icon(self) -> str:
"""Return the icon of the sensor."""
if self.spaman.facade.mrsteam.is_available:
return "mdi:steam"
return "mdi:hot-tub"

@property
def current_operation(self) -> str:
"""The current operation."""
return self._automation_entity.current_operation

@property
def preset_modes(self) -> list[str] | None:
"""List the water care modes."""
return self._water_care.modes

@property
def preset_mode(self) -> str | None:
"""Get the current preset mode."""
if self._water_care.mode is None:
return "Waiting..."
return self._water_care.modes[self._water_care.mode]

async def async_set_preset_mode(self, preset_mode: str) -> None:
"""Set the preset mode asynchronously."""
await self._water_care.async_set_mode(preset_mode)

@property
def temperature_unit(self) -> str:
"""Get the current temperature unit."""
Expand Down

0 comments on commit 280196f

Please sign in to comment.