ESPHome  2022.8.0
toshiba.h
Go to the documentation of this file.
1 #pragma once
2 
4 
5 namespace esphome {
6 namespace toshiba {
7 
8 // Simple enum to represent models.
9 enum Model {
10  MODEL_GENERIC = 0, // Temperature range is from 17 to 30
11  MODEL_RAC_PT1411HWRU_C = 1, // Temperature range is from 16 to 30
12  MODEL_RAC_PT1411HWRU_F = 2, // Temperature range is from 16 to 30
13 };
14 
15 // Supported temperature ranges
16 const float TOSHIBA_GENERIC_TEMP_C_MIN = 17.0;
17 const float TOSHIBA_GENERIC_TEMP_C_MAX = 30.0;
22 
24  public:
25  ToshibaClimate() : climate_ir::ClimateIR(TOSHIBA_GENERIC_TEMP_C_MIN, TOSHIBA_GENERIC_TEMP_C_MAX, 1.0f) {}
26 
27  void setup() override;
28  void set_model(Model model) { this->model_ = model; }
29 
30  protected:
31  void transmit_state() override;
32  void transmit_generic_();
34  void transmit_rac_pt1411hwru_temp_(bool cs_state = true, bool cs_send_update = true);
35  // Returns the header if valid, else returns zero
36  uint8_t is_valid_rac_pt1411hwru_header_(const uint8_t *message);
37  // Returns true if message is a valid RAC-PT1411HWRU IR message, regardless if first or second packet
38  bool is_valid_rac_pt1411hwru_message_(const uint8_t *message);
39  // Returns true if message1 and message 2 are the same
40  bool compare_rac_pt1411hwru_packets_(const uint8_t *message1, const uint8_t *message2);
41  bool on_receive(remote_base::RemoteReceiveData data) override;
42 
43  float temperature_min_() {
45  }
46  float temperature_max_() {
48  }
50  return ((this->model_ == MODEL_RAC_PT1411HWRU_C) || (this->model_ == MODEL_RAC_PT1411HWRU_F));
51  }
53  return ((this->model_ == MODEL_RAC_PT1411HWRU_C) || (this->model_ == MODEL_RAC_PT1411HWRU_F));
54  }
55  std::set<climate::ClimateFanMode> toshiba_fan_modes_() {
56  return (this->model_ == MODEL_GENERIC)
57  ? std::set<climate::ClimateFanMode>{}
58  : std::set<climate::ClimateFanMode>{climate::CLIMATE_FAN_AUTO, climate::CLIMATE_FAN_LOW,
60  }
61  std::set<climate::ClimateSwingMode> toshiba_swing_modes_() {
62  return (this->model_ == MODEL_GENERIC)
63  ? std::set<climate::ClimateSwingMode>{}
64  : std::set<climate::ClimateSwingMode>{climate::CLIMATE_SWING_OFF, climate::CLIMATE_SWING_VERTICAL};
65  }
66  void encode_(remote_base::RemoteTransmitData *data, const uint8_t *message, uint8_t nbytes, uint8_t repeat);
67  bool decode_(remote_base::RemoteReceiveData *data, uint8_t *message, uint8_t nbytes);
68 
70 };
71 
72 } // namespace toshiba
73 } // namespace esphome
The fan mode is set to Low.
Definition: climate_mode.h:54
const float TOSHIBA_RAC_PT1411HWRU_TEMP_C_MAX
Definition: toshiba.h:19
std::set< climate::ClimateFanMode > toshiba_fan_modes_()
Definition: toshiba.h:55
bool decode_(remote_base::RemoteReceiveData *data, uint8_t *message, uint8_t nbytes)
Definition: toshiba.cpp:698
void transmit_state() override
Definition: toshiba.cpp:134
const float TOSHIBA_RAC_PT1411HWRU_TEMP_F_MAX
Definition: toshiba.h:21
void transmit_rac_pt1411hwru_temp_(bool cs_state=true, bool cs_send_update=true)
Definition: toshiba.cpp:354
bool on_receive(remote_base::RemoteReceiveData data) override
Definition: toshiba.cpp:462
void set_model(Model model)
Definition: toshiba.h:28
const float TOSHIBA_RAC_PT1411HWRU_TEMP_F_MIN
Definition: toshiba.h:20
The fan mode is set to Auto.
Definition: climate_mode.h:52
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:23
std::set< climate::ClimateSwingMode > toshiba_swing_modes_()
Definition: toshiba.h:61
bool is_valid_rac_pt1411hwru_message_(const uint8_t *message)
Definition: toshiba.cpp:433
The fan mode is set to Vertical.
Definition: climate_mode.h:74
void encode_(remote_base::RemoteTransmitData *data, const uint8_t *message, uint8_t nbytes, uint8_t repeat)
Definition: toshiba.cpp:677
The fan mode is set to High.
Definition: climate_mode.h:58
The swing mode is set to Off.
Definition: climate_mode.h:70
const float TOSHIBA_RAC_PT1411HWRU_TEMP_C_MIN
Definition: toshiba.h:18
Definition: a4988.cpp:4
The fan mode is set to Medium.
Definition: climate_mode.h:56
const float TOSHIBA_GENERIC_TEMP_C_MAX
Definition: toshiba.h:17
const float TOSHIBA_GENERIC_TEMP_C_MIN
Definition: toshiba.h:16
bool compare_rac_pt1411hwru_packets_(const uint8_t *message1, const uint8_t *message2)
Definition: toshiba.cpp:425
uint8_t is_valid_rac_pt1411hwru_header_(const uint8_t *message)
Definition: toshiba.cpp:411