diff --git a/esphome/components/vornado_ir/button/__init__.py b/esphome/components/vornado_ir/button/__init__.py index 6abc48fe70..599c92132c 100644 --- a/esphome/components/vornado_ir/button/__init__.py +++ b/esphome/components/vornado_ir/button/__init__.py @@ -5,36 +5,52 @@ import esphome.config_validation as cv from .. import CONF_VORNADO_ID, VornadoIR, vornado_ir_ns CODEOWNERS = ["@jzucker2"] -FanButton = vornado_ir_ns.class_("FanButton", button.Button) PowerButton = vornado_ir_ns.class_("PowerButton", button.Button) +ChangeDirectionButton = vornado_ir_ns.class_("ChangeDirectionButton", button.Button) +IncreaseButton = vornado_ir_ns.class_("IncreaseButton", button.Button) +DecreaseButton = vornado_ir_ns.class_("DecreaseButton", button.Button) -# Toto IR buttons -CONF_FAN = "fan" +# Vornado IR buttons CONF_POWER = "power" +CONF_CHANGE_DIRECTION = "change_direction" +CONF_INCREASE = "increase" +CONF_DECREASE = "decrease" # Additional icons ICON_POWER_TOGGLE = "mdi:power-cycle" -ICON_FAN = "mdi:heat-wave" +ICON_CHANGE_DIRECTION = "mdi:power-cycle" +ICON_INCREASE = "mdi:power-cycle" +ICON_DECREASE = "mdi:power-cycle" CONFIG_SCHEMA = cv.Schema( { cv.GenerateID(CONF_VORNADO_ID): cv.use_id(VornadoIR), - cv.Optional(CONF_FAN): button.button_schema( - FanButton, - icon=ICON_FAN, - ), cv.Optional(CONF_POWER): button.button_schema( PowerButton, icon=ICON_POWER_TOGGLE, ), + cv.Optional(CONF_CHANGE_DIRECTION): button.button_schema( + ChangeDirectionButton, + icon=ICON_CHANGE_DIRECTION, + ), + cv.Optional(ICON_INCREASE): button.button_schema( + IncreaseButton, + icon=ICON_INCREASE, + ), + cv.Optional(ICON_DECREASE): button.button_schema( + DecreaseButton, + icon=ICON_DECREASE, + ), } ).extend(cv.COMPONENT_SCHEMA) async def to_code(config): for button_type in [ - CONF_FAN, CONF_POWER, + CONF_CHANGE_DIRECTION, + CONF_INCREASE, + CONF_DECREASE, ]: if conf := config.get(button_type): btn = await button.new_button(conf) diff --git a/esphome/components/vornado_ir/button/change_direction.cpp b/esphome/components/vornado_ir/button/change_direction.cpp new file mode 100644 index 0000000000..641f6c61a1 --- /dev/null +++ b/esphome/components/vornado_ir/button/change_direction.cpp @@ -0,0 +1,11 @@ +#include "power.h" + +namespace esphome { +namespace vornado_ir { + +static const char *const TAG = "vornado_ir.change_direction_button"; + +void ChangeDirectionButton::press_action() { this->parent_->send_change_direction(); } + +} // namespace vornado_ir +} // namespace esphome diff --git a/esphome/components/vornado_ir/button/change_direction.h b/esphome/components/vornado_ir/button/change_direction.h new file mode 100644 index 0000000000..c5e1f9479d --- /dev/null +++ b/esphome/components/vornado_ir/button/change_direction.h @@ -0,0 +1,18 @@ +#pragma once + +#include "esphome/components/button/button.h" +#include "../vornado_ir.h" + +namespace esphome { +namespace vornado_ir { + +class ChangeDirectionButton : public button::Button, public Parented { + public: + ChangeDirectionButton() = default; + + protected: + void press_action() override; +}; + +} // namespace vornado_ir +} // namespace esphome diff --git a/esphome/components/vornado_ir/button/decrease.cpp b/esphome/components/vornado_ir/button/decrease.cpp new file mode 100644 index 0000000000..13d70cae66 --- /dev/null +++ b/esphome/components/vornado_ir/button/decrease.cpp @@ -0,0 +1,11 @@ +#include "power.h" + +namespace esphome { +namespace vornado_ir { + +static const char *const TAG = "vornado_ir.decrease_button"; + +void DecreaseButton::press_action() { this->parent_->send_decrease(); } + +} // namespace vornado_ir +} // namespace esphome diff --git a/esphome/components/vornado_ir/button/fan.h b/esphome/components/vornado_ir/button/decrease.h similarity index 69% rename from esphome/components/vornado_ir/button/fan.h rename to esphome/components/vornado_ir/button/decrease.h index 62e14e7661..bccfa7da05 100644 --- a/esphome/components/vornado_ir/button/fan.h +++ b/esphome/components/vornado_ir/button/decrease.h @@ -6,9 +6,9 @@ namespace esphome { namespace vornado_ir { -class FanButton : public button::Button, public Parented { +class DecreaseButton : public button::Button, public Parented { public: - FanButton() = default; + DecreaseButton() = default; protected: void press_action() override; diff --git a/esphome/components/vornado_ir/button/fan.cpp b/esphome/components/vornado_ir/button/fan.cpp deleted file mode 100644 index 079eb50ef2..0000000000 --- a/esphome/components/vornado_ir/button/fan.cpp +++ /dev/null @@ -1,11 +0,0 @@ -#include "fan.h" - -namespace esphome { -namespace vornado_ir { - -static const char *const TAG = "vornado_ir.fan_button"; - -void FanButton::press_action() { this->parent_->send_start_fans(true); } - -} // namespace vornado_ir -} // namespace esphome diff --git a/esphome/components/vornado_ir/button/increase.cpp b/esphome/components/vornado_ir/button/increase.cpp new file mode 100644 index 0000000000..1012440645 --- /dev/null +++ b/esphome/components/vornado_ir/button/increase.cpp @@ -0,0 +1,11 @@ +#include "power.h" + +namespace esphome { +namespace vornado_ir { + +static const char *const TAG = "vornado_ir.increase_button"; + +void IncreaseButton::press_action() { this->parent_->send_increase(); } + +} // namespace vornado_ir +} // namespace esphome diff --git a/esphome/components/vornado_ir/button/increase.h b/esphome/components/vornado_ir/button/increase.h new file mode 100644 index 0000000000..6fa83a037d --- /dev/null +++ b/esphome/components/vornado_ir/button/increase.h @@ -0,0 +1,18 @@ +#pragma once + +#include "esphome/components/button/button.h" +#include "../vornado_ir.h" + +namespace esphome { +namespace vornado_ir { + +class IncreaseButton : public button::Button, public Parented { + public: + IncreaseButton() = default; + + protected: + void press_action() override; +}; + +} // namespace vornado_ir +} // namespace esphome diff --git a/esphome/components/vornado_ir/vornado_ir.cpp b/esphome/components/vornado_ir/vornado_ir.cpp index 26bb2d6404..de60e2c713 100644 --- a/esphome/components/vornado_ir/vornado_ir.cpp +++ b/esphome/components/vornado_ir/vornado_ir.cpp @@ -12,19 +12,41 @@ void VornadoIR::setup() { ESP_LOGCONFIG(TAG, "Setting up VornadoIR ..."); } void VornadoIR::loop() {} -void VornadoIR::dump_config() { ESP_LOGCONFIG(TAG, "Toto IR"); } +void VornadoIR::dump_config() { ESP_LOGCONFIG(TAG, "Vornado IR"); } -void VornadoIR::send_power_toggle(bool reset_timer) { +void VornadoIR::send_power_toggle() { ESP_LOGI(TAG, "Sending power toggle request"); this->transmit_(TOTO_IR_FIRST_POWER_TIMINGS); this->transmit_(TOTO_IR_SECOND_POWER_TIMINGS); this->transmit_(TOTO_IR_THIRD_POWER_TIMINGS); } -void VornadoIR::send_start_fans(bool reset_timer) { - ESP_LOGI(TAG, "Sending start fans request"); - this->transmit_(TOTO_IR_FIRST_FAN_TIMINGS); - this->transmit_(TOTO_IR_SECOND_FAN_TIMINGS); +void VornadoIR::send_power_toggle() { + ESP_LOGI(TAG, "Sending power toggle request"); + this->transmit_(TOTO_IR_FIRST_POWER_TIMINGS); + this->transmit_(TOTO_IR_SECOND_POWER_TIMINGS); + this->transmit_(TOTO_IR_THIRD_POWER_TIMINGS); +} + +void VornadoIR::send_change_direction() { + ESP_LOGI(TAG, "Sending change direction request"); + this->transmit_(TOTO_IR_FIRST_POWER_TIMINGS); + this->transmit_(TOTO_IR_SECOND_POWER_TIMINGS); + this->transmit_(TOTO_IR_THIRD_POWER_TIMINGS); +} + +void VornadoIR::send_increase() { + ESP_LOGI(TAG, "Sending increase request"); + this->transmit_(TOTO_IR_FIRST_POWER_TIMINGS); + this->transmit_(TOTO_IR_SECOND_POWER_TIMINGS); + this->transmit_(TOTO_IR_THIRD_POWER_TIMINGS); +} + +void VornadoIR::send_decrease() { + ESP_LOGI(TAG, "Sending decrease request"); + this->transmit_(TOTO_IR_FIRST_POWER_TIMINGS); + this->transmit_(TOTO_IR_SECOND_POWER_TIMINGS); + this->transmit_(TOTO_IR_THIRD_POWER_TIMINGS); } void VornadoIR::transmit_(RawTimings ir_code) { diff --git a/esphome/components/vornado_ir/vornado_ir.h b/esphome/components/vornado_ir/vornado_ir.h index 3ef6592ce4..460ac37d9a 100644 --- a/esphome/components/vornado_ir/vornado_ir.h +++ b/esphome/components/vornado_ir/vornado_ir.h @@ -19,8 +19,10 @@ class VornadoIR : public Component, public remote_base::RemoteTransmittable { // general functions void transmit_(RawTimings ir_code); // direct actions - void send_power_toggle(bool reset_timer = false); - void send_start_fans(bool reset_timer = false); + void send_power_toggle(); + void send_change_direction(); + void send_increase(); + void send_decrease(); }; } // namespace vornado_ir