Skip to content

Commit f67948f

Browse files
authored
Daikin: Support setting temperature in 0.5 C unit (#2036)
However, IRDaikinESP didn't support it. This PR allows to set and get the temperature in 0.5 C unit. It looks like some other Daikin protocols also support setting the temperature in 0.5 C unit: * Daikin2 * Daikin216 * Daikin160 * Daikin176 * Daikin152 However, they are not implemented in this PR, because I cannot test them.
1 parent 089ca89 commit f67948f

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

src/ir_Daikin.cpp

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ using irutils::addModeToString;
4646
using irutils::addSwingHToString;
4747
using irutils::addSwingVToString;
4848
using irutils::addTempToString;
49+
using irutils::addTempFloatToString;
4950
using irutils::addFanToString;
5051
using irutils::bcdToUint8;
5152
using irutils::minsToString;
@@ -221,15 +222,15 @@ bool IRDaikinESP::getPower(void) const {
221222

222223
/// Set the temperature.
223224
/// @param[in] temp The temperature in degrees celsius.
224-
void IRDaikinESP::setTemp(const uint8_t temp) {
225-
uint8_t degrees = std::max(temp, kDaikinMinTemp);
226-
degrees = std::min(degrees, kDaikinMaxTemp);
227-
_.Temp = degrees;
225+
void IRDaikinESP::setTemp(const float temp) {
226+
float degrees = std::max(temp, static_cast<float>(kDaikinMinTemp));
227+
degrees = std::min(degrees, static_cast<float>(kDaikinMaxTemp));
228+
_.Temp = degrees * 2.0f;
228229
}
229230

230231
/// Get the current temperature setting.
231232
/// @return The current setting for temp. in degrees celsius.
232-
uint8_t IRDaikinESP::getTemp(void) const { return _.Temp; }
233+
float IRDaikinESP::getTemp(void) const { return _.Temp / 2.0f; }
233234

234235
/// Set the speed of the fan.
235236
/// @param[in] fan The desired setting.
@@ -536,7 +537,7 @@ stdAc::state_t IRDaikinESP::toCommon(void) const {
536537
result.power = _.Power;
537538
result.mode = toCommonMode(_.Mode);
538539
result.celsius = true;
539-
result.degrees = _.Temp;
540+
result.degrees = getTemp();
540541
result.fanspeed = toCommonFanSpeed(getFan());
541542
result.swingv = _.SwingV ? stdAc::swingv_t::kAuto :
542543
stdAc::swingv_t::kOff;
@@ -563,7 +564,7 @@ String IRDaikinESP::toString(void) const {
563564
result += addBoolToString(_.Power, kPowerStr, false);
564565
result += addModeToString(_.Mode, kDaikinAuto, kDaikinCool, kDaikinHeat,
565566
kDaikinDry, kDaikinFan);
566-
result += addTempToString(_.Temp);
567+
result += addTempFloatToString(getTemp());
567568
result += addFanToString(getFan(), kDaikinFanMax, kDaikinFanMin,
568569
kDaikinFanAuto, kDaikinFanQuiet, kDaikinFanMed);
569570
result += addBoolToString(_.Powerful, kPowerfulStr);

src/ir_Daikin.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,7 @@ union DaikinESPProtocol{
9999
uint64_t Mode :3;
100100
uint64_t :1;
101101
// Byte 22
102-
uint64_t :1;
103-
uint64_t Temp :7; // Temp should be between 10 - 32
102+
uint64_t Temp :8; // Temp should be between 20 - 64 (10 C - 32 C)
104103
// Byte 23
105104
uint64_t :8;
106105

@@ -738,8 +737,8 @@ class IRDaikinESP {
738737
void off(void);
739738
void setPower(const bool on);
740739
bool getPower(void) const;
741-
void setTemp(const uint8_t temp);
742-
uint8_t getTemp(void) const;
740+
void setTemp(const float temp);
741+
float getTemp(void) const;
743742
void setFan(const uint8_t fan);
744743
uint8_t getFan(void) const;
745744
void setMode(const uint8_t mode);

0 commit comments

Comments
 (0)