From 5cc6f6a89d4c2e3b132f0036d6490fe02fa70093 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Fri, 16 Oct 2026 13:46:01 -1000 Subject: [PATCH] [haier] Use Apply buttons --- esphome/components/haier/button/__init__.py | 19 ++++++++----------- .../components/haier/button/self_cleaning.cpp | 7 ------- .../components/haier/button/self_cleaning.h | 16 ---------------- .../haier/button/steri_cleaning.cpp | 7 ------- .../components/haier/button/steri_cleaning.h | 16 ---------------- 5 files changed, 8 insertions(+), 57 deletions(-) delete mode 100644 esphome/components/haier/button/self_cleaning.cpp delete mode 100644 esphome/components/haier/button/self_cleaning.h delete mode 100644 esphome/components/haier/button/steri_cleaning.cpp delete mode 100644 esphome/components/haier/button/steri_cleaning.h diff --git a/esphome/components/haier/button/__init__.py b/esphome/components/haier/button/__init__.py index 28bb5045c36..a38cb696944 100644 --- a/esphome/components/haier/button/__init__.py +++ b/esphome/components/haier/button/__init__.py @@ -1,12 +1,10 @@ -import esphome.codegen as cg from esphome.components import button import esphome.config_validation as cv +from esphome.types import ConfigType -from ..climate import CONF_HAIER_ID, HonClimate, haier_ns +from ..climate import CONF_HAIER_ID, HonClimate CODEOWNERS = ["@paveldn"] -SelfCleaningButton = haier_ns.class_("SelfCleaningButton", button.Button) -SteriCleaningButton = haier_ns.class_("SteriCleaningButton", button.Button) # Haier buttons @@ -20,19 +18,18 @@ CONFIG_SCHEMA = cv.Schema( { cv.GenerateID(CONF_HAIER_ID): cv.use_id(HonClimate), cv.Optional(CONF_SELF_CLEANING): button.button_schema( - SelfCleaningButton, + button.ApplyButton, icon=ICON_SPRAY_BOTTLE, ), cv.Optional(CONF_STERI_CLEANING): button.button_schema( - SteriCleaningButton, + button.ApplyButton, icon=ICON_SPRAY_BOTTLE, ), } ) -async def to_code(config): - for button_type in [CONF_SELF_CLEANING, CONF_STERI_CLEANING]: - if conf := config.get(button_type): - btn = await button.new_button(conf) - await cg.register_parented(btn, config[CONF_HAIER_ID]) +async def to_code(config: ConfigType) -> None: + buttons = button.sub_buttons(config, parent=config[CONF_HAIER_ID]) + await buttons(CONF_SELF_CLEANING, None, apply="start_self_cleaning()") + await buttons(CONF_STERI_CLEANING, None, apply="start_steri_cleaning()") diff --git a/esphome/components/haier/button/self_cleaning.cpp b/esphome/components/haier/button/self_cleaning.cpp deleted file mode 100644 index bf4baa716e6..00000000000 --- a/esphome/components/haier/button/self_cleaning.cpp +++ /dev/null @@ -1,7 +0,0 @@ -#include "self_cleaning.h" - -namespace esphome::haier { - -void SelfCleaningButton::press_action() { this->parent_->start_self_cleaning(); } - -} // namespace esphome::haier diff --git a/esphome/components/haier/button/self_cleaning.h b/esphome/components/haier/button/self_cleaning.h deleted file mode 100644 index fc5a73b1e88..00000000000 --- a/esphome/components/haier/button/self_cleaning.h +++ /dev/null @@ -1,16 +0,0 @@ -#pragma once - -#include "esphome/components/button/button.h" -#include "../hon_climate.h" - -namespace esphome::haier { - -class SelfCleaningButton final : public button::Button, public Parented { - public: - SelfCleaningButton() = default; - - protected: - void press_action() override; -}; - -} // namespace esphome::haier diff --git a/esphome/components/haier/button/steri_cleaning.cpp b/esphome/components/haier/button/steri_cleaning.cpp deleted file mode 100644 index 8c4f5808b21..00000000000 --- a/esphome/components/haier/button/steri_cleaning.cpp +++ /dev/null @@ -1,7 +0,0 @@ -#include "steri_cleaning.h" - -namespace esphome::haier { - -void SteriCleaningButton::press_action() { this->parent_->start_steri_cleaning(); } - -} // namespace esphome::haier diff --git a/esphome/components/haier/button/steri_cleaning.h b/esphome/components/haier/button/steri_cleaning.h deleted file mode 100644 index 4799c0e2aed..00000000000 --- a/esphome/components/haier/button/steri_cleaning.h +++ /dev/null @@ -1,16 +0,0 @@ -#pragma once - -#include "esphome/components/button/button.h" -#include "../hon_climate.h" - -namespace esphome::haier { - -class SteriCleaningButton final : public button::Button, public Parented { - public: - SteriCleaningButton() = default; - - protected: - void press_action() override; -}; - -} // namespace esphome::haier