diff --git a/esphome/components/fan/__init__.py b/esphome/components/fan/__init__.py index b292aad029..7b159de9a0 100644 --- a/esphome/components/fan/__init__.py +++ b/esphome/components/fan/__init__.py @@ -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 diff --git a/esphome/const.py b/esphome/const.py index c35adc74ee..bbece14c4f 100644 --- a/esphome/const.py +++ b/esphome/const.py @@ -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" diff --git a/tests/test1.yaml b/tests/test1.yaml index ef321396ac..b579799b29 100644 --- a/tests/test1.yaml +++ b/tests/test1.yaml @@ -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