4#if defined(USE_ARDUINO) || defined(USE_ESP32)
6#include <HeatpumpIRFactory.h>
11static constexpr uint8_t BYTE_SWING_H = 5;
12static constexpr uint8_t BYTE_FAN = 7;
14static constexpr uint8_t VS_MASK_BYTE5 = 0x02;
15static constexpr uint8_t VS_MASK_BYTE7 = 0x18;
18static constexpr uint8_t HORIZONTAL_SWING_MASK = 0xDC;
19static constexpr uint8_t HORIZONTAL_SWING_ACTIVE = 0x5C;
22 uint8_t fan = frame[BYTE_FAN] & FAN_SPEED_MASK;
25 case MITSUBISHI_HEAVY_ZMP_FAN_AUTO:
28 case MITSUBISHI_HEAVY_ZMP_FAN1:
31 case MITSUBISHI_HEAVY_ZMP_FAN2:
34 case MITSUBISHI_HEAVY_ZMP_FAN3:
37 case MITSUBISHI_HEAVY_ZMP_HIPOWER:
40 case MITSUBISHI_HEAVY_ZMP_ECONO:
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);
50 if (h_swing && v_swing) {
optional< ClimateFanMode > fan_mode
The active fan mode of the climate device.
ClimateSwingMode swing_mode
The active swing mode of the climate device.
optional< ClimatePreset > preset
The active preset of the climate device.
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.