Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
plmilord authored Dec 6, 2022
1 parent e6daf03 commit 4cc6dc4
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 14 deletions.
23 changes: 11 additions & 12 deletions custom_components/spaclient/climate.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@
from . import SpaClientDevice
from .const import _LOGGER, DOMAIN, ICONS, SPA
from homeassistant.components.climate import ClimateEntity
from homeassistant.components.climate.const import (
SUPPORT_TARGET_TEMPERATURE, HVAC_MODE_HEAT, HVAC_MODE_OFF)
from homeassistant.components.climate.const import SUPPORT_TARGET_TEMPERATURE, HVAC_MODE_HEAT, HVAC_MODE_OFF
from homeassistant.const import ATTR_TEMPERATURE, TEMP_CELSIUS, TEMP_FAHRENHEIT
from homeassistant.util.temperature import convert as convert_temperature
from homeassistant.util.unit_conversion import TemperatureConverter

from datetime import timedelta
SCAN_INTERVAL = timedelta(seconds=1)
Expand Down Expand Up @@ -67,29 +66,29 @@ def current_temperature(self):
"""Return the current temperature."""
if self._spaclient.get_current_temp() != None:
if self.hass.config.units.temperature_unit == TEMP_CELSIUS and self._spaclient.temp_scale == "Fahrenheit":
return round(convert_temperature(self._spaclient.get_current_temp(), TEMP_FAHRENHEIT, TEMP_CELSIUS) * 2) / 2
return round(TemperatureConverter.convert(self._spaclient.get_current_temp(), TEMP_FAHRENHEIT, TEMP_CELSIUS) * 2) / 2
if self.hass.config.units.temperature_unit == TEMP_CELSIUS and self._spaclient.temp_scale == "Celsius":
return self._spaclient.get_current_temp() / 2
if self.hass.config.units.temperature_unit == TEMP_FAHRENHEIT and self._spaclient.temp_scale == "Celsius":
return round(convert_temperature(self._spaclient.get_current_temp() / 2, TEMP_CELSIUS, TEMP_FAHRENHEIT) * 2) / 2
return round(TemperatureConverter.convert(self._spaclient.get_current_temp() / 2, TEMP_CELSIUS, TEMP_FAHRENHEIT) * 2) / 2
return self._spaclient.get_current_temp()
return None

@property
def target_temperature(self):
"""Return the target temperature."""
if self.hass.config.units.temperature_unit == TEMP_CELSIUS and self._spaclient.temp_scale == "Fahrenheit":
return round(convert_temperature(self._spaclient.get_set_temp(), TEMP_FAHRENHEIT, TEMP_CELSIUS) * 2) / 2
return round(TemperatureConverter.convert(self._spaclient.get_set_temp(), TEMP_FAHRENHEIT, TEMP_CELSIUS) * 2) / 2
if self.hass.config.units.temperature_unit == TEMP_CELSIUS and self._spaclient.temp_scale == "Celsius":
return self._spaclient.get_set_temp() / 2
if self.hass.config.units.temperature_unit == TEMP_FAHRENHEIT and self._spaclient.temp_scale == "Celsius":
return round(convert_temperature(self._spaclient.get_set_temp() / 2, TEMP_CELSIUS, TEMP_FAHRENHEIT) * 2) / 2
return round(TemperatureConverter.convert(self._spaclient.get_set_temp() / 2, TEMP_CELSIUS, TEMP_FAHRENHEIT) * 2) / 2
return self._spaclient.get_set_temp()

async def async_set_temperature(self, **kwargs):
temperature = kwargs[ATTR_TEMPERATURE]
if self.hass.config.units.temperature_unit == TEMP_CELSIUS:
temperature = round(convert_temperature(temperature, TEMP_CELSIUS, TEMP_FAHRENHEIT))
temperature = round(TemperatureConverter.convert(temperature, TEMP_CELSIUS, TEMP_FAHRENHEIT))
await self._spaclient.set_temperature(temperature)

async def async_set_hvac_mode(self, hvac_mode):
Expand All @@ -102,15 +101,15 @@ async def async_set_hvac_mode(self, hvac_mode):
def min_temp(self):
"""Return the minimum temperature."""
if self._spaclient.get_temp_range() == "High":
return convert_temperature(self._spaclient.get_high_range_min(), TEMP_FAHRENHEIT, self.temperature_unit)
return convert_temperature(self._spaclient.get_low_range_min(), TEMP_FAHRENHEIT, self.temperature_unit)
return TemperatureConverter.convert(self._spaclient.get_high_range_min(), TEMP_FAHRENHEIT, self.temperature_unit)
return TemperatureConverter.convert(self._spaclient.get_low_range_min(), TEMP_FAHRENHEIT, self.temperature_unit)

@property
def max_temp(self):
"""Return the maximum temperature."""
if self._spaclient.get_temp_range() == "High":
return convert_temperature(self._spaclient.get_high_range_max(), TEMP_FAHRENHEIT, self.temperature_unit)
return convert_temperature(self._spaclient.get_low_range_max(), TEMP_FAHRENHEIT, self.temperature_unit)
return TemperatureConverter.convert(self._spaclient.get_high_range_max(), TEMP_FAHRENHEIT, self.temperature_unit)
return TemperatureConverter.convert(self._spaclient.get_low_range_max(), TEMP_FAHRENHEIT, self.temperature_unit)

@property
def temperature_unit(self):
Expand Down
4 changes: 2 additions & 2 deletions custom_components/spaclient/manifest.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"domain": "spaclient",
"name": "Spa Client",
"version": 2.0,
"documentation": "https://github.com/plmilord/Hass.io-custom-component-spaclient/blob/master/README.md",
"version": 2.6,
"documentation": "https://github.com/plmilord/Hass.io-custom-component-spaclient",
"issue_tracker": "https://github.com/plmilord/Hass.io-custom-component-spaclient/issues",
"codeowners": ["jmoor3", "plmilord"],
"config_flow": true
Expand Down

0 comments on commit 4cc6dc4

Please sign in to comment.