3#if defined(USE_ARDUINO) || defined(USE_ESP32)
7#include <HeatpumpIRFactory.h>
17class IRSenderESPHome :
public IRSender {
21 void setFrequency(
int frequency)
override {
22 auto *data = this->transmit_.
get_data();
26 void space(
int space_length)
override {
28 auto *data = this->transmit_.
get_data();
29 data->
space(space_length);
35 void mark(
int mark_length)
override {
36 auto *data = this->transmit_.
get_data();
37 data->
mark(mark_length);
44static const char *
const TAG =
"heatpumpir.climate";
57 {
PROTOCOL_GREE, []() {
return new GreeGenericHeatpumpIR(); }},
107 ESP_LOGE(TAG,
"Invalid protocol");
129 uint8_t power_mode_cmd;
130 uint8_t operating_mode_cmd;
131 uint8_t temperature_cmd;
132 uint8_t fan_speed_cmd;
137 swing_v_cmd = VDIR_AUTO;
140 swing_v_cmd = VDIR_UP;
143 swing_v_cmd = VDIR_MUP;
146 swing_v_cmd = VDIR_MIDDLE;
149 swing_v_cmd = VDIR_MDOWN;
152 swing_v_cmd = VDIR_DOWN;
155 ESP_LOGE(TAG,
"Invalid default vertical direction");
159 swing_v_cmd = VDIR_SWING;
165 swing_h_cmd = HDIR_AUTO;
168 swing_h_cmd = HDIR_MIDDLE;
171 swing_h_cmd = HDIR_LEFT;
174 swing_h_cmd = HDIR_MLEFT;
177 swing_h_cmd = HDIR_MRIGHT;
180 swing_h_cmd = HDIR_RIGHT;
183 ESP_LOGE(TAG,
"Invalid default horizontal direction");
187 swing_h_cmd = HDIR_SWING;
192 fan_speed_cmd = FAN_2;
195 fan_speed_cmd = FAN_3;
198 fan_speed_cmd = FAN_4;
202 fan_speed_cmd = FAN_AUTO;
206 switch (this->
mode) {
208 power_mode_cmd = POWER_ON;
209 operating_mode_cmd = MODE_COOL;
212 power_mode_cmd = POWER_ON;
213 operating_mode_cmd = MODE_HEAT;
221 power_mode_cmd = POWER_ON;
222 operating_mode_cmd = MODE_AUTO;
225 power_mode_cmd = POWER_ON;
226 operating_mode_cmd = MODE_FAN;
229 power_mode_cmd = POWER_ON;
230 operating_mode_cmd = MODE_DRY;
234 power_mode_cmd = POWER_OFF;
235 operating_mode_cmd = MODE_AUTO;
242 heatpump_ir_->send(esp_sender, power_mode_cmd, operating_mode_cmd, fan_speed_cmd, temperature_cmd, swing_v_cmd,
ClimateMode mode
The active mode of the climate device.
optional< ClimateFanMode > fan_mode
The active fan mode of the climate device.
float target_temperature
The target temperature of the climate device.
ClimateSwingMode swing_mode
The active swing mode of the climate device.
float current_temperature
The current temperature of the climate device, as reported from the integration.
void publish_state()
Publish the state of the climate device, to be called from integrations.
VerticalDirection default_vertical_direction_
void transmit_state() override
Transmit via IR the state of this climate controller.
HorizontalDirection default_horizontal_direction_
HeatpumpIR * heatpump_ir_
value_type value_or(U const &v) const
void space(uint32_t length)
void set_carrier_frequency(uint32_t carrier_frequency)
void mark(uint32_t length)
RemoteTransmitterBase * transmitter_
RemoteTransmitData * get_data()
void add_on_state_callback(std::function< void(float)> &&callback)
Add a callback that will be called every time a filtered value arrives.
float state
This member variable stores the last state that has passed through all filters.
@ CLIMATE_SWING_HORIZONTAL
The fan mode is set to Horizontal.
@ CLIMATE_SWING_VERTICAL
The fan mode is set to Vertical.
@ CLIMATE_SWING_BOTH
The fan mode is set to Both.
@ CLIMATE_MODE_DRY
The climate device is set to dry/humidity mode.
@ CLIMATE_MODE_FAN_ONLY
The climate device only has the fan enabled, no heating or cooling is taking place.
@ CLIMATE_MODE_HEAT
The climate device is set to heat to reach the target temperature.
@ CLIMATE_MODE_COOL
The climate device is set to cool to reach the target temperature.
@ CLIMATE_MODE_HEAT_COOL
The climate device is set to heat/cool to reach the target temperature.
@ CLIMATE_MODE_OFF
The climate device is off.
@ CLIMATE_MODE_AUTO
The climate device is adjusting the temperature dynamically.
@ CLIMATE_FAN_MEDIUM
The fan mode is set to Medium.
@ CLIMATE_FAN_AUTO
The fan mode is set to Auto.
@ CLIMATE_FAN_LOW
The fan mode is set to Low.
@ CLIMATE_FAN_HIGH
The fan mode is set to High.
@ VERTICAL_DIRECTION_MIDDLE
@ VERTICAL_DIRECTION_MDOWN
@ VERTICAL_DIRECTION_AUTO
@ VERTICAL_DIRECTION_DOWN
const std::map< Protocol, std::function< HeatpumpIR *()> > PROTOCOL_CONSTRUCTOR_MAP
@ HORIZONTAL_DIRECTION_RIGHT
@ HORIZONTAL_DIRECTION_MIDDLE
@ HORIZONTAL_DIRECTION_MRIGHT
@ HORIZONTAL_DIRECTION_AUTO
@ HORIZONTAL_DIRECTION_MLEFT
@ HORIZONTAL_DIRECTION_LEFT
@ PROTOCOL_MITSUBISHI_HEAVY_ZMP
@ PROTOCOL_MITSUBISHI_HEAVY_ZM
@ PROTOCOL_MITSUBISHI_HEAVY_ZJ
@ PROTOCOL_SAMSUNG_AQV12MSAN
@ PROTOCOL_MITSUBISHI_MSC
@ PROTOCOL_MITSUBISHI_MSY
@ PROTOCOL_MITSUBISHI_HEAVY_FDTC
@ PROTOCOL_MITSUBISHI_SEZ
@ PROTOCOL_TOSHIBA_DAISEIKAI
@ PROTOCOL_PANASONIC_ALTDKE
Providing packet encoding functions for exchanging data with a remote host.