[dfplayer] Use register_apply_condition for dfplayer.is_playing (#19701)

This commit is contained in:
J. Nick Koston
2026-09-25 20:33:17 -04:00
committed by GitHub
parent 01a2aaef08
commit c8d3f43712
2 changed files with 2 additions and 10 deletions
+2 -5
View File
@@ -12,9 +12,6 @@ CODEOWNERS = ["@glmnet"]
dfplayer_ns = cg.esphome_ns.namespace("dfplayer")
DFPlayer = dfplayer_ns.class_("DFPlayer", cg.Component)
DFPlayerIsPlayingCondition = dfplayer_ns.class_(
"DFPlayerIsPlayingCondition", automation.Condition
)
MULTI_CONF = True
CONF_FOLDER = "folder"
@@ -199,12 +196,12 @@ automation.register_apply_action(
)
automation.register_parented_condition(
automation.register_apply_condition(
"dfplayer.is_playing",
DFPlayerIsPlayingCondition,
cv.Schema(
{
cv.GenerateID(): cv.use_id(DFPlayer),
}
),
"is_playing()",
)
-5
View File
@@ -77,9 +77,4 @@ class DFPlayer final : public uart::UARTDevice, public Component {
CallbackManager<void()> on_finished_playback_callback_;
};
template<typename... Ts> class DFPlayerIsPlayingCondition final : public Condition<Ts...>, public Parented<DFPlayer> {
public:
bool check(const Ts &...x) override { return this->parent_->is_playing(); }
};
} // namespace esphome::dfplayer