diff --git a/esphome/components/daikin/daikin.cpp b/esphome/components/daikin/daikin.cpp index bb8587fbeb..359c63aeca 100644 --- a/esphome/components/daikin/daikin.cpp +++ b/esphome/components/daikin/daikin.cpp @@ -65,7 +65,7 @@ void DaikinClimate::transmit_state() { transmit.perform(); } -uint8_t DaikinClimate::operation_mode_() { +uint8_t DaikinClimate::operation_mode_() const { uint8_t operating_mode = DAIKIN_MODE_ON; switch (this->mode) { case climate::CLIMATE_MODE_COOL: @@ -92,9 +92,12 @@ uint8_t DaikinClimate::operation_mode_() { return operating_mode; } -uint16_t DaikinClimate::fan_speed_() { +uint16_t DaikinClimate::fan_speed_() const { uint16_t fan_speed; switch (this->fan_mode.value()) { + case climate::CLIMATE_FAN_QUIET: + fan_speed = DAIKIN_FAN_SILENT << 8; + break; case climate::CLIMATE_FAN_LOW: fan_speed = DAIKIN_FAN_1 << 8; break; @@ -126,12 +129,11 @@ uint16_t DaikinClimate::fan_speed_() { return fan_speed; } -uint8_t DaikinClimate::temperature_() { +uint8_t DaikinClimate::temperature_() const { // Force special temperatures depending on the mode switch (this->mode) { case climate::CLIMATE_MODE_FAN_ONLY: return 0x32; - case climate::CLIMATE_MODE_HEAT_COOL: case climate::CLIMATE_MODE_DRY: return 0xc0; default: @@ -148,19 +150,25 @@ bool DaikinClimate::parse_state_frame_(const uint8_t frame[]) { if (frame[DAIKIN_STATE_FRAME_SIZE - 1] != checksum) return false; uint8_t mode = frame[5]; + // Temperature is given in degrees celcius * 2 + // only update for states that use the temperature + uint8_t temperature = frame[6]; if (mode & DAIKIN_MODE_ON) { switch (mode & 0xF0) { case DAIKIN_MODE_COOL: this->mode = climate::CLIMATE_MODE_COOL; + this->target_temperature = static_cast(temperature * 0.5f); break; case DAIKIN_MODE_DRY: this->mode = climate::CLIMATE_MODE_DRY; break; case DAIKIN_MODE_HEAT: this->mode = climate::CLIMATE_MODE_HEAT; + this->target_temperature = static_cast(temperature * 0.5f); break; case DAIKIN_MODE_AUTO: this->mode = climate::CLIMATE_MODE_HEAT_COOL; + this->target_temperature = static_cast(temperature * 0.5f); break; case DAIKIN_MODE_FAN: this->mode = climate::CLIMATE_MODE_FAN_ONLY; @@ -169,10 +177,6 @@ bool DaikinClimate::parse_state_frame_(const uint8_t frame[]) { } else { this->mode = climate::CLIMATE_MODE_OFF; } - uint8_t temperature = frame[6]; - if (!(temperature & 0xC0)) { - this->target_temperature = temperature >> 1; - } uint8_t fan_mode = frame[8]; uint8_t swing_mode = frame[9]; if (fan_mode & 0xF && swing_mode & 0xF) { @@ -187,7 +191,6 @@ bool DaikinClimate::parse_state_frame_(const uint8_t frame[]) { switch (fan_mode & 0xF0) { case DAIKIN_FAN_1: case DAIKIN_FAN_2: - case DAIKIN_FAN_SILENT: this->fan_mode = climate::CLIMATE_FAN_LOW; break; case DAIKIN_FAN_3: @@ -200,6 +203,9 @@ bool DaikinClimate::parse_state_frame_(const uint8_t frame[]) { case DAIKIN_FAN_AUTO: this->fan_mode = climate::CLIMATE_FAN_AUTO; break; + case DAIKIN_FAN_SILENT: + this->fan_mode = climate::CLIMATE_FAN_QUIET; + break; } this->publish_state(); return true; diff --git a/esphome/components/daikin/daikin.h b/esphome/components/daikin/daikin.h index b4ac309de9..159292cb55 100644 --- a/esphome/components/daikin/daikin.h +++ b/esphome/components/daikin/daikin.h @@ -44,17 +44,17 @@ class DaikinClimate : public climate_ir::ClimateIR { public: DaikinClimate() : climate_ir::ClimateIR(DAIKIN_TEMP_MIN, DAIKIN_TEMP_MAX, 1.0f, true, true, - {climate::CLIMATE_FAN_AUTO, climate::CLIMATE_FAN_LOW, climate::CLIMATE_FAN_MEDIUM, - climate::CLIMATE_FAN_HIGH}, + {climate::CLIMATE_FAN_QUIET, climate::CLIMATE_FAN_AUTO, climate::CLIMATE_FAN_LOW, + climate::CLIMATE_FAN_MEDIUM, climate::CLIMATE_FAN_HIGH}, {climate::CLIMATE_SWING_OFF, climate::CLIMATE_SWING_VERTICAL, climate::CLIMATE_SWING_HORIZONTAL, climate::CLIMATE_SWING_BOTH}) {} protected: // Transmit via IR the state of this climate controller. void transmit_state() override; - uint8_t operation_mode_(); - uint16_t fan_speed_(); - uint8_t temperature_(); + uint8_t operation_mode_() const; + uint16_t fan_speed_() const; + uint8_t temperature_() const; // Handle received IR Buffer bool on_receive(remote_base::RemoteReceiveData data) override; bool parse_state_frame_(const uint8_t frame[]);