ESPHome  2021.11.3
climate_ir.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <utility>
4 
9 
10 namespace esphome {
11 namespace 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 */
22  public:
23  ClimateIR(float minimum_temperature, float maximum_temperature, float temperature_step = 1.0f,
24  bool supports_dry = false, bool supports_fan_only = false, std::set<climate::ClimateFanMode> fan_modes = {},
25  std::set<climate::ClimateSwingMode> swing_modes = {}) {
26  this->minimum_temperature_ = minimum_temperature;
27  this->maximum_temperature_ = maximum_temperature;
28  this->temperature_step_ = temperature_step;
29  this->supports_dry_ = supports_dry;
30  this->supports_fan_only_ = supports_fan_only;
31  this->fan_modes_ = std::move(fan_modes);
32  this->swing_modes_ = std::move(swing_modes);
33  }
34 
35  void setup() override;
36  void dump_config() override;
38  this->transmitter_ = transmitter;
39  }
40  void set_supports_cool(bool supports_cool) { this->supports_cool_ = supports_cool; }
41  void set_supports_heat(bool supports_heat) { this->supports_heat_ = supports_heat; }
42  void set_sensor(sensor::Sensor *sensor) { this->sensor_ = sensor; }
43 
44  protected:
46 
48  void control(const climate::ClimateCall &call) override;
50  climate::ClimateTraits traits() override;
51 
53  virtual void transmit_state() = 0;
54 
55  // Dummy implement on_receive so implementation is optional for inheritors
56  bool on_receive(remote_base::RemoteReceiveData data) override { return false; };
57 
58  bool supports_cool_{true};
59  bool supports_heat_{true};
60  bool supports_dry_{false};
61  bool supports_fan_only_{false};
62  std::set<climate::ClimateFanMode> fan_modes_ = {};
63  std::set<climate::ClimateSwingMode> swing_modes_ = {};
64 
67 };
68 
69 } // namespace climate_ir
70 } // namespace esphome
This class is used to encode all control actions on a climate device.
Definition: climate.h:33
std::set< climate::ClimateSwingMode > swing_modes_
Definition: climate_ir.h:63
void set_sensor(sensor::Sensor *sensor)
Definition: climate_ir.h:42
This class contains all static data for climate devices.
virtual void transmit_state()=0
Transmit via IR the state of this climate controller.
void control(const climate::ClimateCall &call) override
Override control to change settings of the climate device.
Definition: climate_ir.cpp:59
void set_supports_heat(bool supports_heat)
Definition: climate_ir.h:41
void set_transmitter(remote_transmitter::RemoteTransmitterComponent *transmitter)
Definition: climate_ir.h:37
climate::ClimateTraits traits() override
Return the traits of this controller.
Definition: climate_ir.cpp:9
bool on_receive(remote_base::RemoteReceiveData data) override
Definition: climate_ir.h:56
Library based on https://github.com/miguelbalboa/rfid and adapted to ESPHome by . ...
Definition: a4988.cpp:4
std::set< climate::ClimateFanMode > fan_modes_
Definition: climate_ir.h:62
Base-class for all sensors.
Definition: sensor.h:47
remote_transmitter::RemoteTransmitterComponent * transmitter_
Definition: climate_ir.h:65
sensor::Sensor * sensor_
Definition: climate_ir.h:66
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={})
Definition: climate_ir.h:23
ClimateDevice - This is the base class for all climate integrations.
Definition: climate.h:167
void set_supports_cool(bool supports_cool)
Definition: climate_ir.h:40