ESPHome 2025.12.0-dev
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 {
11namespace climate_ir {
12
13/* A base for climate which works by sending (and receiving) IR codes
14
15 To send IR codes implement
16 void ClimateIR::transmit_state_()
17
18 Likewise to decode a IR into the AC state, implement
19 bool RemoteReceiverListener::on_receive(remote_base::RemoteReceiveData data) and return true
20*/
21class ClimateIR : public Component,
22 public climate::Climate,
25 public:
26 ClimateIR(float minimum_temperature, float maximum_temperature, float temperature_step = 1.0f,
27 bool supports_dry = false, bool supports_fan_only = false,
31 this->minimum_temperature_ = minimum_temperature;
32 this->maximum_temperature_ = maximum_temperature;
33 this->temperature_step_ = temperature_step;
34 this->supports_dry_ = supports_dry;
35 this->supports_fan_only_ = supports_fan_only;
36 this->fan_modes_ = fan_modes;
37 this->swing_modes_ = swing_modes;
38 this->presets_ = presets;
39 }
40
41 void setup() override;
42 void dump_config() override;
43 void set_supports_cool(bool supports_cool) { this->supports_cool_ = supports_cool; }
44 void set_supports_heat(bool supports_heat) { this->supports_heat_ = supports_heat; }
45 void set_sensor(sensor::Sensor *sensor) { this->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
70};
71
72} // namespace climate_ir
73} // namespace esphome
This class is used to encode all control actions on a climate device.
Definition climate.h:33
ClimateDevice - This is the base class for all climate integrations.
Definition climate.h:178
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.
climate::ClimateTraits traits() override
Return the traits of this controller.
Definition climate_ir.cpp:9
void set_sensor(sensor::Sensor *sensor)
Definition climate_ir.h:45
void set_supports_heat(bool supports_heat)
Definition climate_ir.h:44
virtual void transmit_state()=0
Transmit via IR the state of this climate controller.
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:26
void set_supports_cool(bool supports_cool)
Definition climate_ir.h:43
Base-class for all sensors.
Definition sensor.h:42
Providing packet encoding functions for exchanging data with a remote host.
Definition a01nyub.cpp:7