mirror of
https://github.com/esphome/esphome.git
synced 2026-10-11 22:04:16 +00:00
[mitsubishi] Control both vanes on multi-vane Mitsubishi minisplit heads (#12609)
Co-authored-by: J. Nick Koston <nick@koston.org> Co-authored-by: J. Nick Koston <nick@home-assistant.io>
This commit is contained in:
co-authored by
J. Nick Koston
J. Nick Koston
parent
f70b6a6b03
commit
17cbb75161
@@ -44,6 +44,8 @@ VERTICAL_DIRECTIONS = {
|
||||
"down": VerticalDirections.VERTICAL_DIRECTION_DOWN,
|
||||
}
|
||||
|
||||
CONF_VERTICAL_VANES = "vertical_vanes"
|
||||
|
||||
|
||||
CONFIG_SCHEMA = climate_ir.climate_ir_with_receiver_schema(MitsubishiClimate).extend(
|
||||
{
|
||||
@@ -57,6 +59,7 @@ CONFIG_SCHEMA = climate_ir.climate_ir_with_receiver_schema(MitsubishiClimate).ex
|
||||
cv.Optional(CONF_VERTICAL_DEFAULT, default="middle"): cv.enum(
|
||||
VERTICAL_DIRECTIONS
|
||||
),
|
||||
cv.Optional(CONF_VERTICAL_VANES, default=1): cv.int_range(1, 2),
|
||||
}
|
||||
)
|
||||
|
||||
@@ -70,3 +73,4 @@ async def to_code(config: ConfigType) -> None:
|
||||
cg.add(var.set_fahrenheit_compatibility(config[CONF_FAHRENHEIT_COMPATIBILITY]))
|
||||
cg.add(var.set_horizontal_default(config[CONF_HORIZONTAL_DEFAULT]))
|
||||
cg.add(var.set_vertical_default(config[CONF_VERTICAL_DEFAULT]))
|
||||
cg.add(var.set_vertical_vanes(config[CONF_VERTICAL_VANES]))
|
||||
|
||||
@@ -27,6 +27,7 @@ const uint8_t MITSUBISHI_WIDE_VANE_SWING = 0xC0;
|
||||
|
||||
const uint8_t MITSUBISHI_FAN_AUTO = 0x00;
|
||||
|
||||
const uint8_t MITSUBISHI_VERTICAL_VANE_MASK = 0x38; // Bits 3,4,5
|
||||
const uint8_t MITSUBISHI_VERTICAL_VANE_SWING = 0x38;
|
||||
|
||||
// const uint8_t MITSUBISHI_AUTO = 0x80;
|
||||
@@ -52,7 +53,6 @@ const uint8_t MITSUBISHI_BYTE02 = 0x26;
|
||||
const uint8_t MITSUBISHI_BYTE03 = 0x01;
|
||||
const uint8_t MITSUBISHI_BYTE04 = 0x00;
|
||||
const uint8_t MITSUBISHI_BYTE13 = 0x00;
|
||||
const uint8_t MITSUBISHI_BYTE16 = 0x00;
|
||||
|
||||
// Byte 7 codes for 61°F through 88°F. Bit 4 is the half degree bit Mitsubishi uses so every Fahrenheit degree
|
||||
// maps to its own code.
|
||||
@@ -100,7 +100,7 @@ void MitsubishiClimate::transmit_state() {
|
||||
// Byte 13: Constant 0x00
|
||||
// Byte 14: HVAC specfic, i.e. ECONO COOL, CLEAN MODE, always 0x00
|
||||
// Byte 15: HVAC specfic, i.e. POWERFUL, SMART SET, PLASMA, always 0x00
|
||||
// Byte 16: Constant 0x00
|
||||
// Byte 16: Left vane control (for specific models). Constants match right vane controls.
|
||||
// Byte 17: Checksum: SUM[Byte0...Byte16]
|
||||
uint8_t remote_state[18] = {0x23, 0xCB, 0x26, 0x01, 0x00, 0x20, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
|
||||
@@ -214,7 +214,7 @@ void MitsubishiClimate::transmit_state() {
|
||||
break;
|
||||
}
|
||||
|
||||
ESP_LOGD(TAG, "default_vertical_direction_: %02X", this->default_vertical_direction_);
|
||||
ESP_LOGD(TAG, "Vertical default: 0x%02X, vanes: %u", this->default_vertical_direction_, this->vertical_vanes_);
|
||||
|
||||
// Special modes
|
||||
switch (this->preset.value_or(climate::CLIMATE_PRESET_NONE)) {
|
||||
@@ -236,6 +236,11 @@ void MitsubishiClimate::transmit_state() {
|
||||
break;
|
||||
}
|
||||
|
||||
if (this->vertical_vanes_ > 1) {
|
||||
// Heads with two vertical vanes carry the left vane in byte 16; it follows the right one, presets included
|
||||
remote_state[16] = remote_state[9] & MITSUBISHI_VERTICAL_VANE_MASK;
|
||||
}
|
||||
|
||||
// Checksum
|
||||
for (int i = 0; i < 17; i++) {
|
||||
remote_state[17] += remote_state[i];
|
||||
@@ -296,11 +301,11 @@ bool MitsubishiClimate::on_receive(remote_base::RemoteReceiveData data) {
|
||||
}
|
||||
state_frame[pos] = byte;
|
||||
|
||||
// Check Header && Footer
|
||||
// Check Header && Footer. Byte 16 only ever carries the left vane position (bits 3,4,5).
|
||||
if ((pos == 0 && byte != MITSUBISHI_BYTE00) || (pos == 1 && byte != MITSUBISHI_BYTE01) ||
|
||||
(pos == 2 && byte != MITSUBISHI_BYTE02) || (pos == 3 && byte != MITSUBISHI_BYTE03) ||
|
||||
(pos == 4 && byte != MITSUBISHI_BYTE04) || (pos == 13 && byte != MITSUBISHI_BYTE13) ||
|
||||
(pos == 16 && byte != MITSUBISHI_BYTE16)) {
|
||||
(pos == 16 && (byte & ~MITSUBISHI_VERTICAL_VANE_MASK) != 0)) {
|
||||
ESP_LOGV(TAG, "Bytes 0,1,2,3,4,13 or 16 fail - invalid value");
|
||||
return false;
|
||||
}
|
||||
@@ -362,7 +367,9 @@ bool MitsubishiClimate::on_receive(remote_base::RemoteReceiveData data) {
|
||||
}
|
||||
|
||||
// Vertical Vane
|
||||
uint8_t vertical_vane = state_frame[9] & 0x38; // Bits 3,4,5
|
||||
// On dual vane heads, the left vane is in [16] and right vane is in [9]. Left is ignored here because
|
||||
// the swing_mode enum doesn't convey that level of detail.
|
||||
uint8_t vertical_vane = state_frame[9] & MITSUBISHI_VERTICAL_VANE_MASK;
|
||||
switch (vertical_vane) {
|
||||
case MITSUBISHI_VERTICAL_VANE_SWING:
|
||||
if (this->swing_mode == climate::CLIMATE_SWING_HORIZONTAL) {
|
||||
|
||||
@@ -80,6 +80,7 @@ class MitsubishiClimate final : public climate_ir::ClimateIR {
|
||||
void set_vertical_default(VerticalDirection vertical_direction) {
|
||||
this->default_vertical_direction_ = vertical_direction;
|
||||
}
|
||||
void set_vertical_vanes(uint8_t vertical_vanes) { this->vertical_vanes_ = vertical_vanes; }
|
||||
|
||||
protected:
|
||||
// Transmit via IR the state of this climate controller.
|
||||
@@ -93,6 +94,7 @@ class MitsubishiClimate final : public climate_ir::ClimateIR {
|
||||
|
||||
HorizontalDirection default_horizontal_direction_;
|
||||
VerticalDirection default_vertical_direction_;
|
||||
uint8_t vertical_vanes_{1};
|
||||
};
|
||||
|
||||
} // namespace esphome::mitsubishi
|
||||
|
||||
@@ -3,6 +3,7 @@ climate:
|
||||
name: Mitsubishi
|
||||
transmitter_id: xmitr
|
||||
fahrenheit_compatibility: true
|
||||
vertical_vanes: 2
|
||||
- platform: mitsubishi
|
||||
name: Mitsubishi Celsius
|
||||
transmitter_id: xmitr
|
||||
|
||||
Reference in New Issue
Block a user