diff --git a/esphome/components/heatpumpir/climate.py b/esphome/components/heatpumpir/climate.py index 36e56aa5da..592e03f959 100644 --- a/esphome/components/heatpumpir/climate.py +++ b/esphome/components/heatpumpir/climate.py @@ -30,6 +30,7 @@ PROTOCOLS = { "gree": Protocol.PROTOCOL_GREE, "greeya": Protocol.PROTOCOL_GREEYAA, "greeyan": Protocol.PROTOCOL_GREEYAN, + "greeyac": Protocol.PROTOCOL_GREEYAC, "hisense_aud": Protocol.PROTOCOL_HISENSE_AUD, "hitachi": Protocol.PROTOCOL_HITACHI, "hyundai": Protocol.PROTOCOL_HYUNDAI, @@ -111,4 +112,6 @@ def to_code(config): cg.add(var.set_max_temperature(config[CONF_MIN_TEMPERATURE])) cg.add(var.set_min_temperature(config[CONF_MAX_TEMPERATURE])) - cg.add_library("tonia/HeatpumpIR", "1.0.15") + # PIO isn't updating releases, so referencing the release tag directly. See: + # https://github.com/ToniA/arduino-heatpumpir/commit/0948c619d86407a4e50e8db2f3c193e0576c86fd + cg.add_library("", "", "https://github.com/ToniA/arduino-heatpumpir.git#1.0.18") diff --git a/esphome/components/heatpumpir/heatpumpir.cpp b/esphome/components/heatpumpir/heatpumpir.cpp index 8d9fc962c0..ad3731b955 100644 --- a/esphome/components/heatpumpir/heatpumpir.cpp +++ b/esphome/components/heatpumpir/heatpumpir.cpp @@ -25,6 +25,7 @@ const std::map> PROTOCOL_CONSTRUCTOR_MAP {PROTOCOL_GREE, []() { return new GreeGenericHeatpumpIR(); }}, // NOLINT {PROTOCOL_GREEYAA, []() { return new GreeYAAHeatpumpIR(); }}, // NOLINT {PROTOCOL_GREEYAN, []() { return new GreeYANHeatpumpIR(); }}, // NOLINT + {PROTOCOL_GREEYAC, []() { return new GreeYACHeatpumpIR(); }}, // NOLINT {PROTOCOL_HISENSE_AUD, []() { return new HisenseHeatpumpIR(); }}, // NOLINT {PROTOCOL_HITACHI, []() { return new HitachiHeatpumpIR(); }}, // NOLINT {PROTOCOL_HYUNDAI, []() { return new HyundaiHeatpumpIR(); }}, // NOLINT @@ -61,6 +62,19 @@ void HeatpumpIRClimate::setup() { } this->heatpump_ir_ = protocol_constructor->second(); climate_ir::ClimateIR::setup(); + if (this->sensor_) { + this->sensor_->add_on_state_callback([this](float state) { + this->current_temperature = state; + + IRSenderESPHome esp_sender(this->transmitter_); + this->heatpump_ir_->send(esp_sender, uint8_t(lround(this->current_temperature + 0.5))); + + // current temperature changed, publish state + this->publish_state(); + }); + this->current_temperature = this->sensor_->state; + } else + this->current_temperature = NAN; } void HeatpumpIRClimate::transmit_state() { @@ -171,8 +185,7 @@ void HeatpumpIRClimate::transmit_state() { temperature_cmd = (uint8_t) clamp(this->target_temperature, this->min_temperature_, this->max_temperature_); - IRSenderESPHome esp_sender(0, this->transmitter_); - + IRSenderESPHome esp_sender(this->transmitter_); heatpump_ir_->send(esp_sender, power_mode_cmd, operating_mode_cmd, fan_speed_cmd, temperature_cmd, swing_v_cmd, swing_h_cmd); } diff --git a/esphome/components/heatpumpir/heatpumpir.h b/esphome/components/heatpumpir/heatpumpir.h index e2d2b45dc4..18d9b5040f 100644 --- a/esphome/components/heatpumpir/heatpumpir.h +++ b/esphome/components/heatpumpir/heatpumpir.h @@ -25,6 +25,7 @@ enum Protocol { PROTOCOL_GREE, PROTOCOL_GREEYAA, PROTOCOL_GREEYAN, + PROTOCOL_GREEYAC, PROTOCOL_HISENSE_AUD, PROTOCOL_HITACHI, PROTOCOL_HYUNDAI, diff --git a/esphome/components/heatpumpir/ir_sender_esphome.h b/esphome/components/heatpumpir/ir_sender_esphome.h index 24e8ba9883..7546d990ea 100644 --- a/esphome/components/heatpumpir/ir_sender_esphome.h +++ b/esphome/components/heatpumpir/ir_sender_esphome.h @@ -11,8 +11,8 @@ namespace heatpumpir { class IRSenderESPHome : public IRSender { public: - IRSenderESPHome(uint8_t pin, remote_transmitter::RemoteTransmitterComponent *transmitter) - : IRSender(pin), transmit_(transmitter->transmit()){}; + IRSenderESPHome(remote_transmitter::RemoteTransmitterComponent *transmitter) + : IRSender(0), transmit_(transmitter->transmit()){}; void setFrequency(int frequency) override; // NOLINT(readability-identifier-naming) void space(int space_length) override; void mark(int mark_length) override; diff --git a/platformio.ini b/platformio.ini index 5e89afe8e6..2ac6d0bfc8 100644 --- a/platformio.ini +++ b/platformio.ini @@ -49,7 +49,9 @@ lib_deps = glmnet/Dsmr@0.5 ; dsmr rweather/Crypto@0.2.0 ; dsmr dudanov/MideaUART@1.1.8 ; midea - tonia/HeatpumpIR@1.0.15 ; heatpumpir + ; PIO isn't update releases correctly, see: + ; https://github.com/ToniA/arduino-heatpumpir/commit/0948c619d86407a4e50e8db2f3c193e0576c86fd + https://github.com/ToniA/arduino-heatpumpir.git#1.0.18 ; heatpumpir build_flags = ${common.build_flags} -DUSE_ARDUINO