[sen5x] Use register_apply_action for sen5x.start_fan_autoclean (#19653)

This commit is contained in:
J. Nick Koston
2026-09-25 14:31:39 -04:00
committed by GitHub
parent 9c2616ef7e
commit 6a115e6b25
4 changed files with 11 additions and 25 deletions
-19
View File
@@ -1,19 +0,0 @@
#pragma once
#include "esphome/core/component.h"
#include "esphome/core/automation.h"
#include "sen5x.h"
namespace esphome::sen5x {
template<typename... Ts> class StartFanAction final : public Action<Ts...> {
public:
explicit StartFanAction(SEN5XComponent *sen5x) : sen5x_(sen5x) {}
void play(const Ts &...x) override { this->sen5x_->start_fan_cleaning(); }
protected:
SEN5XComponent *sen5x_;
};
} // namespace esphome::sen5x
+2 -6
View File
@@ -60,9 +60,6 @@ CONF_ACCELERATION_MODE = "acceleration_mode"
CONF_AUTO_CLEANING_INTERVAL = "auto_cleaning_interval"
# Actions
StartFanAction = sen5x_ns.class_("StartFanAction", automation.Action)
ACCELERATION_MODES = {
"low": RhtAccelerationMode.LOW_ACCELERATION,
"medium": RhtAccelerationMode.MEDIUM_ACCELERATION,
@@ -280,9 +277,8 @@ SEN5X_ACTION_SCHEMA = maybe_simple_id(
)
automation.register_simple_action(
automation.register_apply_action(
"sen5x.start_fan_autoclean",
StartFanAction,
SEN5X_ACTION_SCHEMA,
synchronous=True,
automation.ApplyCall("start_fan_cleaning()"),
)
@@ -0,0 +1,5 @@
button:
- platform: template
name: SEN5x Clean the fan
on_press:
- sen5x.start_fan_autoclean: sen54
@@ -0,0 +1,4 @@
packages:
i2c: !include ../../test_build_components/common/i2c/esp8266-ard.yaml
sen5x: !include common.yaml
actions: !include common-actions.yaml