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

Add nightmode #28

Merged
merged 3 commits into from
Mar 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
19 changes: 16 additions & 3 deletions esphome/components/mitsubishi/mitsubishi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ const uint8_t MITSUBISHI_POWERFUL = 0x08;

// Optional presets used to enable some model features
const uint8_t MITSUBISHI_ECONOCOOL = 0x20;
const uint8_t MITSUBISHI_NIGHTMODE = 0xC1;

// Pulse parameters in usec
const uint16_t MITSUBISHI_BIT_MARK = 430;
Expand Down Expand Up @@ -81,8 +82,8 @@ climate::ClimateTraits MitsubishiClimate::traits() {
traits.set_supported_swing_modes({climate::CLIMATE_SWING_OFF, climate::CLIMATE_SWING_BOTH,
climate::CLIMATE_SWING_VERTICAL, climate::CLIMATE_SWING_HORIZONTAL});

traits.set_supported_presets(
{climate::CLIMATE_PRESET_NONE, climate::CLIMATE_PRESET_ECO, climate::CLIMATE_PRESET_BOOST});
traits.set_supported_presets({climate::CLIMATE_PRESET_NONE, climate::CLIMATE_PRESET_ECO,
climate::CLIMATE_PRESET_BOOST, climate::CLIMATE_PRESET_SLEEP});

return traits;
}
Expand All @@ -108,7 +109,6 @@ void MitsubishiClimate::transmit_state() {
// Byte 15: HVAC specfic, i.e. POWERFUL, SMART SET, PLASMA, always 0x00
// Byte 16: Constant 0x00
// Byte 17: Checksum: SUM[Byte0...Byte16]

uint32_t remote_state[18] = {0x23, 0xCB, 0x26, 0x01, 0x00, 0x20, 0x08, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};

Expand Down Expand Up @@ -221,6 +221,10 @@ void MitsubishiClimate::transmit_state() {
remote_state[8] = (remote_state[8] & ~7) | MITSUBISHI_MODE_A_COOL;
remote_state[14] = MITSUBISHI_ECONOCOOL;
break;
case climate::CLIMATE_PRESET_SLEEP:
remote_state[9] = MITSUBISHI_FAN_AUTO;
remote_state[14] = MITSUBISHI_NIGHTMODE;
break;
case climate::CLIMATE_PRESET_BOOST:
remote_state[6] |= MITSUBISHI_OTHERWISE;
remote_state[15] = MITSUBISHI_POWERFUL;
Expand Down Expand Up @@ -367,6 +371,15 @@ bool MitsubishiClimate::on_receive(remote_base::RemoteReceiveData data) {
break;
}

switch (state_frame[14]) {
case MITSUBISHI_ECONOCOOL:
this->preset = climate::CLIMATE_PRESET_ECO;
break;
case MITSUBISHI_NIGHTMODE:
this->preset = climate::CLIMATE_PRESET_SLEEP;
break;
}

ESP_LOGV(TAG, "Receiving: %s", format_hex_pretty(state_frame, 18).c_str());

this->publish_state();
Expand Down
3 changes: 2 additions & 1 deletion esphome/components/mitsubishi/mitsubishi.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ class MitsubishiClimate : public climate_ir::ClimateIR {
climate::CLIMATE_FAN_MEDIUM, climate::CLIMATE_FAN_HIGH, climate::CLIMATE_FAN_QUIET},
{climate::CLIMATE_SWING_OFF, climate::CLIMATE_SWING_BOTH, climate::CLIMATE_SWING_VERTICAL,
climate::CLIMATE_SWING_HORIZONTAL},
{climate::CLIMATE_PRESET_NONE, climate::CLIMATE_PRESET_ECO, climate::CLIMATE_PRESET_BOOST}) {}
{climate::CLIMATE_PRESET_NONE, climate::CLIMATE_PRESET_ECO, climate::CLIMATE_PRESET_BOOST,
climate::CLIMATE_PRESET_SLEEP}) {}

void set_supports_cool(bool supports_cool) { this->supports_cool_ = supports_cool; }
void set_supports_dry(bool supports_dry) { this->supports_dry_ = supports_dry; }
Expand Down
Loading