Fix unit conversion (#14730)

* reviewing this code min_temp and max_temp are always present and always in celsius

* revert change (preserve unit conversion)

* revert (due to unit conversion)

* self

* clean

* cleaner
pull/14865/merge
Diogo Gomes 2018-06-08 03:44:07 +01:00 committed by Paulus Schoutsen
parent 0748466ffc
commit bb0068908d
3 changed files with 14 additions and 17 deletions

View File

@ -14,8 +14,7 @@ from homeassistant.core import DOMAIN as HA_DOMAIN
from homeassistant.components.climate import (
STATE_HEAT, STATE_COOL, STATE_IDLE, STATE_AUTO, ClimateDevice,
ATTR_OPERATION_MODE, ATTR_AWAY_MODE, SUPPORT_OPERATION_MODE,
SUPPORT_AWAY_MODE, SUPPORT_TARGET_TEMPERATURE, PLATFORM_SCHEMA,
DEFAULT_MIN_TEMP, DEFAULT_MAX_TEMP)
SUPPORT_AWAY_MODE, SUPPORT_TARGET_TEMPERATURE, PLATFORM_SCHEMA)
from homeassistant.const import (
ATTR_UNIT_OF_MEASUREMENT, STATE_ON, STATE_OFF, ATTR_TEMPERATURE,
CONF_NAME, ATTR_ENTITY_ID, SERVICE_TURN_ON, SERVICE_TURN_OFF,
@ -268,7 +267,8 @@ class GenericThermostat(ClimateDevice):
if self._min_temp:
return self._min_temp
return DEFAULT_MIN_TEMP
# get default temp from super class
return super().min_temp
@property
def max_temp(self):
@ -277,7 +277,8 @@ class GenericThermostat(ClimateDevice):
if self._max_temp:
return self._max_temp
return DEFAULT_MAX_TEMP
# Get default temp from super class
return super().max_temp
@asyncio.coroutine
def _async_sensor_changed(self, entity_id, old_state, new_state):

View File

@ -19,7 +19,7 @@ from homeassistant.components.climate import (
ATTR_CURRENT_HUMIDITY, ClimateDevice, DOMAIN, PLATFORM_SCHEMA,
SUPPORT_TARGET_TEMPERATURE, SUPPORT_OPERATION_MODE,
SUPPORT_FAN_MODE, SUPPORT_SWING_MODE,
SUPPORT_ON_OFF, DEFAULT_MIN_TEMP, DEFAULT_MAX_TEMP)
SUPPORT_ON_OFF)
from homeassistant.exceptions import PlatformNotReady
from homeassistant.helpers import config_validation as cv
from homeassistant.helpers.aiohttp_client import async_get_clientsession
@ -246,13 +246,13 @@ class SensiboClimate(ClimateDevice):
def min_temp(self):
"""Return the minimum temperature."""
return self._temperatures_list[0] \
if self._temperatures_list else DEFAULT_MIN_TEMP
if self._temperatures_list else super().min_temp
@property
def max_temp(self):
"""Return the maximum temperature."""
return self._temperatures_list[-1] \
if self._temperatures_list else DEFAULT_MAX_TEMP
if self._temperatures_list else super().max_temp
@property
def unique_id(self):

View File

@ -8,8 +8,8 @@ import logging
from homeassistant.const import (PRECISION_TENTHS, TEMP_CELSIUS)
from homeassistant.components.climate import (
ClimateDevice, SUPPORT_TARGET_TEMPERATURE, SUPPORT_OPERATION_MODE,
DEFAULT_MIN_TEMP, DEFAULT_MAX_TEMP)
ClimateDevice, SUPPORT_TARGET_TEMPERATURE, SUPPORT_OPERATION_MODE)
from homeassistant.util.temperature import convert as convert_temperature
from homeassistant.const import ATTR_TEMPERATURE
from homeassistant.components.tado import DATA_TADO
@ -231,18 +231,14 @@ class TadoClimate(ClimateDevice):
@property
def min_temp(self):
"""Return the minimum temperature."""
if self._min_temp:
return self._min_temp
return DEFAULT_MIN_TEMP
return convert_temperature(self._min_temp, self._unit,
self.hass.config.units.temperature_unit)
@property
def max_temp(self):
"""Return the maximum temperature."""
if self._max_temp:
return self._max_temp
return DEFAULT_MAX_TEMP
return convert_temperature(self._max_temp, self._unit,
self.hass.config.units.temperature_unit)
def update(self):
"""Update the state of this climate device."""