mirror of https://github.com/esphome/esphome.git
Merge cb7068bd3c
into c7c0d97a5e
This commit is contained in:
commit
db29179eba
|
@ -24,6 +24,7 @@ from esphome.const import (
|
|||
CONF_ON_PRESET_SET,
|
||||
CONF_TRIGGER_ID,
|
||||
CONF_DIRECTION,
|
||||
CONF_PRESET_MODE,
|
||||
CONF_RESTORE_MODE,
|
||||
)
|
||||
from esphome.core import CORE, coroutine_with_priority
|
||||
|
@ -276,6 +277,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_MODE): cv.templatable(cv.string),
|
||||
}
|
||||
),
|
||||
)
|
||||
|
@ -291,6 +293,9 @@ async def fan_turn_on_to_code(config, action_id, template_arg, args):
|
|||
if (direction := config.get(CONF_DIRECTION)) is not None:
|
||||
template_ = await cg.templatable(direction, args, FanDirection)
|
||||
cg.add(var.set_direction(template_))
|
||||
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
|
||||
|
||||
|
||||
|
|
|
@ -14,6 +14,7 @@ template<typename... Ts> class TurnOnAction : public Action<Ts...> {
|
|||
TEMPLATABLE_VALUE(bool, oscillating)
|
||||
TEMPLATABLE_VALUE(int, speed)
|
||||
TEMPLATABLE_VALUE(FanDirection, direction)
|
||||
TEMPLATABLE_VALUE(std::string, preset_mode)
|
||||
|
||||
void play(Ts... x) override {
|
||||
auto call = this->state_->turn_on();
|
||||
|
@ -26,6 +27,9 @@ template<typename... Ts> class TurnOnAction : public Action<Ts...> {
|
|||
if (this->direction_.has_value()) {
|
||||
call.set_direction(this->direction_.value(x...));
|
||||
}
|
||||
if (this->preset_mode_.has_value()) {
|
||||
call.set_preset_mode(this->preset_mode_.value(x...));
|
||||
}
|
||||
call.perform();
|
||||
}
|
||||
|
||||
|
|
|
@ -633,6 +633,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"
|
||||
|
|
|
@ -4298,6 +4298,20 @@ button:
|
|||
memory_location: 0xA0
|
||||
memory_address: 0x7D
|
||||
memory_data: 0x0F
|
||||
- platform: template
|
||||
name: Fan Turn On Action w/ Preset
|
||||
on_press:
|
||||
then:
|
||||
- fan.turn_on:
|
||||
id: fan_speed_presets
|
||||
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_mode: !lambda 'return "Preset 2";'
|
||||
|
||||
ld2410:
|
||||
id: my_ld2410
|
||||
|
|
Loading…
Reference in New Issue