ESPHome 2026.11.0-dev
Loading...
Searching...
No Matches
receiver_mitsubishi_heavy_zmp.cpp
Go to the documentation of this file.
2#include "heatpumpir.h"
3
4#if defined(USE_ARDUINO) || defined(USE_ESP32)
5
6#include <HeatpumpIRFactory.h>
7
8namespace esphome::heatpumpir {
9
10// Fan speed sits in bits 7:5 of byte 7; the vertical swing code spans bit 1 of byte 5 and bits 4:3 of byte 7
11static constexpr uint8_t BYTE_SWING_H = 5;
12static constexpr uint8_t BYTE_FAN = 7;
13static constexpr uint8_t FAN_SPEED_MASK = 0xE0;
14static constexpr uint8_t VS_MASK_BYTE5 = 0x02;
15static constexpr uint8_t VS_MASK_BYTE7 = 0x18;
16// The library has no horizontal swing for ZMP and always sends MITSUBISHI_HEAVY_ZMP_HS_STOP (0xCC) in byte 5.
17// Captures of the remote show 0x5C while it swings; the mask leaves out the vertical swing and clean bits.
18static constexpr uint8_t HORIZONTAL_SWING_MASK = 0xDC;
19static constexpr uint8_t HORIZONTAL_SWING_ACTIVE = 0x5C;
20
22 uint8_t fan = frame[BYTE_FAN] & FAN_SPEED_MASK;
24 switch (fan) {
25 case MITSUBISHI_HEAVY_ZMP_FAN_AUTO:
27 break;
28 case MITSUBISHI_HEAVY_ZMP_FAN1:
30 break;
31 case MITSUBISHI_HEAVY_ZMP_FAN2:
33 break;
34 case MITSUBISHI_HEAVY_ZMP_FAN3:
36 break;
37 case MITSUBISHI_HEAVY_ZMP_HIPOWER:
39 break; // the remote keeps the fan mode and restores it when the preset ends
40 case MITSUBISHI_HEAVY_ZMP_ECONO:
42 break;
43 }
44
45 uint8_t swing_h = frame[BYTE_SWING_H] & HORIZONTAL_SWING_MASK;
46 uint8_t swing_v = (frame[BYTE_SWING_H] & VS_MASK_BYTE5) | (frame[BYTE_FAN] & VS_MASK_BYTE7);
47 bool h_swing = (swing_h == HORIZONTAL_SWING_ACTIVE);
48 bool v_swing = (swing_v == MITSUBISHI_HEAVY_ZMP_VS_SWING);
49
50 if (h_swing && v_swing) {
52 } else if (h_swing) {
54 } else if (v_swing) {
56 } else {
58 }
59}
60
61} // namespace esphome::heatpumpir
62
63#endif
optional< ClimateFanMode > fan_mode
The active fan mode of the climate device.
Definition climate.h:298
ClimateSwingMode swing_mode
The active swing mode of the climate device.
Definition climate.h:310
optional< ClimatePreset > preset
The active preset of the climate device.
Definition climate.h:301
const uint32_t FAN_SPEED_MASK
@ CLIMATE_PRESET_NONE
No preset is active.
@ CLIMATE_PRESET_BOOST
Device is in boost preset.
@ CLIMATE_PRESET_ECO
Device is running an energy-saving preset.
@ CLIMATE_SWING_OFF
The swing mode is set to Off.
@ CLIMATE_SWING_HORIZONTAL
The fan mode is set to Horizontal.
@ CLIMATE_SWING_VERTICAL
The fan mode is set to Vertical.
@ CLIMATE_SWING_BOTH
The fan mode is set to Both.
@ CLIMATE_FAN_MEDIUM
The fan mode is set to Medium.
@ CLIMATE_FAN_AUTO
The fan mode is set to Auto.
@ CLIMATE_FAN_LOW
The fan mode is set to Low.
@ CLIMATE_FAN_HIGH
The fan mode is set to High.
void decode_mitsubishi_heavy_zmp(const uint8_t frame[MITSUBISHI_HEAVY_FRAME_LENGTH], HeatpumpIRClimate &climate)
Apply the ZMP-specific fields (fan, preset, swing) of a validated frame.
constexpr uint8_t MITSUBISHI_HEAVY_FRAME_LENGTH
Bytes in a Mitsubishi Heavy IR frame, prefix included.