ESPHome 2026.5.1
Loading...
Searching...
No Matches
climate_ir.h
Go to the documentation of this file.
1#pragma once
2
3#include <utility>
4
9
10namespace esphome::climate_ir {
11
12/* A base for climate which works by sending (and receiving) IR codes
13
14 To send IR codes implement
15 void ClimateIR::transmit_state_()
16
17 Likewise to decode a IR into the AC state, implement
18 bool RemoteReceiverListener::on_receive(remote_base::RemoteReceiveData data) and return true
19*/
20class ClimateIR : public Component,
21 public climate::Climate,
24 public:
25 ClimateIR(float minimum_temperature, float maximum_temperature, float temperature_step = 1.0f,
26 bool supports_dry = false, bool supports_fan_only = false,
30 this->minimum_temperature_ = minimum_temperature;
31 this->maximum_temperature_ = maximum_temperature;
32 this->temperature_step_ = temperature_step;
33 this->supports_dry_ = supports_dry;
34 this->supports_fan_only_ = supports_fan_only;
35 this->fan_modes_ = fan_modes;
36 this->swing_modes_ = swing_modes;
37 this->presets_ = presets;
38 }
39
40 void setup() override;
41 void dump_config() override;
42 void set_supports_cool(bool supports_cool) { this->supports_cool_ = supports_cool; }
43 void set_supports_heat(bool supports_heat) { this->supports_heat_ = supports_heat; }
44 void set_sensor(sensor::Sensor *sensor) { this->sensor_ = sensor; }
45 void set_humidity_sensor(sensor::Sensor *sensor) { this->humidity_sensor_ = sensor; }
46
47 protected:
49
51 void control(const climate::ClimateCall &call) override;
54
56 virtual void transmit_state() = 0;
57
58 // Dummy implement on_receive so implementation is optional for inheritors
59 bool on_receive(remote_base::RemoteReceiveData data) override { return false; };
60
61 bool supports_cool_{true};
62 bool supports_heat_{true};
63 bool supports_dry_{false};
64 bool supports_fan_only_{false};
68
71};
72
73} // namespace esphome::climate_ir
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
climate::ClimatePresetMask presets_
Definition climate_ir.h:67
climate::ClimateFanModeMask fan_modes_
Definition climate_ir.h:65
climate::ClimateSwingModeMask swing_modes_
Definition climate_ir.h:66
void control(const climate::ClimateCall &call) override
Override control to change settings of the climate device.
sensor::Sensor * humidity_sensor_
Definition climate_ir.h:70
climate::ClimateTraits traits() override
Return the traits of this controller.
Definition climate_ir.cpp:8
void set_sensor(sensor::Sensor *sensor)
Definition climate_ir.h:44
void set_supports_heat(bool supports_heat)
Definition climate_ir.h:43
virtual void transmit_state()=0
Transmit via IR the state of this climate controller.
void set_humidity_sensor(sensor::Sensor *sensor)
Definition climate_ir.h:45
bool on_receive(remote_base::RemoteReceiveData data) override
Definition climate_ir.h:59
ClimateIR(float minimum_temperature, float maximum_temperature, float temperature_step=1.0f, bool supports_dry=false, bool supports_fan_only=false, climate::ClimateFanModeMask fan_modes=climate::ClimateFanModeMask(), climate::ClimateSwingModeMask swing_modes=climate::ClimateSwingModeMask(), climate::ClimatePresetMask presets=climate::ClimatePresetMask())
Definition climate_ir.h:25
void set_supports_cool(bool supports_cool)
Definition climate_ir.h:42
Base-class for all sensors.
Definition sensor.h:47