[haier] `text_sensor and button` platforms (#6780)

This commit is contained in:
Pavlo Dudnytskyi
2024-05-23 23:07:39 +02:00
committed by GitHub
parent 4ab7a5d964
commit aed0593793
23 changed files with 396 additions and 80 deletions
@@ -0,0 +1,41 @@
import esphome.codegen as cg
import esphome.config_validation as cv
from esphome.components import button
from ..climate import (
CONF_HAIER_ID,
HonClimate,
haier_ns,
)
CODEOWNERS = ["@paveldn"]
SelfCleaningButton = haier_ns.class_("SelfCleaningButton", button.Button)
SteriCleaningButton = haier_ns.class_("SteriCleaningButton", button.Button)
# Haier buttons
CONF_SELF_CLEANING = "self_cleaning"
CONF_STERI_CLEANING = "steri_cleaning"
# Additional icons
ICON_SPRAY_BOTTLE = "mdi:spray-bottle"
CONFIG_SCHEMA = cv.Schema(
{
cv.Required(CONF_HAIER_ID): cv.use_id(HonClimate),
cv.Optional(CONF_SELF_CLEANING): button.button_schema(
SelfCleaningButton,
icon=ICON_SPRAY_BOTTLE,
),
cv.Optional(CONF_STERI_CLEANING): button.button_schema(
SteriCleaningButton,
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])
@@ -0,0 +1,9 @@
#include "self_cleaning.h"
namespace esphome {
namespace haier {
void SelfCleaningButton::press_action() { this->parent_->start_self_cleaning(); }
} // namespace haier
} // namespace esphome
@@ -0,0 +1,18 @@
#pragma once
#include "esphome/components/button/button.h"
#include "../hon_climate.h"
namespace esphome {
namespace haier {
class SelfCleaningButton : public button::Button, public Parented<HonClimate> {
public:
SelfCleaningButton() = default;
protected:
void press_action() override;
};
} // namespace haier
} // namespace esphome
@@ -0,0 +1,9 @@
#include "steri_cleaning.h"
namespace esphome {
namespace haier {
void SteriCleaningButton::press_action() { this->parent_->start_steri_cleaning(); }
} // namespace haier
} // namespace esphome
@@ -0,0 +1,18 @@
#pragma once
#include "esphome/components/button/button.h"
#include "../hon_climate.h"
namespace esphome {
namespace haier {
class SteriCleaningButton : public button::Button, public Parented<HonClimate> {
public:
SteriCleaningButton() = default;
protected:
void press_action() override;
};
} // namespace haier
} // namespace esphome