From 2e8a2fdbd4677b9075ae9bb572b4d66b8fc67794 Mon Sep 17 00:00:00 2001 From: Tomi Junnila Date: Thu, 11 Jul 2024 23:32:38 +0300 Subject: [PATCH] Add support for the Gree YAC1FB9 in climate_ir (#7056) --- esphome/components/gree/climate.py | 1 + esphome/components/gree/gree.cpp | 14 +++++++++++--- esphome/components/gree/gree.h | 6 +++++- 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/esphome/components/gree/climate.py b/esphome/components/gree/climate.py index 02ce7b12d4..c88a428391 100644 --- a/esphome/components/gree/climate.py +++ b/esphome/components/gree/climate.py @@ -16,6 +16,7 @@ MODELS = { "yan": Model.GREE_YAN, "yaa": Model.GREE_YAA, "yac": Model.GREE_YAC, + "yac1fb9": Model.GREE_YAC1FB9, } CONFIG_SCHEMA = climate_ir.CLIMATE_IR_WITH_RECEIVER_SCHEMA.extend( diff --git a/esphome/components/gree/gree.cpp b/esphome/components/gree/gree.cpp index 1bbb443fce..cce2a8ffee 100644 --- a/esphome/components/gree/gree.cpp +++ b/esphome/components/gree/gree.cpp @@ -24,7 +24,7 @@ void GreeClimate::transmit_state() { remote_state[4] |= (this->horizontal_swing_() << 4); } - if (this->model_ == GREE_YAA || this->model_ == GREE_YAC) { + if (this->model_ == GREE_YAA || this->model_ == GREE_YAC || this->model_ == GREE_YAC1FB9) { remote_state[2] = 0x20; // bits 0..3 always 0000, bits 4..7 TURBO,LIGHT,HEALTH,X-FAN remote_state[3] = 0x50; // bits 4..7 always 0101 remote_state[6] = 0x20; // YAA1FB, FAA1FB1, YB1F2 bits 4..7 always 0010 @@ -53,7 +53,11 @@ void GreeClimate::transmit_state() { data->set_carrier_frequency(GREE_IR_FREQUENCY); data->mark(GREE_HEADER_MARK); - data->space(GREE_HEADER_SPACE); + if (this->model_ == GREE_YAC1FB9) { + data->space(GREE_YAC1FB9_HEADER_SPACE); + } else { + data->space(GREE_HEADER_SPACE); + } for (int i = 0; i < 4; i++) { for (uint8_t mask = 1; mask > 0; mask <<= 1) { // iterate through bit mask @@ -71,7 +75,11 @@ void GreeClimate::transmit_state() { data->space(GREE_ZERO_SPACE); data->mark(GREE_BIT_MARK); - data->space(GREE_MESSAGE_SPACE); + if (this->model_ == GREE_YAC1FB9) { + data->space(GREE_YAC1FB9_MESSAGE_SPACE); + } else { + data->space(GREE_MESSAGE_SPACE); + } for (int i = 4; i < 8; i++) { for (uint8_t mask = 1; mask > 0; mask <<= 1) { // iterate through bit mask diff --git a/esphome/components/gree/gree.h b/esphome/components/gree/gree.h index e7131a2b89..524a95aebd 100644 --- a/esphome/components/gree/gree.h +++ b/esphome/components/gree/gree.h @@ -41,6 +41,10 @@ const uint32_t GREE_YAC_HEADER_MARK = 6000; const uint32_t GREE_YAC_HEADER_SPACE = 3000; const uint32_t GREE_YAC_BIT_MARK = 650; +// Timing specific to YAC1FB9 +const uint32_t GREE_YAC1FB9_HEADER_SPACE = 4500; +const uint32_t GREE_YAC1FB9_MESSAGE_SPACE = 19980; + // State Frame size const uint8_t GREE_STATE_FRAME_SIZE = 8; @@ -67,7 +71,7 @@ const uint8_t GREE_HDIR_MRIGHT = 0x05; const uint8_t GREE_HDIR_RIGHT = 0x06; // Model codes -enum Model { GREE_GENERIC, GREE_YAN, GREE_YAA, GREE_YAC }; +enum Model { GREE_GENERIC, GREE_YAN, GREE_YAA, GREE_YAC, GREE_YAC1FB9 }; class GreeClimate : public climate_ir::ClimateIR { public: