8static const char *
const TAG =
"noblex.climate";
19 IR_NOBLEX_MODE_AUTO = 0b000,
20 IR_NOBLEX_MODE_COOL = 0b100,
21 IR_NOBLEX_MODE_DRY = 0b010,
22 IR_NOBLEX_MODE_FAN = 0b110,
23 IR_NOBLEX_MODE_HEAT = 0b001,
27 IR_NOBLEX_FAN_AUTO = 0b00,
28 IR_NOBLEX_FAN_LOW = 0b10,
29 IR_NOBLEX_FAN_MEDIUM = 0b01,
30 IR_NOBLEX_FAN_HIGH = 0b11,
35 uint8_t remote_state[8] = {0x80, 0x10, 0x00, 0x0A, 0x50, 0x00, 0x20, 0x00};
39 remote_state[0] |= 0x10;
40 remote_state[2] = 0x02;
50 remote_state[0] |= (IRNoblexMode::IR_NOBLEX_MODE_AUTO << 5);
51 remote_state[1] = 0x90;
54 remote_state[0] |= (IRNoblexMode::IR_NOBLEX_MODE_COOL << 5);
57 remote_state[0] |= (IRNoblexMode::IR_NOBLEX_MODE_DRY << 5);
60 remote_state[0] |= (IRNoblexMode::IR_NOBLEX_MODE_FAN << 5);
63 remote_state[0] |= (IRNoblexMode::IR_NOBLEX_MODE_HEAT << 5);
69 remote_state[0] &= 0xEF;
70 remote_state[2] = 0x00;
76 remote_state[0] |= (IRNoblexFan::IR_NOBLEX_FAN_LOW << 2);
79 remote_state[0] |= (IRNoblexFan::IR_NOBLEX_FAN_MEDIUM << 2);
82 remote_state[0] |= (IRNoblexFan::IR_NOBLEX_FAN_HIGH << 2);
86 remote_state[0] |= (IRNoblexFan::IR_NOBLEX_FAN_AUTO << 2);
92 remote_state[0] |= 0x02;
93 remote_state[4] = 0x58;
97 remote_state[0] &= 0xFD;
98 remote_state[4] = 0x50;
103 for (uint8_t i : remote_state) {
108 ESP_LOGD(TAG,
"Sending noblex code: %02X%02X %02X%02X %02X%02X %02X%02X", remote_state[0], remote_state[1],
109 remote_state[2], remote_state[3], remote_state[4], remote_state[5], remote_state[6], remote_state[7]);
111 ESP_LOGV(TAG,
"CRC: %01X", crc);
121 for (
int byte_idx = 0; byte_idx < 8; byte_idx++) {
122 for (int8_t bit_idx = 7; bit_idx >= 0; bit_idx--) {
123 if ((byte_idx == 4) && (bit_idx == 4)) {
129 bool bit = remote_state[byte_idx] & (1 << bit_idx);
135 for (int8_t i = 3; i >= 0; i--) {
137 bool bit = crc & (1 << i);
151 ESP_LOGV(TAG,
"Header");
154 for (
int i = 0; i < 5; i++) {
155 for (
int j = 7; j >= 0; j--) {
156 if ((i == 4) && (j == 4)) {
158 ESP_LOGVV(TAG,
"GAP");
164 ESP_LOGVV(TAG,
"Byte %d bit %d fail", i, j);
178 for (
int i = 4; i < 8; i++) {
179 for (
int j = 7; j >= 0; j--) {
180 if ((i == 4) && (j >= 4)) {
185 ESP_LOGVV(TAG,
"Byte %d bit %d fail", i, j);
194 for (
int i = 3; i >= 0; i--) {
198 ESP_LOGVV(TAG,
"Bit %d CRC fail", i);
202 ESP_LOGV(TAG,
"CRC %02X", crc);
206 ESP_LOGV(TAG,
"Footer fail");
211 uint8_t crc_calculated = 0;
214 crc_calculated =
reverse_bits(uint8_t(crc_calculated & 0x0F)) >> 4;
215 ESP_LOGVV(TAG,
"CRC calc %02X", crc_calculated);
217 if (crc != crc_calculated) {
218 ESP_LOGV(TAG,
"CRC fail");
222 ESP_LOGD(TAG,
"Received noblex code: %02X%02X %02X%02X %02X%02X %02X%02X", this->remote_state_[0],
223 this->remote_state_[1], this->remote_state_[2], this->remote_state_[3], this->remote_state_[4],
224 this->remote_state_[5], this->remote_state_[6], this->remote_state_[7]);
226 auto powered_on =
false;
236 ESP_LOGV(TAG,
"Power: %01X", powered_on);
240 auto mode = (this->remote_state_[0] & 0xE0) >> 5;
241 ESP_LOGV(TAG,
"Mode: %02X",
mode);
243 case IRNoblexMode::IR_NOBLEX_MODE_AUTO:
246 case IRNoblexMode::IR_NOBLEX_MODE_COOL:
249 case IRNoblexMode::IR_NOBLEX_MODE_DRY:
252 case IRNoblexMode::IR_NOBLEX_MODE_FAN:
255 case IRNoblexMode::IR_NOBLEX_MODE_HEAT:
262 uint8_t temp = this->remote_state_[1];
263 ESP_LOGVV(TAG,
"Temperature Raw: %02X", temp);
267 ESP_LOGV(TAG,
"Temperature Climate: %u", temp);
271 auto fan = (this->remote_state_[0] & 0x0C) >> 2;
272 ESP_LOGV(TAG,
"Fan: %02X", fan);
274 case IRNoblexFan::IR_NOBLEX_FAN_HIGH:
277 case IRNoblexFan::IR_NOBLEX_FAN_MEDIUM:
280 case IRNoblexFan::IR_NOBLEX_FAN_LOW:
283 case IRNoblexFan::IR_NOBLEX_FAN_AUTO:
290 if (this->remote_state_[0] & 0x02) {
291 ESP_LOGV(TAG,
"Swing vertical");
294 ESP_LOGV(TAG,
"Swing OFF");
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.
void transmit_state() override
Transmit via IR the state of this climate controller.
bool on_receive(remote_base::RemoteReceiveData data) override
Handle received IR Buffer.
bool expect_item(uint32_t mark, uint32_t space)
bool peek_item(uint32_t mark, uint32_t space, uint32_t offset=0) const
bool expect_mark(uint32_t length)
void set_carrier_frequency(uint32_t carrier_frequency)
RemoteTransmitterBase * transmitter_
RemoteTransmitData * get_data()
@ CLIMATE_SWING_OFF
The swing mode is set to Off.
@ CLIMATE_SWING_VERTICAL
The fan mode is set to Vertical.
@ 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_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.
const uint16_t NOBLEX_ONE_SPACE
const uint16_t NOBLEX_HEADER_SPACE
const uint8_t NOBLEX_POWER
const uint16_t NOBLEX_ZERO_SPACE
const uint32_t NOBLEX_GAP
const uint16_t NOBLEX_HEADER_MARK
const uint16_t NOBLEX_BIT_MARK
enum IRNoblexMode { IR_NOBLEX_MODE_AUTO=0b000, IR_NOBLEX_MODE_COOL=0b100, IR_NOBLEX_MODE_DRY=0b010, IR_NOBLEX_MODE_FAN=0b110, IR_NOBLEX_MODE_HEAT=0b001, } IRNoblexMode
const uint8_t NOBLEX_TEMP_MIN
const uint8_t NOBLEX_TEMP_MAX
enum IRNoblexFan { IR_NOBLEX_FAN_AUTO=0b00, IR_NOBLEX_FAN_LOW=0b10, IR_NOBLEX_FAN_MEDIUM=0b01, IR_NOBLEX_FAN_HIGH=0b11, } IRNoblexFan
Providing packet encoding functions for exchanging data with a remote host.
uint8_t reverse_bits(uint8_t x)
Reverse the order of 8 bits.