ESPHome  2024.11.1
emmeti.h
Go to the documentation of this file.
1 #pragma once
2 
4 
5 namespace esphome {
6 namespace emmeti {
7 
8 const uint8_t EMMETI_TEMP_MIN = 16; // Celsius
9 const uint8_t EMMETI_TEMP_MAX = 30; // Celsius
10 
11 // Modes
12 
13 enum EmmetiMode : uint8_t {
19 };
20 
21 // Fan Speed
22 
23 enum EmmetiFanMode : uint8_t {
25  EMMETI_FAN_1 = 0x01,
26  EMMETI_FAN_2 = 0x02,
27  EMMETI_FAN_3 = 0x03,
28 };
29 
30 // Fan Position
31 
32 enum EmmetiBlades : uint8_t {
43 };
44 
45 // IR Transmission
46 const uint32_t EMMETI_IR_FREQUENCY = 38000;
47 const uint32_t EMMETI_HEADER_MARK = 9076;
48 const uint32_t EMMETI_HEADER_SPACE = 4408;
49 const uint32_t EMMETI_BIT_MARK = 660;
50 const uint32_t EMMETI_ONE_SPACE = 1630;
51 const uint32_t EMMETI_ZERO_SPACE = 530;
52 const uint32_t EMMETI_MESSAGE_SPACE = 20000;
53 
54 struct EmmetiState {
55  uint8_t mode = 0;
56  uint8_t bitmap = 0;
57  uint8_t fan_speed = 0;
58  uint8_t temp = 0;
59  uint8_t fan_pos = 0;
60  uint8_t th = 0;
61  uint8_t checksum = 0;
62 };
63 
65  public:
67  : climate_ir::ClimateIR(EMMETI_TEMP_MIN, EMMETI_TEMP_MAX, 1.0f, true, true,
71 
72  protected:
73  // Transmit via IR the state of this climate controller
74  void transmit_state() override;
75  // Handle received IR Buffer
76  bool on_receive(remote_base::RemoteReceiveData data) override;
77  bool parse_state_frame_(EmmetiState curr_state);
78 
79  // setters
80  uint8_t set_mode_();
81  uint8_t set_temp_();
82  uint8_t set_fan_speed_();
83  uint8_t gen_checksum_();
84  uint8_t set_blades_();
85 
86  // getters
87  climate::ClimateMode get_mode_(uint8_t mode);
88  climate::ClimateFanMode get_fan_speed_(uint8_t fan);
89  void get_blades_(uint8_t fanpos);
90  // get swing
91  climate::ClimateSwingMode get_swing_(uint8_t bitmap);
92  float get_temp_(uint8_t temp);
93 
94  // check if the received frame is valid
95  bool check_checksum_(uint8_t checksum);
96 
97  template<typename T> T reverse_(T val, size_t len);
98 
99  template<typename T> void add_(T val, size_t len, esphome::remote_base::RemoteTransmitData *ata);
100 
101  template<typename T> void add_(T val, esphome::remote_base::RemoteTransmitData *data);
102 
103  template<typename T> void reverse_add_(T val, size_t len, esphome::remote_base::RemoteTransmitData *data);
104 
105  uint8_t blades_ = EMMETI_BLADES_STOP;
106 };
107 
108 } // namespace emmeti
109 } // namespace esphome
The fan mode is set to Low.
Definition: climate_mode.h:54
const uint32_t EMMETI_HEADER_MARK
Definition: emmeti.h:47
const uint32_t EMMETI_MESSAGE_SPACE
Definition: emmeti.h:52
mopeka_std_values val[4]
ClimateSwingMode
Enum for all modes a climate swing can be in.
Definition: climate_mode.h:70
The fan mode is set to Auto.
Definition: climate_mode.h:52
const uint32_t EMMETI_IR_FREQUENCY
Definition: emmeti.h:46
The fan mode is set to Vertical.
Definition: climate_mode.h:76
The fan mode is set to High.
Definition: climate_mode.h:58
ClimateMode
Enum for all modes a climate device can be in.
Definition: climate_mode.h:10
const uint32_t EMMETI_HEADER_SPACE
Definition: emmeti.h:48
The swing mode is set to Off.
Definition: climate_mode.h:72
const uint32_t EMMETI_ONE_SPACE
Definition: emmeti.h:50
const uint32_t EMMETI_BIT_MARK
Definition: emmeti.h:49
std::string size_t len
Definition: helpers.h:293
Implementation of SPI Controller mode.
Definition: a01nyub.cpp:7
const uint8_t EMMETI_TEMP_MAX
Definition: emmeti.h:9
The fan mode is set to Medium.
Definition: climate_mode.h:56
const uint32_t EMMETI_ZERO_SPACE
Definition: emmeti.h:51
const uint8_t EMMETI_TEMP_MIN
Definition: emmeti.h:8