6static const char *
const TAG =
"zhlt01.climate";
9 uint8_t ir_message[12] = {0};
16 ir_message[3] = AC1_FAN_TURBO;
25 ir_message[7] = AC1_POWER_OFF;
27 ir_message[7] = AC1_POWER_ON;
33 ir_message[7] |= AC1_HDIR_FIXED | AC1_VDIR_FIXED;
36 ir_message[7] |= AC1_HDIR_SWING | AC1_VDIR_FIXED;
39 ir_message[7] |= AC1_HDIR_FIXED | AC1_VDIR_SWING;
42 ir_message[7] |= AC1_HDIR_SWING | AC1_VDIR_SWING;
51 ir_message[7] |= AC1_FAN3;
54 ir_message[7] |= AC1_FAN_SILENT;
59 ir_message[7] |= AC1_FAN1;
62 ir_message[7] |= AC1_FAN2;
65 ir_message[7] |= AC1_FAN3;
68 ir_message[7] |= AC1_FAN_AUTO;
80 ir_message[9] = AC1_MODE_AUTO;
83 ir_message[9] = AC1_MODE_COOL;
86 ir_message[9] = AC1_MODE_HEAT;
89 ir_message[9] = AC1_MODE_DRY;
92 ir_message[9] = AC1_MODE_FAN;
102 ir_message[11] = 0xD5;
105 for (
int i = 0; i < 12; i += 2) {
106 ir_message[i] = ~ir_message[i + 1];
111 auto *data = transmit.get_data();
113 data->set_carrier_frequency(38000);
116 data->mark(AC1_HDR_MARK);
117 data->space(AC1_HDR_SPACE);
120 for (uint8_t i : ir_message) {
121 for (uint8_t j = 0; j < 8; j++) {
122 data->mark(AC1_BIT_MARK);
123 bool bit = i & (1 << j);
124 data->space(bit ? AC1_ONE_SPACE : AC1_ZERO_SPACE);
129 data->mark(AC1_BIT_MARK);
137 if (!data.expect_item(AC1_HDR_MARK, AC1_HDR_SPACE)) {
138 ESP_LOGV(TAG,
"Header fail");
143 uint8_t ir_message[12] = {0};
145 for (
int i = 0; i < 12; i++) {
147 for (
int j = 0; j < 8; j++) {
148 if (data.expect_item(AC1_BIT_MARK, AC1_ONE_SPACE)) {
149 ir_message[i] |= 1 << j;
150 }
else if (!data.expect_item(AC1_BIT_MARK, AC1_ZERO_SPACE)) {
151 ESP_LOGV(TAG,
"Byte %d bit %d fail", i, j);
155 ESP_LOGVV(TAG,
"Byte %d %02X", i, ir_message[i]);
159 if (!data.expect_mark(AC1_BIT_MARK)) {
160 ESP_LOGV(TAG,
"Footer fail");
165 for (
int i = 0; i < 12; i += 2) {
166 if (ir_message[i] != (uint8_t) (~ir_message[i + 1])) {
167 ESP_LOGV(TAG,
"Byte %d checksum incorrect (%02X != %02X)", i, ir_message[i], (uint8_t) (~ir_message[i + 1]));
173 if (ir_message[11] != 0xD5) {
174 ESP_LOGV(TAG,
"Invalid remote control ID");
180 if ((ir_message[7] & AC1_POWER_ON) == 0) {
184 if ((ir_message[7] & 0x0C) == AC1_VDIR_FIXED) {
185 if ((ir_message[7] & 0x10) == AC1_HDIR_FIXED) {
191 if ((ir_message[7] & 0x10) == AC1_HDIR_FIXED) {
199 if ((ir_message[3] & AC1_FAN_TURBO) == AC1_FAN_TURBO) {
202 }
else if ((ir_message[7] & 0xE1) == AC1_FAN_SILENT) {
205 }
else if ((ir_message[7] & 0xE1) == AC1_FAN_AUTO) {
207 }
else if ((ir_message[7] & 0xE1) == AC1_FAN1) {
209 }
else if ((ir_message[7] & 0xE1) == AC1_FAN2) {
211 }
else if ((ir_message[7] & 0xE1) == AC1_FAN3) {
216 if ((ir_message[9] & 0xE0) == AC1_MODE_COOL) {
218 }
else if ((ir_message[9] & 0xE0) == AC1_MODE_HEAT) {
220 }
else if ((ir_message[9] & 0xE0) == AC1_MODE_DRY) {
222 }
else if ((ir_message[9] & 0xE0) == AC1_MODE_FAN) {
ClimateMode mode
The active mode of the climate device.
optional< ClimateFanMode > fan_mode
The active fan mode of the climate device.
float target_temperature
The target temperature of the climate device.
ClimateSwingMode swing_mode
The active swing mode of the climate device.
void publish_state()
Publish the state of the climate device, to be called from integrations.
optional< ClimatePreset > preset
The active preset of the climate device.
RemoteTransmitterBase * transmitter_
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.
@ CLIMATE_PRESET_NONE
No preset is active.
@ CLIMATE_PRESET_BOOST
Device is in boost preset.
@ CLIMATE_PRESET_SLEEP
Device is prepared for sleep.
@ CLIMATE_SWING_OFF
The swing mode is set to Off.
@ CLIMATE_SWING_HORIZONTAL
The fan mode is set to Horizontal.
@ CLIMATE_SWING_VERTICAL
The fan mode is set to Vertical.
@ CLIMATE_SWING_BOTH
The fan mode is set to Both.
@ CLIMATE_MODE_DRY
The climate device is set to dry/humidity mode.
@ CLIMATE_MODE_FAN_ONLY
The climate device only has the fan enabled, no heating or cooling is taking place.
@ CLIMATE_MODE_HEAT
The climate device is set to heat to reach the target temperature.
@ CLIMATE_MODE_COOL
The climate device is set to cool to reach the target temperature.
@ CLIMATE_MODE_HEAT_COOL
The climate device is set to heat/cool to reach the target temperature.
@ CLIMATE_MODE_OFF
The climate device is off.
@ CLIMATE_MODE_AUTO
The climate device is adjusting the temperature dynamically.
@ CLIMATE_FAN_MEDIUM
The fan mode is set to Medium.
@ CLIMATE_FAN_ON
The fan mode is set to On.
@ CLIMATE_FAN_AUTO
The fan mode is set to Auto.
@ CLIMATE_FAN_LOW
The fan mode is set to Low.
@ CLIMATE_FAN_HIGH
The fan mode is set to High.