Skip to content
Snippets Groups Projects
Commit dae90abb authored by Philip Rosenberg-Watt's avatar Philip Rosenberg-Watt
Browse files

Change climate default limits to constants

Min and max temp and humidity are now defined in climate __init__.py
and are available for import in subclasses.
parent 60f692c7
No related branches found
No related tags found
No related merge requests found
...@@ -22,6 +22,12 @@ from homeassistant.const import ( ...@@ -22,6 +22,12 @@ from homeassistant.const import (
ATTR_ENTITY_ID, ATTR_TEMPERATURE, SERVICE_TURN_ON, SERVICE_TURN_OFF, ATTR_ENTITY_ID, ATTR_TEMPERATURE, SERVICE_TURN_ON, SERVICE_TURN_OFF,
STATE_ON, STATE_OFF, STATE_UNKNOWN, TEMP_CELSIUS, PRECISION_WHOLE, STATE_ON, STATE_OFF, STATE_UNKNOWN, TEMP_CELSIUS, PRECISION_WHOLE,
PRECISION_TENTHS, ) PRECISION_TENTHS, )
DEFAULT_MIN_TEMP = 7
DEFAULT_MAX_TEMP = 35
DEFAULT_MIN_HUMITIDY = 30
DEFAULT_MAX_HUMIDITY = 99
DOMAIN = 'climate' DOMAIN = 'climate'
ENTITY_ID_FORMAT = DOMAIN + '.{}' ENTITY_ID_FORMAT = DOMAIN + '.{}'
...@@ -778,19 +784,19 @@ class ClimateDevice(Entity): ...@@ -778,19 +784,19 @@ class ClimateDevice(Entity):
@property @property
def min_temp(self): def min_temp(self):
"""Return the minimum temperature.""" """Return the minimum temperature."""
return convert_temperature(7, TEMP_CELSIUS, self.temperature_unit) return convert_temperature(DEFAULT_MIN_TEMP, TEMP_CELSIUS, self.temperature_unit)
@property @property
def max_temp(self): def max_temp(self):
"""Return the maximum temperature.""" """Return the maximum temperature."""
return convert_temperature(35, TEMP_CELSIUS, self.temperature_unit) return convert_temperature(DEFAULT_MAX_TEMP, TEMP_CELSIUS, self.temperature_unit)
@property @property
def min_humidity(self): def min_humidity(self):
"""Return the minimum humidity.""" """Return the minimum humidity."""
return 30 return DEFAULT_MIN_HUMITIDY
@property @property
def max_humidity(self): def max_humidity(self):
"""Return the maximum humidity.""" """Return the maximum humidity."""
return 99 return DEFAULT_MAX_HUMIDITY
...@@ -14,7 +14,8 @@ from homeassistant.core import DOMAIN as HA_DOMAIN ...@@ -14,7 +14,8 @@ from homeassistant.core import DOMAIN as HA_DOMAIN
from homeassistant.components.climate import ( from homeassistant.components.climate import (
STATE_HEAT, STATE_COOL, STATE_IDLE, STATE_AUTO, ClimateDevice, STATE_HEAT, STATE_COOL, STATE_IDLE, STATE_AUTO, ClimateDevice,
ATTR_OPERATION_MODE, ATTR_AWAY_MODE, SUPPORT_OPERATION_MODE, ATTR_OPERATION_MODE, ATTR_AWAY_MODE, SUPPORT_OPERATION_MODE,
SUPPORT_AWAY_MODE, SUPPORT_TARGET_TEMPERATURE, PLATFORM_SCHEMA) SUPPORT_AWAY_MODE, SUPPORT_TARGET_TEMPERATURE, PLATFORM_SCHEMA,
DEFAULT_MIN_TEMP, DEFAULT_MAX_TEMP)
from homeassistant.const import ( from homeassistant.const import (
ATTR_UNIT_OF_MEASUREMENT, STATE_ON, STATE_OFF, ATTR_TEMPERATURE, ATTR_UNIT_OF_MEASUREMENT, STATE_ON, STATE_OFF, ATTR_TEMPERATURE,
CONF_NAME, ATTR_ENTITY_ID, SERVICE_TURN_ON, SERVICE_TURN_OFF, CONF_NAME, ATTR_ENTITY_ID, SERVICE_TURN_ON, SERVICE_TURN_OFF,
...@@ -268,7 +269,7 @@ class GenericThermostat(ClimateDevice): ...@@ -268,7 +269,7 @@ class GenericThermostat(ClimateDevice):
return self._min_temp return self._min_temp
# get default temp from super class # get default temp from super class
return ClimateDevice.min_temp.fget(self) return DEFAULT_MIN_TEMP
@property @property
def max_temp(self): def max_temp(self):
...@@ -278,7 +279,7 @@ class GenericThermostat(ClimateDevice): ...@@ -278,7 +279,7 @@ class GenericThermostat(ClimateDevice):
return self._max_temp return self._max_temp
# Get default temp from super class # Get default temp from super class
return ClimateDevice.max_temp.fget(self) return DEFAULT_MAX_TEMP
@asyncio.coroutine @asyncio.coroutine
def _async_sensor_changed(self, entity_id, old_state, new_state): def _async_sensor_changed(self, entity_id, old_state, new_state):
......
...@@ -19,7 +19,7 @@ from homeassistant.components.climate import ( ...@@ -19,7 +19,7 @@ from homeassistant.components.climate import (
ATTR_CURRENT_HUMIDITY, ClimateDevice, DOMAIN, PLATFORM_SCHEMA, ATTR_CURRENT_HUMIDITY, ClimateDevice, DOMAIN, PLATFORM_SCHEMA,
SUPPORT_TARGET_TEMPERATURE, SUPPORT_OPERATION_MODE, SUPPORT_TARGET_TEMPERATURE, SUPPORT_OPERATION_MODE,
SUPPORT_FAN_MODE, SUPPORT_SWING_MODE, SUPPORT_FAN_MODE, SUPPORT_SWING_MODE,
SUPPORT_ON_OFF) SUPPORT_ON_OFF, DEFAULT_MIN_TEMP, DEFAULT_MAX_TEMP)
from homeassistant.exceptions import PlatformNotReady from homeassistant.exceptions import PlatformNotReady
from homeassistant.helpers import config_validation as cv from homeassistant.helpers import config_validation as cv
from homeassistant.helpers.aiohttp_client import async_get_clientsession from homeassistant.helpers.aiohttp_client import async_get_clientsession
...@@ -240,13 +240,13 @@ class SensiboClimate(ClimateDevice): ...@@ -240,13 +240,13 @@ class SensiboClimate(ClimateDevice):
def min_temp(self): def min_temp(self):
"""Return the minimum temperature.""" """Return the minimum temperature."""
return self._temperatures_list[0] \ return self._temperatures_list[0] \
if self._temperatures_list else super().min_temp if self._temperatures_list else DEFAULT_MIN_TEMP
@property @property
def max_temp(self): def max_temp(self):
"""Return the maximum temperature.""" """Return the maximum temperature."""
return self._temperatures_list[-1] \ return self._temperatures_list[-1] \
if self._temperatures_list else super().max_temp if self._temperatures_list else DEFAULT_MAX_TEMP
@property @property
def unique_id(self): def unique_id(self):
......
...@@ -8,7 +8,8 @@ import logging ...@@ -8,7 +8,8 @@ import logging
from homeassistant.const import (PRECISION_TENTHS, TEMP_CELSIUS) from homeassistant.const import (PRECISION_TENTHS, TEMP_CELSIUS)
from homeassistant.components.climate import ( from homeassistant.components.climate import (
ClimateDevice, SUPPORT_TARGET_TEMPERATURE, SUPPORT_OPERATION_MODE) ClimateDevice, SUPPORT_TARGET_TEMPERATURE, SUPPORT_OPERATION_MODE,
DEFAULT_MIN_TEMP, DEFAULT_MAX_TEMP)
from homeassistant.const import ATTR_TEMPERATURE from homeassistant.const import ATTR_TEMPERATURE
from homeassistant.components.tado import DATA_TADO from homeassistant.components.tado import DATA_TADO
...@@ -233,7 +234,7 @@ class TadoClimate(ClimateDevice): ...@@ -233,7 +234,7 @@ class TadoClimate(ClimateDevice):
if self._min_temp: if self._min_temp:
return self._min_temp return self._min_temp
# get default temp from super class # get default temp from super class
return super().min_temp return DEFAULT_MIN_TEMP
@property @property
def max_temp(self): def max_temp(self):
...@@ -241,7 +242,7 @@ class TadoClimate(ClimateDevice): ...@@ -241,7 +242,7 @@ class TadoClimate(ClimateDevice):
if self._max_temp: if self._max_temp:
return self._max_temp return self._max_temp
# Get default temp from super class # Get default temp from super class
return super().max_temp return DEFAULT_MAX_TEMP
def update(self): def update(self):
"""Update the state of this climate device.""" """Update the state of this climate device."""
......
...@@ -9,9 +9,9 @@ from homeassistant.setup import setup_component ...@@ -9,9 +9,9 @@ from homeassistant.setup import setup_component
from homeassistant.components import climate from homeassistant.components import climate
from homeassistant.const import STATE_OFF, STATE_UNAVAILABLE from homeassistant.const import STATE_OFF, STATE_UNAVAILABLE
from homeassistant.components.climate import ( from homeassistant.components.climate import (
SUPPORT_OPERATION_MODE, SUPPORT_TARGET_TEMPERATURE, SUPPORT_OPERATION_MODE, SUPPORT_TARGET_TEMPERATURE,
SUPPORT_FAN_MODE, SUPPORT_SWING_MODE, SUPPORT_HOLD_MODE, SUPPORT_FAN_MODE, SUPPORT_SWING_MODE, SUPPORT_HOLD_MODE,
SUPPORT_AWAY_MODE, SUPPORT_AUX_HEAT) SUPPORT_AWAY_MODE, SUPPORT_AUX_HEAT, DEFAULT_MAX_TEMP, DEFAULT_MIN_TEMP)
from tests.common import (get_test_home_assistant, mock_mqtt_component, from tests.common import (get_test_home_assistant, mock_mqtt_component,
fire_mqtt_message, mock_component) fire_mqtt_message, mock_component)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment