Introduce cv.temperature_delta and fix problematic thermostat configuration behavior (#5297)

This commit is contained in:
Sebastian Rasor 2023-08-22 20:01:34 -05:00 committed by Jesse Hills
parent a67b92a04c
commit 2cabe59c22
No known key found for this signature in database
GPG Key ID: BEAAE804EFD8E83A
2 changed files with 28 additions and 7 deletions

View File

@ -591,11 +591,11 @@ CONFIG_SCHEMA = cv.All(
cv.Optional(CONF_DEFAULT_TARGET_TEMPERATURE_LOW): cv.temperature, cv.Optional(CONF_DEFAULT_TARGET_TEMPERATURE_LOW): cv.temperature,
cv.Optional( cv.Optional(
CONF_SET_POINT_MINIMUM_DIFFERENTIAL, default=0.5 CONF_SET_POINT_MINIMUM_DIFFERENTIAL, default=0.5
): cv.temperature, ): cv.temperature_delta,
cv.Optional(CONF_COOL_DEADBAND, default=0.5): cv.temperature, cv.Optional(CONF_COOL_DEADBAND, default=0.5): cv.temperature_delta,
cv.Optional(CONF_COOL_OVERRUN, default=0.5): cv.temperature, cv.Optional(CONF_COOL_OVERRUN, default=0.5): cv.temperature_delta,
cv.Optional(CONF_HEAT_DEADBAND, default=0.5): cv.temperature, cv.Optional(CONF_HEAT_DEADBAND, default=0.5): cv.temperature_delta,
cv.Optional(CONF_HEAT_OVERRUN, default=0.5): cv.temperature, cv.Optional(CONF_HEAT_OVERRUN, default=0.5): cv.temperature_delta,
cv.Optional(CONF_MAX_COOLING_RUN_TIME): cv.positive_time_period_seconds, cv.Optional(CONF_MAX_COOLING_RUN_TIME): cv.positive_time_period_seconds,
cv.Optional(CONF_MAX_HEATING_RUN_TIME): cv.positive_time_period_seconds, cv.Optional(CONF_MAX_HEATING_RUN_TIME): cv.positive_time_period_seconds,
cv.Optional(CONF_MIN_COOLING_OFF_TIME): cv.positive_time_period_seconds, cv.Optional(CONF_MIN_COOLING_OFF_TIME): cv.positive_time_period_seconds,
@ -608,8 +608,8 @@ CONFIG_SCHEMA = cv.All(
cv.Optional(CONF_MIN_HEATING_OFF_TIME): cv.positive_time_period_seconds, cv.Optional(CONF_MIN_HEATING_OFF_TIME): cv.positive_time_period_seconds,
cv.Optional(CONF_MIN_HEATING_RUN_TIME): cv.positive_time_period_seconds, cv.Optional(CONF_MIN_HEATING_RUN_TIME): cv.positive_time_period_seconds,
cv.Required(CONF_MIN_IDLE_TIME): cv.positive_time_period_seconds, cv.Required(CONF_MIN_IDLE_TIME): cv.positive_time_period_seconds,
cv.Optional(CONF_SUPPLEMENTAL_COOLING_DELTA): cv.temperature, cv.Optional(CONF_SUPPLEMENTAL_COOLING_DELTA): cv.temperature_delta,
cv.Optional(CONF_SUPPLEMENTAL_HEATING_DELTA): cv.temperature, cv.Optional(CONF_SUPPLEMENTAL_HEATING_DELTA): cv.temperature_delta,
cv.Optional( cv.Optional(
CONF_FAN_ONLY_ACTION_USES_FAN_MODE_TIMER, default=False CONF_FAN_ONLY_ACTION_USES_FAN_MODE_TIMER, default=False
): cv.boolean, ): cv.boolean,

View File

@ -929,6 +929,27 @@ def temperature(value):
raise err raise err
def temperature_delta(value):
err = None
try:
return _temperature_c(value)
except Invalid as orig_err:
err = orig_err
try:
return _temperature_k(value)
except Invalid:
pass
try:
fahrenheit = _temperature_f(value)
return fahrenheit * (5 / 9)
except Invalid:
pass
raise err
_color_temperature_mireds = float_with_unit("Color Temperature", r"(mireds|Mireds)") _color_temperature_mireds = float_with_unit("Color Temperature", r"(mireds|Mireds)")
_color_temperature_kelvin = float_with_unit("Color Temperature", r"(K|Kelvin)") _color_temperature_kelvin = float_with_unit("Color Temperature", r"(K|Kelvin)")