Skip to content

Commit

Permalink
V1.5.1
Browse files Browse the repository at this point in the history
  • Loading branch information
tggm committed Dec 25, 2023
1 parent c15b804 commit 5c6918e
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 258 deletions.
31 changes: 15 additions & 16 deletions custom_components/rointe/climate.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

from __future__ import annotations

from typing import Any

from rointesdk.device import RointeDevice

from homeassistant.components.climate import (
Expand All @@ -19,16 +21,7 @@
from homeassistant.exceptions import HomeAssistantError
from homeassistant.helpers.entity_platform import AddEntitiesCallback

from .const import (
DOMAIN,
LOGGER,
RADIATOR_TEMP_MAX,
RADIATOR_TEMP_MIN,
RADIATOR_TEMP_STEP,
RointeCommand,
RointeOperationMode,
RointePreset,
)
from .const import DOMAIN, LOGGER, RointeCommand, RointeOperationMode, RointePreset
from .coordinator import RointeDataUpdateCoordinator
from .entity import RointeRadiatorEntity

Expand All @@ -45,6 +38,10 @@
RointePreset.ICE: RointePreset.ICE,
}

RADIATOR_TEMP_STEP = 0.5
RADIATOR_TEMP_MIN = 7.0
RADIATOR_TEMP_MAX = 30.0


async def async_setup_entry(
hass: HomeAssistant, entry: ConfigEntry, async_add_entities: AddEntitiesCallback
Expand Down Expand Up @@ -171,14 +168,16 @@ def preset_mode(self) -> str | None:
# Also captures "none" (man mode, temperature outside presets)
return ROINTE_HASS_MAP.get(self._radiator.preset, None)

async def async_set_temperature(self, **kwargs):
async def async_set_temperature(self, **kwargs: Any) -> None:
"""Set new target temperature."""

target_temperature = kwargs["temperature"]

LOGGER.debug("Setting temperature to %s", target_temperature)

if not RADIATOR_TEMP_MIN <= target_temperature <= RADIATOR_TEMP_MAX:
raise ValueError(
f"Invalid set_humidity value (must be in range 7.0, 30.0): {target_temperature}"
f"Invalid set_temperature value (must be in range {RADIATOR_TEMP_MIN}, {RADIATOR_TEMP_MAX}): {target_temperature}"
)

# Round to the nearest half value.
Expand All @@ -188,12 +187,12 @@ async def async_set_temperature(self, **kwargs):
self._radiator, RointeCommand.SET_TEMP, rounded_temp
):
raise HomeAssistantError(
f"Failed to set HVAC mode for {self._radiator.name}"
f"Failed to set temperature for {self._radiator.name}"
)

await self._signal_thermostat_update()

async def async_set_hvac_mode(self, hvac_mode):
async def async_set_hvac_mode(self, hvac_mode: HVACMode) -> None:
"""Set new target hvac mode."""

LOGGER.debug("Setting HVAC mode to %s", hvac_mode)
Expand All @@ -207,15 +206,15 @@ async def async_set_hvac_mode(self, hvac_mode):

await self._signal_thermostat_update()

async def async_set_preset_mode(self, preset_mode):
async def async_set_preset_mode(self, preset_mode: str) -> None:
"""Set new target preset mode."""
LOGGER.debug("Setting preset mode: %s", preset_mode)

if not await self.device_manager.send_command(
self._radiator, RointeCommand.SET_PRESET, preset_mode
):
raise HomeAssistantError(
f"Failed to set HVAC mode for {self._radiator.name}"
f"Failed to set HVAC preset for {self._radiator.name}"
)

await self._signal_thermostat_update()
Expand Down
4 changes: 0 additions & 4 deletions custom_components/rointe/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,6 @@

PRESET_ROINTE_ICE = "ice"

RADIATOR_TEMP_STEP = 0.5
RADIATOR_TEMP_MIN = 7.0
RADIATOR_TEMP_MAX = 30.0


class RointePreset(StrEnum):
"""Rointe radiators preset modes."""
Expand Down
13 changes: 12 additions & 1 deletion custom_components/rointe/device_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,12 @@ async def send_command(
) -> bool:
"""Send command to the device."""

LOGGER.debug("Sending command [%s] to device ID [%s]", command, device.name)
LOGGER.debug(
"Sending command [%s] to device ID [%s]. Args: %s",
command,
device.name,
arg,
)

if command == RointeCommand.SET_TEMP:
return await self._set_device_temp(device, arg)
Expand All @@ -313,8 +318,11 @@ async def _set_device_temp(self, device: RointeDevice, new_temp: float) -> bool:
)

if not result.success:
LOGGER.debug("_set_device_temp failed: %s", result.error_message)

# Set the device as unavailable.
device.hass_available = False

return False

# Update the device internal status
Expand All @@ -341,6 +349,7 @@ async def _set_device_mode(self, device: RointeDevice, hvac_mode: str) -> bool:
)

if not result.success:
LOGGER.debug("_set_device_mode failed: %s", result.error_message)
# Set the device as unavailable.
device.hass_available = False
return False
Expand Down Expand Up @@ -388,6 +397,8 @@ async def _set_device_preset(self, device: RointeDevice, preset: str) -> bool:
)

if not result.success:
LOGGER.debug("_set_device_preset failed: %s", result.error_message)

# Set the device as unavailable.
device.hass_available = False
return False
Expand Down
4 changes: 2 additions & 2 deletions custom_components/rointe/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
"config_flow": true,
"documentation": "https://www.home-assistant.io/integrations/rointe",
"iot_class": "cloud_polling",
"version": "1.5.0",
"requirements": ["rointe-sdk==1.5.0"]
"requirements": ["rointe-sdk==1.5.0"],
"version": "1.5.1"
}
62 changes: 0 additions & 62 deletions custom_components/rointe/sensor.py

This file was deleted.

74 changes: 0 additions & 74 deletions custom_components/rointe/sensor_descriptions.py

This file was deleted.

27 changes: 0 additions & 27 deletions custom_components/rointe/translations/en.json

This file was deleted.

72 changes: 0 additions & 72 deletions custom_components/rointe/update.py

This file was deleted.

0 comments on commit 5c6918e

Please sign in to comment.