8 struct RacPt1411hwruFanSpeed {
13 static const char *
const TAG =
"toshiba.climate";
94 0x04, 0x0C, 0x0D, 0x09, 0x08, 0x0A, 0x0B};
97 0x22, 0x06, 0x26, 0x07, 0x05, 0x25, 0x04, 0x24, 0x0C,
98 0x2C, 0x0D, 0x2D, 0x09, 0x08, 0x28, 0x0A, 0x2A, 0x0B};
102 this->sensor_->add_on_state_callback([
this](
float state) {
103 this->current_temperature =
state;
104 this->transmit_rac_pt1411hwru_temp_();
106 this->publish_state();
108 this->current_temperature = this->sensor_->state;
110 this->current_temperature = NAN;
112 auto restore = this->restore_state_();
113 if (restore.has_value()) {
114 restore->apply(
this);
120 roundf(clamp<float>(this->current_temperature, this->minimum_temperature_, this->maximum_temperature_));
125 this->minimum_temperature_ = this->temperature_min_();
126 this->maximum_temperature_ = this->temperature_max_();
127 this->swing_modes_ = this->toshiba_swing_modes_();
135 transmit_rac_pt1411hwru_();
142 uint8_t message[16] = {0};
143 uint8_t message_length = 9;
150 message[2] = message_length - 6;
153 message[3] = message[0] ^ message[1] ^ message[2];
165 switch (this->mode) {
214 message[6] = fan |
mode;
224 for (uint8_t i = 4; i < 8; i++) {
225 message[8] ^= message[i];
229 auto transmit = this->transmitter_->transmit();
230 auto *data = transmit.get_data();
232 encode_(data, message, message_length, 1);
238 uint8_t code = 0, index = 0, message[RAC_PT1411HWRU_MESSAGE_LENGTH * 2] = {0};
242 auto transmit = this->transmitter_->transmit();
243 auto *data = transmit.get_data();
248 message[1] = ~message[0];
281 message[3] = ~message[2];
284 temperature = (temperature * 1.8) + 32;
288 index =
static_cast<uint8_t
>(roundf(temp_adjd));
300 if (code & RAC_PT1411HWRU_FLAG_FRAC) {
303 if (code & RAC_PT1411HWRU_FLAG_NEG) {
308 switch (this->
mode) {
336 message[5] = ~message[4];
346 for (index = 6; index <= 10; index++) {
347 message[11] += message[index];
350 ESP_LOGV(TAG,
"*** Generated codes: 0x%.2X%.2X%.2X%.2X%.2X%.2X 0x%.2X%.2X%.2X%.2X%.2X%.2X", message[0], message[1],
351 message[2], message[3], message[4], message[5], message[6], message[7], message[8], message[9], message[10],
355 encode_(data, &message[0], RAC_PT1411HWRU_MESSAGE_LENGTH, 1);
357 if (message[6] != 0) {
358 encode_(data, &message[6], RAC_PT1411HWRU_MESSAGE_LENGTH, 0);
365 data->space(TOSHIBA_PACKET_SPACE);
376 data->space(TOSHIBA_PACKET_SPACE);
380 transmit_rac_pt1411hwru_temp_(
true,
false);
389 auto transmit = this->transmitter_->transmit();
390 auto *data = transmit.get_data();
403 message[1] = ~message[0];
405 message[2] =
static_cast<uint8_t
>(roundf(temperature));
406 if (cs_send_update) {
408 }
else if (cs_state) {
412 message[3] = ~message[2];
414 switch (this->
mode) {
430 message[5] = ~message[4];
432 ESP_LOGV(TAG,
"*** Generated code: 0x%.2X%.2X%.2X%.2X%.2X%.2X", message[0], message[1], message[2], message[3],
433 message[4], message[5]);
435 encode_(data, message, RAC_PT1411HWRU_MESSAGE_LENGTH, 1);
443 RAC_PT1411HWRU_SWING_HEADER};
445 for (
auto i : header) {
446 if ((message[0] == i) && (message[1] == static_cast<uint8_t>(~i)))
449 if (message[0] == RAC_PT1411HWRU_MESSAGE_HEADER1)
457 if (message1[i] != message2[i])
466 switch (is_valid_rac_pt1411hwru_header_(message)) {
470 if (is_valid_rac_pt1411hwru_header_(message) && (message[2] == static_cast<uint8_t>(~message[3])) &&
471 (message[4] == static_cast<uint8_t>(~message[5]))) {
477 for (uint8_t i = 0; i < RAC_PT1411HWRU_MESSAGE_LENGTH - 1; i++) {
478 checksum += message[i];
480 if (checksum == message[RAC_PT1411HWRU_MESSAGE_LENGTH - 1]) {
493 uint8_t message[18] = {0};
497 if (!data.
expect_item(TOSHIBA_HEADER_MARK, TOSHIBA_HEADER_SPACE)) {
501 if (!decode_(&data, message, message_length)) {
505 if (is_valid_rac_pt1411hwru_header_(message)) {
507 message_length = RAC_PT1411HWRU_MESSAGE_LENGTH - 4;
508 }
else if ((message[0] ^ message[1] ^ message[2]) != message[3]) {
513 message_length = message[2] + 2;
516 if (!decode_(&data, &message[4], message_length)) {
520 if (is_valid_rac_pt1411hwru_header_(message)) {
522 if (!data.
expect_item(TOSHIBA_BIT_MARK, TOSHIBA_GAP_SPACE)) {
526 if (!data.
expect_item(TOSHIBA_HEADER_MARK, TOSHIBA_HEADER_SPACE)) {
529 if (!decode_(&data, &message[6], RAC_PT1411HWRU_MESSAGE_LENGTH)) {
534 if (data.
expect_item(TOSHIBA_BIT_MARK, TOSHIBA_GAP_SPACE)) {
536 data.
expect_item(TOSHIBA_HEADER_MARK, TOSHIBA_HEADER_SPACE);
537 if (decode_(&data, &message[12], RAC_PT1411HWRU_MESSAGE_LENGTH)) {
538 if (!is_valid_rac_pt1411hwru_message_(&message[12])) {
544 if (!compare_rac_pt1411hwru_packets_(&message[0], &message[6])) {
548 if (!is_valid_rac_pt1411hwru_message_(&message[0])) {
555 switch (is_valid_rac_pt1411hwru_header_(message)) {
559 switch (message[4] & 0x0F) {
566 if (((message[4] >> 4) == RAC_PT1411HWRU_TEMPERATURE_FAN_ONLY) && (message[2] == RAC_PT1411HWRU_FAN_OFF)) {
575 if ((message[4] >> 4) == RAC_PT1411HWRU_TEMPERATURE_FAN_ONLY) {
591 switch (message[2]) {
610 if (is_valid_rac_pt1411hwru_message_(&message[12])) {
613 if (message[15] & RAC_PT1411HWRU_FLAG_FAH) {
659 for (uint8_t i = TOSHIBA_HEADER_LENGTH; i < message_length - 1; i++) {
660 checksum ^= message[i];
663 if (checksum != message[message_length - 1]) {
667 if (message[4] & TOSHIBA_COMMAND_MOTION) {
673 switch (message[6] & 0x0F) {
700 switch (message[6] & 0xF0) {
727 this->publish_state();
732 const uint8_t repeat) {
735 for (uint8_t copy = 0; copy <= repeat; copy++) {
736 data->
item(TOSHIBA_HEADER_MARK, TOSHIBA_HEADER_SPACE);
738 for (uint8_t byte = 0; byte < nbytes; byte++) {
739 for (uint8_t bit = 0; bit < 8; bit++) {
740 data->
mark(TOSHIBA_BIT_MARK);
741 if (message[byte] & (1 << (7 - bit))) {
742 data->
space(TOSHIBA_ONE_SPACE);
744 data->
space(TOSHIBA_ZERO_SPACE);
748 data->
item(TOSHIBA_BIT_MARK, TOSHIBA_GAP_SPACE);
753 for (uint8_t byte = 0; byte < nbytes; byte++) {
754 for (uint8_t bit = 0; bit < 8; bit++) {
755 if (data->
expect_item(TOSHIBA_BIT_MARK, TOSHIBA_ONE_SPACE)) {
756 message[byte] |= 1 << (7 - bit);
757 }
else if (data->
expect_item(TOSHIBA_BIT_MARK, TOSHIBA_ZERO_SPACE)) {
758 message[byte] &=
static_cast<uint8_t
>(~(1 << (7 - bit)));
The fan mode is set to Low.
const uint8_t RAC_PT1411HWRU_MESSAGE_LENGTH
The fan mode is set to Quiet.
const float TOSHIBA_RAC_PT1411HWRU_TEMP_C_MAX
const uint8_t TOSHIBA_HEADER_LENGTH
const std::vector< uint8_t > RAC_PT1411HWRU_TEMPERATURE_F
const uint16_t TOSHIBA_HEADER_MARK
const uint8_t RAC_PT1411HWRU_TEMPERATURE_FAN_ONLY
bool decode_(remote_base::RemoteReceiveData *data, uint8_t *message, uint8_t nbytes)
void transmit_state() override
const std::vector< uint8_t > RAC_PT1411HWRU_TEMPERATURE_C
const uint8_t TOSHIBA_FAN_SPEED_QUIET
void set_carrier_frequency(uint32_t carrier_frequency)
const uint8_t TOSHIBA_COMMAND_POWER
const uint8_t TOSHIBA_FAN_SPEED_3
void item(uint32_t mark, uint32_t space)
The climate device is set to heat to reach the target temperature.
const uint8_t TOSHIBA_FAN_SPEED_2
void transmit_rac_pt1411hwru_temp_(bool cs_state=true, bool cs_send_update=true)
const uint16_t TOSHIBA_ONE_SPACE
const uint8_t RAC_PT1411HWRU_SWING_HEADER
const uint8_t TOSHIBA_COMMAND_DEFAULT
const uint8_t TOSHIBA_COMMAND_MOTION
const uint16_t TOSHIBA_CARRIER_FREQUENCY
const RacPt1411hwruFanSpeed RAC_PT1411HWRU_NO_FAN
const uint8_t RAC_PT1411HWRU_MODE_AUTO
The climate device is set to dry/humidity mode.
constexpr RacPt1411hwruFanSpeed RAC_PT1411HWRU_FAN_LOW
const uint8_t RAC_PT1411HWRU_MODE_OFF
const uint8_t TOSHIBA_FAN_SPEED_5
const uint8_t TOSHIBA_MODE_DRY
const uint8_t TOSHIBA_MODE_FAN_ONLY
ClimateSwingMode swing_mode
const uint8_t RAC_PT1411HWRU_FAN_OFF
const uint8_t TOSHIBA_MOTION_FIX
bool on_receive(remote_base::RemoteReceiveData data) override
void transmit_rac_pt1411hwru_()
const uint8_t RAC_PT1411HWRU_FLAG_FAH
const uint8_t TOSHIBA_MODE_OFF
const uint16_t TOSHIBA_HEADER_SPACE
const float TOSHIBA_RAC_PT1411HWRU_TEMP_F_MIN
const uint16_t TOSHIBA_BIT_MARK
const uint8_t RAC_PT1411HWRU_FLAG_NEG
const uint8_t RAC_PT1411HWRU_FLAG_FRAC
The climate device is set to cool to reach the target temperature.
const uint8_t RAC_PT1411HWRU_CS_DATA
const uint8_t RAC_PT1411HWRU_MODE_COOL
The fan mode is set to Auto.
const uint8_t TOSHIBA_MODE_COOL
const uint8_t RAC_PT1411HWRU_MODE_HEAT
const uint16_t TOSHIBA_ZERO_SPACE
constexpr RacPt1411hwruFanSpeed RAC_PT1411HWRU_FAN_AUTO
BedjetMode mode
BedJet operating mode.
const uint8_t RAC_PT1411HWRU_FLAG_MASK
const std::vector< uint8_t > RAC_PT1411HWRU_SWING_OFF
const uint8_t RAC_PT1411HWRU_CS_FOOTER_HEAT
void mark(uint32_t length)
const uint16_t TOSHIBA_PACKET_SPACE
const uint8_t RAC_PT1411HWRU_MESSAGE_HEADER0
The climate device is set to heat/cool to reach the target temperature.
bool is_valid_rac_pt1411hwru_message_(const uint8_t *message)
The fan mode is set to Vertical.
void encode_(remote_base::RemoteTransmitData *data, const uint8_t *message, uint8_t nbytes, uint8_t repeat)
The fan mode is set to High.
The swing mode is set to Off.
The climate device is off.
const uint8_t RAC_PT1411HWRU_CS_HEADER
const uint8_t TOSHIBA_MODE_AUTO
const uint8_t TOSHIBA_FAN_SPEED_AUTO
const uint8_t TOSHIBA_MODE_HEAT
constexpr RacPt1411hwruFanSpeed RAC_PT1411HWRU_FAN_HIGH
const uint8_t RAC_PT1411HWRU_CS_ENABLED
const uint8_t TOSHIBA_COMMAND_TIMER
const float TOSHIBA_RAC_PT1411HWRU_TEMP_C_MIN
const uint8_t RAC_PT1411HWRU_MESSAGE_HEADER1
void space(uint32_t length)
const uint8_t RAC_PT1411HWRU_MODE_DRY
constexpr RacPt1411hwruFanSpeed RAC_PT1411HWRU_FAN_MED
Implementation of SPI Controller mode.
const uint16_t TOSHIBA_GAP_SPACE
const uint8_t TOSHIBA_FAN_SPEED_1
const uint8_t TOSHIBA_FAN_SPEED_4
const uint8_t RAC_PT1411HWRU_MODE_FAN
The fan mode is set to Medium.
const uint8_t RAC_PT1411HWRU_CS_FOOTER_COOL
const uint8_t TOSHIBA_POWER_ECO
bool expect_item(uint32_t mark, uint32_t space)
const std::vector< uint8_t > RAC_PT1411HWRU_SWING_VERTICAL
The climate device only has the fan enabled, no heating or cooling is taking place.
const uint8_t RAC_PT1411HWRU_CS_FOOTER_AUTO
const float TOSHIBA_GENERIC_TEMP_C_MAX
const float TOSHIBA_GENERIC_TEMP_C_MIN
const uint8_t TOSHIBA_MOTION_SWING
const uint8_t TOSHIBA_POWER_HIGH
bool compare_rac_pt1411hwru_packets_(const uint8_t *message1, const uint8_t *message2)
uint8_t is_valid_rac_pt1411hwru_header_(const uint8_t *message)