7 static const char *
const TAG =
"mitsubishi.climate";
112 uint32_t remote_state[18] = {0x23, 0xCB, 0x26, 0x01, 0x00, 0x20, 0x08, 0x00, 0x00,
113 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
115 switch (this->
mode) {
146 remote_state[7] = (uint8_t) roundf(
200 ESP_LOGD(TAG,
"fan: %02x state: %02x", this->
fan_mode.
value(), remote_state[9]);
221 remote_state[8] = (remote_state[8] & ~7) | MITSUBISHI_MODE_A_COOL;
238 for (
int i = 0; i < 17; i++) {
239 remote_state[17] += remote_state[i];
242 ESP_LOGD(TAG,
"sending: %02X,%02X,%02X,%02X,%02X,%02X,%02X,%02X,%02X,%02X,%02X,%02X,%02X,%02X,%02X,%02X,%02X,%02X",
243 remote_state[0], remote_state[1], remote_state[2], remote_state[3], remote_state[4], remote_state[5],
244 remote_state[6], remote_state[7], remote_state[8], remote_state[9], remote_state[10], remote_state[11],
245 remote_state[12], remote_state[13], remote_state[14], remote_state[15], remote_state[16], remote_state[17]);
252 for (uint16_t r = 0; r < 2; r++) {
254 data->mark(MITSUBISHI_HEADER_MARK);
255 data->space(MITSUBISHI_HEADER_SPACE);
257 for (uint8_t i : remote_state) {
258 for (uint8_t j = 0; j < 8; j++) {
259 data->mark(MITSUBISHI_BIT_MARK);
260 bool bit = i & (1 << j);
261 data->space(bit ? MITSUBISHI_ONE_SPACE : MITSUBISHI_ZERO_SPACE);
266 data->mark(MITSUBISHI_BIT_MARK);
267 data->space(MITSUBISHI_MIN_GAP);
270 data->mark(MITSUBISHI_BIT_MARK);
278 uint8_t state_frame[18] = {};
280 if (!data.
expect_item(MITSUBISHI_HEADER_MARK, MITSUBISHI_HEADER_SPACE)) {
281 ESP_LOGV(TAG,
"Header fail");
285 for (uint8_t pos = 0; pos < 18; pos++) {
287 for (int8_t bit = 0; bit < 8; bit++) {
288 if (data.
expect_item(MITSUBISHI_BIT_MARK, MITSUBISHI_ONE_SPACE)) {
290 }
else if (!data.
expect_item(MITSUBISHI_BIT_MARK, MITSUBISHI_ZERO_SPACE)) {
291 ESP_LOGV(TAG,
"Byte %d bit %d fail", pos, bit);
295 state_frame[pos] = byte;
298 if ((pos == 0 && byte != MITSUBISHI_BYTE00) || (pos == 1 && byte != MITSUBISHI_BYTE01) ||
299 (pos == 2 && byte != MITSUBISHI_BYTE02) || (pos == 3 && byte != MITSUBISHI_BYTE03) ||
300 (pos == 4 && byte != MITSUBISHI_BYTE04) || (pos == 13 && byte != MITSUBISHI_BYTE13) ||
301 (pos == 16 && byte != MITSUBISHI_BYTE16)) {
302 ESP_LOGV(TAG,
"Bytes 0,1,2,3,4,13 or 16 fail - invalid value");
308 if (state_frame[5] == MITSUBISHI_OFF) {
311 switch (state_frame[6]) {
334 uint8_t fan = state_frame[9] & 0x07;
348 climate::CLIMATE_FAN_AUTO};
349 this->
fan_mode = modes_mapping[fan];
352 uint8_t wide_vane = state_frame[8] & 0xF0;
363 uint8_t vertical_vane = state_frame[9] & 0x38;
364 switch (vertical_vane) {
374 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 uint32_t MITSUBISHI_OFF
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
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.
This is a workaround until we can figure out a way to get the tflite-micro idf component code availab...
void set_supported_swing_modes(std::set< ClimateSwingMode > modes)
Device is running an energy-saving preset.
const uint8_t MITSUBISHI_BYTE03
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