7static const char *
const TAG =
"zhlt01.climate";
10 uint8_t ir_message[12] = {0};
17 ir_message[3] = AC1_FAN_TURBO;
26 ir_message[7] = AC1_POWER_OFF;
28 ir_message[7] = AC1_POWER_ON;
34 ir_message[7] |= AC1_HDIR_FIXED | AC1_VDIR_FIXED;
37 ir_message[7] |= AC1_HDIR_SWING | AC1_VDIR_FIXED;
40 ir_message[7] |= AC1_HDIR_FIXED | AC1_VDIR_SWING;
43 ir_message[7] |= AC1_HDIR_SWING | AC1_VDIR_SWING;
52 ir_message[7] |= AC1_FAN3;
55 ir_message[7] |= AC1_FAN_SILENT;
60 ir_message[7] |= AC1_FAN1;
63 ir_message[7] |= AC1_FAN2;
66 ir_message[7] |= AC1_FAN3;
69 ir_message[7] |= AC1_FAN_AUTO;
81 ir_message[9] = AC1_MODE_AUTO;
84 ir_message[9] = AC1_MODE_COOL;
87 ir_message[9] = AC1_MODE_HEAT;
90 ir_message[9] = AC1_MODE_DRY;
93 ir_message[9] = AC1_MODE_FAN;
103 ir_message[11] = 0xD5;
106 for (
int i = 0; i < 12; i += 2) {
107 ir_message[i] = ~ir_message[i + 1];
117 data->mark(AC1_HDR_MARK);
118 data->space(AC1_HDR_SPACE);
121 for (uint8_t i : ir_message) {
122 for (uint8_t j = 0; j < 8; j++) {
123 data->mark(AC1_BIT_MARK);
124 bool bit = i & (1 << j);
125 data->space(bit ? AC1_ONE_SPACE : AC1_ZERO_SPACE);
130 data->mark(AC1_BIT_MARK);
138 if (!data.
expect_item(AC1_HDR_MARK, AC1_HDR_SPACE)) {
139 ESP_LOGV(TAG,
"Header fail");
144 uint8_t ir_message[12] = {0};
146 for (
int i = 0; i < 12; i++) {
148 for (
int j = 0; j < 8; j++) {
149 if (data.
expect_item(AC1_BIT_MARK, AC1_ONE_SPACE)) {
150 ir_message[i] |= 1 << j;
151 }
else if (!data.
expect_item(AC1_BIT_MARK, AC1_ZERO_SPACE)) {
152 ESP_LOGV(TAG,
"Byte %d bit %d fail", i, j);
156 ESP_LOGVV(TAG,
"Byte %d %02X", i, ir_message[i]);
161 ESP_LOGV(TAG,
"Footer fail");
166 for (
int i = 0; i < 12; i += 2) {
167 if (ir_message[i] != (uint8_t) (~ir_message[i + 1])) {
168 ESP_LOGV(TAG,
"Byte %d checksum incorrect (%02X != %02X)", i, ir_message[i], (uint8_t) (~ir_message[i + 1]));
174 if (ir_message[11] != 0xD5) {
175 ESP_LOGV(TAG,
"Invalid remote control ID");
181 if ((ir_message[7] & AC1_POWER_ON) == 0) {
185 if ((ir_message[7] & 0x0C) == AC1_VDIR_FIXED) {
186 if ((ir_message[7] & 0x10) == AC1_HDIR_FIXED) {
192 if ((ir_message[7] & 0x10) == AC1_HDIR_FIXED) {
200 if ((ir_message[3] & AC1_FAN_TURBO) == AC1_FAN_TURBO) {
203 }
else if ((ir_message[7] & 0xE1) == AC1_FAN_SILENT) {
206 }
else if ((ir_message[7] & 0xE1) == AC1_FAN_AUTO) {
208 }
else if ((ir_message[7] & 0xE1) == AC1_FAN1) {
210 }
else if ((ir_message[7] & 0xE1) == AC1_FAN2) {
212 }
else if ((ir_message[7] & 0xE1) == AC1_FAN3) {
217 if ((ir_message[9] & 0xE0) == AC1_MODE_COOL) {
219 }
else if ((ir_message[9] & 0xE0) == AC1_MODE_HEAT) {
221 }
else if ((ir_message[9] & 0xE0) == AC1_MODE_DRY) {
223 }
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.
value_type const & value() const
bool expect_item(uint32_t mark, uint32_t space)
bool expect_mark(uint32_t length)
void set_carrier_frequency(uint32_t carrier_frequency)
RemoteTransmitterBase * transmitter_
RemoteTransmitData * get_data()
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_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_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.
Providing packet encoding functions for exchanging data with a remote host.