Rename "preset" to "preset_mode" to stay in line with the other uses in Fan

This commit is contained in:
Tucker Kern 2024-03-22 17:37:09 +00:00
parent 2482287f79
commit cb7068bd3c
3 changed files with 7 additions and 6 deletions

View File

@ -21,7 +21,7 @@ from esphome.const import (
CONF_ON_PRESET_SET,
CONF_TRIGGER_ID,
CONF_DIRECTION,
CONF_PRESET,
CONF_PRESET_MODE,
CONF_RESTORE_MODE,
)
from esphome.core import CORE, coroutine_with_priority
@ -245,7 +245,7 @@ async def fan_turn_off_to_code(config, action_id, template_arg, args):
cv.Optional(CONF_DIRECTION): cv.templatable(
cv.enum(FAN_DIRECTION_ENUM, upper=True)
),
cv.Optional(CONF_PRESET): cv.templatable(cv.string),
cv.Optional(CONF_PRESET_MODE): cv.templatable(cv.string),
}
),
)
@ -261,8 +261,8 @@ async def fan_turn_on_to_code(config, action_id, template_arg, args):
if CONF_DIRECTION in config:
template_ = await cg.templatable(config[CONF_DIRECTION], args, FanDirection)
cg.add(var.set_direction(template_))
if CONF_PRESET in config:
template_ = await cg.templatable(config[CONF_PRESET], args, cg.std_string)
if CONF_PRESET_MODE in config:
template_ = await cg.templatable(config[CONF_PRESET_MODE], args, cg.std_string)
cg.add(var.set_preset_mode(template_))
return var

View File

@ -615,6 +615,7 @@ CONF_PRESET = "preset"
CONF_PRESET_BOOST = "preset_boost"
CONF_PRESET_COMMAND_TOPIC = "preset_command_topic"
CONF_PRESET_ECO = "preset_eco"
CONF_PRESET_MODE = "preset_mode"
CONF_PRESET_MODES = "preset_modes"
CONF_PRESET_SLEEP = "preset_sleep"
CONF_PRESET_STATE_TOPIC = "preset_state_topic"

View File

@ -4165,14 +4165,14 @@ button:
then:
- fan.turn_on:
id: fan_speed_presets
preset: Preset 1
preset_mode: Preset 1
- platform: template
name: Fan Turn On Action w/ Preset Template
on_press:
then:
- fan.turn_on:
id: fan_hbridge_presets
preset: !lambda 'return "Preset 2";'
preset_mode: !lambda 'return "Preset 2";'
ld2410:
id: my_ld2410