From dca0c69f2e8531999a52dfb7647944643679f642 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Tue, 20 Oct 2026 17:13:15 -1000 Subject: [PATCH] [airton] Use an Apply select for the vane direction --- esphome/components/airton/airton.h | 4 ++++ esphome/components/airton/select/__init__.py | 8 ++++---- esphome/components/airton/select/direction.h | 17 ----------------- 3 files changed, 8 insertions(+), 21 deletions(-) delete mode 100644 esphome/components/airton/select/direction.h diff --git a/esphome/components/airton/airton.h b/esphome/components/airton/airton.h index 25f15372e67..7f4e8039797 100644 --- a/esphome/components/airton/airton.h +++ b/esphome/components/airton/airton.h @@ -90,6 +90,10 @@ class AirtonClimate : public climate_ir::ClimateIR { bool set_display_state(bool state); bool set_vertical_direction_state(VerticalDirection direction); void send_settings(); + void set_vertical_direction(VerticalDirection direction) { + if (this->set_vertical_direction_state(direction)) + this->send_settings(); + } void set_setting(AirtonSetting setting, bool state) { const bool changed = setting == AirtonSetting::AIRTON_SETTING_DISPLAY ? this->set_display_state(state) : this->set_sleep_mode_state(state); diff --git a/esphome/components/airton/select/__init__.py b/esphome/components/airton/select/__init__.py index 1772701611a..c849ccbca07 100644 --- a/esphome/components/airton/select/__init__.py +++ b/esphome/components/airton/select/__init__.py @@ -9,18 +9,16 @@ from ..climate import ( CONF_VERTICAL_DIRECTION, VERTICAL_DIRECTIONS, AirtonClimate, - airton_ns, + VerticalDirection, ) CODEOWNERS = ["@Procsiab"] -VerticalDirectionSelect = airton_ns.class_("VerticalDirectionSelect", select.Select) - CONFIG_SCHEMA = cv.Schema( { cv.GenerateID(CONF_AIRTON_ID): cv.use_id(AirtonClimate), cv.Optional(CONF_VERTICAL_DIRECTION): select.select_schema( - VerticalDirectionSelect, + select.ApplySelect, entity_category=ENTITY_CATEGORY_CONFIG, ), } @@ -34,4 +32,6 @@ async def to_code(config: ConfigType) -> None: CONF_VERTICAL_DIRECTION, hub.set_vertical_direction_select, options=list(VERTICAL_DIRECTIONS), + # The options are in the order of the enum; the hub publishes the state + apply=f"set_vertical_direction(static_cast<{VerticalDirection}>(index))", ) diff --git a/esphome/components/airton/select/direction.h b/esphome/components/airton/select/direction.h deleted file mode 100644 index 4697385c161..00000000000 --- a/esphome/components/airton/select/direction.h +++ /dev/null @@ -1,17 +0,0 @@ -#pragma once - -#include "esphome/components/select/select.h" -#include "../airton.h" - -namespace esphome::airton { - -class VerticalDirectionSelect : public select::Select, public Parented { - protected: - // The options are in the order of the enum, so the index is the direction; the parent publishes the state - void control(size_t index) override { - if (this->parent_->set_vertical_direction_state(static_cast(index))) - this->parent_->send_settings(); - } -}; - -} // namespace esphome::airton