mirror of
https://github.com/esphome/esphome.git
synced 2024-11-21 11:37:27 +01:00
fix: [climate] Allow substitutions in visual.temperature_step.{target_temperature,current_temperature}
(#7679)
This commit is contained in:
parent
0982ab58ac
commit
bac6880a1e
@ -119,10 +119,21 @@ visual_temperature = cv.float_with_unit(
|
||||
)
|
||||
|
||||
|
||||
def single_visual_temperature(value):
|
||||
if isinstance(value, dict):
|
||||
return value
|
||||
VISUAL_TEMPERATURE_STEP_SCHEMA = cv.Schema(
|
||||
{
|
||||
cv.Required(CONF_TARGET_TEMPERATURE): visual_temperature,
|
||||
cv.Required(CONF_CURRENT_TEMPERATURE): visual_temperature,
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
def visual_temperature_step(value):
|
||||
|
||||
# Allow defining target/current temperature steps separately
|
||||
if isinstance(value, dict):
|
||||
return VISUAL_TEMPERATURE_STEP_SCHEMA(value)
|
||||
|
||||
# Otherwise, use the single value for both properties
|
||||
value = visual_temperature(value)
|
||||
return VISUAL_TEMPERATURE_STEP_SCHEMA(
|
||||
{
|
||||
@ -141,16 +152,6 @@ ControlTrigger = climate_ns.class_(
|
||||
"ControlTrigger", automation.Trigger.template(ClimateCall.operator("ref"))
|
||||
)
|
||||
|
||||
VISUAL_TEMPERATURE_STEP_SCHEMA = cv.Any(
|
||||
single_visual_temperature,
|
||||
cv.Schema(
|
||||
{
|
||||
cv.Required(CONF_TARGET_TEMPERATURE): visual_temperature,
|
||||
cv.Required(CONF_CURRENT_TEMPERATURE): visual_temperature,
|
||||
}
|
||||
),
|
||||
)
|
||||
|
||||
CLIMATE_SCHEMA = (
|
||||
cv.ENTITY_BASE_SCHEMA.extend(web_server.WEBSERVER_SORTING_SCHEMA)
|
||||
.extend(cv.MQTT_COMMAND_COMPONENT_SCHEMA)
|
||||
@ -162,7 +163,7 @@ CLIMATE_SCHEMA = (
|
||||
{
|
||||
cv.Optional(CONF_MIN_TEMPERATURE): cv.temperature,
|
||||
cv.Optional(CONF_MAX_TEMPERATURE): cv.temperature,
|
||||
cv.Optional(CONF_TEMPERATURE_STEP): VISUAL_TEMPERATURE_STEP_SCHEMA,
|
||||
cv.Optional(CONF_TEMPERATURE_STEP): visual_temperature_step,
|
||||
cv.Optional(CONF_MIN_HUMIDITY): cv.percentage_int,
|
||||
cv.Optional(CONF_MAX_HUMIDITY): cv.percentage_int,
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user