[update] Use register_apply_action for update.perform (#19505)

This commit is contained in:
J. Nick Koston
2026-09-23 18:28:03 -04:00
committed by GitHub
parent 1be1f67516
commit b7b1507daf
3 changed files with 4 additions and 25 deletions
+2 -18
View File
@@ -32,9 +32,6 @@ UpdateEntity = update_ns.class_("UpdateEntity", cg.EntityBase)
UpdateInfo = update_ns.struct("UpdateInfo")
PerformAction = update_ns.class_(
"PerformAction", automation.Action, cg.Parented.template(UpdateEntity)
)
CheckAction = update_ns.class_(
"CheckAction", automation.Action, cg.Parented.template(UpdateEntity)
)
@@ -133,9 +130,8 @@ async def to_code(config: ConfigType) -> None:
cg.add_global(update_ns.using)
@automation.register_action(
automation.register_apply_action(
"update.perform",
PerformAction,
automation.maybe_simple_id(
{
cv.GenerateID(): cv.use_id(UpdateEntity),
@@ -144,20 +140,8 @@ async def to_code(config: ConfigType) -> None:
): cv.templatable(cv.boolean),
}
),
synchronous=True,
automation.ApplyField(CONF_FORCE_UPDATE, "perform", cg.bool_),
)
async def update_perform_action_to_code(
config: ConfigType,
action_id: ID,
template_arg: cg.TemplateArguments,
args: TemplateArgsType,
) -> MockObj:
var = cg.new_Pvariable(action_id, template_arg)
await cg.register_parented(var, config[CONF_ID])
force = await cg.templatable(config[CONF_FORCE_UPDATE], args, cg.bool_)
cg.add(var.set_force(force))
return var
@automation.register_action(
-7
View File
@@ -6,13 +6,6 @@
namespace esphome::update {
template<typename... Ts> class PerformAction final : public Action<Ts...>, public Parented<UpdateEntity> {
TEMPLATABLE_VALUE(bool, force)
public:
void play(const Ts &...x) override { this->parent_->perform(this->force_.value(x...)); }
};
template<typename... Ts> class CheckAction final : public Action<Ts...>, public Parented<UpdateEntity> {
public:
void play(const Ts &...x) override { this->parent_->check(); }
+2
View File
@@ -13,6 +13,8 @@ esphome:
- update.check:
- update.perform:
force_update: true
- update.perform:
force_update: !lambda return false;
wifi:
ssid: MySSID