mirror of
https://github.com/esphome/esphome.git
synced 2026-09-28 15:30:21 +00:00
[max17043] Use register_apply_action for max17043.sleep_mode (#19682)
This commit is contained in:
@@ -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
|
||||
@@ -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()")
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user