7 static const char *
const TAG =
"tcl112.climate";
39 remote_state[0] = 0x23;
40 remote_state[1] = 0xCB;
41 remote_state[2] = 0x26;
42 remote_state[3] = 0x01;
43 remote_state[5] = 0x24;
44 remote_state[6] = 0x03;
45 remote_state[7] = 0x07;
46 remote_state[8] = 0x40;
51 remote_state[6] &= 0xF0;
55 remote_state[6] &= 0xF0;
59 remote_state[6] &= 0xF0;
63 remote_state[6] &= 0xF0;
67 remote_state[6] &= 0xF0;
72 remote_state[5] &= ~TCL112_POWER_MASK;
81 auto half_degrees =
static_cast<uint8_t
>(safecelsius * 2);
82 if (half_degrees & 1) {
85 remote_state[12] &= ~TCL112_HALF_DEGREE;
87 remote_state[7] &= 0xF0;
106 remote_state[8] |= selected_fan;
115 for (uint8_t checksum_byte = 0; checksum_byte < TCL112_STATE_LENGTH - 1; checksum_byte++)
116 remote_state[TCL112_STATE_LENGTH - 1] += remote_state[checksum_byte];
118 ESP_LOGV(TAG,
"Sending: %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X", remote_state[0],
119 remote_state[1], remote_state[2], remote_state[3], remote_state[4], remote_state[5], remote_state[6],
120 remote_state[7], remote_state[8], remote_state[9], remote_state[10], remote_state[11], remote_state[12],
129 data->mark(TCL112_HEADER_MARK);
130 data->space(TCL112_HEADER_SPACE);
132 for (uint8_t i : remote_state) {
133 for (uint8_t j = 0; j < 8; j++) {
134 data->mark(TCL112_BIT_MARK);
135 bool bit = i & (1 << j);
136 data->space(bit ? TCL112_ONE_SPACE : TCL112_ZERO_SPACE);
140 data->mark(TCL112_BIT_MARK);
141 data->space(TCL112_GAP);
148 if (!data.
expect_item(TCL112_HEADER_MARK, TCL112_HEADER_SPACE)) {
149 ESP_LOGVV(TAG,
"Header fail");
157 for (
int j = 0; j < 8; j++) {
158 if (data.
expect_item(TCL112_BIT_MARK, TCL112_ONE_SPACE)) {
159 remote_state[i] |= 1 << j;
160 }
else if (!data.
expect_item(TCL112_BIT_MARK, TCL112_ZERO_SPACE)) {
161 ESP_LOGVV(TAG,
"Byte %d bit %d fail", i, j);
168 ESP_LOGVV(TAG,
"Footer fail");
175 for (uint8_t checksum_byte = 0; checksum_byte < TCL112_STATE_LENGTH - 1; checksum_byte++)
176 checksum += remote_state[checksum_byte];
177 if (checksum != remote_state[TCL112_STATE_LENGTH - 1]) {
178 ESP_LOGVV(TAG,
"Checksum fail");
182 ESP_LOGV(TAG,
"Received: %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X",
183 remote_state[0], remote_state[1], remote_state[2], remote_state[3], remote_state[4], remote_state[5],
184 remote_state[6], remote_state[7], remote_state[8], remote_state[9], remote_state[10], remote_state[11],
185 remote_state[12], remote_state[13]);
188 if (remote_state[0] != 0x23 || remote_state[1] != 0xCB)
191 if ((remote_state[5] & TCL112_POWER_MASK) == 0) {
194 auto mode = remote_state[6] & 0x0F;
214 if (remote_state[12] & TCL112_HALF_DEGREE)
217 auto fan = remote_state[8] & 0x7;
233 if ((remote_state[8] & TCL112_VSWING_MASK) == TCL112_VSWING_MASK) {
The fan mode is set to Low.
value_type const & value() const
ClimateSwingMode swing_mode
The active swing mode of the climate device.
const uint8_t TCL112_VSWING_MASK
const float TCL112_TEMP_MIN
const uint16_t TCL112_STATE_LENGTH
float target_temperature
The target temperature of the climate device.
void set_carrier_frequency(uint32_t carrier_frequency)
const uint8_t TCL112_COOL
The climate device is set to heat to reach the target temperature.
ClimateMode mode
The active mode of the climate device.
const uint16_t TCL112_BIT_MARK
The climate device is set to dry/humidity mode.
bool on_receive(remote_base::RemoteReceiveData data) override
Handle received IR Buffer.
void transmit_state() override
Transmit via IR the state of this climate controller.
bool expect_mark(uint32_t length)
const uint8_t TCL112_FAN_AUTO
const uint8_t TCL112_AUTO
The climate device is set to cool to reach the target temperature.
The fan mode is set to Auto.
const uint8_t TCL112_HALF_DEGREE
const uint16_t TCL112_HEADER_SPACE
RemoteTransmitterBase * transmitter_
The climate device is set to heat/cool to reach the target temperature.
const uint16_t TCL112_BITS
The fan mode is set to Vertical.
const uint32_t TCL112_GAP
void publish_state()
Publish the state of the climate device, to be called from integrations.
The fan mode is set to High.
RemoteTransmitData * get_data()
The swing mode is set to Off.
The climate device is off.
const float TCL112_TEMP_MAX
const uint8_t TCL112_FAN_LOW
const uint8_t TCL112_FAN_HIGH
const uint16_t TCL112_ZERO_SPACE
optional< ClimateFanMode > fan_mode
The active fan mode of the climate device.
const uint16_t TCL112_ONE_SPACE
Implementation of SPI Controller mode.
const uint8_t TCL112_HEAT
The fan mode is set to Medium.
const uint8_t TCL112_POWER_MASK
bool expect_item(uint32_t mark, uint32_t space)
The climate device only has the fan enabled, no heating or cooling is taking place.
const uint8_t TCL112_FAN_MED
const uint16_t TCL112_HEADER_MARK