7 static const char *
const TAG =
"mitsubishi.climate";
113 uint8_t remote_state[18] = {0x23, 0xCB, 0x26, 0x01, 0x00, 0x20, 0x00, 0x00, 0x00,
114 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
116 switch (this->
mode) {
153 remote_state[7] = (uint8_t) roundf(
207 ESP_LOGD(TAG,
"fan: %02x state: %02x", this->
fan_mode.
value(), remote_state[9]);
228 remote_state[8] = (remote_state[8] & ~7) | MITSUBISHI_MODE_A_COOL;
245 for (
int i = 0; i < 17; i++) {
246 remote_state[17] += remote_state[i];
249 ESP_LOGD(TAG,
"sending: %02X,%02X,%02X,%02X,%02X,%02X,%02X,%02X,%02X,%02X,%02X,%02X,%02X,%02X,%02X,%02X,%02X,%02X",
250 remote_state[0], remote_state[1], remote_state[2], remote_state[3], remote_state[4], remote_state[5],
251 remote_state[6], remote_state[7], remote_state[8], remote_state[9], remote_state[10], remote_state[11],
252 remote_state[12], remote_state[13], remote_state[14], remote_state[15], remote_state[16], remote_state[17]);
259 for (uint8_t r = 0; r < 2; r++) {
261 data->mark(MITSUBISHI_HEADER_MARK);
262 data->space(MITSUBISHI_HEADER_SPACE);
264 for (uint8_t i : remote_state) {
265 for (uint8_t j = 0; j < 8; j++) {
266 data->mark(MITSUBISHI_BIT_MARK);
267 bool bit = i & (1 << j);
268 data->space(bit ? MITSUBISHI_ONE_SPACE : MITSUBISHI_ZERO_SPACE);
273 data->mark(MITSUBISHI_BIT_MARK);
274 data->space(MITSUBISHI_MIN_GAP);
277 data->mark(MITSUBISHI_BIT_MARK);
285 uint8_t state_frame[18] = {};
287 if (!data.
expect_item(MITSUBISHI_HEADER_MARK, MITSUBISHI_HEADER_SPACE)) {
288 ESP_LOGV(TAG,
"Header fail");
292 for (uint8_t pos = 0; pos < 18; pos++) {
294 for (int8_t bit = 0; bit < 8; bit++) {
295 if (data.
expect_item(MITSUBISHI_BIT_MARK, MITSUBISHI_ONE_SPACE)) {
297 }
else if (!data.
expect_item(MITSUBISHI_BIT_MARK, MITSUBISHI_ZERO_SPACE)) {
298 ESP_LOGV(TAG,
"Byte %d bit %d fail", pos, bit);
302 state_frame[pos] = byte;
305 if ((pos == 0 && byte != MITSUBISHI_BYTE00) || (pos == 1 && byte != MITSUBISHI_BYTE01) ||
306 (pos == 2 && byte != MITSUBISHI_BYTE02) || (pos == 3 && byte != MITSUBISHI_BYTE03) ||
307 (pos == 4 && byte != MITSUBISHI_BYTE04) || (pos == 13 && byte != MITSUBISHI_BYTE13) ||
308 (pos == 16 && byte != MITSUBISHI_BYTE16)) {
309 ESP_LOGV(TAG,
"Bytes 0,1,2,3,4,13 or 16 fail - invalid value");
315 if (state_frame[5] == MITSUBISHI_OFF) {
318 switch (state_frame[6]) {
341 uint8_t fan = state_frame[9] & 0x07;
355 climate::CLIMATE_FAN_AUTO};
356 this->
fan_mode = modes_mapping[fan];
359 uint8_t wide_vane = state_frame[8] & 0xF0;
370 uint8_t vertical_vane = state_frame[9] & 0x38;
371 switch (vertical_vane) {
381 switch (state_frame[14]) {
The fan mode is set to Low.
const uint16_t MITSUBISHI_MIN_GAP
value_type const & value() const
const uint16_t MITSUBISHI_ONE_SPACE
The fan mode is set to Quiet.
bool parse_state_frame_(const uint8_t frame[])
const uint8_t MITSUBISHI_BYTE01
ClimateSwingMode swing_mode
The active swing mode of the climate device.
const uint8_t MITSUBISHI_BYTE13
void set_visual_temperature_step(float temperature_step)
const uint8_t MITSUBISHI_MODE_COOL
The fan mode is set to Both.
std::string format_hex_pretty(const uint8_t *data, size_t length)
Format the byte array data of length len in pretty-printed, human-readable hex.
const uint8_t MITSUBISHI_BYTE02
const uint8_t MITSUBISHI_MODE_A_COOL
const uint8_t MITSUBISHI_BYTE00
float target_temperature
The target temperature of the climate device.
void set_carrier_frequency(uint32_t carrier_frequency)
The fan mode is set to Middle.
const uint8_t MITSUBISHI_MODE_A_AUTO
This class contains all static data for climate devices.
void set_visual_min_temperature(float visual_min_temperature)
The climate device is set to heat to reach the target temperature.
const uint8_t MITSUBISHI_VERTICAL_VANE_SWING
const uint8_t MITSUBISHI_POWERFUL
ClimateMode mode
The active mode of the climate device.
const uint8_t MITSUBISHI_ECONOCOOL
const uint8_t MITSUBISHI_MODE_A_DRY
const uint8_t MITSUBISHI_OTHERWISE
void transmit_state() override
const uint8_t MITSUBISHI_MODE_HEAT
The climate device is set to dry/humidity mode.
const uint8_t MITSUBISHI_MODE_A_HEAT
const uint8_t MITSUBISHI_BYTE04
void set_supported_presets(std::set< ClimatePreset > presets)
climate::ClimateTraits traits() override
const uint8_t MITSUBISHI_BYTE16
const uint16_t MITSUBISHI_BIT_MARK
const uint8_t MITSUBISHI_OFF
Device is prepared for sleep.
const uint8_t MITSUBISHI_WIDE_VANE_SWING
bool on_receive(remote_base::RemoteReceiveData data) override
HorizontalDirection default_horizontal_direction_
The fan mode is set to Horizontal.
The climate device is set to cool to reach the target temperature.
const uint8_t MITSUBISHI_FAN_AUTO
void set_supported_fan_modes(std::set< ClimateFanMode > modes)
The fan mode is set to Auto.
optional< ClimatePreset > preset
The active preset of the climate device.
const uint8_t MITSUBISHI_TEMP_MAX
const uint16_t MITSUBISHI_HEADER_SPACE
void set_supported_modes(std::set< ClimateMode > modes)
const uint16_t MITSUBISHI_HEADER_MARK
RemoteTransmitterBase * transmitter_
void set_visual_max_temperature(float visual_max_temperature)
The climate device is set to heat/cool to reach the target temperature.
The fan mode is set to Vertical.
void add_supported_fan_mode(ClimateFanMode mode)
void publish_state()
Publish the state of the climate device, to be called from integrations.
The fan mode is set to High.
RemoteTransmitData * get_data()
The swing mode is set to Off.
The climate device is off.
const uint8_t MITSUBISHI_NIGHTMODE
void set_supports_action(bool supports_action)
optional< ClimateFanMode > fan_mode
The active fan mode of the climate device.
const uint8_t MITSUBISHI_MODE_FAN_ONLY
Device is in boost preset.
Implementation of SPI Controller mode.
void set_supported_swing_modes(std::set< ClimateSwingMode > modes)
Device is running an energy-saving preset.
const uint8_t MITSUBISHI_BYTE03
void set_supports_current_temperature(bool supports_current_temperature)
const uint8_t MITSUBISHI_TEMP_MIN
The fan mode is set to Medium.
const uint8_t MITSUBISHI_MODE_DRY
bool expect_item(uint32_t mark, uint32_t space)
const uint16_t MITSUBISHI_ZERO_SPACE
The climate device only has the fan enabled, no heating or cooling is taking place.
VerticalDirection default_vertical_direction_
void add_supported_mode(ClimateMode mode)
const uint8_t MITSUBISHI_MODE_AUTO