Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Daikin: Support setting temperature in 0.5 C unit #2036

Merged
merged 2 commits into from
Dec 11, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions src/ir_Daikin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ using irutils::addModeToString;
using irutils::addSwingHToString;
using irutils::addSwingVToString;
using irutils::addTempToString;
using irutils::addTempFloatToString;
using irutils::addFanToString;
using irutils::bcdToUint8;
using irutils::minsToString;
Expand Down Expand Up @@ -221,15 +222,15 @@ bool IRDaikinESP::getPower(void) const {

/// Set the temperature.
/// @param[in] temp The temperature in degrees celsius.
void IRDaikinESP::setTemp(const uint8_t temp) {
uint8_t degrees = std::max(temp, kDaikinMinTemp);
degrees = std::min(degrees, kDaikinMaxTemp);
_.Temp = degrees;
void IRDaikinESP::setTemp(const float temp) {
float degrees = std::max(temp, static_cast<float>(kDaikinMinTemp));
degrees = std::min(degrees, static_cast<float>(kDaikinMaxTemp));
_.Temp2 = degrees * 2.0f;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Temp, not Temp2 please

}

/// Get the current temperature setting.
/// @return The current setting for temp. in degrees celsius.
uint8_t IRDaikinESP::getTemp(void) const { return _.Temp; }
float IRDaikinESP::getTemp(void) const { return _.Temp2 / 2.0f; }
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Temp, not Temp2 please


/// Set the speed of the fan.
/// @param[in] fan The desired setting.
Expand Down Expand Up @@ -536,7 +537,7 @@ stdAc::state_t IRDaikinESP::toCommon(void) const {
result.power = _.Power;
result.mode = toCommonMode(_.Mode);
result.celsius = true;
result.degrees = _.Temp;
result.degrees = _.Temp2 / 2.0f;
result.fanspeed = toCommonFanSpeed(getFan());
result.swingv = _.SwingV ? stdAc::swingv_t::kAuto :
stdAc::swingv_t::kOff;
Expand All @@ -563,7 +564,7 @@ String IRDaikinESP::toString(void) const {
result += addBoolToString(_.Power, kPowerStr, false);
result += addModeToString(_.Mode, kDaikinAuto, kDaikinCool, kDaikinHeat,
kDaikinDry, kDaikinFan);
result += addTempToString(_.Temp);
result += addTempFloatToString(_.Temp2 / 2.0f);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use:

  result += addTempFloatToString(getTemp());

result += addFanToString(getFan(), kDaikinFanMax, kDaikinFanMin,
kDaikinFanAuto, kDaikinFanQuiet, kDaikinFanMed);
result += addBoolToString(_.Powerful, kPowerfulStr);
Expand Down
7 changes: 3 additions & 4 deletions src/ir_Daikin.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,7 @@ union DaikinESPProtocol{
uint64_t Mode :3;
uint64_t :1;
// Byte 22
uint64_t :1;
uint64_t Temp :7; // Temp should be between 10 - 32
uint64_t Temp2 :8; // Temp2 should be between 20 - 64 (10 C - 32 C)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please keep it as Temp, not Temp2

// Byte 23
uint64_t :8;

Expand Down Expand Up @@ -738,8 +737,8 @@ class IRDaikinESP {
void off(void);
void setPower(const bool on);
bool getPower(void) const;
void setTemp(const uint8_t temp);
uint8_t getTemp(void) const;
void setTemp(const float temp);
float getTemp(void) const;
void setFan(const uint8_t fan);
uint8_t getFan(void) const;
void setMode(const uint8_t mode);
Expand Down