[max17043] Use register_apply_action for max17043.sleep_mode (#19682)

This commit is contained in:
J. Nick Koston
2026-09-25 20:28:58 -04:00
committed by GitHub
parent 2f4eb3e1ee
commit 1889f6c9b5
2 changed files with 2 additions and 26 deletions
-18
View File
@@ -1,18 +0,0 @@
#pragma once
#include "esphome/core/automation.h"
#include "max17043.h"
namespace esphome::max17043 {
template<typename... Ts> class SleepAction final : public Action<Ts...> {
public:
explicit SleepAction(MAX17043Component *max17043) : max17043_(max17043) {}
void play(const Ts &...x) override { this->max17043_->sleep_mode(); }
protected:
MAX17043Component *max17043_;
};
} // namespace esphome::max17043
+2 -8
View File
@@ -23,9 +23,6 @@ MAX17043Component = max17043_ns.class_(
"MAX17043Component", cg.PollingComponent, i2c.I2CDevice
)
# Actions
SleepAction = max17043_ns.class_("SleepAction", automation.Action)
CONFIG_SCHEMA = (
cv.Schema(
{
@@ -72,9 +69,6 @@ MAX17043_ACTION_SCHEMA = maybe_simple_id(
)
automation.register_simple_action(
"max17043.sleep_mode",
SleepAction,
MAX17043_ACTION_SCHEMA,
synchronous=True,
automation.register_apply_action(
"max17043.sleep_mode", MAX17043_ACTION_SCHEMA, automation.ApplyCall("sleep_mode()")
)