ESPHome 2025.5.0
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, std::set<climate::ClimateFanMode> fan_modes = {},
28 std::set<climate::ClimateSwingMode> swing_modes = {}, std::set<climate::ClimatePreset> presets = {}) {
29 this->minimum_temperature_ = minimum_temperature;
30 this->maximum_temperature_ = maximum_temperature;
31 this->temperature_step_ = temperature_step;
32 this->supports_dry_ = supports_dry;
33 this->supports_fan_only_ = supports_fan_only;
34 this->fan_modes_ = std::move(fan_modes);
35 this->swing_modes_ = std::move(swing_modes);
36 this->presets_ = std::move(presets);
37 }
38
39 void setup() override;
40 void dump_config() override;
41 void set_supports_cool(bool supports_cool) { this->supports_cool_ = supports_cool; }
42 void set_supports_heat(bool supports_heat) { this->supports_heat_ = supports_heat; }
43 void set_sensor(sensor::Sensor *sensor) { this->sensor_ = sensor; }
44
45 protected:
47
49 void control(const climate::ClimateCall &call) override;
52
54 virtual void transmit_state() = 0;
55
56 // Dummy implement on_receive so implementation is optional for inheritors
57 bool on_receive(remote_base::RemoteReceiveData data) override { return false; };
58
59 bool supports_cool_{true};
60 bool supports_heat_{true};
61 bool supports_dry_{false};
62 bool supports_fan_only_{false};
63 std::set<climate::ClimateFanMode> fan_modes_ = {};
64 std::set<climate::ClimateSwingMode> swing_modes_ = {};
65 std::set<climate::ClimatePreset> presets_ = {};
66
68};
69
70} // namespace climate_ir
71} // 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:168
This class contains all static data for climate devices.
std::set< climate::ClimateFanMode > fan_modes_
Definition climate_ir.h:63
void control(const climate::ClimateCall &call) override
Override control to change settings of the climate device.
ClimateIR(float minimum_temperature, float maximum_temperature, float temperature_step=1.0f, bool supports_dry=false, bool supports_fan_only=false, std::set< climate::ClimateFanMode > fan_modes={}, std::set< climate::ClimateSwingMode > swing_modes={}, std::set< climate::ClimatePreset > presets={})
Definition climate_ir.h:26
climate::ClimateTraits traits() override
Return the traits of this controller.
Definition climate_ir.cpp:9
std::set< climate::ClimatePreset > presets_
Definition climate_ir.h:65
void set_sensor(sensor::Sensor *sensor)
Definition climate_ir.h:43
void set_supports_heat(bool supports_heat)
Definition climate_ir.h:42
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:57
std::set< climate::ClimateSwingMode > swing_modes_
Definition climate_ir.h:64
void set_supports_cool(bool supports_cool)
Definition climate_ir.h:41
Base-class for all sensors.
Definition sensor.h:57
Providing packet encoding functions for exchanging data with a remote host.
Definition a01nyub.cpp:7