11static constexpr size_t MITSUBISHI_FRAME_SIZE = 18;
59static const uint8_t FAHRENHEIT_CODES[] PROGMEM = {0x00, 0x10, 0x01, 0x11, 0x02, 0x12, 0x03, 0x04, 0x05, 0x15,
60 0x06, 0x16, 0x07, 0x17, 0x08, 0x18, 0x09, 0x19, 0x0a, 0x1a,
61 0x0b, 0x1b, 0x0c, 0x1c, 0x0d, 0x1d, 0x0e, 0x0f};
62static constexpr uint8_t FAHRENHEIT_MIN = 61;
63static constexpr uint8_t MITSUBISHI_HALF_DEGREE = 0x10;
65static uint8_t fahrenheit_code(
float celsius) {
67 size_t index = clamp<int>(fahrenheit - FAHRENHEIT_MIN, 0,
sizeof(FAHRENHEIT_CODES) - 1);
73static float decode_temperature(uint8_t code,
bool fahrenheit) {
75 for (
size_t i = 0; i <
sizeof(FAHRENHEIT_CODES); i++) {
81 return MITSUBISHI_TEMP_MIN + (code & 0x0F) + ((code & MITSUBISHI_HALF_DEGREE) ? 0.5f : 0.0f);
105 uint8_t remote_state[MITSUBISHI_FRAME_SIZE] = {0x23, 0xCB, 0x26, 0x01, 0x00, 0x20, 0x00, 0x00, 0x00,
106 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
108 switch (this->
mode) {
147 remote_state[7] = (uint8_t) roundf(
245 remote_state[17] =
sum_bytes(remote_state, 17);
247 ESP_LOGD(TAG,
"sending: %02X,%02X,%02X,%02X,%02X,%02X,%02X,%02X,%02X,%02X,%02X,%02X,%02X,%02X,%02X,%02X,%02X,%02X",
248 remote_state[0], remote_state[1], remote_state[2], remote_state[3], remote_state[4], remote_state[5],
249 remote_state[6], remote_state[7], remote_state[8], remote_state[9], remote_state[10], remote_state[11],
250 remote_state[12], remote_state[13], remote_state[14], remote_state[15], remote_state[16], remote_state[17]);
253 auto *data = transmit.get_data();
255 data->set_carrier_frequency(38000);
257 for (uint8_t r = 0; r < 2; r++) {
262 data->item_bytes<MITSUBISHI_BIT_TIMINGS>(remote_state,
sizeof(remote_state));
277 uint8_t state_frame[MITSUBISHI_FRAME_SIZE];
280 ESP_LOGV(TAG,
"Header fail");
285 if (!data.expect_bytes<MITSUBISHI_BIT_TIMINGS>(state_frame,
sizeof(state_frame)) ||
290 ESP_LOGV(TAG,
"Bit decode or bytes 0,1,2,3,4,13 or 16 fail");
298 switch (state_frame[6]) {
321 uint8_t fan = state_frame[9] & 0x07;
336 this->
fan_mode = modes_mapping[fan];
339 uint8_t wide_vane = state_frame[8] & 0xF0;
353 switch (vertical_vane) {
363 switch (state_frame[14]) {
372 ESP_LOGV_HEX(TAG, state_frame, MITSUBISHI_FRAME_SIZE, MITSUBISHI_FRAME_SIZE,
"Receiving: %s");
constexpr size_t count(ValueType value) const
Check if the set contains a specific value (std::set compatibility) Returns 1 if present,...
ClimateMode mode
The active mode of the climate device.
optional< ClimateFanMode > fan_mode
The active fan mode of the climate device.
float target_temperature
The target temperature of the climate device.
ClimateSwingMode swing_mode
The active swing mode of the climate device.
void publish_state()
Publish the state of the climate device, to be called from integrations.
optional< ClimatePreset > preset
The active preset of the climate device.
climate::ClimateModeMask modes_
void transmit_state() override
bool on_receive(remote_base::RemoteReceiveData data) override
VerticalDirection default_vertical_direction_
HorizontalDirection default_horizontal_direction_
bool fahrenheit_compatibility_
bool parse_state_frame_(const uint8_t frame[])
RemoteTransmitterBase * transmitter_
@ CLIMATE_PRESET_NONE
No preset is active.
@ CLIMATE_PRESET_BOOST
Device is in boost preset.
@ CLIMATE_PRESET_SLEEP
Device is prepared for sleep.
@ 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_MODE_DRY
The climate device is set to dry/humidity mode.
@ CLIMATE_MODE_FAN_ONLY
The climate device only has the fan enabled, no heating or cooling is taking place.
@ CLIMATE_MODE_HEAT
The climate device is set to heat to reach the target temperature.
@ CLIMATE_MODE_COOL
The climate device is set to cool to reach the target temperature.
@ CLIMATE_MODE_HEAT_COOL
The climate device is set to heat/cool to reach the target temperature.
@ CLIMATE_MODE_OFF
The climate device is off.
ClimateFanMode
NOTE: If adding values, update ClimateFanModeMask in climate_traits.h to use the new last value.
@ CLIMATE_FAN_MEDIUM
The fan mode is set to Medium.
@ CLIMATE_FAN_ON
The fan mode is set to On.
@ CLIMATE_FAN_AUTO
The fan mode is set to Auto.
@ CLIMATE_FAN_LOW
The fan mode is set to Low.
@ CLIMATE_FAN_MIDDLE
The fan mode is set to Middle.
@ CLIMATE_FAN_QUIET
The fan mode is set to Quiet.
@ CLIMATE_FAN_HIGH
The fan mode is set to High.
const uint8_t MITSUBISHI_POWERFUL
const uint16_t MITSUBISHI_MIN_GAP
ESPHOME_LOG_TAG(TAG, "mitsubishi.climate")
const uint8_t MITSUBISHI_MODE_AUTO
const uint8_t MITSUBISHI_MODE_COOL
const uint8_t MITSUBISHI_FAN_AUTO
const uint8_t MITSUBISHI_BYTE00
const uint16_t MITSUBISHI_HEADER_MARK
const uint8_t MITSUBISHI_BYTE13
const uint8_t MITSUBISHI_BYTE01
const uint8_t MITSUBISHI_MODE_A_HEAT
const uint8_t MITSUBISHI_BYTE04
const uint8_t MITSUBISHI_BYTE03
const uint8_t MITSUBISHI_BYTE02
const uint8_t MITSUBISHI_TEMP_MAX
const uint8_t MITSUBISHI_NIGHTMODE
const uint8_t MITSUBISHI_TEMP_MIN
const uint8_t MITSUBISHI_WIDE_VANE_SWING
const uint16_t MITSUBISHI_HEADER_SPACE
const uint8_t MITSUBISHI_VERTICAL_VANE_SWING
const uint8_t MITSUBISHI_MODE_A_DRY
const uint8_t MITSUBISHI_OTHERWISE
const uint8_t MITSUBISHI_ECONOCOOL
const uint8_t MITSUBISHI_OFF
const uint8_t MITSUBISHI_MODE_A_COOL
const uint8_t MITSUBISHI_MODE_DRY
const uint8_t MITSUBISHI_MODE_FAN_ONLY
const uint8_t MITSUBISHI_MODE_A_AUTO
const uint8_t MITSUBISHI_VERTICAL_VANE_MASK
const uint16_t MITSUBISHI_BIT_MARK
const uint8_t MITSUBISHI_MODE_HEAT
constexpr uint8_t sum_bytes(const uint8_t *data, size_t len, uint8_t sum=0)
Add up the bytes of data with size len, truncated to 8 bits: the checksum many serial and IR protocol...
constexpr float celsius_to_fahrenheit(float value)
Convert degrees Celsius to degrees Fahrenheit.
constexpr float fahrenheit_to_celsius(float value)
Convert degrees Fahrenheit to degrees Celsius.
uint8_t progmem_read_byte(const uint8_t *addr)
A bit is a mark (one_mark or zero_mark, both bit_mark unless set) and a space (one_space or zero_spac...