5#if defined(USE_ARDUINO) || defined(USE_ESP32)
9#include <HeatpumpIRFactory.h>
18class IRSenderESPHome :
public IRSender {
22 void setFrequency(
int frequency)
override {
23 auto *data = this->transmit_.
get_data();
24 data->set_carrier_frequency(1000 *
frequency);
27 void space(
int space_length)
override {
29 auto *data = this->transmit_.
get_data();
30 data->space(space_length);
36 void mark(
int mark_length)
override {
37 auto *data = this->transmit_.
get_data();
38 data->mark(mark_length);
47template<Protocol P>
struct ProtocolClass;
50 return new typename ProtocolClass<P>::type();
54#define HEATPUMPIR_PROTOCOL(protocol, cls) \
55 template<> struct ProtocolClass<protocol> { \
58 template HeatpumpIR *create_heatpump_ir<protocol>();
116#undef HEATPUMPIR_PROTOCOL
144 uint8_t power_mode_cmd;
145 uint8_t operating_mode_cmd;
146 uint8_t temperature_cmd;
147 uint8_t fan_speed_cmd;
152 swing_v_cmd = VDIR_AUTO;
155 swing_v_cmd = VDIR_UP;
158 swing_v_cmd = VDIR_MUP;
161 swing_v_cmd = VDIR_MIDDLE;
164 swing_v_cmd = VDIR_MDOWN;
167 swing_v_cmd = VDIR_DOWN;
170 ESP_LOGE(TAG,
"Invalid default vertical direction");
174 swing_v_cmd = VDIR_SWING;
180 swing_h_cmd = HDIR_AUTO;
183 swing_h_cmd = HDIR_MIDDLE;
186 swing_h_cmd = HDIR_LEFT;
189 swing_h_cmd = HDIR_MLEFT;
192 swing_h_cmd = HDIR_MRIGHT;
195 swing_h_cmd = HDIR_RIGHT;
198 ESP_LOGE(TAG,
"Invalid default horizontal direction");
202 swing_h_cmd = HDIR_SWING;
211 fan_speed_cmd = three_speed_fan ? FAN_1 : FAN_2;
214 fan_speed_cmd = three_speed_fan ? FAN_2 : FAN_3;
217 fan_speed_cmd = three_speed_fan ? FAN_3 : FAN_4;
221 fan_speed_cmd = FAN_AUTO;
228 fan_speed_cmd = FAN_4;
231 fan_speed_cmd = FAN_5;
238 switch (this->
mode) {
240 power_mode_cmd = POWER_ON;
241 operating_mode_cmd = MODE_COOL;
244 power_mode_cmd = POWER_ON;
245 operating_mode_cmd = MODE_HEAT;
253 power_mode_cmd = POWER_ON;
254 operating_mode_cmd = MODE_AUTO;
257 power_mode_cmd = POWER_ON;
258 operating_mode_cmd = MODE_FAN;
261 power_mode_cmd = POWER_ON;
262 operating_mode_cmd = MODE_DRY;
266 power_mode_cmd = POWER_OFF;
267 operating_mode_cmd = MODE_AUTO;
274 heatpump_ir_->send(esp_sender, power_mode_cmd, operating_mode_cmd, fan_speed_cmd, temperature_cmd, swing_v_cmd,
This class is used to encode all control actions on a climate device.
const optional< ClimateFanMode > & get_fan_mode() const
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.
optional< ClimatePreset > preset
The active preset of the climate device.
void control(const climate::ClimateCall &call) override
Override control to change settings of the climate device.
bool on_receive(remote_base::RemoteReceiveData data) override
Handle received IR data from the remote control.
VerticalDirection default_vertical_direction_
void transmit_state() override
Transmit via IR the state of this climate controller.
bool has_fan_byte_presets_() const
Mitsubishi Heavy ZJ and ZMP carry HiPower and Econo in the fan byte as FAN_4 and FAN_5.
HorizontalDirection default_horizontal_direction_
HeatpumpIR * heatpump_ir_
void control(const climate::ClimateCall &call) override
RemoteTransmitterBase * transmitter_
RemoteTransmitData * get_data()
void add_on_state_callback(F &&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_PRESET_NONE
No preset is active.
@ CLIMATE_PRESET_BOOST
Device is in boost preset.
@ CLIMATE_PRESET_ECO
Device is running an energy-saving preset.
@ 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
HEATPUMPIR_PROTOCOL(PROTOCOL_AUX, AUXHeatpumpIR) HEATPUMPIR_PROTOCOL(PROTOCOL_BALLU
bool decode_mitsubishi_heavy_frame(remote_base::RemoteReceiveData &data, uint8_t frame[MITSUBISHI_HEAVY_FRAME_LENGTH], HeatpumpIRClimate &climate)
Read a Mitsubishi Heavy frame into frame, check its prefix and inverted byte pairs,...
ESPHOME_LOG_TAG(TAG, "heatpumpir.climate")
@ HORIZONTAL_DIRECTION_RIGHT
@ HORIZONTAL_DIRECTION_MIDDLE
@ HORIZONTAL_DIRECTION_MRIGHT
@ HORIZONTAL_DIRECTION_AUTO
@ HORIZONTAL_DIRECTION_MLEFT
@ HORIZONTAL_DIRECTION_LEFT
HeatpumpIR * create_heatpump_ir()
Creates the HeatpumpIR library class for a protocol; instantiated in heatpumpir.cpp.
void decode_mitsubishi_heavy_zmp(const uint8_t frame[MITSUBISHI_HEAVY_FRAME_LENGTH], HeatpumpIRClimate &climate)
Apply the ZMP-specific fields (fan, preset, swing) of a validated frame.
@ 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
constexpr uint8_t MITSUBISHI_HEAVY_FRAME_LENGTH
Bytes in a Mitsubishi Heavy IR frame, prefix included.