mirror of
https://github.com/home-assistant/core.git
synced 2025-07-22 20:57:21 +00:00
clean up a couple away temperature settings
This commit is contained in:
parent
6892033556
commit
f1fe8e95ba
@ -93,8 +93,8 @@ class NuHeatThermostat(ClimateDevice):
|
||||
@property
|
||||
def min_away_temp(self):
|
||||
"""Return the minimum target temperature to be used in away mode."""
|
||||
if self._min_away_temp:
|
||||
return self._min_away_temp
|
||||
if self._min_away_temp and self._min_away_temp > self.min_temp:
|
||||
return int(self._min_away_temp)
|
||||
|
||||
return self.min_temp
|
||||
|
||||
@ -154,18 +154,13 @@ class NuHeatThermostat(ClimateDevice):
|
||||
to the user-defined minimum away temperature or the minimum
|
||||
temperature supported by the thermostat.
|
||||
"""
|
||||
if self._min_away_temp:
|
||||
if self._temperature_unit == "C":
|
||||
min_target = self._min_away_temp
|
||||
target = self._thermostat.target_celsius
|
||||
else:
|
||||
min_target = self._min_away_temp
|
||||
target = self._thermostat.target_fahrenheit
|
||||
min_target = self.min_away_temp
|
||||
if self._temperature_unit == "C":
|
||||
target = self._thermostat.target_celsius
|
||||
else:
|
||||
target = self._thermostat.target_fahrenheit
|
||||
|
||||
if target > min_target:
|
||||
return False
|
||||
|
||||
elif self._thermostat.target_celsius > self._thermostat.min_celsius:
|
||||
if target > min_target:
|
||||
return False
|
||||
|
||||
if self._thermostat.schedule_mode != SCHEDULE_HOLD:
|
||||
|
@ -41,7 +41,16 @@ def setup(hass, config):
|
||||
username = conf.get(CONF_USERNAME)
|
||||
password = conf.get(CONF_PASSWORD)
|
||||
devices = conf.get(CONF_DEVICES)
|
||||
min_away_temp = conf.get(CONF_MIN_AWAY_TEMP)
|
||||
|
||||
min_away_temp = None
|
||||
_min_away_temp = conf.get(CONF_MIN_AWAY_TEMP)
|
||||
if _min_away_temp:
|
||||
try:
|
||||
min_away_temp = int(_min_away_temp)
|
||||
except ValueError:
|
||||
_LOGGER.error(
|
||||
"Configuration error. %s.%s=%s is invalid. Please provide a "
|
||||
"numeric value.", DATA_NUHEAT, CONF_MIN_AWAY_TEMP, _min_away_temp)
|
||||
|
||||
api = nuheat.NuHeat(username, password)
|
||||
api.authenticate()
|
||||
|
@ -89,9 +89,15 @@ class TestNuHeat(unittest.TestCase):
|
||||
def test_min_away_temp(self):
|
||||
"""Test the minimum target temperature to be used in away mode."""
|
||||
self.assertEqual(self.thermostat.min_away_temp, 41)
|
||||
|
||||
# User defined minimum
|
||||
self.thermostat._min_away_temp = 60
|
||||
self.assertEqual(self.thermostat.min_away_temp, 60)
|
||||
|
||||
# User defined minimum below the thermostat's supported minimum
|
||||
self.thermostat._min_away_temp = 0
|
||||
self.assertEqual(self.thermostat.min_away_temp, 41)
|
||||
|
||||
def test_min_temp(self):
|
||||
"""Test min temp."""
|
||||
self.assertEqual(self.thermostat.min_temp, 41)
|
||||
|
Loading…
x
Reference in New Issue
Block a user