Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix temperature for AtlanticElectricalTowelDryer #704

Merged
merged 8 commits into from
Jan 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@
PRESET_NONE,
)
from homeassistant.const import ATTR_TEMPERATURE, TEMP_CELSIUS
from pyoverkiz.enums import OverkizState

from ..coordinator import OverkizDataUpdateCoordinator
from ..entity import OverkizEntity

COMMAND_SET_TARGET_TEMPERATURE = "setTargetTemperature"
Expand Down Expand Up @@ -68,6 +70,11 @@ class AtlanticElectricalTowelDryer(OverkizEntity, ClimateEntity):
_attr_supported_features = SUPPORT_PRESET_MODE | SUPPORT_TARGET_TEMPERATURE
_attr_temperature_unit = TEMP_CELSIUS

def __init__(self, device_url: str, coordinator: OverkizDataUpdateCoordinator):
"""Init method."""
super().__init__(device_url, coordinator)
self.temperature_device = self.executor.linked_device(7)

@property
def hvac_mode(self) -> str:
"""Return hvac operation ie. heat, cool mode."""
Expand Down Expand Up @@ -103,13 +110,14 @@ def target_temperature(self) -> None:
"""Return the temperature."""
if self.hvac_mode == HVAC_MODE_AUTO:
return self.executor.select_state(IO_EFFECTIVE_TEMPERATURE_SETPOINT_STATE)
else:
return self.executor.select_state(CORE_TARGET_TEMPERATURE_STATE)
return self.executor.select_state(CORE_TARGET_TEMPERATURE_STATE)

@property
def current_temperature(self):
def current_temperature(self) -> float:
"""Return current temperature."""
return self.executor.select_state(CORE_COMFORT_ROOM_TEMPERATURE_STATE)
return float(
self.temperature_device.states.get(OverkizState.CORE_TEMPERATURE).value
)

async def async_set_temperature(self, **kwargs) -> None:
"""Set new temperature."""
Expand Down
4 changes: 4 additions & 0 deletions custom_components/tahoma/executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ def device(self) -> Device:
"""Return Overkiz device linked to this entity."""
return self.coordinator.data[self.device_url]

def linked_device(self, index) -> Device:
"""Return Overkiz device sharing the same base url."""
return self.coordinator.data[f"{self.base_device_url}#{index}"]

def select_command(self, *commands: str) -> str | None:
"""Select first existing command in a list of commands."""
existing_commands = self.device.definition.commands
Expand Down