From 39a017a24f2f169575693db0a3ed03c6e6291086 Mon Sep 17 00:00:00 2001 From: Pavlo Dudnytskyi Date: Fri, 13 Sep 2024 07:52:55 +0200 Subject: [PATCH] Added vertical airflow select implementation --- components/haier/select/vertical_airflow.cpp | 25 ++++++++++++++++++++ docs/script/make_doc.py | 6 ++--- 2 files changed, 28 insertions(+), 3 deletions(-) diff --git a/components/haier/select/vertical_airflow.cpp b/components/haier/select/vertical_airflow.cpp index dac0dc9..2ba65af 100644 --- a/components/haier/select/vertical_airflow.cpp +++ b/components/haier/select/vertical_airflow.cpp @@ -5,6 +5,31 @@ namespace esphome { namespace haier { void VerticalAirflowSelect::control(const std::string &value) { + hon_protocol::VerticalSwingMode state; + if (value == "Auto") { + state = hon_protocol::VerticalSwingMode::AUTO; + } else if (value == "Health Up") { + state = hon_protocol::VerticalSwingMode::HEALTH_UP; + } else if (value == "Max Up") { + state = hon_protocol::VerticalSwingMode::MAX_UP; + } else if (value == "Up") { + state = hon_protocol::VerticalSwingMode::UP; + } else if (value == "Center") { + state = hon_protocol::VerticalSwingMode::CENTER; + } else if (value == "Down") { + state = hon_protocol::VerticalSwingMode::DOWN; + } else if (value == "Max Down") { + state = hon_protocol::VerticalSwingMode::MAX_DOWN; + } else if (value == "Health Down") { + state = hon_protocol::VerticalSwingMode::HEALTH_DOWN; + } else { + ESP_LOGE("haier", "Invalid vertical airflow mode: %s", value.c_str()); + return; + } + const esphome::optional current_state = this->parent_->get_vertical_airflow(); + if (!current_state.has_value() || (current_state.value() != state)) { + this->parent_->set_vertical_airflow(state); + } this->publish_state(value); } diff --git a/docs/script/make_doc.py b/docs/script/make_doc.py index 2d9fd84..dc56e23 100644 --- a/docs/script/make_doc.py +++ b/docs/script/make_doc.py @@ -2,13 +2,13 @@ import os import sys -doc_file_path = [ +doc_file_path = [ "/".join(["esphome-docs", "climate", "haier.rst"]), "/".join(["esphome-docs", "sensor", "haier.rst"]), "/".join(["esphome-docs", "binary_sensor", "haier.rst"]), "/".join(["esphome-docs", "text_sensor", "haier.rst"]), "/".join(["esphome-docs", "button", "haier.rst"]), - "/".join(["esphome-docs", "switch", "haier.rst"]), + "/".join(["esphome-docs", "switch", "haier.rst"]), "esp32_backup.rst", "additional_information.rst", ] @@ -29,7 +29,7 @@ def process_esphome_refs(line, l_num): (":ref:`Text Sensor `", "`Text Sensor `_"), (":ref:`Button `", "`Button `_"), (":ref:`Switch `", "`Switch `_"), - + (":ref:`Select `", "`Select `_"), ] res = line for o, r in esphome_refs: