diff --git a/esphome/components/gree/climate.py b/esphome/components/gree/climate.py index 75436f2cf5..389c9fb3c7 100644 --- a/esphome/components/gree/climate.py +++ b/esphome/components/gree/climate.py @@ -18,6 +18,7 @@ MODELS = { "yac": Model.GREE_YAC, "yac1fb9": Model.GREE_YAC1FB9, "yx1ff": Model.GREE_YX1FF, + "yag": Model.GREE_YAG, } 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 6d179a947b..e0cacb4f1e 100644 --- a/esphome/components/gree/gree.cpp +++ b/esphome/components/gree/gree.cpp @@ -22,13 +22,21 @@ void GreeClimate::transmit_state() { remote_state[0] = this->fan_speed_() | this->operation_mode_(); remote_state[1] = this->temperature_(); - if (this->model_ == GREE_YAN || this->model_ == GREE_YX1FF) { + if (this->model_ == GREE_YAN || this->model_ == GREE_YX1FF || this->model_ == GREE_YAG) { remote_state[2] = 0x60; remote_state[3] = 0x50; remote_state[4] = this->vertical_swing_(); } - if (this->model_ == GREE_YAC) { + if (this->model_ == GREE_YAG) { + remote_state[5] = 0x40; + + if (this->vertical_swing_() == GREE_VDIR_SWING || this->horizontal_swing_() == GREE_HDIR_SWING) { + remote_state[0] |= (1 << 6); + } + } + + if (this->model_ == GREE_YAC || this->model_ == GREE_YAG) { remote_state[4] |= (this->horizontal_swing_() << 4); } @@ -57,6 +65,12 @@ void GreeClimate::transmit_state() { // Calculate the checksum if (this->model_ == GREE_YAN || this->model_ == GREE_YX1FF) { remote_state[7] = ((remote_state[0] << 4) + (remote_state[1] << 4) + 0xC0); + } else if (this->model_ == GREE_YAG) { + remote_state[7] = + ((((remote_state[0] & 0x0F) + (remote_state[1] & 0x0F) + (remote_state[2] & 0x0F) + (remote_state[3] & 0x0F) + + ((remote_state[4] & 0xF0) >> 4) + ((remote_state[5] & 0xF0) >> 4) + ((remote_state[6] & 0xF0) >> 4) + 0x0A) & + 0x0F) + << 4); } else { remote_state[7] = ((((remote_state[0] & 0x0F) + (remote_state[1] & 0x0F) + (remote_state[2] & 0x0F) + (remote_state[3] & 0x0F) + diff --git a/esphome/components/gree/gree.h b/esphome/components/gree/gree.h index 6762b41eb0..f91d78cabd 100644 --- a/esphome/components/gree/gree.h +++ b/esphome/components/gree/gree.h @@ -58,7 +58,7 @@ const uint8_t GREE_VDIR_MIDDLE = 0x04; const uint8_t GREE_VDIR_MDOWN = 0x05; const uint8_t GREE_VDIR_DOWN = 0x06; -// Only available on YAC +// Only available on YAC/YAG // Horizontal air directions. Note that these cannot be set on all heat pumps const uint8_t GREE_HDIR_AUTO = 0x00; const uint8_t GREE_HDIR_MANUAL = 0x00; @@ -78,7 +78,7 @@ const uint8_t GREE_PRESET_SLEEP = 0x01; const uint8_t GREE_PRESET_SLEEP_BIT = 0x80; // Model codes -enum Model { GREE_GENERIC, GREE_YAN, GREE_YAA, GREE_YAC, GREE_YAC1FB9, GREE_YX1FF }; +enum Model { GREE_GENERIC, GREE_YAN, GREE_YAA, GREE_YAC, GREE_YAC1FB9, GREE_YX1FF, GREE_YAG }; class GreeClimate : public climate_ir::ClimateIR { public: