Move constants to const.py in generic Thermostat (#120789)

This commit is contained in:
dougiteixeira 2024-07-19 14:49:11 -03:00 committed by GitHub
parent 099110767a
commit 75b1700ed3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 56 additions and 36 deletions

View file

@ -1,15 +1,12 @@
"""The generic_thermostat component."""
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import Platform
from homeassistant.core import HomeAssistant
from homeassistant.helpers.device import (
async_remove_stale_devices_links_keep_entity_device,
)
CONF_HEATER = "heater"
DOMAIN = "generic_thermostat"
PLATFORMS = [Platform.CLIMATE]
from .const import CONF_HEATER, PLATFORMS
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:

View file

@ -14,13 +14,7 @@ import voluptuous as vol
from homeassistant.components.climate import (
ATTR_PRESET_MODE,
PLATFORM_SCHEMA as CLIMATE_PLATFORM_SCHEMA,
PRESET_ACTIVITY,
PRESET_AWAY,
PRESET_COMFORT,
PRESET_ECO,
PRESET_HOME,
PRESET_NONE,
PRESET_SLEEP,
ClimateEntity,
ClimateEntityFeature,
HVACAction,
@ -64,36 +58,31 @@ from homeassistant.helpers.reload import async_setup_reload_service
from homeassistant.helpers.restore_state import RestoreEntity
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType, VolDictType
from . import CONF_HEATER, DOMAIN, PLATFORMS
from .const import (
CONF_AC_MODE,
CONF_COLD_TOLERANCE,
CONF_HEATER,
CONF_HOT_TOLERANCE,
CONF_MIN_DUR,
CONF_PRESETS,
CONF_SENSOR,
DEFAULT_TOLERANCE,
DOMAIN,
PLATFORMS,
)
_LOGGER = logging.getLogger(__name__)
DEFAULT_TOLERANCE = 0.3
DEFAULT_NAME = "Generic Thermostat"
CONF_SENSOR = "target_sensor"
CONF_INITIAL_HVAC_MODE = "initial_hvac_mode"
CONF_KEEP_ALIVE = "keep_alive"
CONF_MIN_TEMP = "min_temp"
CONF_MAX_TEMP = "max_temp"
CONF_TARGET_TEMP = "target_temp"
CONF_AC_MODE = "ac_mode"
CONF_MIN_DUR = "min_cycle_duration"
CONF_COLD_TOLERANCE = "cold_tolerance"
CONF_HOT_TOLERANCE = "hot_tolerance"
CONF_KEEP_ALIVE = "keep_alive"
CONF_INITIAL_HVAC_MODE = "initial_hvac_mode"
CONF_PRECISION = "precision"
CONF_TARGET_TEMP = "target_temp"
CONF_TEMP_STEP = "target_temp_step"
CONF_PRESETS = {
p: f"{p}_temp"
for p in (
PRESET_AWAY,
PRESET_COMFORT,
PRESET_ECO,
PRESET_HOME,
PRESET_SLEEP,
PRESET_ACTIVITY,
)
}
PRESETS_SCHEMA: VolDictType = {
vol.Optional(v): vol.Coerce(float) for v in CONF_PRESETS.values()

View file

@ -16,7 +16,7 @@ from homeassistant.helpers.schema_config_entry_flow import (
SchemaFlowFormStep,
)
from .climate import (
from .const import (
CONF_AC_MODE,
CONF_COLD_TOLERANCE,
CONF_HEATER,

View file

@ -0,0 +1,34 @@
"""Constants for the Generic Thermostat helper."""
from homeassistant.components.climate import (
PRESET_ACTIVITY,
PRESET_AWAY,
PRESET_COMFORT,
PRESET_ECO,
PRESET_HOME,
PRESET_SLEEP,
)
from homeassistant.const import Platform
DOMAIN = "generic_thermostat"
PLATFORMS = [Platform.CLIMATE]
CONF_AC_MODE = "ac_mode"
CONF_COLD_TOLERANCE = "cold_tolerance"
CONF_HEATER = "heater"
CONF_HOT_TOLERANCE = "hot_tolerance"
CONF_MIN_DUR = "min_cycle_duration"
CONF_PRESETS = {
p: f"{p}_temp"
for p in (
PRESET_AWAY,
PRESET_COMFORT,
PRESET_ECO,
PRESET_HOME,
PRESET_SLEEP,
PRESET_ACTIVITY,
)
}
CONF_SENSOR = "target_sensor"
DEFAULT_TOLERANCE = 0.3

View file

@ -21,7 +21,7 @@ from homeassistant.components.climate import (
PRESET_SLEEP,
HVACMode,
)
from homeassistant.components.generic_thermostat import (
from homeassistant.components.generic_thermostat.const import (
DOMAIN as GENERIC_THERMOSTAT_DOMAIN,
)
from homeassistant.const import (

View file

@ -6,12 +6,11 @@ from syrupy.assertion import SnapshotAssertion
from syrupy.filters import props
from homeassistant.components.climate import PRESET_AWAY
from homeassistant.components.generic_thermostat.climate import (
from homeassistant.components.generic_thermostat.const import (
CONF_AC_MODE,
CONF_COLD_TOLERANCE,
CONF_HEATER,
CONF_HOT_TOLERANCE,
CONF_NAME,
CONF_PRESETS,
CONF_SENSOR,
DOMAIN,
@ -21,6 +20,7 @@ from homeassistant.config_entries import SOURCE_USER
from homeassistant.const import (
ATTR_DEVICE_CLASS,
ATTR_UNIT_OF_MEASUREMENT,
CONF_NAME,
STATE_OFF,
UnitOfTemperature,
)

View file

@ -2,7 +2,7 @@
from __future__ import annotations
from homeassistant.components.generic_thermostat import DOMAIN
from homeassistant.components.generic_thermostat.const import DOMAIN
from homeassistant.core import HomeAssistant
from homeassistant.helpers import device_registry as dr, entity_registry as er