ESPHome 2026.11.0-dev
Loading...
Searching...
No Matches
midea_portasplit.h
Go to the documentation of this file.
1#pragma once
2
3// Midea PortaSplit climate component.
4//
5// The PortaSplit uses sync byte 0x00 for climate frames and silently drops the
6// XOR sync byte (LEN ^ 0xAC) frames that the `midea` component sends, which is
7// why the stock `midea` platform cannot drive this unit.
8//
9// Frame: AA | LEN | AC | SYNC | 00 00 00 00 | PROTO | TYPE | PAYLOAD | CRC8 | CS
10
14
15#include <array>
16
18
19static constexpr uint8_t FAN_AUTO = 102;
20
22 public:
23 void setup() override;
24 void loop() override;
25 void dump_config() override;
26
28 void control(const climate::ClimateCall &call) override;
29
30 protected:
31 static constexpr size_t MAX_FRAME = 128;
32
33 // The payload may live in PROGMEM.
34 void send_frame_(uint8_t proto, uint8_t type, const uint8_t *payload, size_t len);
35 void send_set_command_();
36 void send_status_query_();
37 void send_module_frame_(uint8_t type, uint8_t counter, uint8_t wifi_flags);
39
40 void rx_feed_(uint8_t b);
41 void handle_frame_(const uint8_t *f, size_t len);
42 void handle_c0_(const uint8_t *f, size_t len);
43
45 // Last known device state, mirrored from C0 so a set command does not clobber it.
46 uint8_t st_target_half_{48}; // Target temperature in half degrees
47 uint8_t st_mode_{1};
48 uint8_t st_fan_{FAN_AUTO};
49 bool st_power_ : 1 {false};
50 bool st_swing_ : 1 {false};
51 bool st_turbo_ : 1 {false};
52 bool st_ion_ : 1 {false};
53 bool st_sleep_ : 1 {false};
54 bool st_eco_ : 1 {false};
55 bool st_frost_ : 1 {false};
56
57 uint8_t msg_id_{1};
58 uint8_t net_counter_{0};
59 uint8_t rx_len_{0};
60 std::array<uint8_t, MAX_FRAME> rx_{};
61};
62
63} // namespace esphome::midea_portasplit
This class is used to encode all control actions on a climate device.
Definition climate.h:34
ClimateDevice - This is the base class for all climate integrations.
Definition climate.h:187
void handle_frame_(const uint8_t *f, size_t len)
void handle_c0_(const uint8_t *f, size_t len)
climate::ClimateTraits traits() override
void control(const climate::ClimateCall &call) override
std::array< uint8_t, MAX_FRAME > rx_
void send_module_frame_(uint8_t type, uint8_t counter, uint8_t wifi_flags)
void send_frame_(uint8_t proto, uint8_t type, const uint8_t *payload, size_t len)
uint8_t type
const void size_t len
Definition hal.h:68
static void uint32_t