From c5de32e7b13df9f63b1279f733ea59d7ecec8243 Mon Sep 17 00:00:00 2001 From: Joakim Plate Date: Thu, 14 Feb 2019 20:34:43 +0100 Subject: [PATCH] Climate const.py move (#20945) * Move constants to const.py * Import from const instead of climate --- homeassistant/components/alexa/smart_home.py | 9 +- homeassistant/components/climate/__init__.py | 34 +++---- homeassistant/components/climate/const.py | 28 ++++++ .../components/climate/coolmaster.py | 7 +- homeassistant/components/climate/demo.py | 5 +- homeassistant/components/climate/dyson.py | 5 +- homeassistant/components/climate/ephember.py | 8 +- .../components/climate/eq3btsmart.py | 9 +- homeassistant/components/climate/flexit.py | 5 +- .../components/climate/generic_thermostat.py | 7 +- homeassistant/components/climate/heatmiser.py | 5 +- homeassistant/components/climate/honeywell.py | 5 +- homeassistant/components/climate/melissa.py | 5 +- homeassistant/components/climate/mill.py | 5 +- homeassistant/components/climate/nuheat.py | 4 +- homeassistant/components/climate/oem.py | 11 +-- homeassistant/components/climate/proliphix.py | 9 +- .../components/climate/radiotherm.py | 10 ++- homeassistant/components/climate/sensibo.py | 5 +- homeassistant/components/climate/touchline.py | 5 +- homeassistant/components/climate/venstar.py | 8 +- .../components/climate/zhong_hong.py | 7 +- homeassistant/components/daikin/climate.py | 12 +-- homeassistant/components/ecobee/climate.py | 9 +- homeassistant/components/elkm1/climate.py | 10 ++- homeassistant/components/evohome/climate.py | 7 +- homeassistant/components/fritzbox/climate.py | 11 +-- .../components/google_assistant/trait.py | 9 +- homeassistant/components/hive/climate.py | 10 ++- .../components/homekit/type_thermostats.py | 2 +- .../components/homekit_controller/climate.py | 11 +-- homeassistant/components/homematic/climate.py | 5 +- .../components/homematicip_cloud/climate.py | 8 +- homeassistant/components/knx/climate.py | 7 +- homeassistant/components/maxcube/climate.py | 5 +- homeassistant/components/modbus/climate.py | 5 +- homeassistant/components/mqtt/climate.py | 6 +- homeassistant/components/mysensors/climate.py | 11 +-- homeassistant/components/nest/__init__.py | 2 +- homeassistant/components/nest/climate.py | 11 +-- homeassistant/components/nest/sensor.py | 2 +- homeassistant/components/netatmo/climate.py | 5 +- .../components/opentherm_gw/climate.py | 6 +- .../components/prometheus/__init__.py | 2 +- .../components/smartthings/climate.py | 11 +-- homeassistant/components/spider/climate.py | 9 +- homeassistant/components/tado/climate.py | 5 +- homeassistant/components/tesla/climate.py | 6 +- homeassistant/components/toon/climate.py | 9 +- homeassistant/components/tuya/climate.py | 9 +- homeassistant/components/velbus/climate.py | 5 +- homeassistant/components/vera/climate.py | 7 +- homeassistant/components/wink/climate.py | 11 +-- homeassistant/components/xs1/climate.py | 6 +- homeassistant/components/zwave/climate.py | 5 +- homeassistant/helpers/state.py | 2 +- tests/components/climate/common.py | 5 +- tests/components/climate/test_demo.py | 14 +-- .../climate/test_generic_thermostat.py | 67 +++++++------- tests/components/climate/test_honeywell.py | 2 +- tests/components/climate/test_melissa.py | 5 +- tests/components/climate/test_nuheat.py | 2 +- .../climate/test_reproduce_state.py | 4 +- tests/components/ecobee/test_climate.py | 2 +- .../google_assistant/test_google_assistant.py | 3 +- .../google_assistant/test_smart_home.py | 12 +-- .../components/google_assistant/test_trait.py | 12 +-- .../homekit/test_type_thermostats.py | 2 +- .../homekit_controller/test_climate.py | 2 +- tests/components/mqtt/test_climate.py | 90 ++++++++++--------- tests/components/smartthings/test_climate.py | 6 +- tests/components/zwave/test_climate.py | 2 +- 72 files changed, 372 insertions(+), 295 deletions(-) diff --git a/homeassistant/components/alexa/smart_home.py b/homeassistant/components/alexa/smart_home.py index 4e2383bb43d0..a856a3d8e825 100644 --- a/homeassistant/components/alexa/smart_home.py +++ b/homeassistant/components/alexa/smart_home.py @@ -11,8 +11,9 @@ import aiohttp import async_timeout from homeassistant.components import ( - alert, automation, binary_sensor, climate, cover, fan, group, http, + alert, automation, binary_sensor, cover, fan, group, http, input_boolean, light, lock, media_player, scene, script, sensor, switch) +from homeassistant.components.climate import const as climate from homeassistant.helpers import aiohttp_client from homeassistant.helpers.event import async_track_state_change from homeassistant.const import ( @@ -22,7 +23,7 @@ from homeassistant.const import ( SERVICE_MEDIA_PLAY, SERVICE_MEDIA_PREVIOUS_TRACK, SERVICE_MEDIA_STOP, SERVICE_SET_COVER_POSITION, SERVICE_TURN_OFF, SERVICE_TURN_ON, SERVICE_UNLOCK, SERVICE_VOLUME_DOWN, SERVICE_VOLUME_UP, SERVICE_VOLUME_SET, - SERVICE_VOLUME_MUTE, STATE_LOCKED, STATE_ON, STATE_UNAVAILABLE, + SERVICE_VOLUME_MUTE, STATE_LOCKED, STATE_ON, STATE_OFF, STATE_UNAVAILABLE, STATE_UNLOCKED, TEMP_CELSIUS, TEMP_FAHRENHEIT, MATCH_ALL) import homeassistant.core as ha import homeassistant.util.color as color_util @@ -58,7 +59,7 @@ API_THERMOSTAT_MODES = OrderedDict([ (climate.STATE_AUTO, 'AUTO'), (climate.STATE_ECO, 'ECO'), (climate.STATE_MANUAL, 'AUTO'), - (climate.STATE_OFF, 'OFF'), + (STATE_OFF, 'OFF'), (climate.STATE_IDLE, 'OFF'), (climate.STATE_FAN_ONLY, 'OFF'), (climate.STATE_DRY, 'OFF'), @@ -765,7 +766,7 @@ class _AlexaThermostatController(_AlexaInterface): unit = self.hass.config.units.temperature_unit if name == 'targetSetpoint': - temp = self.entity.attributes.get(climate.ATTR_TEMPERATURE) + temp = self.entity.attributes.get(ATTR_TEMPERATURE) elif name == 'lowerSetpoint': temp = self.entity.attributes.get(climate.ATTR_TARGET_TEMP_LOW) elif name == 'upperSetpoint': diff --git a/homeassistant/components/climate/__init__.py b/homeassistant/components/climate/__init__.py index e1d3093995c4..0283359b1f23 100644 --- a/homeassistant/components/climate/__init__.py +++ b/homeassistant/components/climate/__init__.py @@ -51,6 +51,17 @@ from .const import ( SERVICE_SET_OPERATION_MODE, SERVICE_SET_SWING_MODE, SERVICE_SET_TEMPERATURE, + SUPPORT_TARGET_TEMPERATURE_HIGH, + SUPPORT_TARGET_TEMPERATURE_LOW, + SUPPORT_TARGET_HUMIDITY, + SUPPORT_TARGET_HUMIDITY_HIGH, + SUPPORT_TARGET_HUMIDITY_LOW, + SUPPORT_FAN_MODE, + SUPPORT_OPERATION_MODE, + SUPPORT_HOLD_MODE, + SUPPORT_SWING_MODE, + SUPPORT_AWAY_MODE, + SUPPORT_AUX_HEAT, ) from .reproduce_state import async_reproduce_states # noqa @@ -62,29 +73,6 @@ DEFAULT_MAX_HUMIDITY = 99 ENTITY_ID_FORMAT = DOMAIN + '.{}' SCAN_INTERVAL = timedelta(seconds=60) -STATE_HEAT = 'heat' -STATE_COOL = 'cool' -STATE_IDLE = 'idle' -STATE_AUTO = 'auto' -STATE_MANUAL = 'manual' -STATE_DRY = 'dry' -STATE_FAN_ONLY = 'fan_only' -STATE_ECO = 'eco' - -SUPPORT_TARGET_TEMPERATURE = 1 -SUPPORT_TARGET_TEMPERATURE_HIGH = 2 -SUPPORT_TARGET_TEMPERATURE_LOW = 4 -SUPPORT_TARGET_HUMIDITY = 8 -SUPPORT_TARGET_HUMIDITY_HIGH = 16 -SUPPORT_TARGET_HUMIDITY_LOW = 32 -SUPPORT_FAN_MODE = 64 -SUPPORT_OPERATION_MODE = 128 -SUPPORT_HOLD_MODE = 256 -SUPPORT_SWING_MODE = 512 -SUPPORT_AWAY_MODE = 1024 -SUPPORT_AUX_HEAT = 2048 -SUPPORT_ON_OFF = 4096 - CONVERTIBLE_ATTRIBUTE = [ ATTR_TEMPERATURE, ATTR_TARGET_TEMP_LOW, diff --git a/homeassistant/components/climate/const.py b/homeassistant/components/climate/const.py index 2f84ee27bbdc..e213ae09de6a 100644 --- a/homeassistant/components/climate/const.py +++ b/homeassistant/components/climate/const.py @@ -20,6 +20,11 @@ ATTR_TARGET_TEMP_HIGH = 'target_temp_high' ATTR_TARGET_TEMP_LOW = 'target_temp_low' ATTR_TARGET_TEMP_STEP = 'target_temp_step' +DEFAULT_MIN_TEMP = 7 +DEFAULT_MAX_TEMP = 35 +DEFAULT_MIN_HUMITIDY = 30 +DEFAULT_MAX_HUMIDITY = 99 + DOMAIN = 'climate' SERVICE_SET_AUX_HEAT = 'set_aux_heat' @@ -30,3 +35,26 @@ SERVICE_SET_HUMIDITY = 'set_humidity' SERVICE_SET_OPERATION_MODE = 'set_operation_mode' SERVICE_SET_SWING_MODE = 'set_swing_mode' SERVICE_SET_TEMPERATURE = 'set_temperature' + +STATE_HEAT = 'heat' +STATE_COOL = 'cool' +STATE_IDLE = 'idle' +STATE_AUTO = 'auto' +STATE_MANUAL = 'manual' +STATE_DRY = 'dry' +STATE_FAN_ONLY = 'fan_only' +STATE_ECO = 'eco' + +SUPPORT_TARGET_TEMPERATURE = 1 +SUPPORT_TARGET_TEMPERATURE_HIGH = 2 +SUPPORT_TARGET_TEMPERATURE_LOW = 4 +SUPPORT_TARGET_HUMIDITY = 8 +SUPPORT_TARGET_HUMIDITY_HIGH = 16 +SUPPORT_TARGET_HUMIDITY_LOW = 32 +SUPPORT_FAN_MODE = 64 +SUPPORT_OPERATION_MODE = 128 +SUPPORT_HOLD_MODE = 256 +SUPPORT_SWING_MODE = 512 +SUPPORT_AWAY_MODE = 1024 +SUPPORT_AUX_HEAT = 2048 +SUPPORT_ON_OFF = 4096 diff --git a/homeassistant/components/climate/coolmaster.py b/homeassistant/components/climate/coolmaster.py index 32c77b93eeab..fd00c9f22c46 100644 --- a/homeassistant/components/climate/coolmaster.py +++ b/homeassistant/components/climate/coolmaster.py @@ -9,10 +9,11 @@ import logging import voluptuous as vol -from homeassistant.components.climate import ( - PLATFORM_SCHEMA, STATE_AUTO, STATE_COOL, STATE_DRY, STATE_FAN_ONLY, +from homeassistant.components.climate import ClimateDevice, PLATFORM_SCHEMA +from homeassistant.components.climate.const import ( + STATE_AUTO, STATE_COOL, STATE_DRY, STATE_FAN_ONLY, STATE_HEAT, SUPPORT_FAN_MODE, SUPPORT_ON_OFF, SUPPORT_OPERATION_MODE, - SUPPORT_TARGET_TEMPERATURE, ClimateDevice) + SUPPORT_TARGET_TEMPERATURE) from homeassistant.const import ( ATTR_TEMPERATURE, CONF_HOST, CONF_PORT, TEMP_CELSIUS, TEMP_FAHRENHEIT) import homeassistant.helpers.config_validation as cv diff --git a/homeassistant/components/climate/demo.py b/homeassistant/components/climate/demo.py index 14c22cefbe90..5b4775982a6b 100644 --- a/homeassistant/components/climate/demo.py +++ b/homeassistant/components/climate/demo.py @@ -4,8 +4,9 @@ Demo platform that offers a fake climate device. For more details about this platform, please refer to the documentation https://home-assistant.io/components/demo/ """ -from homeassistant.components.climate import ( - ClimateDevice, ATTR_TARGET_TEMP_HIGH, ATTR_TARGET_TEMP_LOW, +from homeassistant.components.climate import ClimateDevice +from homeassistant.components.climate.const import ( + ATTR_TARGET_TEMP_HIGH, ATTR_TARGET_TEMP_LOW, SUPPORT_TARGET_TEMPERATURE, SUPPORT_TARGET_HUMIDITY, SUPPORT_TARGET_HUMIDITY_LOW, SUPPORT_TARGET_HUMIDITY_HIGH, SUPPORT_AWAY_MODE, SUPPORT_HOLD_MODE, SUPPORT_FAN_MODE, diff --git a/homeassistant/components/climate/dyson.py b/homeassistant/components/climate/dyson.py index 0b09ec7f0b4c..09196a82bed8 100644 --- a/homeassistant/components/climate/dyson.py +++ b/homeassistant/components/climate/dyson.py @@ -7,8 +7,9 @@ https://home-assistant.io/components/climate.dyson/ import logging from homeassistant.components.dyson import DYSON_DEVICES -from homeassistant.components.climate import ( - ClimateDevice, STATE_HEAT, STATE_COOL, STATE_IDLE, +from homeassistant.components.climate import ClimateDevice +from homeassistant.components.climate.const import ( + STATE_HEAT, STATE_COOL, STATE_IDLE, SUPPORT_TARGET_TEMPERATURE, SUPPORT_FAN_MODE, SUPPORT_OPERATION_MODE) from homeassistant.const import TEMP_CELSIUS, ATTR_TEMPERATURE diff --git a/homeassistant/components/climate/ephember.py b/homeassistant/components/climate/ephember.py index cd410cf3be45..9884d81a1992 100644 --- a/homeassistant/components/climate/ephember.py +++ b/homeassistant/components/climate/ephember.py @@ -8,12 +8,12 @@ import logging from datetime import timedelta import voluptuous as vol -from homeassistant.components.climate import ( - ClimateDevice, PLATFORM_SCHEMA, STATE_HEAT, STATE_OFF, - STATE_AUTO, SUPPORT_AUX_HEAT, SUPPORT_OPERATION_MODE, +from homeassistant.components.climate import ClimateDevice, PLATFORM_SCHEMA +from homeassistant.components.climate.const import ( + STATE_HEAT, STATE_AUTO, SUPPORT_AUX_HEAT, SUPPORT_OPERATION_MODE, SUPPORT_TARGET_TEMPERATURE) from homeassistant.const import ( - TEMP_CELSIUS, CONF_USERNAME, CONF_PASSWORD, ATTR_TEMPERATURE) + ATTR_TEMPERATURE, TEMP_CELSIUS, CONF_USERNAME, CONF_PASSWORD, STATE_OFF) import homeassistant.helpers.config_validation as cv REQUIREMENTS = ['pyephember==0.2.0'] diff --git a/homeassistant/components/climate/eq3btsmart.py b/homeassistant/components/climate/eq3btsmart.py index 1eaaaa9d34e8..c7c5973fb865 100644 --- a/homeassistant/components/climate/eq3btsmart.py +++ b/homeassistant/components/climate/eq3btsmart.py @@ -8,13 +8,14 @@ import logging import voluptuous as vol -from homeassistant.components.climate import ( - STATE_ON, STATE_OFF, STATE_HEAT, STATE_MANUAL, STATE_ECO, PLATFORM_SCHEMA, - ClimateDevice, +from homeassistant.components.climate import ClimateDevice, PLATFORM_SCHEMA +from homeassistant.components.climate.const import ( + STATE_HEAT, STATE_MANUAL, STATE_ECO, SUPPORT_TARGET_TEMPERATURE, SUPPORT_OPERATION_MODE, SUPPORT_AWAY_MODE, SUPPORT_ON_OFF) from homeassistant.const import ( - CONF_MAC, CONF_DEVICES, TEMP_CELSIUS, ATTR_TEMPERATURE, PRECISION_HALVES) + ATTR_TEMPERATURE, CONF_MAC, CONF_DEVICES, STATE_ON, STATE_OFF, + TEMP_CELSIUS, PRECISION_HALVES) import homeassistant.helpers.config_validation as cv REQUIREMENTS = ['python-eq3bt==0.1.9', 'construct==2.9.45'] diff --git a/homeassistant/components/climate/flexit.py b/homeassistant/components/climate/flexit.py index e0453b8bf90f..fe7b5ff8e7cd 100644 --- a/homeassistant/components/climate/flexit.py +++ b/homeassistant/components/climate/flexit.py @@ -17,8 +17,9 @@ import voluptuous as vol from homeassistant.const import ( CONF_NAME, CONF_SLAVE, TEMP_CELSIUS, ATTR_TEMPERATURE, DEVICE_DEFAULT_NAME) -from homeassistant.components.climate import ( - ClimateDevice, PLATFORM_SCHEMA, SUPPORT_TARGET_TEMPERATURE, +from homeassistant.components.climate import ClimateDevice, PLATFORM_SCHEMA +from homeassistant.components.climate.const import ( + SUPPORT_TARGET_TEMPERATURE, SUPPORT_FAN_MODE) from homeassistant.components.modbus import ( CONF_HUB, DEFAULT_HUB, DOMAIN as MODBUS_DOMAIN) diff --git a/homeassistant/components/climate/generic_thermostat.py b/homeassistant/components/climate/generic_thermostat.py index ffab50c989d7..da4f79ec1e6b 100644 --- a/homeassistant/components/climate/generic_thermostat.py +++ b/homeassistant/components/climate/generic_thermostat.py @@ -11,10 +11,11 @@ import voluptuous as vol from homeassistant.core import callback from homeassistant.core import DOMAIN as HA_DOMAIN -from homeassistant.components.climate import ( - STATE_HEAT, STATE_COOL, STATE_IDLE, STATE_AUTO, ClimateDevice, +from homeassistant.components.climate import ClimateDevice, PLATFORM_SCHEMA +from homeassistant.components.climate.const import ( + STATE_HEAT, STATE_COOL, STATE_IDLE, STATE_AUTO, ATTR_OPERATION_MODE, ATTR_AWAY_MODE, SUPPORT_OPERATION_MODE, - SUPPORT_AWAY_MODE, SUPPORT_TARGET_TEMPERATURE, PLATFORM_SCHEMA) + SUPPORT_AWAY_MODE, SUPPORT_TARGET_TEMPERATURE) from homeassistant.const import ( STATE_ON, STATE_OFF, ATTR_TEMPERATURE, CONF_NAME, ATTR_ENTITY_ID, SERVICE_TURN_ON, SERVICE_TURN_OFF, STATE_UNKNOWN, PRECISION_HALVES, diff --git a/homeassistant/components/climate/heatmiser.py b/homeassistant/components/climate/heatmiser.py index a03d1567e01a..ff495706be77 100644 --- a/homeassistant/components/climate/heatmiser.py +++ b/homeassistant/components/climate/heatmiser.py @@ -8,8 +8,9 @@ import logging import voluptuous as vol -from homeassistant.components.climate import ( - ClimateDevice, PLATFORM_SCHEMA, SUPPORT_TARGET_TEMPERATURE) +from homeassistant.components.climate import ClimateDevice, PLATFORM_SCHEMA +from homeassistant.components.climate.const import ( + SUPPORT_TARGET_TEMPERATURE) from homeassistant.const import ( TEMP_CELSIUS, ATTR_TEMPERATURE, CONF_PORT, CONF_NAME, CONF_ID) import homeassistant.helpers.config_validation as cv diff --git a/homeassistant/components/climate/honeywell.py b/homeassistant/components/climate/honeywell.py index e0f104a84b19..dbcbebff5665 100644 --- a/homeassistant/components/climate/honeywell.py +++ b/homeassistant/components/climate/honeywell.py @@ -12,8 +12,9 @@ import requests import voluptuous as vol import homeassistant.helpers.config_validation as cv -from homeassistant.components.climate import ( - ClimateDevice, PLATFORM_SCHEMA, ATTR_FAN_MODE, ATTR_FAN_LIST, +from homeassistant.components.climate import ClimateDevice, PLATFORM_SCHEMA +from homeassistant.components.climate.const import ( + ATTR_FAN_MODE, ATTR_FAN_LIST, ATTR_OPERATION_MODE, ATTR_OPERATION_LIST, SUPPORT_TARGET_TEMPERATURE, SUPPORT_AWAY_MODE, SUPPORT_OPERATION_MODE) from homeassistant.const import ( diff --git a/homeassistant/components/climate/melissa.py b/homeassistant/components/climate/melissa.py index 25beedfe0dd2..b9eb28a61d75 100644 --- a/homeassistant/components/climate/melissa.py +++ b/homeassistant/components/climate/melissa.py @@ -6,8 +6,9 @@ https://home-assistant.io/components/climate.melissa/ """ import logging -from homeassistant.components.climate import ( - ClimateDevice, SUPPORT_OPERATION_MODE, SUPPORT_TARGET_TEMPERATURE, +from homeassistant.components.climate import ClimateDevice +from homeassistant.components.climate.const import ( + SUPPORT_OPERATION_MODE, SUPPORT_TARGET_TEMPERATURE, SUPPORT_ON_OFF, STATE_AUTO, STATE_HEAT, STATE_COOL, STATE_DRY, STATE_FAN_ONLY, SUPPORT_FAN_MODE ) diff --git a/homeassistant/components/climate/mill.py b/homeassistant/components/climate/mill.py index b735927cb808..6867f57ee485 100644 --- a/homeassistant/components/climate/mill.py +++ b/homeassistant/components/climate/mill.py @@ -9,8 +9,9 @@ import logging import voluptuous as vol -from homeassistant.components.climate import ( - ClimateDevice, DOMAIN, PLATFORM_SCHEMA, STATE_HEAT, +from homeassistant.components.climate import ClimateDevice, PLATFORM_SCHEMA +from homeassistant.components.climate.const import ( + DOMAIN, STATE_HEAT, SUPPORT_TARGET_TEMPERATURE, SUPPORT_FAN_MODE, SUPPORT_ON_OFF, SUPPORT_OPERATION_MODE) from homeassistant.const import ( diff --git a/homeassistant/components/climate/nuheat.py b/homeassistant/components/climate/nuheat.py index d0bfe5add581..f52d2c7b5017 100644 --- a/homeassistant/components/climate/nuheat.py +++ b/homeassistant/components/climate/nuheat.py @@ -9,8 +9,8 @@ from datetime import timedelta import voluptuous as vol -from homeassistant.components.climate import ( - ClimateDevice, +from homeassistant.components.climate import ClimateDevice +from homeassistant.components.climate.const import ( DOMAIN, SUPPORT_HOLD_MODE, SUPPORT_OPERATION_MODE, diff --git a/homeassistant/components/climate/oem.py b/homeassistant/components/climate/oem.py index e006242331c1..f1e03396b050 100644 --- a/homeassistant/components/climate/oem.py +++ b/homeassistant/components/climate/oem.py @@ -13,11 +13,12 @@ import requests import voluptuous as vol # Import the device class from the component that you want to support -from homeassistant.components.climate import ( - ClimateDevice, PLATFORM_SCHEMA, STATE_HEAT, STATE_IDLE, ATTR_TEMPERATURE, - SUPPORT_TARGET_TEMPERATURE, SUPPORT_AWAY_MODE) -from homeassistant.const import (CONF_HOST, CONF_USERNAME, CONF_PASSWORD, - CONF_PORT, TEMP_CELSIUS, CONF_NAME) +from homeassistant.components.climate import ClimateDevice, PLATFORM_SCHEMA +from homeassistant.components.climate.const import ( + STATE_HEAT, STATE_IDLE, SUPPORT_TARGET_TEMPERATURE, SUPPORT_AWAY_MODE) +from homeassistant.const import ( + ATTR_TEMPERATURE, CONF_HOST, CONF_USERNAME, CONF_PASSWORD, + CONF_PORT, TEMP_CELSIUS, CONF_NAME) import homeassistant.helpers.config_validation as cv REQUIREMENTS = ['oemthermostat==1.1'] diff --git a/homeassistant/components/climate/proliphix.py b/homeassistant/components/climate/proliphix.py index 76160a28c6e5..c88ece033df4 100644 --- a/homeassistant/components/climate/proliphix.py +++ b/homeassistant/components/climate/proliphix.py @@ -6,11 +6,12 @@ https://home-assistant.io/components/climate.proliphix/ """ import voluptuous as vol -from homeassistant.components.climate import ( - PRECISION_TENTHS, STATE_COOL, STATE_HEAT, STATE_IDLE, - ClimateDevice, PLATFORM_SCHEMA, SUPPORT_TARGET_TEMPERATURE) +from homeassistant.components.climate import ClimateDevice, PLATFORM_SCHEMA +from homeassistant.components.climate.const import ( + STATE_COOL, STATE_HEAT, STATE_IDLE, SUPPORT_TARGET_TEMPERATURE) from homeassistant.const import ( - CONF_HOST, CONF_PASSWORD, CONF_USERNAME, TEMP_FAHRENHEIT, ATTR_TEMPERATURE) + CONF_HOST, CONF_PASSWORD, CONF_USERNAME, PRECISION_TENTHS, TEMP_FAHRENHEIT, + ATTR_TEMPERATURE) import homeassistant.helpers.config_validation as cv REQUIREMENTS = ['proliphix==0.4.1'] diff --git a/homeassistant/components/climate/radiotherm.py b/homeassistant/components/climate/radiotherm.py index a72bf711242b..bad20884536f 100644 --- a/homeassistant/components/climate/radiotherm.py +++ b/homeassistant/components/climate/radiotherm.py @@ -9,12 +9,14 @@ import logging import voluptuous as vol -from homeassistant.components.climate import ( - STATE_AUTO, STATE_COOL, STATE_HEAT, STATE_IDLE, STATE_ON, STATE_OFF, - ClimateDevice, PLATFORM_SCHEMA, SUPPORT_TARGET_TEMPERATURE, +from homeassistant.components.climate import ClimateDevice, PLATFORM_SCHEMA +from homeassistant.components.climate.const import ( + STATE_AUTO, STATE_COOL, STATE_HEAT, STATE_IDLE, + SUPPORT_TARGET_TEMPERATURE, SUPPORT_OPERATION_MODE, SUPPORT_FAN_MODE, SUPPORT_AWAY_MODE) from homeassistant.const import ( - CONF_HOST, TEMP_FAHRENHEIT, ATTR_TEMPERATURE, PRECISION_HALVES) + ATTR_TEMPERATURE, CONF_HOST, PRECISION_HALVES, TEMP_FAHRENHEIT, STATE_ON, + STATE_OFF) import homeassistant.helpers.config_validation as cv REQUIREMENTS = ['radiotherm==2.0.0'] diff --git a/homeassistant/components/climate/sensibo.py b/homeassistant/components/climate/sensibo.py index bf1cf5bf345e..7850b08fd6b7 100644 --- a/homeassistant/components/climate/sensibo.py +++ b/homeassistant/components/climate/sensibo.py @@ -15,8 +15,9 @@ import voluptuous as vol from homeassistant.const import ( ATTR_ENTITY_ID, ATTR_STATE, ATTR_TEMPERATURE, CONF_API_KEY, CONF_ID, STATE_ON, STATE_OFF, TEMP_CELSIUS, TEMP_FAHRENHEIT) -from homeassistant.components.climate import ( - ATTR_CURRENT_HUMIDITY, ClimateDevice, DOMAIN, PLATFORM_SCHEMA, +from homeassistant.components.climate import ClimateDevice, PLATFORM_SCHEMA +from homeassistant.components.climate.const import ( + ATTR_CURRENT_HUMIDITY, DOMAIN, SUPPORT_TARGET_TEMPERATURE, SUPPORT_OPERATION_MODE, SUPPORT_FAN_MODE, SUPPORT_SWING_MODE, SUPPORT_ON_OFF, STATE_HEAT, STATE_COOL, STATE_FAN_ONLY, STATE_DRY, diff --git a/homeassistant/components/climate/touchline.py b/homeassistant/components/climate/touchline.py index 641f6e9a1d8b..fa38bd37c8f7 100644 --- a/homeassistant/components/climate/touchline.py +++ b/homeassistant/components/climate/touchline.py @@ -8,8 +8,9 @@ import logging import voluptuous as vol -from homeassistant.components.climate import ( - ClimateDevice, PLATFORM_SCHEMA, SUPPORT_TARGET_TEMPERATURE) +from homeassistant.components.climate import ClimateDevice, PLATFORM_SCHEMA +from homeassistant.components.climate.const import ( + SUPPORT_TARGET_TEMPERATURE) from homeassistant.const import CONF_HOST, TEMP_CELSIUS, ATTR_TEMPERATURE import homeassistant.helpers.config_validation as cv diff --git a/homeassistant/components/climate/venstar.py b/homeassistant/components/climate/venstar.py index 16c0b2061546..820443ee186d 100644 --- a/homeassistant/components/climate/venstar.py +++ b/homeassistant/components/climate/venstar.py @@ -8,14 +8,14 @@ import logging import voluptuous as vol -from homeassistant.components.climate import ( +from homeassistant.components.climate import ClimateDevice, PLATFORM_SCHEMA +from homeassistant.components.climate.const import ( ATTR_OPERATION_MODE, ATTR_TARGET_TEMP_HIGH, ATTR_TARGET_TEMP_LOW, - PLATFORM_SCHEMA, STATE_AUTO, STATE_COOL, STATE_HEAT, SUPPORT_FAN_MODE, + STATE_AUTO, STATE_COOL, STATE_HEAT, SUPPORT_FAN_MODE, SUPPORT_OPERATION_MODE, SUPPORT_TARGET_HUMIDITY, SUPPORT_AWAY_MODE, SUPPORT_TARGET_HUMIDITY_HIGH, SUPPORT_TARGET_HUMIDITY_LOW, SUPPORT_HOLD_MODE, SUPPORT_TARGET_TEMPERATURE, - SUPPORT_TARGET_TEMPERATURE_HIGH, SUPPORT_TARGET_TEMPERATURE_LOW, - ClimateDevice) + SUPPORT_TARGET_TEMPERATURE_HIGH, SUPPORT_TARGET_TEMPERATURE_LOW) from homeassistant.const import ( ATTR_TEMPERATURE, CONF_HOST, CONF_PASSWORD, CONF_SSL, CONF_TIMEOUT, CONF_USERNAME, PRECISION_WHOLE, STATE_OFF, STATE_ON, TEMP_CELSIUS, diff --git a/homeassistant/components/climate/zhong_hong.py b/homeassistant/components/climate/zhong_hong.py index b564e9d1fa4a..78cd7d16c483 100644 --- a/homeassistant/components/climate/zhong_hong.py +++ b/homeassistant/components/climate/zhong_hong.py @@ -8,10 +8,11 @@ import logging import voluptuous as vol -from homeassistant.components.climate import ( - ATTR_OPERATION_MODE, PLATFORM_SCHEMA, STATE_COOL, STATE_DRY, +from homeassistant.components.climate import ClimateDevice, PLATFORM_SCHEMA +from homeassistant.components.climate.const import ( + ATTR_OPERATION_MODE, STATE_COOL, STATE_DRY, STATE_FAN_ONLY, STATE_HEAT, SUPPORT_FAN_MODE, SUPPORT_ON_OFF, - SUPPORT_OPERATION_MODE, SUPPORT_TARGET_TEMPERATURE, ClimateDevice) + SUPPORT_OPERATION_MODE, SUPPORT_TARGET_TEMPERATURE) from homeassistant.const import (ATTR_TEMPERATURE, CONF_HOST, CONF_PORT, EVENT_HOMEASSISTANT_STOP, TEMP_CELSIUS) import homeassistant.helpers.config_validation as cv diff --git a/homeassistant/components/daikin/climate.py b/homeassistant/components/daikin/climate.py index d97b506e2732..775e4a216e5c 100644 --- a/homeassistant/components/daikin/climate.py +++ b/homeassistant/components/daikin/climate.py @@ -4,17 +4,17 @@ import re import voluptuous as vol -from homeassistant.components.climate import ( +from homeassistant.components.climate import ClimateDevice, PLATFORM_SCHEMA +from homeassistant.components.climate.const import ( ATTR_CURRENT_TEMPERATURE, ATTR_FAN_MODE, ATTR_OPERATION_MODE, - ATTR_SWING_MODE, PLATFORM_SCHEMA, STATE_AUTO, STATE_COOL, STATE_DRY, - STATE_FAN_ONLY, STATE_HEAT, STATE_OFF, SUPPORT_FAN_MODE, - SUPPORT_OPERATION_MODE, SUPPORT_SWING_MODE, SUPPORT_TARGET_TEMPERATURE, - ClimateDevice) + ATTR_SWING_MODE, STATE_AUTO, STATE_COOL, STATE_DRY, + STATE_FAN_ONLY, STATE_HEAT, SUPPORT_FAN_MODE, + SUPPORT_OPERATION_MODE, SUPPORT_SWING_MODE, SUPPORT_TARGET_TEMPERATURE) from homeassistant.components.daikin import DOMAIN as DAIKIN_DOMAIN from homeassistant.components.daikin.const import ( ATTR_INSIDE_TEMPERATURE, ATTR_OUTSIDE_TEMPERATURE, ATTR_TARGET_TEMPERATURE) from homeassistant.const import ( - ATTR_TEMPERATURE, CONF_HOST, CONF_NAME, TEMP_CELSIUS) + ATTR_TEMPERATURE, CONF_HOST, CONF_NAME, STATE_OFF, TEMP_CELSIUS) import homeassistant.helpers.config_validation as cv _LOGGER = logging.getLogger(__name__) diff --git a/homeassistant/components/ecobee/climate.py b/homeassistant/components/ecobee/climate.py index aa6440894e1e..bfc67e7cfafc 100644 --- a/homeassistant/components/ecobee/climate.py +++ b/homeassistant/components/ecobee/climate.py @@ -4,15 +4,16 @@ import logging import voluptuous as vol from homeassistant.components import ecobee -from homeassistant.components.climate import ( - DOMAIN, STATE_COOL, STATE_HEAT, STATE_AUTO, STATE_IDLE, ClimateDevice, +from homeassistant.components.climate import ClimateDevice +from homeassistant.components.climate.const import ( + DOMAIN, STATE_COOL, STATE_HEAT, STATE_AUTO, STATE_IDLE, ATTR_TARGET_TEMP_LOW, ATTR_TARGET_TEMP_HIGH, SUPPORT_TARGET_TEMPERATURE, SUPPORT_AWAY_MODE, SUPPORT_HOLD_MODE, SUPPORT_OPERATION_MODE, SUPPORT_TARGET_HUMIDITY_LOW, SUPPORT_TARGET_HUMIDITY_HIGH, SUPPORT_AUX_HEAT, SUPPORT_TARGET_TEMPERATURE_HIGH, SUPPORT_FAN_MODE, - SUPPORT_TARGET_TEMPERATURE_LOW, STATE_OFF) + SUPPORT_TARGET_TEMPERATURE_LOW) from homeassistant.const import ( - ATTR_ENTITY_ID, STATE_ON, ATTR_TEMPERATURE, TEMP_FAHRENHEIT) + ATTR_ENTITY_ID, STATE_ON, STATE_OFF, ATTR_TEMPERATURE, TEMP_FAHRENHEIT) import homeassistant.helpers.config_validation as cv _CONFIGURING = {} diff --git a/homeassistant/components/elkm1/climate.py b/homeassistant/components/elkm1/climate.py index 467d542ee6d4..72f93b5419c5 100644 --- a/homeassistant/components/elkm1/climate.py +++ b/homeassistant/components/elkm1/climate.py @@ -1,12 +1,14 @@ """Support for control of Elk-M1 connected thermostats.""" -from homeassistant.components.climate import ( - ATTR_TARGET_TEMP_HIGH, ATTR_TARGET_TEMP_LOW, PRECISION_WHOLE, STATE_AUTO, +from homeassistant.components.climate import ClimateDevice +from homeassistant.components.climate.const import ( + ATTR_TARGET_TEMP_HIGH, ATTR_TARGET_TEMP_LOW, STATE_AUTO, STATE_COOL, STATE_FAN_ONLY, STATE_HEAT, STATE_IDLE, SUPPORT_AUX_HEAT, SUPPORT_FAN_MODE, SUPPORT_OPERATION_MODE, SUPPORT_TARGET_TEMPERATURE_HIGH, - SUPPORT_TARGET_TEMPERATURE_LOW, ClimateDevice) + SUPPORT_TARGET_TEMPERATURE_LOW) from homeassistant.components.elkm1 import ( DOMAIN as ELK_DOMAIN, ElkEntity, create_elk_entities) -from homeassistant.const import STATE_ON +from homeassistant.const import ( + STATE_ON, PRECISION_WHOLE) DEPENDENCIES = [ELK_DOMAIN] diff --git a/homeassistant/components/evohome/climate.py b/homeassistant/components/evohome/climate.py index ef82a3dc81cf..955b82e37e3c 100644 --- a/homeassistant/components/evohome/climate.py +++ b/homeassistant/components/evohome/climate.py @@ -4,13 +4,13 @@ import logging from requests.exceptions import HTTPError -from homeassistant.components.climate import ( - STATE_AUTO, STATE_ECO, STATE_MANUAL, STATE_OFF, +from homeassistant.components.climate import ClimateDevice +from homeassistant.components.climate.const import ( + STATE_AUTO, STATE_ECO, STATE_MANUAL, SUPPORT_AWAY_MODE, SUPPORT_ON_OFF, SUPPORT_OPERATION_MODE, SUPPORT_TARGET_TEMPERATURE, - ClimateDevice ) from homeassistant.components.evohome import ( DATA_EVOHOME, DISPATCHER_EVOHOME, @@ -22,6 +22,7 @@ from homeassistant.const import ( CONF_SCAN_INTERVAL, HTTP_TOO_MANY_REQUESTS, PRECISION_HALVES, + STATE_OFF, TEMP_CELSIUS ) from homeassistant.core import callback diff --git a/homeassistant/components/fritzbox/climate.py b/homeassistant/components/fritzbox/climate.py index 64d99ebf133f..e8c20061b4e2 100644 --- a/homeassistant/components/fritzbox/climate.py +++ b/homeassistant/components/fritzbox/climate.py @@ -8,13 +8,14 @@ from homeassistant.components.fritzbox import ( ATTR_STATE_DEVICE_LOCKED, ATTR_STATE_BATTERY_LOW, ATTR_STATE_HOLIDAY_MODE, ATTR_STATE_LOCKED, ATTR_STATE_SUMMER_MODE, ATTR_STATE_WINDOW_OPEN) -from homeassistant.components.climate import ( - ATTR_OPERATION_MODE, ClimateDevice, STATE_ECO, STATE_HEAT, STATE_MANUAL, - STATE_OFF, STATE_ON, SUPPORT_OPERATION_MODE, +from homeassistant.components.climate import ClimateDevice +from homeassistant.components.climate.const import ( + ATTR_OPERATION_MODE, STATE_ECO, STATE_HEAT, STATE_MANUAL, + SUPPORT_OPERATION_MODE, SUPPORT_TARGET_TEMPERATURE) from homeassistant.const import ( - ATTR_BATTERY_LEVEL, ATTR_TEMPERATURE, PRECISION_HALVES, TEMP_CELSIUS) - + ATTR_BATTERY_LEVEL, ATTR_TEMPERATURE, PRECISION_HALVES, TEMP_CELSIUS, + STATE_OFF, STATE_ON) DEPENDENCIES = ['fritzbox'] _LOGGER = logging.getLogger(__name__) diff --git a/homeassistant/components/google_assistant/trait.py b/homeassistant/components/google_assistant/trait.py index af2d726328e4..d0368ee07759 100644 --- a/homeassistant/components/google_assistant/trait.py +++ b/homeassistant/components/google_assistant/trait.py @@ -2,7 +2,6 @@ import logging from homeassistant.components import ( - climate, cover, group, fan, @@ -15,6 +14,7 @@ from homeassistant.components import ( switch, vacuum, ) +from homeassistant.components.climate import const as climate from homeassistant.const import ( ATTR_ENTITY_ID, SERVICE_TURN_OFF, @@ -24,6 +24,7 @@ from homeassistant.const import ( TEMP_CELSIUS, TEMP_FAHRENHEIT, ATTR_SUPPORTED_FEATURES, + ATTR_TEMPERATURE, ) from homeassistant.core import DOMAIN as HA_DOMAIN from homeassistant.util import color as color_util, temperature as temp_util @@ -516,7 +517,7 @@ class TemperatureSettingTrait(_Trait): hass_to_google = { climate.STATE_HEAT: 'heat', climate.STATE_COOL: 'cool', - climate.STATE_OFF: 'off', + STATE_OFF: 'off', climate.STATE_AUTO: 'heatcool', climate.STATE_FAN_ONLY: 'fan-only', climate.STATE_DRY: 'dry', @@ -576,7 +577,7 @@ class TemperatureSettingTrait(_Trait): round(temp_util.convert(attrs[climate.ATTR_TARGET_TEMP_LOW], unit, TEMP_CELSIUS), 1) else: - target_temp = attrs.get(climate.ATTR_TEMPERATURE) + target_temp = attrs.get(ATTR_TEMPERATURE) if target_temp is not None: response['thermostatTemperatureSetpoint'] = round( temp_util.convert(target_temp, unit, TEMP_CELSIUS), 1) @@ -606,7 +607,7 @@ class TemperatureSettingTrait(_Trait): await self.hass.services.async_call( climate.DOMAIN, climate.SERVICE_SET_TEMPERATURE, { ATTR_ENTITY_ID: self.state.entity_id, - climate.ATTR_TEMPERATURE: temp + ATTR_TEMPERATURE: temp }, blocking=True) elif command == COMMAND_THERMOSTAT_TEMPERATURE_SET_RANGE: diff --git a/homeassistant/components/hive/climate.py b/homeassistant/components/hive/climate.py index 2ecc195061a6..45829cda0873 100644 --- a/homeassistant/components/hive/climate.py +++ b/homeassistant/components/hive/climate.py @@ -1,9 +1,11 @@ """Support for the Hive climate devices.""" -from homeassistant.components.climate import ( - STATE_AUTO, STATE_HEAT, STATE_OFF, STATE_ON, SUPPORT_AUX_HEAT, - SUPPORT_OPERATION_MODE, SUPPORT_TARGET_TEMPERATURE, ClimateDevice) +from homeassistant.components.climate import ClimateDevice +from homeassistant.components.climate.const import ( + STATE_AUTO, STATE_HEAT, + SUPPORT_AUX_HEAT, SUPPORT_TARGET_TEMPERATURE, SUPPORT_OPERATION_MODE) from homeassistant.components.hive import DATA_HIVE, DOMAIN -from homeassistant.const import ATTR_TEMPERATURE, TEMP_CELSIUS +from homeassistant.const import ( + ATTR_TEMPERATURE, STATE_OFF, STATE_ON, TEMP_CELSIUS) DEPENDENCIES = ['hive'] diff --git a/homeassistant/components/homekit/type_thermostats.py b/homeassistant/components/homekit/type_thermostats.py index 4a9ccdee0098..85cf7938fbde 100644 --- a/homeassistant/components/homekit/type_thermostats.py +++ b/homeassistant/components/homekit/type_thermostats.py @@ -3,7 +3,7 @@ import logging from pyhap.const import CATEGORY_THERMOSTAT -from homeassistant.components.climate import ( +from homeassistant.components.climate.const import ( ATTR_CURRENT_TEMPERATURE, ATTR_MAX_TEMP, ATTR_MIN_TEMP, ATTR_OPERATION_LIST, ATTR_OPERATION_MODE, ATTR_TARGET_TEMP_HIGH, ATTR_TARGET_TEMP_LOW, DEFAULT_MAX_TEMP, DEFAULT_MIN_TEMP, diff --git a/homeassistant/components/homekit_controller/climate.py b/homeassistant/components/homekit_controller/climate.py index 5531b266d21e..ceadcd46b9d3 100644 --- a/homeassistant/components/homekit_controller/climate.py +++ b/homeassistant/components/homekit_controller/climate.py @@ -1,12 +1,13 @@ """Support for Homekit climate devices.""" import logging -from homeassistant.components.climate import ( - STATE_COOL, STATE_HEAT, STATE_IDLE, SUPPORT_OPERATION_MODE, - SUPPORT_TARGET_TEMPERATURE, ClimateDevice) +from homeassistant.components.climate import ClimateDevice +from homeassistant.components.climate.const import ( + STATE_HEAT, STATE_COOL, STATE_IDLE, + SUPPORT_TARGET_TEMPERATURE, SUPPORT_OPERATION_MODE) from homeassistant.components.homekit_controller import ( - KNOWN_ACCESSORIES, HomeKitEntity) -from homeassistant.const import ATTR_TEMPERATURE, STATE_OFF, TEMP_CELSIUS + HomeKitEntity, KNOWN_ACCESSORIES) +from homeassistant.const import TEMP_CELSIUS, STATE_OFF, ATTR_TEMPERATURE DEPENDENCIES = ['homekit_controller'] diff --git a/homeassistant/components/homematic/climate.py b/homeassistant/components/homematic/climate.py index 4fc4b190808d..e5eb292b4ff9 100644 --- a/homeassistant/components/homematic/climate.py +++ b/homeassistant/components/homematic/climate.py @@ -1,9 +1,10 @@ """Support for Homematic thermostats.""" import logging -from homeassistant.components.climate import ( +from homeassistant.components.climate import ClimateDevice +from homeassistant.components.climate.const import ( STATE_AUTO, STATE_MANUAL, SUPPORT_OPERATION_MODE, - SUPPORT_TARGET_TEMPERATURE, ClimateDevice) + SUPPORT_TARGET_TEMPERATURE) from homeassistant.components.homematic import ( ATTR_DISCOVER_DEVICES, HM_ATTRIBUTE_SUPPORT, HMDevice) from homeassistant.const import ATTR_TEMPERATURE, TEMP_CELSIUS diff --git a/homeassistant/components/homematicip_cloud/climate.py b/homeassistant/components/homematicip_cloud/climate.py index 2dff48774bb7..08c88bbb796b 100644 --- a/homeassistant/components/homematicip_cloud/climate.py +++ b/homeassistant/components/homematicip_cloud/climate.py @@ -1,12 +1,12 @@ """Support for HomematicIP Cloud climate devices.""" import logging -from homeassistant.components.climate import ( - ATTR_TEMPERATURE, STATE_AUTO, STATE_MANUAL, SUPPORT_TARGET_TEMPERATURE, - ClimateDevice) +from homeassistant.components.climate import ClimateDevice +from homeassistant.components.climate.const import ( + STATE_AUTO, STATE_MANUAL, SUPPORT_TARGET_TEMPERATURE) from homeassistant.components.homematicip_cloud import ( DOMAIN as HMIPC_DOMAIN, HMIPC_HAPID, HomematicipGenericDevice) -from homeassistant.const import TEMP_CELSIUS +from homeassistant.const import ATTR_TEMPERATURE, TEMP_CELSIUS _LOGGER = logging.getLogger(__name__) diff --git a/homeassistant/components/knx/climate.py b/homeassistant/components/knx/climate.py index 82eaa52ae5a4..7e172287d4d5 100644 --- a/homeassistant/components/knx/climate.py +++ b/homeassistant/components/knx/climate.py @@ -1,11 +1,12 @@ """Support for KNX/IP climate devices.""" import voluptuous as vol import homeassistant.helpers.config_validation as cv -from homeassistant.components.climate import ( - PLATFORM_SCHEMA, SUPPORT_ON_OFF, SUPPORT_OPERATION_MODE, +from homeassistant.components.climate import ClimateDevice, PLATFORM_SCHEMA +from homeassistant.components.climate.const import ( + SUPPORT_ON_OFF, SUPPORT_OPERATION_MODE, SUPPORT_TARGET_TEMPERATURE, STATE_HEAT, STATE_IDLE, STATE_MANUAL, STATE_DRY, - STATE_FAN_ONLY, STATE_ECO, ClimateDevice) + STATE_FAN_ONLY, STATE_ECO) from homeassistant.const import ( ATTR_TEMPERATURE, CONF_NAME, TEMP_CELSIUS) from homeassistant.core import callback diff --git a/homeassistant/components/maxcube/climate.py b/homeassistant/components/maxcube/climate.py index f5c4533123f1..170a3ba349cc 100644 --- a/homeassistant/components/maxcube/climate.py +++ b/homeassistant/components/maxcube/climate.py @@ -2,8 +2,9 @@ import socket import logging -from homeassistant.components.climate import ( - ClimateDevice, STATE_AUTO, SUPPORT_TARGET_TEMPERATURE, +from homeassistant.components.climate import ClimateDevice +from homeassistant.components.climate.const import ( + STATE_AUTO, SUPPORT_TARGET_TEMPERATURE, SUPPORT_OPERATION_MODE) from homeassistant.components.maxcube import DATA_KEY from homeassistant.const import TEMP_CELSIUS, ATTR_TEMPERATURE diff --git a/homeassistant/components/modbus/climate.py b/homeassistant/components/modbus/climate.py index ed8cbda863f7..860816cb63ed 100644 --- a/homeassistant/components/modbus/climate.py +++ b/homeassistant/components/modbus/climate.py @@ -6,8 +6,9 @@ import voluptuous as vol from homeassistant.const import ( CONF_NAME, CONF_SLAVE, ATTR_TEMPERATURE) -from homeassistant.components.climate import ( - ClimateDevice, PLATFORM_SCHEMA, SUPPORT_TARGET_TEMPERATURE) +from homeassistant.components.climate import ClimateDevice, PLATFORM_SCHEMA +from homeassistant.components.climate.const import ( + SUPPORT_TARGET_TEMPERATURE) from homeassistant.components.modbus import ( CONF_HUB, DEFAULT_HUB, DOMAIN as MODBUS_DOMAIN) import homeassistant.helpers.config_validation as cv diff --git a/homeassistant/components/mqtt/climate.py b/homeassistant/components/mqtt/climate.py index c028ca5a6f69..957e1aadfb7a 100644 --- a/homeassistant/components/mqtt/climate.py +++ b/homeassistant/components/mqtt/climate.py @@ -10,11 +10,13 @@ import voluptuous as vol from homeassistant.components import climate, mqtt from homeassistant.components.climate import ( + ClimateDevice, PLATFORM_SCHEMA as CLIMATE_PLATFORM_SCHEMA) +from homeassistant.components.climate.const import ( ATTR_OPERATION_MODE, DEFAULT_MAX_TEMP, DEFAULT_MIN_TEMP, - PLATFORM_SCHEMA as CLIMATE_PLATFORM_SCHEMA, STATE_AUTO, STATE_COOL, + STATE_AUTO, STATE_COOL, STATE_DRY, STATE_FAN_ONLY, STATE_HEAT, SUPPORT_AUX_HEAT, SUPPORT_AWAY_MODE, SUPPORT_FAN_MODE, SUPPORT_HOLD_MODE, SUPPORT_OPERATION_MODE, - SUPPORT_SWING_MODE, SUPPORT_TARGET_TEMPERATURE, ClimateDevice) + SUPPORT_SWING_MODE, SUPPORT_TARGET_TEMPERATURE) from homeassistant.components.fan import SPEED_HIGH, SPEED_LOW, SPEED_MEDIUM from homeassistant.components.mqtt import ( ATTR_DISCOVERY_HASH, CONF_QOS, CONF_RETAIN, CONF_STATE_TOPIC, diff --git a/homeassistant/components/mysensors/climate.py b/homeassistant/components/mysensors/climate.py index 20d608e1ca5f..f8c52f65cdaa 100644 --- a/homeassistant/components/mysensors/climate.py +++ b/homeassistant/components/mysensors/climate.py @@ -1,12 +1,13 @@ """MySensors platform that offers a Climate (MySensors-HVAC) component.""" from homeassistant.components import mysensors -from homeassistant.components.climate import ( +from homeassistant.components.climate import ClimateDevice +from homeassistant.components.climate.const import ( ATTR_TARGET_TEMP_HIGH, ATTR_TARGET_TEMP_LOW, DOMAIN, STATE_AUTO, - STATE_COOL, STATE_HEAT, STATE_OFF, SUPPORT_FAN_MODE, + STATE_COOL, STATE_HEAT, SUPPORT_FAN_MODE, SUPPORT_OPERATION_MODE, SUPPORT_TARGET_TEMPERATURE, - SUPPORT_TARGET_TEMPERATURE_HIGH, SUPPORT_TARGET_TEMPERATURE_LOW, - ClimateDevice) -from homeassistant.const import ATTR_TEMPERATURE, TEMP_CELSIUS, TEMP_FAHRENHEIT + SUPPORT_TARGET_TEMPERATURE_HIGH, SUPPORT_TARGET_TEMPERATURE_LOW) +from homeassistant.const import ( + ATTR_TEMPERATURE, STATE_OFF, TEMP_CELSIUS, TEMP_FAHRENHEIT) DICT_HA_TO_MYS = { STATE_AUTO: 'AutoChangeOver', diff --git a/homeassistant/components/nest/__init__.py b/homeassistant/components/nest/__init__.py index fe6a34cf4044..21aaa2109a10 100644 --- a/homeassistant/components/nest/__init__.py +++ b/homeassistant/components/nest/__init__.py @@ -7,7 +7,7 @@ import threading import voluptuous as vol from homeassistant import config_entries -from homeassistant.components.climate import ( +from homeassistant.components.climate.const import ( ATTR_AWAY_MODE, SERVICE_SET_AWAY_MODE) from homeassistant.const import ( CONF_BINARY_SENSORS, CONF_FILENAME, CONF_MONITORED_CONDITIONS, diff --git a/homeassistant/components/nest/climate.py b/homeassistant/components/nest/climate.py index 8746a1959ae2..88b6cbbbeb00 100644 --- a/homeassistant/components/nest/climate.py +++ b/homeassistant/components/nest/climate.py @@ -5,14 +5,15 @@ import voluptuous as vol from homeassistant.components.nest import ( DATA_NEST, SIGNAL_NEST_UPDATE, DOMAIN as NEST_DOMAIN) -from homeassistant.components.climate import ( - STATE_AUTO, STATE_COOL, STATE_HEAT, STATE_ECO, ClimateDevice, - PLATFORM_SCHEMA, ATTR_TARGET_TEMP_HIGH, ATTR_TARGET_TEMP_LOW, - ATTR_TEMPERATURE, SUPPORT_TARGET_TEMPERATURE, +from homeassistant.components.climate import ClimateDevice, PLATFORM_SCHEMA +from homeassistant.components.climate.const import ( + STATE_AUTO, STATE_COOL, STATE_HEAT, STATE_ECO, + ATTR_TARGET_TEMP_HIGH, ATTR_TARGET_TEMP_LOW, + SUPPORT_TARGET_TEMPERATURE, SUPPORT_TARGET_TEMPERATURE_HIGH, SUPPORT_TARGET_TEMPERATURE_LOW, SUPPORT_OPERATION_MODE, SUPPORT_AWAY_MODE, SUPPORT_FAN_MODE) from homeassistant.const import ( - TEMP_CELSIUS, TEMP_FAHRENHEIT, + ATTR_TEMPERATURE, TEMP_CELSIUS, TEMP_FAHRENHEIT, CONF_SCAN_INTERVAL, STATE_ON, STATE_OFF) from homeassistant.helpers.dispatcher import async_dispatcher_connect diff --git a/homeassistant/components/nest/sensor.py b/homeassistant/components/nest/sensor.py index 10fa83d23e0f..bde3f681c2b5 100644 --- a/homeassistant/components/nest/sensor.py +++ b/homeassistant/components/nest/sensor.py @@ -1,7 +1,7 @@ """Support for Nest Thermostat sensors.""" import logging -from homeassistant.components.climate import ( +from homeassistant.components.climate.const import ( STATE_COOL, STATE_HEAT) from homeassistant.components.nest import ( DATA_NEST, DATA_NEST_CONFIG, CONF_SENSORS, NestSensorDevice) diff --git a/homeassistant/components/netatmo/climate.py b/homeassistant/components/netatmo/climate.py index 2b9bcbebaf29..1e16f2d3e050 100644 --- a/homeassistant/components/netatmo/climate.py +++ b/homeassistant/components/netatmo/climate.py @@ -4,8 +4,9 @@ from datetime import timedelta import voluptuous as vol from homeassistant.const import TEMP_CELSIUS, ATTR_TEMPERATURE -from homeassistant.components.climate import ( - STATE_HEAT, STATE_IDLE, ClimateDevice, PLATFORM_SCHEMA, +from homeassistant.components.climate import ClimateDevice, PLATFORM_SCHEMA +from homeassistant.components.climate.const import ( + STATE_HEAT, STATE_IDLE, SUPPORT_TARGET_TEMPERATURE, SUPPORT_OPERATION_MODE, SUPPORT_AWAY_MODE) from homeassistant.util import Throttle import homeassistant.helpers.config_validation as cv diff --git a/homeassistant/components/opentherm_gw/climate.py b/homeassistant/components/opentherm_gw/climate.py index ff6acc1a8845..584be4c0c648 100644 --- a/homeassistant/components/opentherm_gw/climate.py +++ b/homeassistant/components/opentherm_gw/climate.py @@ -1,9 +1,9 @@ """Support for OpenTherm Gateway climate devices.""" import logging -from homeassistant.components.climate import (ClimateDevice, STATE_IDLE, - STATE_HEAT, STATE_COOL, - SUPPORT_TARGET_TEMPERATURE) +from homeassistant.components.climate import ClimateDevice +from homeassistant.components.climate.const import ( + STATE_IDLE, STATE_HEAT, STATE_COOL, SUPPORT_TARGET_TEMPERATURE) from homeassistant.components.opentherm_gw import ( CONF_FLOOR_TEMP, CONF_PRECISION, DATA_DEVICE, DATA_GW_VARS, DATA_OPENTHERM_GW, SIGNAL_OPENTHERM_GW_UPDATE) diff --git a/homeassistant/components/prometheus/__init__.py b/homeassistant/components/prometheus/__init__.py index 4508611e51b4..65c1fbc4eb05 100644 --- a/homeassistant/components/prometheus/__init__.py +++ b/homeassistant/components/prometheus/__init__.py @@ -5,7 +5,7 @@ from aiohttp import web import voluptuous as vol from homeassistant import core as hacore -from homeassistant.components.climate import ATTR_CURRENT_TEMPERATURE +from homeassistant.components.climate.const import ATTR_CURRENT_TEMPERATURE from homeassistant.components.http import HomeAssistantView from homeassistant.const import ( ATTR_TEMPERATURE, ATTR_UNIT_OF_MEASUREMENT, CONTENT_TYPE_TEXT_PLAIN, diff --git a/homeassistant/components/smartthings/climate.py b/homeassistant/components/smartthings/climate.py index 9340bcef337b..d70d865202df 100644 --- a/homeassistant/components/smartthings/climate.py +++ b/homeassistant/components/smartthings/climate.py @@ -1,13 +1,14 @@ """Support for climate devices through the SmartThings cloud API.""" import asyncio -from homeassistant.components.climate import ( +from homeassistant.components.climate import ClimateDevice +from homeassistant.components.climate.const import ( ATTR_OPERATION_MODE, ATTR_TARGET_TEMP_HIGH, ATTR_TARGET_TEMP_LOW, - ATTR_TEMPERATURE, STATE_AUTO, STATE_COOL, STATE_ECO, STATE_HEAT, STATE_OFF, + STATE_AUTO, STATE_COOL, STATE_ECO, STATE_HEAT, SUPPORT_FAN_MODE, SUPPORT_OPERATION_MODE, SUPPORT_TARGET_TEMPERATURE, - SUPPORT_TARGET_TEMPERATURE_HIGH, SUPPORT_TARGET_TEMPERATURE_LOW, - ClimateDevice) -from homeassistant.const import TEMP_CELSIUS, TEMP_FAHRENHEIT + SUPPORT_TARGET_TEMPERATURE_HIGH, SUPPORT_TARGET_TEMPERATURE_LOW) +from homeassistant.const import ( + ATTR_TEMPERATURE, STATE_OFF, TEMP_CELSIUS, TEMP_FAHRENHEIT) from . import SmartThingsEntity from .const import DATA_BROKERS, DOMAIN diff --git a/homeassistant/components/spider/climate.py b/homeassistant/components/spider/climate.py index 08af44ad1ad1..b3380ec8fb4b 100644 --- a/homeassistant/components/spider/climate.py +++ b/homeassistant/components/spider/climate.py @@ -2,12 +2,13 @@ import logging -from homeassistant.components.climate import ( - ATTR_TEMPERATURE, STATE_COOL, STATE_HEAT, STATE_IDLE, +from homeassistant.components.climate import ClimateDevice +from homeassistant.components.climate.const import ( + STATE_COOL, STATE_HEAT, STATE_IDLE, SUPPORT_OPERATION_MODE, SUPPORT_TARGET_TEMPERATURE, - SUPPORT_FAN_MODE, ClimateDevice) + SUPPORT_FAN_MODE) from homeassistant.components.spider import DOMAIN as SPIDER_DOMAIN -from homeassistant.const import TEMP_CELSIUS +from homeassistant.const import ATTR_TEMPERATURE, TEMP_CELSIUS DEPENDENCIES = ['spider'] diff --git a/homeassistant/components/tado/climate.py b/homeassistant/components/tado/climate.py index 1812d36b7cdb..d5f152bbd76d 100644 --- a/homeassistant/components/tado/climate.py +++ b/homeassistant/components/tado/climate.py @@ -2,8 +2,9 @@ import logging from homeassistant.const import (PRECISION_TENTHS, TEMP_CELSIUS) -from homeassistant.components.climate import ( - ClimateDevice, SUPPORT_TARGET_TEMPERATURE, SUPPORT_OPERATION_MODE) +from homeassistant.components.climate import ClimateDevice +from homeassistant.components.climate.const import ( + 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 diff --git a/homeassistant/components/tesla/climate.py b/homeassistant/components/tesla/climate.py index 302c0006bcf2..118e7204bca0 100644 --- a/homeassistant/components/tesla/climate.py +++ b/homeassistant/components/tesla/climate.py @@ -1,9 +1,9 @@ """Support for Tesla HVAC system.""" import logging -from homeassistant.components.climate import ( - ENTITY_ID_FORMAT, SUPPORT_OPERATION_MODE, SUPPORT_TARGET_TEMPERATURE, - ClimateDevice) +from homeassistant.components.climate import ClimateDevice, ENTITY_ID_FORMAT +from homeassistant.components.climate.const import ( + SUPPORT_OPERATION_MODE, SUPPORT_TARGET_TEMPERATURE) from homeassistant.components.tesla import DOMAIN as TESLA_DOMAIN from homeassistant.components.tesla import TeslaDevice from homeassistant.const import ( diff --git a/homeassistant/components/toon/climate.py b/homeassistant/components/toon/climate.py index 3397e3dacc2a..c07ccf79d261 100644 --- a/homeassistant/components/toon/climate.py +++ b/homeassistant/components/toon/climate.py @@ -1,9 +1,10 @@ """Support for Toon van Eneco Thermostats.""" -from homeassistant.components.climate import ( - ATTR_TEMPERATURE, STATE_COOL, STATE_ECO, STATE_HEAT, STATE_AUTO, - SUPPORT_OPERATION_MODE, SUPPORT_TARGET_TEMPERATURE, ClimateDevice) +from homeassistant.components.climate import ClimateDevice +from homeassistant.components.climate.const import ( + STATE_COOL, STATE_ECO, STATE_HEAT, STATE_AUTO, + SUPPORT_OPERATION_MODE, SUPPORT_TARGET_TEMPERATURE) import homeassistant.components.toon as toon_main -from homeassistant.const import TEMP_CELSIUS +from homeassistant.const import ATTR_TEMPERATURE, TEMP_CELSIUS SUPPORT_FLAGS = SUPPORT_TARGET_TEMPERATURE | SUPPORT_OPERATION_MODE diff --git a/homeassistant/components/tuya/climate.py b/homeassistant/components/tuya/climate.py index 97ff18ba911b..06714760a024 100644 --- a/homeassistant/components/tuya/climate.py +++ b/homeassistant/components/tuya/climate.py @@ -1,13 +1,14 @@ """Support for the Tuya climate devices.""" -from homeassistant.components.climate import ( - ATTR_TEMPERATURE, ENTITY_ID_FORMAT, STATE_AUTO, STATE_COOL, STATE_ECO, +from homeassistant.components.climate import ClimateDevice, ENTITY_ID_FORMAT +from homeassistant.components.climate.const import ( + STATE_AUTO, STATE_COOL, STATE_ECO, STATE_FAN_ONLY, STATE_HEAT, SUPPORT_FAN_MODE, SUPPORT_ON_OFF, - SUPPORT_OPERATION_MODE, SUPPORT_TARGET_TEMPERATURE, ClimateDevice) + SUPPORT_OPERATION_MODE, SUPPORT_TARGET_TEMPERATURE) from homeassistant.components.fan import SPEED_LOW, SPEED_MEDIUM, SPEED_HIGH from homeassistant.components.tuya import DATA_TUYA, TuyaDevice from homeassistant.const import ( - PRECISION_WHOLE, TEMP_CELSIUS, TEMP_FAHRENHEIT) + ATTR_TEMPERATURE, PRECISION_WHOLE, TEMP_CELSIUS, TEMP_FAHRENHEIT) DEPENDENCIES = ['tuya'] DEVICE_TYPE = 'climate' diff --git a/homeassistant/components/velbus/climate.py b/homeassistant/components/velbus/climate.py index ae7a28284921..1f45408a666c 100644 --- a/homeassistant/components/velbus/climate.py +++ b/homeassistant/components/velbus/climate.py @@ -1,8 +1,9 @@ """Support for Velbus thermostat.""" import logging -from homeassistant.components.climate import ( - STATE_HEAT, SUPPORT_TARGET_TEMPERATURE, ClimateDevice) +from homeassistant.components.climate import ClimateDevice +from homeassistant.components.climate.const import ( + STATE_HEAT, SUPPORT_TARGET_TEMPERATURE) from homeassistant.components.velbus import ( DOMAIN as VELBUS_DOMAIN, VelbusEntity) from homeassistant.const import ( diff --git a/homeassistant/components/vera/climate.py b/homeassistant/components/vera/climate.py index 7cd3129bc148..9c812da9208e 100644 --- a/homeassistant/components/vera/climate.py +++ b/homeassistant/components/vera/climate.py @@ -2,9 +2,10 @@ import logging from homeassistant.util import convert -from homeassistant.components.climate import ( - ClimateDevice, STATE_AUTO, STATE_COOL, - STATE_HEAT, ENTITY_ID_FORMAT, SUPPORT_TARGET_TEMPERATURE, +from homeassistant.components.climate import ClimateDevice, ENTITY_ID_FORMAT +from homeassistant.components.climate.const import ( + STATE_AUTO, STATE_COOL, + STATE_HEAT, SUPPORT_TARGET_TEMPERATURE, SUPPORT_OPERATION_MODE, SUPPORT_FAN_MODE) from homeassistant.const import ( STATE_ON, diff --git a/homeassistant/components/wink/climate.py b/homeassistant/components/wink/climate.py index 8d946bf03dfe..efd8eecf5afc 100644 --- a/homeassistant/components/wink/climate.py +++ b/homeassistant/components/wink/climate.py @@ -1,17 +1,18 @@ """Support for Wink thermostats and Air Conditioners.""" import logging -from homeassistant.components.climate import ( +from homeassistant.components.climate import ClimateDevice +from homeassistant.components.climate.const import ( ATTR_CURRENT_HUMIDITY, ATTR_TARGET_TEMP_HIGH, ATTR_TARGET_TEMP_LOW, - ATTR_TEMPERATURE, STATE_AUTO, STATE_COOL, STATE_ECO, + STATE_AUTO, STATE_COOL, STATE_ECO, STATE_FAN_ONLY, STATE_HEAT, SUPPORT_AUX_HEAT, SUPPORT_AWAY_MODE, SUPPORT_FAN_MODE, SUPPORT_OPERATION_MODE, SUPPORT_TARGET_TEMPERATURE, - SUPPORT_TARGET_TEMPERATURE_HIGH, SUPPORT_TARGET_TEMPERATURE_LOW, - ClimateDevice) + SUPPORT_TARGET_TEMPERATURE_HIGH, SUPPORT_TARGET_TEMPERATURE_LOW) from homeassistant.components.wink import DOMAIN, WinkDevice from homeassistant.const import ( - PRECISION_TENTHS, STATE_OFF, STATE_ON, STATE_UNKNOWN, TEMP_CELSIUS) + ATTR_TEMPERATURE, PRECISION_TENTHS, STATE_OFF, STATE_ON, STATE_UNKNOWN, + TEMP_CELSIUS) from homeassistant.helpers.temperature import display_temp as show_temp _LOGGER = logging.getLogger(__name__) diff --git a/homeassistant/components/xs1/climate.py b/homeassistant/components/xs1/climate.py index 92a2c75895ce..e579761474bb 100644 --- a/homeassistant/components/xs1/climate.py +++ b/homeassistant/components/xs1/climate.py @@ -2,10 +2,12 @@ from functools import partial import logging -from homeassistant.components.climate import ( - ATTR_TEMPERATURE, ClimateDevice, SUPPORT_TARGET_TEMPERATURE) +from homeassistant.components.climate import ClimateDevice +from homeassistant.components.climate.const import ( + SUPPORT_TARGET_TEMPERATURE) from homeassistant.components.xs1 import ( ACTUATORS, DOMAIN as COMPONENT_DOMAIN, SENSORS, XS1DeviceEntity) +from homeassistant.const import ATTR_TEMPERATURE DEPENDENCIES = ['xs1'] _LOGGER = logging.getLogger(__name__) diff --git a/homeassistant/components/zwave/climate.py b/homeassistant/components/zwave/climate.py index bf7b64549ace..b0ab273e86af 100644 --- a/homeassistant/components/zwave/climate.py +++ b/homeassistant/components/zwave/climate.py @@ -2,8 +2,9 @@ # Because we do not compile openzwave on CI import logging from homeassistant.core import callback -from homeassistant.components.climate import ( - DOMAIN, ClimateDevice, STATE_AUTO, STATE_COOL, STATE_HEAT, +from homeassistant.components.climate import ClimateDevice +from homeassistant.components.climate.const import ( + DOMAIN, STATE_AUTO, STATE_COOL, STATE_HEAT, SUPPORT_TARGET_TEMPERATURE, SUPPORT_FAN_MODE, SUPPORT_OPERATION_MODE, SUPPORT_SWING_MODE) from homeassistant.components.zwave import ZWaveDeviceEntity diff --git a/homeassistant/helpers/state.py b/homeassistant/helpers/state.py index 7d69defed480..bbed1ffbbcd9 100644 --- a/homeassistant/helpers/state.py +++ b/homeassistant/helpers/state.py @@ -218,7 +218,7 @@ def state_as_number(state: State) -> float: Raises ValueError if this is not possible. """ - from homeassistant.components.climate import ( + from homeassistant.components.climate.const import ( STATE_HEAT, STATE_COOL, STATE_IDLE) if state.state in (STATE_ON, STATE_LOCKED, STATE_ABOVE_HORIZON, diff --git a/tests/components/climate/common.py b/tests/components/climate/common.py index d1626e1f2354..b5b6137a0a8d 100644 --- a/tests/components/climate/common.py +++ b/tests/components/climate/common.py @@ -3,8 +3,9 @@ All containing methods are legacy helpers that should not be used by new components. Instead call the service directly. """ -from homeassistant.components.climate import ( - _LOGGER, ATTR_AUX_HEAT, ATTR_AWAY_MODE, ATTR_FAN_MODE, ATTR_HOLD_MODE, +from homeassistant.components.climate import _LOGGER +from homeassistant.components.climate.const import ( + ATTR_AUX_HEAT, ATTR_AWAY_MODE, ATTR_FAN_MODE, ATTR_HOLD_MODE, ATTR_HUMIDITY, ATTR_OPERATION_MODE, ATTR_SWING_MODE, ATTR_TARGET_TEMP_HIGH, ATTR_TARGET_TEMP_LOW, DOMAIN, SERVICE_SET_AWAY_MODE, SERVICE_SET_HOLD_MODE, SERVICE_SET_AUX_HEAT, SERVICE_SET_TEMPERATURE, SERVICE_SET_HUMIDITY, diff --git a/tests/components/climate/test_demo.py b/tests/components/climate/test_demo.py index 3a023916741c..3166b2d31586 100644 --- a/tests/components/climate/test_demo.py +++ b/tests/components/climate/test_demo.py @@ -8,7 +8,9 @@ from homeassistant.util.unit_system import ( METRIC_SYSTEM ) from homeassistant.setup import setup_component -from homeassistant.components import climate +from homeassistant.components.climate import ( + DOMAIN, SERVICE_TURN_OFF, SERVICE_TURN_ON) +from homeassistant.const import (ATTR_ENTITY_ID) from tests.common import get_test_home_assistant from tests.components.climate import common @@ -26,7 +28,7 @@ class TestDemoClimate(unittest.TestCase): """Set up things to be run when tests are started.""" self.hass = get_test_home_assistant() self.hass.config.units = METRIC_SYSTEM - assert setup_component(self.hass, climate.DOMAIN, { + assert setup_component(self.hass, DOMAIN, { 'climate': { 'platform': 'demo', }}) @@ -267,14 +269,14 @@ class TestDemoClimate(unittest.TestCase): state = self.hass.states.get(ENTITY_ECOBEE) assert 'auto' == state.state - self.hass.services.call(climate.DOMAIN, climate.SERVICE_TURN_OFF, - {climate.ATTR_ENTITY_ID: ENTITY_ECOBEE}) + self.hass.services.call(DOMAIN, SERVICE_TURN_OFF, + {ATTR_ENTITY_ID: ENTITY_ECOBEE}) self.hass.block_till_done() state = self.hass.states.get(ENTITY_ECOBEE) assert 'off' == state.state - self.hass.services.call(climate.DOMAIN, climate.SERVICE_TURN_ON, - {climate.ATTR_ENTITY_ID: ENTITY_ECOBEE}) + self.hass.services.call(DOMAIN, SERVICE_TURN_ON, + {ATTR_ENTITY_ID: ENTITY_ECOBEE}) self.hass.block_till_done() state = self.hass.states.get(ENTITY_ECOBEE) assert 'auto' == state.state diff --git a/tests/components/climate/test_generic_thermostat.py b/tests/components/climate/test_generic_thermostat.py index 8d2346260d93..1d532f4757cf 100644 --- a/tests/components/climate/test_generic_thermostat.py +++ b/tests/components/climate/test_generic_thermostat.py @@ -20,8 +20,9 @@ from homeassistant.const import ( ) from homeassistant import loader from homeassistant.util.unit_system import METRIC_SYSTEM -from homeassistant.components import climate, input_boolean, switch -from homeassistant.components.climate import STATE_HEAT, STATE_COOL +from homeassistant.components import input_boolean, switch +from homeassistant.components.climate.const import ( + ATTR_OPERATION_MODE, STATE_HEAT, STATE_COOL, DOMAIN) import homeassistant.components as comps from tests.common import assert_setup_component, mock_restore_cache from tests.components.climate import common @@ -77,7 +78,7 @@ async def test_heater_input_boolean(hass, setup_comp_1): assert await async_setup_component(hass, input_boolean.DOMAIN, { 'input_boolean': {'test': None}}) - assert await async_setup_component(hass, climate.DOMAIN, {'climate': { + assert await async_setup_component(hass, DOMAIN, {'climate': { 'platform': 'generic_thermostat', 'name': 'test', 'heater': heater_switch, @@ -105,7 +106,7 @@ async def test_heater_switch(hass, setup_comp_1): 'platform': 'test'}}) heater_switch = switch_1.entity_id - assert await async_setup_component(hass, climate.DOMAIN, {'climate': { + assert await async_setup_component(hass, DOMAIN, {'climate': { 'platform': 'generic_thermostat', 'name': 'test', 'heater': heater_switch, @@ -134,7 +135,7 @@ def setup_comp_2(hass): """Initialize components.""" hass.config.units = METRIC_SYSTEM assert hass.loop.run_until_complete(async_setup_component( - hass, climate.DOMAIN, {'climate': { + hass, DOMAIN, {'climate': { 'platform': 'generic_thermostat', 'name': 'test', 'cold_tolerance': 2, @@ -162,7 +163,7 @@ async def test_get_operation_modes(hass, setup_comp_2): """Test that the operation list returns the correct modes.""" state = hass.states.get(ENTITY) modes = state.attributes.get('operation_list') - assert [climate.STATE_HEAT, STATE_OFF] == modes + assert [STATE_HEAT, STATE_OFF] == modes async def test_set_target_temp(hass, setup_comp_2): @@ -355,7 +356,7 @@ async def test_operating_mode_heat(hass, setup_comp_2): _setup_sensor(hass, 25) await hass.async_block_till_done() calls = _setup_switch(hass, False) - common.async_set_operation_mode(hass, climate.STATE_HEAT) + common.async_set_operation_mode(hass, STATE_HEAT) await hass.async_block_till_done() assert 1 == len(calls) call = calls[0] @@ -385,7 +386,7 @@ def setup_comp_3(hass): """Initialize components.""" hass.config.temperature_unit = TEMP_CELSIUS assert hass.loop.run_until_complete(async_setup_component( - hass, climate.DOMAIN, {'climate': { + hass, DOMAIN, {'climate': { 'platform': 'generic_thermostat', 'name': 'test', 'cold_tolerance': 2, @@ -433,7 +434,7 @@ async def test_operating_mode_cool(hass, setup_comp_3): _setup_sensor(hass, 30) await hass.async_block_till_done() calls = _setup_switch(hass, False) - common.async_set_operation_mode(hass, climate.STATE_COOL) + common.async_set_operation_mode(hass, STATE_COOL) await hass.async_block_till_done() assert 1 == len(calls) call = calls[0] @@ -535,7 +536,7 @@ def setup_comp_4(hass): """Initialize components.""" hass.config.temperature_unit = TEMP_CELSIUS assert hass.loop.run_until_complete(async_setup_component( - hass, climate.DOMAIN, {'climate': { + hass, DOMAIN, {'climate': { 'platform': 'generic_thermostat', 'name': 'test', 'cold_tolerance': 0.3, @@ -611,7 +612,7 @@ async def test_mode_change_ac_trigger_off_not_long_enough(hass, setup_comp_4): _setup_sensor(hass, 25) await hass.async_block_till_done() assert 0 == len(calls) - common.async_set_operation_mode(hass, climate.STATE_OFF) + common.async_set_operation_mode(hass, STATE_OFF) await hass.async_block_till_done() assert 1 == len(calls) call = calls[0] @@ -628,7 +629,7 @@ async def test_mode_change_ac_trigger_on_not_long_enough(hass, setup_comp_4): _setup_sensor(hass, 30) await hass.async_block_till_done() assert 0 == len(calls) - common.async_set_operation_mode(hass, climate.STATE_HEAT) + common.async_set_operation_mode(hass, STATE_HEAT) await hass.async_block_till_done() assert 1 == len(calls) call = calls[0] @@ -642,7 +643,7 @@ def setup_comp_5(hass): """Initialize components.""" hass.config.temperature_unit = TEMP_CELSIUS assert hass.loop.run_until_complete(async_setup_component( - hass, climate.DOMAIN, {'climate': { + hass, DOMAIN, {'climate': { 'platform': 'generic_thermostat', 'name': 'test', 'cold_tolerance': 0.3, @@ -720,7 +721,7 @@ async def test_mode_change_ac_trigger_off_not_long_enough_2( _setup_sensor(hass, 25) await hass.async_block_till_done() assert 0 == len(calls) - common.async_set_operation_mode(hass, climate.STATE_OFF) + common.async_set_operation_mode(hass, STATE_OFF) await hass.async_block_till_done() assert 1 == len(calls) call = calls[0] @@ -737,7 +738,7 @@ async def test_mode_change_ac_trigger_on_not_long_enough_2(hass, setup_comp_5): _setup_sensor(hass, 30) await hass.async_block_till_done() assert 0 == len(calls) - common.async_set_operation_mode(hass, climate.STATE_HEAT) + common.async_set_operation_mode(hass, STATE_HEAT) await hass.async_block_till_done() assert 1 == len(calls) call = calls[0] @@ -751,7 +752,7 @@ def setup_comp_6(hass): """Initialize components.""" hass.config.temperature_unit = TEMP_CELSIUS assert hass.loop.run_until_complete(async_setup_component( - hass, climate.DOMAIN, {'climate': { + hass, DOMAIN, {'climate': { 'platform': 'generic_thermostat', 'name': 'test', 'cold_tolerance': 0.3, @@ -829,7 +830,7 @@ async def test_mode_change_heater_trigger_off_not_long_enough( _setup_sensor(hass, 30) await hass.async_block_till_done() assert 0 == len(calls) - common.async_set_operation_mode(hass, climate.STATE_OFF) + common.async_set_operation_mode(hass, STATE_OFF) await hass.async_block_till_done() assert 1 == len(calls) call = calls[0] @@ -847,7 +848,7 @@ async def test_mode_change_heater_trigger_on_not_long_enough( _setup_sensor(hass, 25) await hass.async_block_till_done() assert 0 == len(calls) - common.async_set_operation_mode(hass, climate.STATE_HEAT) + common.async_set_operation_mode(hass, STATE_HEAT) await hass.async_block_till_done() assert 1 == len(calls) call = calls[0] @@ -861,7 +862,7 @@ def setup_comp_7(hass): """Initialize components.""" hass.config.temperature_unit = TEMP_CELSIUS assert hass.loop.run_until_complete(async_setup_component( - hass, climate.DOMAIN, {'climate': { + hass, DOMAIN, {'climate': { 'platform': 'generic_thermostat', 'name': 'test', 'cold_tolerance': 0.3, @@ -933,7 +934,7 @@ def setup_comp_8(hass): """Initialize components.""" hass.config.temperature_unit = TEMP_CELSIUS assert hass.loop.run_until_complete(async_setup_component( - hass, climate.DOMAIN, {'climate': { + hass, DOMAIN, {'climate': { 'platform': 'generic_thermostat', 'name': 'test', 'cold_tolerance': 0.3, @@ -1000,7 +1001,7 @@ def setup_comp_9(hass): """Initialize components.""" hass.config.temperature_unit = TEMP_CELSIUS assert hass.loop.run_until_complete(async_setup_component( - hass, climate.DOMAIN, {'climate': [ + hass, DOMAIN, {'climate': [ { 'platform': 'generic_thermostat', 'name': 'test_heat', @@ -1080,7 +1081,7 @@ def setup_comp_10(hass): """Initialize components.""" hass.config.temperature_unit = TEMP_FAHRENHEIT assert hass.loop.run_until_complete(async_setup_component( - hass, climate.DOMAIN, {'climate': { + hass, DOMAIN, {'climate': { 'platform': 'generic_thermostat', 'name': 'test', 'cold_tolerance': 0.3, @@ -1109,7 +1110,7 @@ async def test_precision(hass, setup_comp_10): async def test_custom_setup_params(hass): """Test the setup with custom parameters.""" result = await async_setup_component( - hass, climate.DOMAIN, {'climate': { + hass, DOMAIN, {'climate': { 'platform': 'generic_thermostat', 'name': 'test', 'heater': ENT_SWITCH, @@ -1129,13 +1130,14 @@ async def test_restore_state(hass): """Ensure states are restored on startup.""" mock_restore_cache(hass, ( State('climate.test_thermostat', '0', {ATTR_TEMPERATURE: "20", - climate.ATTR_OPERATION_MODE: "off", ATTR_AWAY_MODE: "on"}), + ATTR_OPERATION_MODE: "off", + ATTR_AWAY_MODE: "on"}), )) hass.state = CoreState.starting await async_setup_component( - hass, climate.DOMAIN, {'climate': { + hass, DOMAIN, {'climate': { 'platform': 'generic_thermostat', 'name': 'test_thermostat', 'heater': ENT_SWITCH, @@ -1144,7 +1146,7 @@ async def test_restore_state(hass): state = hass.states.get('climate.test_thermostat') assert(state.attributes[ATTR_TEMPERATURE] == 20) - assert(state.attributes[climate.ATTR_OPERATION_MODE] == "off") + assert(state.attributes[ATTR_OPERATION_MODE] == "off") assert(state.state == STATE_OFF) @@ -1155,13 +1157,14 @@ async def test_no_restore_state(hass): """ mock_restore_cache(hass, ( State('climate.test_thermostat', '0', {ATTR_TEMPERATURE: "20", - climate.ATTR_OPERATION_MODE: "off", ATTR_AWAY_MODE: "on"}), + ATTR_OPERATION_MODE: "off", + ATTR_AWAY_MODE: "on"}), )) hass.state = CoreState.starting await async_setup_component( - hass, climate.DOMAIN, {'climate': { + hass, DOMAIN, {'climate': { 'platform': 'generic_thermostat', 'name': 'test_thermostat', 'heater': ENT_SWITCH, @@ -1191,7 +1194,7 @@ async def test_restore_state_uncoherence_case(hass): state = hass.states.get(ENTITY) assert 20 == state.attributes[ATTR_TEMPERATURE] assert STATE_OFF == \ - state.attributes[climate.ATTR_OPERATION_MODE] + state.attributes[ATTR_OPERATION_MODE] assert STATE_OFF == state.state assert 0 == len(calls) @@ -1199,12 +1202,12 @@ async def test_restore_state_uncoherence_case(hass): await hass.async_block_till_done() state = hass.states.get(ENTITY) assert STATE_OFF == \ - state.attributes[climate.ATTR_OPERATION_MODE] + state.attributes[ATTR_OPERATION_MODE] assert STATE_OFF == state.state async def _setup_climate(hass): - assert await async_setup_component(hass, climate.DOMAIN, {'climate': { + assert await async_setup_component(hass, DOMAIN, {'climate': { 'platform': 'generic_thermostat', 'name': 'test', 'cold_tolerance': 2, @@ -1220,6 +1223,6 @@ def _mock_restore_cache(hass, temperature=20, operation_mode=STATE_OFF): mock_restore_cache(hass, ( State(ENTITY, '0', { ATTR_TEMPERATURE: str(temperature), - climate.ATTR_OPERATION_MODE: operation_mode, + ATTR_OPERATION_MODE: operation_mode, ATTR_AWAY_MODE: "on"}), )) diff --git a/tests/components/climate/test_honeywell.py b/tests/components/climate/test_honeywell.py index 7daed2ff4a97..b01b5b35c35c 100644 --- a/tests/components/climate/test_honeywell.py +++ b/tests/components/climate/test_honeywell.py @@ -8,7 +8,7 @@ import somecomfort from homeassistant.const import ( CONF_USERNAME, CONF_PASSWORD, TEMP_CELSIUS, TEMP_FAHRENHEIT) -from homeassistant.components.climate import ( +from homeassistant.components.climate.const import ( ATTR_FAN_MODE, ATTR_OPERATION_MODE, ATTR_FAN_LIST, ATTR_OPERATION_LIST) import homeassistant.components.climate.honeywell as honeywell diff --git a/tests/components/climate/test_melissa.py b/tests/components/climate/test_melissa.py index 2c135bfc09d8..6b77981a9140 100644 --- a/tests/components/climate/test_melissa.py +++ b/tests/components/climate/test_melissa.py @@ -4,8 +4,9 @@ import json from homeassistant.components.climate.melissa import MelissaClimate -from homeassistant.components.climate import ( - melissa, SUPPORT_TARGET_TEMPERATURE, SUPPORT_OPERATION_MODE, +from homeassistant.components.climate import melissa +from homeassistant.components.climate.const import ( + SUPPORT_TARGET_TEMPERATURE, SUPPORT_OPERATION_MODE, SUPPORT_ON_OFF, SUPPORT_FAN_MODE, STATE_HEAT, STATE_FAN_ONLY, STATE_DRY, STATE_COOL, STATE_AUTO ) diff --git a/tests/components/climate/test_nuheat.py b/tests/components/climate/test_nuheat.py index 40b0732f661e..19919d259544 100644 --- a/tests/components/climate/test_nuheat.py +++ b/tests/components/climate/test_nuheat.py @@ -3,7 +3,7 @@ import unittest from unittest.mock import Mock, patch from tests.common import get_test_home_assistant -from homeassistant.components.climate import ( +from homeassistant.components.climate.const import ( SUPPORT_HOLD_MODE, SUPPORT_OPERATION_MODE, SUPPORT_TARGET_TEMPERATURE, diff --git a/tests/components/climate/test_reproduce_state.py b/tests/components/climate/test_reproduce_state.py index c16151320b44..8ec8e7b14290 100644 --- a/tests/components/climate/test_reproduce_state.py +++ b/tests/components/climate/test_reproduce_state.py @@ -2,13 +2,13 @@ import pytest -from homeassistant.components.climate import STATE_HEAT, async_reproduce_states +from homeassistant.components.climate import async_reproduce_states from homeassistant.components.climate.const import ( ATTR_AUX_HEAT, ATTR_AWAY_MODE, ATTR_HOLD_MODE, ATTR_HUMIDITY, ATTR_OPERATION_MODE, ATTR_SWING_MODE, ATTR_TARGET_TEMP_HIGH, ATTR_TARGET_TEMP_LOW, DOMAIN, SERVICE_SET_AUX_HEAT, SERVICE_SET_AWAY_MODE, SERVICE_SET_HOLD_MODE, SERVICE_SET_HUMIDITY, SERVICE_SET_OPERATION_MODE, - SERVICE_SET_SWING_MODE, SERVICE_SET_TEMPERATURE) + SERVICE_SET_SWING_MODE, SERVICE_SET_TEMPERATURE, STATE_HEAT) from homeassistant.const import ( ATTR_TEMPERATURE, SERVICE_TURN_OFF, SERVICE_TURN_ON, STATE_OFF, STATE_ON) from homeassistant.core import Context, State diff --git a/tests/components/ecobee/test_climate.py b/tests/components/ecobee/test_climate.py index 965fb37dcb81..f4412b5d564e 100644 --- a/tests/components/ecobee/test_climate.py +++ b/tests/components/ecobee/test_climate.py @@ -3,7 +3,7 @@ import unittest from unittest import mock import homeassistant.const as const from homeassistant.components.ecobee import climate as ecobee -from homeassistant.components.climate import STATE_OFF +from homeassistant.const import STATE_OFF class TestEcobee(unittest.TestCase): diff --git a/tests/components/google_assistant/test_google_assistant.py b/tests/components/google_assistant/test_google_assistant.py index 89e9090da98a..18f99c826852 100644 --- a/tests/components/google_assistant/test_google_assistant.py +++ b/tests/components/google_assistant/test_google_assistant.py @@ -8,7 +8,8 @@ import pytest from homeassistant import core, const, setup from homeassistant.components import ( - fan, cover, light, switch, climate, lock, async_setup, media_player) + fan, cover, light, switch, lock, async_setup, media_player) +from homeassistant.components.climate import const as climate from homeassistant.const import CLOUD_NEVER_EXPOSED_ENTITIES from homeassistant.components import google_assistant as ga diff --git a/tests/components/google_assistant/test_smart_home.py b/tests/components/google_assistant/test_smart_home.py index 36971224f92e..d7c6094bebb1 100644 --- a/tests/components/google_assistant/test_smart_home.py +++ b/tests/components/google_assistant/test_smart_home.py @@ -3,7 +3,9 @@ from homeassistant.core import State from homeassistant.const import ( ATTR_SUPPORTED_FEATURES, ATTR_UNIT_OF_MEASUREMENT, TEMP_CELSIUS) from homeassistant.setup import async_setup_component -from homeassistant.components import climate +from homeassistant.components.climate.const import ( + ATTR_MIN_TEMP, ATTR_MAX_TEMP, STATE_HEAT, SUPPORT_OPERATION_MODE +) from homeassistant.components.google_assistant import ( const, trait, helpers, smart_home as sh) from homeassistant.components.light.demo import DemoLight @@ -210,10 +212,10 @@ async def test_execute(hass): async def test_raising_error_trait(hass): """Test raising an error while executing a trait command.""" - hass.states.async_set('climate.bla', climate.STATE_HEAT, { - climate.ATTR_MIN_TEMP: 15, - climate.ATTR_MAX_TEMP: 30, - ATTR_SUPPORTED_FEATURES: climate.SUPPORT_OPERATION_MODE, + hass.states.async_set('climate.bla', STATE_HEAT, { + ATTR_MIN_TEMP: 15, + ATTR_MAX_TEMP: 30, + ATTR_SUPPORTED_FEATURES: SUPPORT_OPERATION_MODE, ATTR_UNIT_OF_MEASUREMENT: TEMP_CELSIUS, }) result = await sh.async_handle_message(hass, BASIC_CONFIG, { diff --git a/tests/components/google_assistant/test_trait.py b/tests/components/google_assistant/test_trait.py index e9169c9bbbe1..e051a5de4da4 100644 --- a/tests/components/google_assistant/test_trait.py +++ b/tests/components/google_assistant/test_trait.py @@ -2,7 +2,6 @@ import pytest from homeassistant.components import ( - climate, cover, fan, input_boolean, @@ -15,10 +14,11 @@ from homeassistant.components import ( vacuum, group, ) +from homeassistant.components.climate import const as climate from homeassistant.components.google_assistant import trait, helpers, const from homeassistant.const import ( STATE_ON, STATE_OFF, ATTR_ENTITY_ID, SERVICE_TURN_ON, SERVICE_TURN_OFF, - TEMP_CELSIUS, TEMP_FAHRENHEIT, ATTR_SUPPORTED_FEATURES) + TEMP_CELSIUS, TEMP_FAHRENHEIT, ATTR_SUPPORTED_FEATURES, ATTR_TEMPERATURE) from homeassistant.core import State, DOMAIN as HA_DOMAIN from homeassistant.util import color from tests.common import async_mock_service @@ -668,7 +668,7 @@ async def test_temperature_setting_climate_range(hass): climate.ATTR_CURRENT_HUMIDITY: 25, climate.ATTR_OPERATION_MODE: climate.STATE_AUTO, climate.ATTR_OPERATION_LIST: [ - climate.STATE_OFF, + STATE_OFF, climate.STATE_COOL, climate.STATE_HEAT, climate.STATE_AUTO, @@ -737,12 +737,12 @@ async def test_temperature_setting_climate_setpoint(hass): 'climate.bla', climate.STATE_AUTO, { climate.ATTR_OPERATION_MODE: climate.STATE_COOL, climate.ATTR_OPERATION_LIST: [ - climate.STATE_OFF, + STATE_OFF, climate.STATE_COOL, ], climate.ATTR_MIN_TEMP: 10, climate.ATTR_MAX_TEMP: 30, - climate.ATTR_TEMPERATURE: 18, + ATTR_TEMPERATURE: 18, climate.ATTR_CURRENT_TEMPERATURE: 20 }), BASIC_CONFIG) assert trt.sync_attributes() == { @@ -772,7 +772,7 @@ async def test_temperature_setting_climate_setpoint(hass): assert len(calls) == 1 assert calls[0].data == { ATTR_ENTITY_ID: 'climate.bla', - climate.ATTR_TEMPERATURE: 19 + ATTR_TEMPERATURE: 19 } diff --git a/tests/components/homekit/test_type_thermostats.py b/tests/components/homekit/test_type_thermostats.py index f645cddf7300..ce6774796d33 100644 --- a/tests/components/homekit/test_type_thermostats.py +++ b/tests/components/homekit/test_type_thermostats.py @@ -4,7 +4,7 @@ from unittest.mock import patch import pytest -from homeassistant.components.climate import ( +from homeassistant.components.climate.const import ( ATTR_CURRENT_TEMPERATURE, ATTR_MAX_TEMP, ATTR_MIN_TEMP, ATTR_TARGET_TEMP_LOW, ATTR_TARGET_TEMP_HIGH, ATTR_OPERATION_MODE, ATTR_OPERATION_LIST, DEFAULT_MAX_TEMP, DEFAULT_MIN_TEMP, diff --git a/tests/components/homekit_controller/test_climate.py b/tests/components/homekit_controller/test_climate.py index 9f5cc9d87642..b04a57fa967e 100644 --- a/tests/components/homekit_controller/test_climate.py +++ b/tests/components/homekit_controller/test_climate.py @@ -1,5 +1,5 @@ """Basic checks for HomeKitclimate.""" -from homeassistant.components.climate import ( +from homeassistant.components.climate.const import ( DOMAIN, SERVICE_SET_OPERATION_MODE, SERVICE_SET_TEMPERATURE) from tests.components.homekit_controller.common import ( setup_test_component) diff --git a/tests/components/mqtt/test_climate.py b/tests/components/mqtt/test_climate.py index ecbdc39e22bc..7bdfe8f452fa 100644 --- a/tests/components/mqtt/test_climate.py +++ b/tests/components/mqtt/test_climate.py @@ -7,11 +7,15 @@ from unittest.mock import ANY import pytest import voluptuous as vol -from homeassistant.components import climate, mqtt +from homeassistant.components import mqtt from homeassistant.components.climate import ( - DEFAULT_MAX_TEMP, DEFAULT_MIN_TEMP, SUPPORT_AUX_HEAT, SUPPORT_AWAY_MODE, + DEFAULT_MAX_TEMP, DEFAULT_MIN_TEMP) +from homeassistant.components.climate.const import ( + DOMAIN as CLIMATE_DOMAIN, + SUPPORT_AUX_HEAT, SUPPORT_AWAY_MODE, SUPPORT_FAN_MODE, SUPPORT_HOLD_MODE, SUPPORT_OPERATION_MODE, - SUPPORT_SWING_MODE, SUPPORT_TARGET_TEMPERATURE) + SUPPORT_SWING_MODE, SUPPORT_TARGET_TEMPERATURE, STATE_AUTO, + STATE_COOL, STATE_HEAT, STATE_DRY, STATE_FAN_ONLY) from homeassistant.components.mqtt.discovery import async_start from homeassistant.const import STATE_OFF, STATE_UNAVAILABLE from homeassistant.setup import setup_component @@ -54,7 +58,7 @@ class TestMQTTClimate(unittest.TestCase): def test_setup_params(self): """Test the initial parameters.""" - assert setup_component(self.hass, climate.DOMAIN, DEFAULT_CONFIG) + assert setup_component(self.hass, CLIMATE_DOMAIN, DEFAULT_CONFIG) state = self.hass.states.get(ENTITY_CLIMATE) assert 21 == state.attributes.get('temperature') @@ -66,7 +70,7 @@ class TestMQTTClimate(unittest.TestCase): def test_supported_features(self): """Test the supported_features.""" - assert setup_component(self.hass, climate.DOMAIN, DEFAULT_CONFIG) + assert setup_component(self.hass, CLIMATE_DOMAIN, DEFAULT_CONFIG) state = self.hass.states.get(ENTITY_CLIMATE) support = (SUPPORT_TARGET_TEMPERATURE | SUPPORT_OPERATION_MODE | @@ -77,13 +81,13 @@ class TestMQTTClimate(unittest.TestCase): def test_get_operation_modes(self): """Test that the operation list returns the correct modes.""" - assert setup_component(self.hass, climate.DOMAIN, DEFAULT_CONFIG) + assert setup_component(self.hass, CLIMATE_DOMAIN, DEFAULT_CONFIG) state = self.hass.states.get(ENTITY_CLIMATE) modes = state.attributes.get('operation_list') assert [ - climate.STATE_AUTO, STATE_OFF, climate.STATE_COOL, - climate.STATE_HEAT, climate.STATE_DRY, climate.STATE_FAN_ONLY + STATE_AUTO, STATE_OFF, STATE_COOL, + STATE_HEAT, STATE_DRY, STATE_FAN_ONLY ] == modes def test_set_operation_bad_attr_and_state(self): @@ -91,7 +95,7 @@ class TestMQTTClimate(unittest.TestCase): Also check the state. """ - assert setup_component(self.hass, climate.DOMAIN, DEFAULT_CONFIG) + assert setup_component(self.hass, CLIMATE_DOMAIN, DEFAULT_CONFIG) state = self.hass.states.get(ENTITY_CLIMATE) assert "off" == state.attributes.get('operation_mode') @@ -105,7 +109,7 @@ class TestMQTTClimate(unittest.TestCase): def test_set_operation(self): """Test setting of new operation mode.""" - assert setup_component(self.hass, climate.DOMAIN, DEFAULT_CONFIG) + assert setup_component(self.hass, CLIMATE_DOMAIN, DEFAULT_CONFIG) state = self.hass.states.get(ENTITY_CLIMATE) assert "off" == state.attributes.get('operation_mode') @@ -122,7 +126,7 @@ class TestMQTTClimate(unittest.TestCase): """Test setting operation mode in pessimistic mode.""" config = copy.deepcopy(DEFAULT_CONFIG) config['climate']['mode_state_topic'] = 'mode-state' - assert setup_component(self.hass, climate.DOMAIN, config) + assert setup_component(self.hass, CLIMATE_DOMAIN, config) state = self.hass.states.get(ENTITY_CLIMATE) assert state.attributes.get('operation_mode') is None @@ -150,7 +154,7 @@ class TestMQTTClimate(unittest.TestCase): """Test setting of new operation mode with power command enabled.""" config = copy.deepcopy(DEFAULT_CONFIG) config['climate']['power_command_topic'] = 'power-command' - assert setup_component(self.hass, climate.DOMAIN, config) + assert setup_component(self.hass, CLIMATE_DOMAIN, config) state = self.hass.states.get(ENTITY_CLIMATE) assert "off" == state.attributes.get('operation_mode') @@ -179,7 +183,7 @@ class TestMQTTClimate(unittest.TestCase): def test_set_fan_mode_bad_attr(self): """Test setting fan mode without required attribute.""" - assert setup_component(self.hass, climate.DOMAIN, DEFAULT_CONFIG) + assert setup_component(self.hass, CLIMATE_DOMAIN, DEFAULT_CONFIG) state = self.hass.states.get(ENTITY_CLIMATE) assert "low" == state.attributes.get('fan_mode') @@ -193,7 +197,7 @@ class TestMQTTClimate(unittest.TestCase): """Test setting of new fan mode in pessimistic mode.""" config = copy.deepcopy(DEFAULT_CONFIG) config['climate']['fan_mode_state_topic'] = 'fan-state' - assert setup_component(self.hass, climate.DOMAIN, config) + assert setup_component(self.hass, CLIMATE_DOMAIN, config) state = self.hass.states.get(ENTITY_CLIMATE) assert state.attributes.get('fan_mode') is None @@ -215,7 +219,7 @@ class TestMQTTClimate(unittest.TestCase): def test_set_fan_mode(self): """Test setting of new fan mode.""" - assert setup_component(self.hass, climate.DOMAIN, DEFAULT_CONFIG) + assert setup_component(self.hass, CLIMATE_DOMAIN, DEFAULT_CONFIG) state = self.hass.states.get(ENTITY_CLIMATE) assert "low" == state.attributes.get('fan_mode') @@ -228,7 +232,7 @@ class TestMQTTClimate(unittest.TestCase): def test_set_swing_mode_bad_attr(self): """Test setting swing mode without required attribute.""" - assert setup_component(self.hass, climate.DOMAIN, DEFAULT_CONFIG) + assert setup_component(self.hass, CLIMATE_DOMAIN, DEFAULT_CONFIG) state = self.hass.states.get(ENTITY_CLIMATE) assert "off" == state.attributes.get('swing_mode') @@ -242,7 +246,7 @@ class TestMQTTClimate(unittest.TestCase): """Test setting swing mode in pessimistic mode.""" config = copy.deepcopy(DEFAULT_CONFIG) config['climate']['swing_mode_state_topic'] = 'swing-state' - assert setup_component(self.hass, climate.DOMAIN, config) + assert setup_component(self.hass, CLIMATE_DOMAIN, config) state = self.hass.states.get(ENTITY_CLIMATE) assert state.attributes.get('swing_mode') is None @@ -264,7 +268,7 @@ class TestMQTTClimate(unittest.TestCase): def test_set_swing(self): """Test setting of new swing mode.""" - assert setup_component(self.hass, climate.DOMAIN, DEFAULT_CONFIG) + assert setup_component(self.hass, CLIMATE_DOMAIN, DEFAULT_CONFIG) state = self.hass.states.get(ENTITY_CLIMATE) assert "off" == state.attributes.get('swing_mode') @@ -277,7 +281,7 @@ class TestMQTTClimate(unittest.TestCase): def test_set_target_temperature(self): """Test setting the target temperature.""" - assert setup_component(self.hass, climate.DOMAIN, DEFAULT_CONFIG) + assert setup_component(self.hass, CLIMATE_DOMAIN, DEFAULT_CONFIG) state = self.hass.states.get(ENTITY_CLIMATE) assert 21 == state.attributes.get('temperature') @@ -315,7 +319,7 @@ class TestMQTTClimate(unittest.TestCase): """Test setting the target temperature.""" config = copy.deepcopy(DEFAULT_CONFIG) config['climate']['temperature_state_topic'] = 'temperature-state' - assert setup_component(self.hass, climate.DOMAIN, config) + assert setup_component(self.hass, CLIMATE_DOMAIN, config) state = self.hass.states.get(ENTITY_CLIMATE) assert state.attributes.get('temperature') is None @@ -342,7 +346,7 @@ class TestMQTTClimate(unittest.TestCase): config = copy.deepcopy(DEFAULT_CONFIG) config['climate']['current_temperature_topic'] = 'current_temperature' mock_component(self.hass, 'mqtt') - assert setup_component(self.hass, climate.DOMAIN, config) + assert setup_component(self.hass, CLIMATE_DOMAIN, config) fire_mqtt_message(self.hass, 'current_temperature', '47') self.hass.block_till_done() @@ -353,7 +357,7 @@ class TestMQTTClimate(unittest.TestCase): """Test setting of the away mode.""" config = copy.deepcopy(DEFAULT_CONFIG) config['climate']['away_mode_state_topic'] = 'away-state' - assert setup_component(self.hass, climate.DOMAIN, config) + assert setup_component(self.hass, CLIMATE_DOMAIN, config) state = self.hass.states.get(ENTITY_CLIMATE) assert 'off' == state.attributes.get('away_mode') @@ -384,7 +388,7 @@ class TestMQTTClimate(unittest.TestCase): config['climate']['payload_on'] = 'AN' config['climate']['payload_off'] = 'AUS' - assert setup_component(self.hass, climate.DOMAIN, config) + assert setup_component(self.hass, CLIMATE_DOMAIN, config) state = self.hass.states.get(ENTITY_CLIMATE) assert 'off' == state.attributes.get('away_mode') @@ -407,7 +411,7 @@ class TestMQTTClimate(unittest.TestCase): """Test setting the hold mode in pessimistic mode.""" config = copy.deepcopy(DEFAULT_CONFIG) config['climate']['hold_state_topic'] = 'hold-state' - assert setup_component(self.hass, climate.DOMAIN, config) + assert setup_component(self.hass, CLIMATE_DOMAIN, config) state = self.hass.states.get(ENTITY_CLIMATE) assert state.attributes.get('hold_mode') is None @@ -429,7 +433,7 @@ class TestMQTTClimate(unittest.TestCase): def test_set_hold(self): """Test setting the hold mode.""" - assert setup_component(self.hass, climate.DOMAIN, DEFAULT_CONFIG) + assert setup_component(self.hass, CLIMATE_DOMAIN, DEFAULT_CONFIG) state = self.hass.states.get(ENTITY_CLIMATE) assert state.attributes.get('hold_mode') is None @@ -452,7 +456,7 @@ class TestMQTTClimate(unittest.TestCase): """Test setting of the aux heating in pessimistic mode.""" config = copy.deepcopy(DEFAULT_CONFIG) config['climate']['aux_state_topic'] = 'aux-state' - assert setup_component(self.hass, climate.DOMAIN, config) + assert setup_component(self.hass, CLIMATE_DOMAIN, config) state = self.hass.states.get(ENTITY_CLIMATE) assert 'off' == state.attributes.get('aux_heat') @@ -479,7 +483,7 @@ class TestMQTTClimate(unittest.TestCase): def test_set_aux(self): """Test setting of the aux heating.""" - assert setup_component(self.hass, climate.DOMAIN, DEFAULT_CONFIG) + assert setup_component(self.hass, CLIMATE_DOMAIN, DEFAULT_CONFIG) state = self.hass.states.get(ENTITY_CLIMATE) assert 'off' == state.attributes.get('aux_heat') @@ -505,7 +509,7 @@ class TestMQTTClimate(unittest.TestCase): config['climate']['payload_available'] = 'good' config['climate']['payload_not_available'] = 'nogood' - assert setup_component(self.hass, climate.DOMAIN, config) + assert setup_component(self.hass, CLIMATE_DOMAIN, config) state = self.hass.states.get('climate.test') assert STATE_UNAVAILABLE == state.state @@ -543,7 +547,7 @@ class TestMQTTClimate(unittest.TestCase): config['climate']['aux_state_topic'] = 'aux-state' config['climate']['current_temperature_topic'] = 'current-temperature' - assert setup_component(self.hass, climate.DOMAIN, config) + assert setup_component(self.hass, CLIMATE_DOMAIN, config) # Operation Mode state = self.hass.states.get(ENTITY_CLIMATE) @@ -638,7 +642,7 @@ class TestMQTTClimate(unittest.TestCase): config = copy.deepcopy(DEFAULT_CONFIG) config['climate']['min_temp'] = 26 - assert setup_component(self.hass, climate.DOMAIN, config) + assert setup_component(self.hass, CLIMATE_DOMAIN, config) state = self.hass.states.get(ENTITY_CLIMATE) min_temp = state.attributes.get('min_temp') @@ -651,7 +655,7 @@ class TestMQTTClimate(unittest.TestCase): config = copy.deepcopy(DEFAULT_CONFIG) config['climate']['max_temp'] = 60 - assert setup_component(self.hass, climate.DOMAIN, config) + assert setup_component(self.hass, CLIMATE_DOMAIN, config) state = self.hass.states.get(ENTITY_CLIMATE) max_temp = state.attributes.get('max_temp') @@ -664,7 +668,7 @@ class TestMQTTClimate(unittest.TestCase): config = copy.deepcopy(DEFAULT_CONFIG) config['climate']['temp_step'] = 0.01 - assert setup_component(self.hass, climate.DOMAIN, config) + assert setup_component(self.hass, CLIMATE_DOMAIN, config) state = self.hass.states.get(ENTITY_CLIMATE) temp_step = state.attributes.get('target_temp_step') @@ -675,8 +679,8 @@ class TestMQTTClimate(unittest.TestCase): async def test_setting_attribute_via_mqtt_json_message(hass, mqtt_mock): """Test the setting of attribute via MQTT with JSON payload.""" - assert await async_setup_component(hass, climate.DOMAIN, { - climate.DOMAIN: { + assert await async_setup_component(hass, CLIMATE_DOMAIN, { + CLIMATE_DOMAIN: { 'platform': 'mqtt', 'name': 'test', 'power_state_topic': 'test-topic', @@ -694,8 +698,8 @@ async def test_setting_attribute_via_mqtt_json_message(hass, mqtt_mock): async def test_update_with_json_attrs_not_dict(hass, mqtt_mock, caplog): """Test attributes get extracted from a JSON result.""" - assert await async_setup_component(hass, climate.DOMAIN, { - climate.DOMAIN: { + assert await async_setup_component(hass, CLIMATE_DOMAIN, { + CLIMATE_DOMAIN: { 'platform': 'mqtt', 'name': 'test', 'power_state_topic': 'test-topic', @@ -714,8 +718,8 @@ async def test_update_with_json_attrs_not_dict(hass, mqtt_mock, caplog): async def test_update_with_json_attrs_bad_JSON(hass, mqtt_mock, caplog): """Test attributes get extracted from a JSON result.""" - assert await async_setup_component(hass, climate.DOMAIN, { - climate.DOMAIN: { + assert await async_setup_component(hass, CLIMATE_DOMAIN, { + CLIMATE_DOMAIN: { 'platform': 'mqtt', 'name': 'test', 'power_state_topic': 'test-topic', @@ -781,8 +785,8 @@ async def test_discovery_update_attr(hass, mqtt_mock, caplog): async def test_unique_id(hass): """Test unique id option only creates one climate per unique_id.""" await async_mock_mqtt_component(hass) - assert await async_setup_component(hass, climate.DOMAIN, { - climate.DOMAIN: [{ + assert await async_setup_component(hass, CLIMATE_DOMAIN, { + CLIMATE_DOMAIN: [{ 'platform': 'mqtt', 'name': 'Test 1', 'power_state_topic': 'test-topic', @@ -798,7 +802,7 @@ async def test_unique_id(hass): }) async_fire_mqtt_message(hass, 'test-topic', 'payload') await hass.async_block_till_done() - assert len(hass.states.async_entity_ids(climate.DOMAIN)) == 1 + assert len(hass.states.async_entity_ids(CLIMATE_DOMAIN)) == 1 async def test_discovery_removal_climate(hass, mqtt_mock, caplog): @@ -974,8 +978,8 @@ async def test_entity_id_update(hass, mqtt_mock): """Test MQTT subscriptions are managed when entity_id is updated.""" registry = mock_registry(hass, {}) mock_mqtt = await async_mock_mqtt_component(hass) - assert await async_setup_component(hass, climate.DOMAIN, { - climate.DOMAIN: [{ + assert await async_setup_component(hass, CLIMATE_DOMAIN, { + CLIMATE_DOMAIN: [{ 'platform': 'mqtt', 'name': 'beer', 'mode_state_topic': 'test-topic', diff --git a/tests/components/smartthings/test_climate.py b/tests/components/smartthings/test_climate.py index 0f1102e2ab10..c615ca66e34c 100644 --- a/tests/components/smartthings/test_climate.py +++ b/tests/components/smartthings/test_climate.py @@ -8,18 +8,18 @@ from pysmartthings import Attribute, Capability from pysmartthings.device import Status import pytest -from homeassistant.components.climate import ( +from homeassistant.components.climate.const import ( ATTR_CURRENT_HUMIDITY, ATTR_CURRENT_TEMPERATURE, ATTR_FAN_LIST, ATTR_FAN_MODE, ATTR_OPERATION_LIST, ATTR_OPERATION_MODE, ATTR_TARGET_TEMP_HIGH, ATTR_TARGET_TEMP_LOW, DOMAIN as CLIMATE_DOMAIN, SERVICE_SET_FAN_MODE, SERVICE_SET_OPERATION_MODE, SERVICE_SET_TEMPERATURE, - STATE_AUTO, STATE_COOL, STATE_ECO, STATE_HEAT, STATE_OFF, SUPPORT_FAN_MODE, + STATE_AUTO, STATE_COOL, STATE_ECO, STATE_HEAT, SUPPORT_FAN_MODE, SUPPORT_OPERATION_MODE, SUPPORT_TARGET_TEMPERATURE, SUPPORT_TARGET_TEMPERATURE_HIGH, SUPPORT_TARGET_TEMPERATURE_LOW) from homeassistant.components.smartthings import climate from homeassistant.components.smartthings.const import DOMAIN from homeassistant.const import ( - ATTR_ENTITY_ID, ATTR_SUPPORTED_FEATURES, ATTR_TEMPERATURE) + ATTR_ENTITY_ID, ATTR_SUPPORTED_FEATURES, ATTR_TEMPERATURE, STATE_OFF) from .conftest import setup_platform diff --git a/tests/components/zwave/test_climate.py b/tests/components/zwave/test_climate.py index 9a9ed41381f7..b5e5639bdc6d 100644 --- a/tests/components/zwave/test_climate.py +++ b/tests/components/zwave/test_climate.py @@ -1,7 +1,7 @@ """Test Z-Wave climate devices.""" import pytest -from homeassistant.components.climate import STATE_COOL, STATE_HEAT +from homeassistant.components.climate.const import STATE_COOL, STATE_HEAT from homeassistant.components.zwave import climate from homeassistant.const import ( STATE_OFF, TEMP_CELSIUS, TEMP_FAHRENHEIT, ATTR_TEMPERATURE)