ESPHome 2025.5.0
Loading...
Searching...
No Matches
midea_data.h
Go to the documentation of this file.
1#pragma once
2
5
6namespace esphome {
7namespace midea_ir {
8
12
13class ControlData : public MideaData {
14 public:
15 // Default constructor (power: ON, mode: AUTO, fan: AUTO, temp: 25C)
16 ControlData() : MideaData({MIDEA_TYPE_CONTROL, 0x82, 0x48, 0xFF, 0xFF}) {}
17 // Copy from Base
19
20 void set_temp(float temp);
21 float get_temp() const;
22
24 ClimateMode get_mode() const;
25
28
29 void set_sleep_preset(bool value) { this->set_mask_(1, value, 64); }
30 bool get_sleep_preset() const { return this->get_value_(1, 64); }
31
32 void set_fahrenheit(bool value) { this->set_mask_(2, value, 32); }
33 bool get_fahrenheit() const { return this->get_value_(2, 32); }
34
35 void fix();
36
37 protected:
51 void set_fan_mode_(FanMode mode) { this->set_value_(1, mode, 3, 3); }
52 FanMode get_fan_mode_() const { return static_cast<FanMode>(this->get_value_(1, 3, 3)); }
53 void set_mode_(Mode mode) { this->set_value_(1, mode, 7); }
54 Mode get_mode_() const { return static_cast<Mode>(this->get_value_(1, 7)); }
55 void set_power_(bool value) { this->set_mask_(1, value, 128); }
56 bool get_power_() const { return this->get_value_(1, 128); }
57};
58
59class FollowMeData : public MideaData {
60 public:
61 // Default constructor (temp: 30C, beeper: off)
62 FollowMeData() : MideaData({MIDEA_TYPE_FOLLOW_ME, 0x82, 0x48, 0x7F, 0x1F}) {}
63 // Copy from Base
65 // Direct from temperature and beeper values
66 FollowMeData(uint8_t temp, bool beeper = false) : FollowMeData() {
67 this->set_temp(temp);
68 this->set_beeper(beeper);
69 }
70
71 /* TEMPERATURE */
72 uint8_t temp() const { return this->get_value_(4) - 1; }
73 void set_temp(uint8_t val) { this->set_value_(4, std::min(MAX_TEMP, val) + 1); }
74
75 /* BEEPER */
76 bool beeper() const { return this->get_value_(3, 128); }
77 void set_beeper(bool value) { this->set_mask_(3, value, 128); }
78
79 protected:
80 static const uint8_t MAX_TEMP = 37;
81};
82
83class SpecialData : public MideaData {
84 public:
85 SpecialData(uint8_t code) : MideaData({MIDEA_TYPE_SPECIAL, code, 0xFF, 0xFF, 0xFF}) {}
86 static const uint8_t VSWING_STEP = 1;
87 static const uint8_t VSWING_TOGGLE = 2;
88 static const uint8_t TURBO_TOGGLE = 9;
89};
90
91} // namespace midea_ir
92} // namespace esphome
BedjetMode mode
BedJet operating mode.
ControlData(const MideaData &data)
Definition midea_data.h:18
void set_mode(ClimateMode mode)
Definition midea_ir.cpp:41
void set_sleep_preset(bool value)
Definition midea_data.h:29
void set_fahrenheit(bool value)
Definition midea_data.h:32
ClimateMode get_mode() const
Definition midea_ir.cpp:65
FanMode get_fan_mode_() const
Definition midea_data.h:52
void set_fan_mode(ClimateFanMode mode)
Definition midea_ir.cpp:82
void set_power_(bool value)
Definition midea_data.h:55
ClimateFanMode get_fan_mode() const
Definition midea_ir.cpp:99
void set_fan_mode_(FanMode mode)
Definition midea_data.h:51
FollowMeData(const MideaData &data)
Definition midea_data.h:64
static const uint8_t MAX_TEMP
Definition midea_data.h:80
FollowMeData(uint8_t temp, bool beeper=false)
Definition midea_data.h:66
static const uint8_t VSWING_STEP
Definition midea_data.h:86
static const uint8_t TURBO_TOGGLE
Definition midea_data.h:88
static const uint8_t VSWING_TOGGLE
Definition midea_data.h:87
void set_value_(uint8_t idx, uint8_t value, uint8_t mask=255, uint8_t shift=0)
uint8_t get_value_(uint8_t idx, uint8_t mask=255, uint8_t shift=0) const
void set_mask_(uint8_t idx, bool state, uint8_t mask=255)
mopeka_std_values val[4]
ClimateMode
Enum for all modes a climate device can be in.
Providing packet encoding functions for exchanging data with a remote host.
Definition a01nyub.cpp:7