Support Daikin horizontal swing (#1247)

Co-authored-by: Ben Buxton <bb@cactii.net>
This commit is contained in:
buxtronix 2020-10-02 00:24:55 +10:00 committed by GitHub
parent e09fefd389
commit d7b76aadb2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 34 additions and 11 deletions

View File

@ -12,8 +12,10 @@ void DaikinClimate::transmit_state() {
0x00, 0x00, 0x00, 0x06, 0x60, 0x00, 0x00, 0xC0, 0x00, 0x00, 0x00}; 0x00, 0x00, 0x00, 0x06, 0x60, 0x00, 0x00, 0xC0, 0x00, 0x00, 0x00};
remote_state[21] = this->operation_mode_(); remote_state[21] = this->operation_mode_();
remote_state[24] = this->fan_speed_();
remote_state[22] = this->temperature_(); remote_state[22] = this->temperature_();
uint16_t fan_speed = this->fan_speed_();
remote_state[24] = fan_speed >> 8;
remote_state[25] = fan_speed & 0xff;
// Calculate checksum // Calculate checksum
for (int i = 16; i < 34; i++) { for (int i = 16; i < 34; i++) {
@ -90,25 +92,38 @@ uint8_t DaikinClimate::operation_mode_() {
return operating_mode; return operating_mode;
} }
uint8_t DaikinClimate::fan_speed_() { uint16_t DaikinClimate::fan_speed_() {
uint8_t fan_speed; uint16_t fan_speed;
switch (this->fan_mode) { switch (this->fan_mode) {
case climate::CLIMATE_FAN_LOW: case climate::CLIMATE_FAN_LOW:
fan_speed = DAIKIN_FAN_1; fan_speed = DAIKIN_FAN_1 << 8;
break; break;
case climate::CLIMATE_FAN_MEDIUM: case climate::CLIMATE_FAN_MEDIUM:
fan_speed = DAIKIN_FAN_3; fan_speed = DAIKIN_FAN_3 << 8;
break; break;
case climate::CLIMATE_FAN_HIGH: case climate::CLIMATE_FAN_HIGH:
fan_speed = DAIKIN_FAN_5; fan_speed = DAIKIN_FAN_5 << 8;
break; break;
case climate::CLIMATE_FAN_AUTO: case climate::CLIMATE_FAN_AUTO:
default: default:
fan_speed = DAIKIN_FAN_AUTO; fan_speed = DAIKIN_FAN_AUTO << 8;
} }
// If swing is enabled switch first 4 bits to 1111 // If swing is enabled switch first 4 bits to 1111
return this->swing_mode == climate::CLIMATE_SWING_VERTICAL ? fan_speed | 0xF : fan_speed; switch (this->swing_mode) {
case climate::CLIMATE_SWING_VERTICAL:
fan_speed |= 0x0F00;
break;
case climate::CLIMATE_SWING_HORIZONTAL:
fan_speed |= 0x000F;
break;
case climate::CLIMATE_SWING_BOTH:
fan_speed |= 0x0F0F;
break;
default:
break;
}
return fan_speed;
} }
uint8_t DaikinClimate::temperature_() { uint8_t DaikinClimate::temperature_() {
@ -159,13 +174,19 @@ bool DaikinClimate::parse_state_frame_(const uint8_t frame[]) {
this->target_temperature = temperature >> 1; this->target_temperature = temperature >> 1;
} }
uint8_t fan_mode = frame[8]; uint8_t fan_mode = frame[8];
if (fan_mode & 0xF) uint8_t swing_mode = frame[9];
if (fan_mode & 0xF && swing_mode & 0xF)
this->swing_mode = climate::CLIMATE_SWING_BOTH;
else if (fan_mode & 0xF)
this->swing_mode = climate::CLIMATE_SWING_VERTICAL; this->swing_mode = climate::CLIMATE_SWING_VERTICAL;
else if (swing_mode & 0xF)
this->swing_mode = climate::CLIMATE_SWING_HORIZONTAL;
else else
this->swing_mode = climate::CLIMATE_SWING_OFF; this->swing_mode = climate::CLIMATE_SWING_OFF;
switch (fan_mode & 0xF0) { switch (fan_mode & 0xF0) {
case DAIKIN_FAN_1: case DAIKIN_FAN_1:
case DAIKIN_FAN_2: case DAIKIN_FAN_2:
case DAIKIN_FAN_SILENT:
this->fan_mode = climate::CLIMATE_FAN_LOW; this->fan_mode = climate::CLIMATE_FAN_LOW;
break; break;
case DAIKIN_FAN_3: case DAIKIN_FAN_3:

View File

@ -21,6 +21,7 @@ const uint8_t DAIKIN_MODE_ON = 0x01;
// Fan Speed // Fan Speed
const uint8_t DAIKIN_FAN_AUTO = 0xA0; const uint8_t DAIKIN_FAN_AUTO = 0xA0;
const uint8_t DAIKIN_FAN_SILENT = 0xB0;
const uint8_t DAIKIN_FAN_1 = 0x30; const uint8_t DAIKIN_FAN_1 = 0x30;
const uint8_t DAIKIN_FAN_2 = 0x40; const uint8_t DAIKIN_FAN_2 = 0x40;
const uint8_t DAIKIN_FAN_3 = 0x50; const uint8_t DAIKIN_FAN_3 = 0x50;
@ -46,13 +47,14 @@ class DaikinClimate : public climate_ir::ClimateIR {
DAIKIN_TEMP_MIN, DAIKIN_TEMP_MAX, 1.0f, true, true, DAIKIN_TEMP_MIN, DAIKIN_TEMP_MAX, 1.0f, true, true,
std::vector<climate::ClimateFanMode>{climate::CLIMATE_FAN_AUTO, climate::CLIMATE_FAN_LOW, std::vector<climate::ClimateFanMode>{climate::CLIMATE_FAN_AUTO, climate::CLIMATE_FAN_LOW,
climate::CLIMATE_FAN_MEDIUM, climate::CLIMATE_FAN_HIGH}, climate::CLIMATE_FAN_MEDIUM, climate::CLIMATE_FAN_HIGH},
std::vector<climate::ClimateSwingMode>{climate::CLIMATE_SWING_OFF, climate::CLIMATE_SWING_VERTICAL}) {} std::vector<climate::ClimateSwingMode>{climate::CLIMATE_SWING_OFF, climate::CLIMATE_SWING_VERTICAL,
climate::CLIMATE_SWING_HORIZONTAL, climate::CLIMATE_SWING_BOTH}) {}
protected: protected:
// Transmit via IR the state of this climate controller. // Transmit via IR the state of this climate controller.
void transmit_state() override; void transmit_state() override;
uint8_t operation_mode_(); uint8_t operation_mode_();
uint8_t fan_speed_(); uint16_t fan_speed_();
uint8_t temperature_(); uint8_t temperature_();
// Handle received IR Buffer // Handle received IR Buffer
bool on_receive(remote_base::RemoteReceiveData data) override; bool on_receive(remote_base::RemoteReceiveData data) override;