Translate TCL AC comments to English
This commit is contained in:
@@ -1,9 +1,8 @@
|
|||||||
/**
|
/**
|
||||||
* Create by Miguel Ã<EFBFBD>ngel López on 20/07/19
|
* Created by Miguel Angel Lopez on 20/07/19
|
||||||
* and modify by xaxexa
|
* Modified by xaxexa
|
||||||
* Refactoring & component making:
|
* ESPHome component refactor completed on 15.03.2024
|
||||||
* Соловей Ñ<> паÑ<C2B0>льником 15.03.2024
|
*/
|
||||||
**/
|
|
||||||
#include "esphome.h"
|
#include "esphome.h"
|
||||||
#include "esphome/core/defines.h"
|
#include "esphome/core/defines.h"
|
||||||
#include "tclac.h"
|
#include "tclac.h"
|
||||||
@@ -30,11 +29,11 @@ ClimateTraits tclacClimate::traits() {
|
|||||||
if (!this->supported_swing_modes_.empty())
|
if (!this->supported_swing_modes_.empty())
|
||||||
traits.set_supported_swing_modes(this->supported_swing_modes_);
|
traits.set_supported_swing_modes(this->supported_swing_modes_);
|
||||||
|
|
||||||
traits.add_supported_mode(climate::CLIMATE_MODE_OFF); // Выключенный режим кондиционера доÑ<C2BE>тупен вÑ<C2B2>егда
|
traits.add_supported_mode(climate::CLIMATE_MODE_OFF); // Always expose the OFF mode.
|
||||||
traits.add_supported_mode(climate::CLIMATE_MODE_AUTO); // Ð<EFBFBD>втоматичеÑ<EFBFBD>кий режим кондиционера тоже
|
traits.add_supported_mode(climate::CLIMATE_MODE_AUTO); // Always expose the AUTO mode as well.
|
||||||
traits.add_supported_fan_mode(climate::CLIMATE_FAN_AUTO); // Ð<EFBFBD>втоматичеÑ<EFBFBD>кий режим вентилÑ<C2BB>тора доÑ<C2BE>тупен вÑ<C2B2>егда
|
traits.add_supported_fan_mode(climate::CLIMATE_FAN_AUTO); // Fan AUTO mode is always available.
|
||||||
traits.add_supported_swing_mode(climate::CLIMATE_SWING_OFF); // Выключенный режим качаниÑ<C2B8> заÑ<C2B0>лонок доÑ<C2BE>тупен вÑ<C2B2>егда
|
traits.add_supported_swing_mode(climate::CLIMATE_SWING_OFF); // Always expose the Swing OFF mode.
|
||||||
traits.add_supported_preset(ClimatePreset::CLIMATE_PRESET_NONE);// Ð<EFBFBD>а вÑ<C2B2>Ñ<EFBFBD>кий Ñ<>лучай без предуÑ<C692>тановок
|
traits.add_supported_preset(ClimatePreset::CLIMATE_PRESET_NONE);// Expose the NONE preset even when presets are not configured.
|
||||||
|
|
||||||
return traits;
|
return traits;
|
||||||
}
|
}
|
||||||
@@ -127,7 +126,7 @@ void tclacClimate::readData() {
|
|||||||
|
|
||||||
bool device_is_on = (dataRX[MODE_POS] & MODE_STATUS_POWER_FLAG) != 0;
|
bool device_is_on = (dataRX[MODE_POS] & MODE_STATUS_POWER_FLAG) != 0;
|
||||||
if (device_is_on) {
|
if (device_is_on) {
|
||||||
// ЕÑ<EFBFBD>ли кондиционер включен, то разбираем данные длÑ<C2BB> отображениÑ<C2B8>
|
// When the AC is running, parse the state so we can show it.
|
||||||
// ESP_LOGD("TCL", "AC is on");
|
// ESP_LOGD("TCL", "AC is on");
|
||||||
uint8_t modeswitch = MODE_MASK & dataRX[MODE_POS];
|
uint8_t modeswitch = MODE_MASK & dataRX[MODE_POS];
|
||||||
uint8_t fanspeedswitch = FAN_SPEED_MASK & dataRX[FAN_SPEED_POS];
|
uint8_t fanspeedswitch = FAN_SPEED_MASK & dataRX[FAN_SPEED_POS];
|
||||||
@@ -197,8 +196,7 @@ void tclacClimate::readData() {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Обработка данныÑ
|
// Handle preset information received from the unit.
|
||||||
о преÑ<EFBFBD>ете
|
|
||||||
preset = ClimatePreset::CLIMATE_PRESET_NONE;
|
preset = ClimatePreset::CLIMATE_PRESET_NONE;
|
||||||
if (dataRX[7] & (1 << 6)){
|
if (dataRX[7] & (1 << 6)){
|
||||||
preset = ClimatePreset::CLIMATE_PRESET_ECO;
|
preset = ClimatePreset::CLIMATE_PRESET_ECO;
|
||||||
@@ -209,20 +207,20 @@ void tclacClimate::readData() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
// ЕÑ<EFBFBD>ли кондиционер выключен, то вÑ<C2B2>е режимы показываютÑ<E2809A>Ñ<EFBFBD>, как выключенные
|
// If the AC is off, pretend every mode is OFF.
|
||||||
mode = climate::CLIMATE_MODE_OFF;
|
mode = climate::CLIMATE_MODE_OFF;
|
||||||
//fan_mode = climate::CLIMATE_FAN_OFF;
|
//fan_mode = climate::CLIMATE_FAN_OFF;
|
||||||
swing_mode = climate::CLIMATE_SWING_OFF;
|
swing_mode = climate::CLIMATE_SWING_OFF;
|
||||||
preset = ClimatePreset::CLIMATE_PRESET_NONE;
|
preset = ClimatePreset::CLIMATE_PRESET_NONE;
|
||||||
}
|
}
|
||||||
// Публикуем данные
|
// Publish the freshly parsed climate state.
|
||||||
this->publish_state();
|
this->publish_state();
|
||||||
allow_take_control = true;
|
allow_take_control = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Climate control
|
// Climate control
|
||||||
void tclacClimate::control(const ClimateCall &call) {
|
void tclacClimate::control(const ClimateCall &call) {
|
||||||
// Запрашиваем данные из переключателÑ<C2BB> режимов работы кондиционера
|
// Figure out which climate mode should be sent (call override or current).
|
||||||
if (call.get_mode().has_value()){
|
if (call.get_mode().has_value()){
|
||||||
switch_climate_mode = call.get_mode().value();
|
switch_climate_mode = call.get_mode().value();
|
||||||
ESP_LOGD("TCL", "Get MODE from call");
|
ESP_LOGD("TCL", "Get MODE from call");
|
||||||
@@ -231,29 +229,29 @@ void tclacClimate::control(const ClimateCall &call) {
|
|||||||
ESP_LOGD("TCL", "Get MODE from AC");
|
ESP_LOGD("TCL", "Get MODE from AC");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Запрашиваем данные из переключателÑ<C2BB> предуÑ<C692>тановок кондиционера
|
// Figure out which preset should be sent.
|
||||||
if (call.get_preset().has_value()){
|
if (call.get_preset().has_value()){
|
||||||
switch_preset = call.get_preset().value();
|
switch_preset = call.get_preset().value();
|
||||||
} else {
|
} else {
|
||||||
switch_preset = preset.value();
|
switch_preset = preset.value();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Запрашиваем данные из переключателÑ<C2BB> режимов вентилÑ<C2BB>тора
|
// Figure out which fan mode should be sent.
|
||||||
if (call.get_fan_mode().has_value()){
|
if (call.get_fan_mode().has_value()){
|
||||||
switch_fan_mode = call.get_fan_mode().value();
|
switch_fan_mode = call.get_fan_mode().value();
|
||||||
} else {
|
} else {
|
||||||
switch_fan_mode = fan_mode.value();
|
switch_fan_mode = fan_mode.value();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Запрашиваем данные из переключателÑ<C2BB> режимов качаниÑ<C2B8> заÑ<C2B0>лонок
|
// Figure out which swing mode should be sent.
|
||||||
if (call.get_swing_mode().has_value()){
|
if (call.get_swing_mode().has_value()){
|
||||||
switch_swing_mode = call.get_swing_mode().value();
|
switch_swing_mode = call.get_swing_mode().value();
|
||||||
} else {
|
} else {
|
||||||
// Ð<EFBFBD> еÑ<C2B5>ли в переключателе пуÑ<C692>то- заполнÑ<C2BD>ем значением из поÑ<C2BE>леднего опроÑ<C2BE>а Ñ<>оÑ<C2BE>тоÑ<C2BE>ниÑ<C2B8>. Типа, ничего не поменÑ<C2BD>лоÑ<C2BE>ÑŒ.
|
// If nothing was provided, reuse the last known value so behavior stays unchanged.
|
||||||
switch_swing_mode = swing_mode;
|
switch_swing_mode = swing_mode;
|
||||||
}
|
}
|
||||||
|
|
||||||
// РаÑ<EFBFBD>чет температуры
|
// Encode the requested target temperature (AC expects 31 - value).
|
||||||
if (call.get_target_temperature().has_value()) {
|
if (call.get_target_temperature().has_value()) {
|
||||||
target_temperature_set = 31-(int)call.get_target_temperature().value();
|
target_temperature_set = 31-(int)call.get_target_temperature().value();
|
||||||
} else {
|
} else {
|
||||||
@@ -286,7 +284,7 @@ void tclacClimate::takeControl() {
|
|||||||
target_temperature_set = 31-(int)target_temperature;
|
target_temperature_set = 31-(int)target_temperature;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Включаем или отключаем пищалку в завиÑ<C2B8>имоÑ<C2BE>ти от переключателÑ<C2BB> в наÑ<C2B0>тройкаÑ
|
// Toggle the beeper according to the configuration flag.
|
||||||
|
|
||||||
if (beeper_status_){
|
if (beeper_status_){
|
||||||
ESP_LOGD("TCL", "Beep mode ON");
|
ESP_LOGD("TCL", "Beep mode ON");
|
||||||
@@ -296,13 +294,11 @@ void tclacClimate::takeControl() {
|
|||||||
dataTX[7] += 0b00000000;
|
dataTX[7] += 0b00000000;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Включаем или отключаем диÑ<C2B8>плей на кондиционере в завиÑ<C2B8>имоÑ<C2BE>ти от переключателÑ<C2BB> в наÑ<C2B0>тройкаÑ
|
// Toggle the AC display according to the configuration flag.
|
||||||
|
|
||||||
// Включаем диÑ<C2B8>плей только еÑ<C2B5>ли кондиционер в одном из рабочиÑ
|
// Only enable the display while the AC runs in an active mode.
|
||||||
режимов
|
|
||||||
|
|
||||||
// Ð’Ð<EFBFBD>ИМÐ<EFBFBD>Ð<EFBFBD>ИЕ! При выключении диÑ<C2B8>плеÑ<C2B5> кондиционер Ñ<>ам принудительно переÑ
|
// WARNING: turning the display off forces the AC into AUTO mode!
|
||||||
одит в автоматичеÑ<EFBFBD>кий режим!
|
|
||||||
|
|
||||||
if ((display_status_) && (switch_climate_mode != climate::CLIMATE_MODE_OFF)){
|
if ((display_status_) && (switch_climate_mode != climate::CLIMATE_MODE_OFF)){
|
||||||
ESP_LOGD("TCL", "Dispaly turn ON");
|
ESP_LOGD("TCL", "Dispaly turn ON");
|
||||||
@@ -312,7 +308,7 @@ void tclacClimate::takeControl() {
|
|||||||
dataTX[7] += 0b00000000;
|
dataTX[7] += 0b00000000;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ð<EFBFBD>аÑ<EFBFBD>траиваем режим работы кондиционера
|
// Encode the selected climate mode into the control frame.
|
||||||
switch (switch_climate_mode) {
|
switch (switch_climate_mode) {
|
||||||
case climate::CLIMATE_MODE_OFF:
|
case climate::CLIMATE_MODE_OFF:
|
||||||
dataTX[7] += 0b00000000;
|
dataTX[7] += 0b00000000;
|
||||||
@@ -340,7 +336,7 @@ void tclacClimate::takeControl() {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ð<EFBFBD>аÑ<EFBFBD>траиваем режим вентилÑ<C2BB>тора
|
// Encode the selected fan mode into the control frame.
|
||||||
switch(switch_fan_mode) {
|
switch(switch_fan_mode) {
|
||||||
case climate::CLIMATE_FAN_AUTO:
|
case climate::CLIMATE_FAN_AUTO:
|
||||||
dataTX[8] += 0b00000000;
|
dataTX[8] += 0b00000000;
|
||||||
@@ -376,7 +372,7 @@ void tclacClimate::takeControl() {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// УÑ<EFBFBD>танавливаем режим качаниÑ<C2B8> заÑ<C2B0>лонок
|
// Encode the requested swing mode bits.
|
||||||
switch(switch_swing_mode) {
|
switch(switch_swing_mode) {
|
||||||
case climate::CLIMATE_SWING_OFF:
|
case climate::CLIMATE_SWING_OFF:
|
||||||
dataTX[10] += 0b00000000;
|
dataTX[10] += 0b00000000;
|
||||||
@@ -396,7 +392,7 @@ void tclacClimate::takeControl() {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// УÑ<EFBFBD>танавливаем предуÑ<C692>тановки кондиционера
|
// Encode the requested preset bits.
|
||||||
switch(switch_preset) {
|
switch(switch_preset) {
|
||||||
case ClimatePreset::CLIMATE_PRESET_NONE:
|
case ClimatePreset::CLIMATE_PRESET_NONE:
|
||||||
break;
|
break;
|
||||||
@@ -411,48 +407,41 @@ void tclacClimate::takeControl() {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Режим заÑ<C2B0>лонок
|
// Louver control helper information.
|
||||||
// ВертикальнаÑ<C2B0> заÑ<C2B0>лонка
|
// Vertical louver handling.
|
||||||
// Качание вертикальной заÑ<C2B0>лонки [10 байт, маÑ<C2B0>ка 00111000]:
|
// Vertical swing bits [byte 10, mask 0b00111000]:
|
||||||
// 000 - Качание отключено, заÑ<C2B0>лонка в поÑ<C2BE>ледней позиции или в фикÑ<C2BA>ации
|
// 000 - swing off, louver stays in its last/fixed position.
|
||||||
// 111 - Качание включено в выбранном режиме
|
// 111 - swing enabled per the requested pattern.
|
||||||
// Режим качаниÑ<C2B8> вертикальной заÑ<C2B0>лонки (режим фикÑ<C2BA>ации заÑ<C2B0>лонки роли не играет, еÑ<C2B5>ли качание включено) [32 байт, маÑ<C2B0>ка 00011000]:
|
// Vertical swing macro mode (fixation ignored when swing runs) [byte 32, mask 0b00011000]:
|
||||||
// 01 - качание Ñ<>верÑ
|
// 01 - sweep from top to bottom (default).
|
||||||
у вниз, ПО УМОЛЧÐ<EFBFBD>Ð<EFBFBD>ИЮ
|
// 10 - sweep only in the upper half.
|
||||||
// 10 - качание в верÑ
|
// 11 - sweep only in the lower half.
|
||||||
ней половине
|
// Vertical fixation position when swing is disabled [byte 32, mask 0b00000111]:
|
||||||
// 11 - качание в нижней половине
|
// 000 - no fixation (default).
|
||||||
// Режим фикÑ<C2BA>ации заÑ<C2B0>лонки (режим качаниÑ<C2B8> заÑ<C2B0>лонки роли не играет, еÑ<C2B5>ли качание выключено) [32 байт, маÑ<C2B0>ка 00000111]:
|
// 001 - fix at the top.
|
||||||
// 000 - нет фикÑ<C2BA>ации, ПО УМОЛЧÐ<C2A7>Ð<EFBFBD>ИЮ
|
// 010 - fix between top and center.
|
||||||
// 001 - фикÑ<C2BA>ациÑ<C2B8> вверÑ
|
// 011 - fix at the center.
|
||||||
у
|
// 100 - fix between center and bottom.
|
||||||
// 010 - фикÑ<EFBFBD>ациÑ<EFBFBD> между верÑ
|
// 101 - fix at the bottom.
|
||||||
ом и Ñ<EFBFBD>ерединой
|
// Horizontal louver handling.
|
||||||
// 011 - фикÑ<C2BA>ациÑ<C2B8> в Ñ<>ередине
|
// Horizontal swing bit [byte 11, mask 0b00001000]:
|
||||||
// 100 - фикÑ<C2BA>ациÑ<C2B8> между Ñ<>ерединой и низом
|
// 0 - swing off, louvers stay where they were.
|
||||||
// 101 - фикÑ<C2BA>ациÑ<C2B8> внизу
|
// 1 - swing enabled.
|
||||||
// Горизонтальные заÑ<C2B0>лонки
|
// Horizontal swing macro mode (fixation ignored while swinging) [byte 33, mask 0b00111000]:
|
||||||
// Качание горизонтальныÑ
|
// 001 - sweep from left to right (default).
|
||||||
заÑ<EFBFBD>лонок [11 байт, маÑ<EFBFBD>ка 00001000]:
|
// 010 - sweep primarily on the left side.
|
||||||
// 0 - Качание отключено, заÑ<C2B0>лонки в поÑ<C2BE>ледней позиции или в фикÑ<C2BA>ации
|
// 011 - sweep around the center.
|
||||||
// 1 - Качание включено в выбранном режиме
|
// 100 - sweep primarily on the right side.
|
||||||
// Режим качаниÑ<C2B8> горизонтальныÑ
|
// Horizontal fixation position when swing is disabled [byte 33, mask 0b00000111]:
|
||||||
заÑ<EFBFBD>лонок (режим фикÑ<EFBFBD>ации заÑ<EFBFBD>лонок роли не играет, еÑ<EFBFBD>ли качание включено) [33 байт, маÑ<EFBFBD>ка 00111000]:
|
// 000 - no fixation (default).
|
||||||
// 001 - качание Ñ<>лева направо, ПО УМОЛЧÐ<C2A7>Ð<EFBFBD>ИЮ
|
// 001 - fix to the far left.
|
||||||
// 010 - качание Ñ<>лева
|
// 010 - fix between the left edge and center.
|
||||||
// 011 - качание по Ñ<>ередине
|
// 011 - fix at the center.
|
||||||
// 100 - качание Ñ<>права
|
// 100 - fix between the center and right edge.
|
||||||
// Режим фикÑ<C2BA>ации горизонтальныÑ
|
// 101 - fix to the far right.
|
||||||
заÑ<EFBFBD>лонок (режим качаниÑ<EFBFBD> заÑ<EFBFBD>лонок роли не играет, еÑ<EFBFBD>ли качание выключено) [33 байт, маÑ<EFBFBD>ка 00000111]:
|
|
||||||
// 000 - нет фикÑ<C2BA>ации, ПО УМОЛЧÐ<C2A7>Ð<EFBFBD>ИЮ
|
|
||||||
// 001 - фикÑ<C2BA>ациÑ<C2B8> Ñ<>лева
|
|
||||||
// 010 - фикÑ<C2BA>ациÑ<C2B8> между левой Ñ<>тороной и Ñ<>ерединой
|
|
||||||
// 011 - фикÑ<C2BA>ациÑ<C2B8> в Ñ<>ередине
|
|
||||||
// 100 - фикÑ<C2BA>ациÑ<C2B8> между Ñ<>ерединой и правой Ñ<>тороной
|
|
||||||
// 101 - фикÑ<C2BA>ациÑ<C2B8> Ñ<>права
|
|
||||||
|
|
||||||
|
|
||||||
// УÑ<EFBFBD>танавливаем режим длÑ<C2BB> качаниÑ<C2B8> вертикальной заÑ<C2B0>лонки
|
// Apply the requested vertical swing direction.
|
||||||
switch(vertical_swing_direction_) {
|
switch(vertical_swing_direction_) {
|
||||||
case VerticalSwingDirection::UP_DOWN:
|
case VerticalSwingDirection::UP_DOWN:
|
||||||
dataTX[32] += 0b00001000;
|
dataTX[32] += 0b00001000;
|
||||||
@@ -467,8 +456,7 @@ void tclacClimate::takeControl() {
|
|||||||
ESP_LOGD("TCL", "Vertical swing: downer");
|
ESP_LOGD("TCL", "Vertical swing: downer");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
// УÑ<EFBFBD>танавливаем режим длÑ<C2BB> качаниÑ<C2B8> горизонтальныÑ
|
// Apply the requested horizontal swing direction.
|
||||||
заÑ<EFBFBD>лонок
|
|
||||||
switch(horizontal_swing_direction_) {
|
switch(horizontal_swing_direction_) {
|
||||||
case HorizontalSwingDirection::LEFT_RIGHT:
|
case HorizontalSwingDirection::LEFT_RIGHT:
|
||||||
dataTX[33] += 0b00001000;
|
dataTX[33] += 0b00001000;
|
||||||
@@ -487,7 +475,7 @@ void tclacClimate::takeControl() {
|
|||||||
ESP_LOGD("TCL", "Horizontal swing: righter");
|
ESP_LOGD("TCL", "Horizontal swing: righter");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
// УÑ<EFBFBD>танавливаем положение фикÑ<C2BA>ации вертикальной заÑ<C2B0>лонки
|
// Apply the requested vertical fixation position.
|
||||||
switch(vertical_direction_) {
|
switch(vertical_direction_) {
|
||||||
case AirflowVerticalDirection::LAST:
|
case AirflowVerticalDirection::LAST:
|
||||||
dataTX[32] += 0b00000000;
|
dataTX[32] += 0b00000000;
|
||||||
@@ -514,8 +502,7 @@ void tclacClimate::takeControl() {
|
|||||||
ESP_LOGD("TCL", "Vertical fix: down");
|
ESP_LOGD("TCL", "Vertical fix: down");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
// УÑ<EFBFBD>танавливаем положение фикÑ<C2BA>ации горизонтальныÑ
|
// Apply the requested horizontal fixation position.
|
||||||
заÑ<EFBFBD>лонок
|
|
||||||
switch(horizontal_direction_) {
|
switch(horizontal_direction_) {
|
||||||
case AirflowHorizontalDirection::LAST:
|
case AirflowHorizontalDirection::LAST:
|
||||||
dataTX[33] += 0b00000000;
|
dataTX[33] += 0b00000000;
|
||||||
@@ -543,15 +530,15 @@ void tclacClimate::takeControl() {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// УÑ<EFBFBD>тановка температуры
|
// Set the encoded temperature byte.
|
||||||
dataTX[9] = target_temperature_set;
|
dataTX[9] = target_temperature_set;
|
||||||
|
|
||||||
// Собираем маÑ<C2B0>Ñ<EFBFBD>ив байт длÑ<C2BB> отправки в кондиционер
|
// Assemble the outbound control frame.
|
||||||
dataTX[0] = 0xBB; //Ñ<EFBFBD>тартовый байт заголовка
|
dataTX[0] = 0xBB; // Frame header byte.
|
||||||
dataTX[1] = 0x00; //Ñ<EFBFBD>тартовый байт заголовка
|
dataTX[1] = 0x00; // Frame header byte.
|
||||||
dataTX[2] = 0x01; //Ñ<EFBFBD>тартовый байт заголовка
|
dataTX[2] = 0x01; // Frame header byte.
|
||||||
dataTX[3] = 0x03; //0x03 - управление, 0x04 - опроÑ<C2BE>
|
dataTX[3] = 0x03; // 0x03 = control frame, 0x04 = status frame.
|
||||||
dataTX[4] = 0x20; //0x20 - управление, 0x19 - опроÑ<C2BE>
|
dataTX[4] = 0x20; // 0x20 is the control payload length, 0x19 is the status payload length.
|
||||||
dataTX[5] = 0x03; //??
|
dataTX[5] = 0x03; //??
|
||||||
dataTX[6] = 0x01; //??
|
dataTX[6] = 0x01; //??
|
||||||
//dataTX[7] = 0x64; //eco,display,beep,ontimerenable, offtimerenable,power,0,0
|
//dataTX[7] = 0x64; //eco,display,beep,ontimerenable, offtimerenable,power,0,0
|
||||||
@@ -578,12 +565,12 @@ void tclacClimate::takeControl() {
|
|||||||
dataTX[28] = 0x00; //??
|
dataTX[28] = 0x00; //??
|
||||||
dataTX[30] = 0x00; //??
|
dataTX[30] = 0x00; //??
|
||||||
dataTX[31] = 0x00; //??
|
dataTX[31] = 0x00; //??
|
||||||
//dataTX[32] = 0x00; //0,0,0,режим вертикального качаниÑ<C2B8>(2),режим вертикальной фикÑ<C2BA>ации(3)
|
// 0,0,0, vertical swing bits (2), vertical fixation bits (3).
|
||||||
//dataTX[33] = 0x00; //0,0,режим горизонтального качаниÑ<C2B8>(3),режим горизонтальной фикÑ<C2BA>ации(3)
|
// 0,0, horizontal swing bits (3), horizontal fixation bits (3).
|
||||||
dataTX[34] = 0x00; //??
|
dataTX[34] = 0x00; //??
|
||||||
dataTX[35] = 0x00; //??
|
dataTX[35] = 0x00; //??
|
||||||
dataTX[36] = 0x00; //??
|
dataTX[36] = 0x00; //??
|
||||||
dataTX[37] = 0xFF; //КонтрольнаÑ<EFBFBD> Ñ<>умма
|
dataTX[37] = 0xFF; // Checksum byte.
|
||||||
dataTX[37] = tclacClimate::getChecksum(dataTX, sizeof(dataTX));
|
dataTX[37] = tclacClimate::getChecksum(dataTX, sizeof(dataTX));
|
||||||
|
|
||||||
tclacClimate::sendData(dataTX, sizeof(dataTX));
|
tclacClimate::sendData(dataTX, sizeof(dataTX));
|
||||||
@@ -591,8 +578,7 @@ void tclacClimate::takeControl() {
|
|||||||
is_call_control = false;
|
is_call_control = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Отправка данныÑ
|
// Send the prepared frame to the AC.
|
||||||
в кондиционер
|
|
||||||
void tclacClimate::sendData(uint8_t * message, uint8_t size) {
|
void tclacClimate::sendData(uint8_t * message, uint8_t size) {
|
||||||
tclacClimate::dataShow(1,1);
|
tclacClimate::dataShow(1,1);
|
||||||
//Serial.write(message, size);
|
//Serial.write(message, size);
|
||||||
@@ -602,7 +588,7 @@ void tclacClimate::sendData(uint8_t * message, uint8_t size) {
|
|||||||
tclacClimate::dataShow(1,0);
|
tclacClimate::dataShow(1,0);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Преобразование байта в читабельный формат
|
// Convert a byte array into a readable hex string.
|
||||||
std::string tclacClimate::getHex(const byte *message, size_t size) {
|
std::string tclacClimate::getHex(const byte *message, size_t size) {
|
||||||
std::ostringstream oss;
|
std::ostringstream oss;
|
||||||
for (size_t i = 0; i < size; ++i) {
|
for (size_t i = 0; i < size; ++i) {
|
||||||
@@ -619,7 +605,7 @@ std::string tclacClimate::getHex(const byte *message, size_t size) {
|
|||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ВычиÑ<EFBFBD>ление контрольной Ñ<>уммы
|
// Calculate the XOR checksum for a frame.
|
||||||
uint8_t tclacClimate::getChecksum(const byte * message, size_t size) {
|
uint8_t tclacClimate::getChecksum(const byte * message, size_t size) {
|
||||||
uint8_t position = size - 1;
|
uint8_t position = size - 1;
|
||||||
uint8_t crc = 0;
|
uint8_t crc = 0;
|
||||||
@@ -628,7 +614,7 @@ uint8_t tclacClimate::getChecksum(const byte * message, size_t size) {
|
|||||||
return crc;
|
return crc;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Мигаем Ñ<>ветодиодами
|
// Blink LEDs to indicate RX/TX activity.
|
||||||
void tclacClimate::dataShow(bool flow, bool shine) {
|
void tclacClimate::dataShow(bool flow, bool shine) {
|
||||||
if (module_display_status_){
|
if (module_display_status_){
|
||||||
if (flow == 0){
|
if (flow == 0){
|
||||||
@@ -656,9 +642,9 @@ void tclacClimate::dataShow(bool flow, bool shine) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ДейÑ<EFBFBD>твиÑ<EFBFBD> Ñ<> данными из конфига
|
// Helpers for manipulating configuration-backed state.
|
||||||
|
|
||||||
// Получение Ñ<>оÑ<C2BE>тоÑ<C2BE>ниÑ<C2B8> пищалки
|
// Update the stored beeper state.
|
||||||
void tclacClimate::set_beeper_state(bool state) {
|
void tclacClimate::set_beeper_state(bool state) {
|
||||||
this->beeper_status_ = state;
|
this->beeper_status_ = state;
|
||||||
if (force_mode_status_){
|
if (force_mode_status_){
|
||||||
@@ -667,7 +653,7 @@ void tclacClimate::set_beeper_state(bool state) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Получение Ñ<>оÑ<C2BE>тоÑ<C2BE>ниÑ<C2B8> диÑ<C2B8>плеÑ<C2B5> кондиционера
|
// Update the stored AC display state.
|
||||||
void tclacClimate::set_display_state(bool state) {
|
void tclacClimate::set_display_state(bool state) {
|
||||||
this->display_status_ = state;
|
this->display_status_ = state;
|
||||||
if (force_mode_status_){
|
if (force_mode_status_){
|
||||||
@@ -676,29 +662,29 @@ void tclacClimate::set_display_state(bool state) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Получение Ñ<>оÑ<C2BE>тоÑ<C2BE>ниÑ<C2B8> режима принудительного применениÑ<C2B8> наÑ<C2B0>троек
|
// Update whether forced control is currently enabled.
|
||||||
void tclacClimate::set_force_mode_state(bool state) {
|
void tclacClimate::set_force_mode_state(bool state) {
|
||||||
this->force_mode_status_ = state;
|
this->force_mode_status_ = state;
|
||||||
}
|
}
|
||||||
// Получение пина Ñ<>ветодиода приема данныÑ
|
// Assign the RX LED pin.
|
||||||
|
|
||||||
#ifdef CONF_RX_LED
|
#ifdef CONF_RX_LED
|
||||||
void tclacClimate::set_rx_led_pin(GPIOPin *rx_led_pin) {
|
void tclacClimate::set_rx_led_pin(GPIOPin *rx_led_pin) {
|
||||||
this->rx_led_pin_ = rx_led_pin;
|
this->rx_led_pin_ = rx_led_pin;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
// Получение пина Ñ<>ветодиода передачи данныÑ
|
// Assign the TX LED pin.
|
||||||
|
|
||||||
#ifdef CONF_TX_LED
|
#ifdef CONF_TX_LED
|
||||||
void tclacClimate::set_tx_led_pin(GPIOPin *tx_led_pin) {
|
void tclacClimate::set_tx_led_pin(GPIOPin *tx_led_pin) {
|
||||||
this->tx_led_pin_ = tx_led_pin;
|
this->tx_led_pin_ = tx_led_pin;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
// Получение Ñ<>оÑ<C2BE>тоÑ<C2BE>ниÑ<C2B8> Ñ<>ветодиодов Ñ<>вÑ<C2B2>зи модулÑ<C2BB>
|
// Update the module display flag.
|
||||||
void tclacClimate::set_module_display_state(bool state) {
|
void tclacClimate::set_module_display_state(bool state) {
|
||||||
this->module_display_status_ = state;
|
this->module_display_status_ = state;
|
||||||
}
|
}
|
||||||
// Получение режима фикÑ<C2BA>ации вертикальной заÑ<C2B0>лонки
|
// Update the stored vertical airflow fixation target.
|
||||||
void tclacClimate::set_vertical_airflow(AirflowVerticalDirection direction) {
|
void tclacClimate::set_vertical_airflow(AirflowVerticalDirection direction) {
|
||||||
this->vertical_direction_ = direction;
|
this->vertical_direction_ = direction;
|
||||||
if (force_mode_status_){
|
if (force_mode_status_){
|
||||||
@@ -707,8 +693,7 @@ void tclacClimate::set_vertical_airflow(AirflowVerticalDirection direction) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Получение режима фикÑ<C2BA>ации горизонтальныÑ
|
// Update the stored horizontal airflow fixation target.
|
||||||
заÑ<EFBFBD>лонок
|
|
||||||
void tclacClimate::set_horizontal_airflow(AirflowHorizontalDirection direction) {
|
void tclacClimate::set_horizontal_airflow(AirflowHorizontalDirection direction) {
|
||||||
this->horizontal_direction_ = direction;
|
this->horizontal_direction_ = direction;
|
||||||
if (force_mode_status_){
|
if (force_mode_status_){
|
||||||
@@ -717,7 +702,7 @@ void tclacClimate::set_horizontal_airflow(AirflowHorizontalDirection direction)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Получение режима качаниÑ<C2B8> вертикальной заÑ<C2B0>лонки
|
// Update the stored vertical swing direction.
|
||||||
void tclacClimate::set_vertical_swing_direction(VerticalSwingDirection direction) {
|
void tclacClimate::set_vertical_swing_direction(VerticalSwingDirection direction) {
|
||||||
this->vertical_swing_direction_ = direction;
|
this->vertical_swing_direction_ = direction;
|
||||||
if (force_mode_status_){
|
if (force_mode_status_){
|
||||||
@@ -726,13 +711,11 @@ void tclacClimate::set_vertical_swing_direction(VerticalSwingDirection direction
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Получение доÑ<C2BE>тупныÑ
|
// Register supported climate modes.
|
||||||
режимов работы кондиционера
|
|
||||||
void tclacClimate::set_supported_modes(const std::set<climate::ClimateMode> &modes) {
|
void tclacClimate::set_supported_modes(const std::set<climate::ClimateMode> &modes) {
|
||||||
this->supported_modes_ = modes;
|
this->supported_modes_ = modes;
|
||||||
}
|
}
|
||||||
// Получение режима качаниÑ<C2B8> горизонтальныÑ
|
// Update the stored horizontal swing direction.
|
||||||
заÑ<EFBFBD>лонок
|
|
||||||
void tclacClimate::set_horizontal_swing_direction(HorizontalSwingDirection direction) {
|
void tclacClimate::set_horizontal_swing_direction(HorizontalSwingDirection direction) {
|
||||||
horizontal_swing_direction_ = direction;
|
horizontal_swing_direction_ = direction;
|
||||||
if (force_mode_status_){
|
if (force_mode_status_){
|
||||||
@@ -741,18 +724,15 @@ void tclacClimate::set_horizontal_swing_direction(HorizontalSwingDirection direc
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Получение доÑ<C2BE>тупныÑ
|
// Register supported fan modes.
|
||||||
Ñ<EFBFBD>короÑ<EFBFBD>тей вентилÑ<EFBFBD>тора
|
|
||||||
void tclacClimate::set_supported_fan_modes(const std::set<climate::ClimateFanMode> &modes){
|
void tclacClimate::set_supported_fan_modes(const std::set<climate::ClimateFanMode> &modes){
|
||||||
this->supported_fan_modes_ = modes;
|
this->supported_fan_modes_ = modes;
|
||||||
}
|
}
|
||||||
// Получение доÑ<C2BE>тупныÑ
|
// Register supported swing modes.
|
||||||
режимов качаниÑ<EFBFBD> заÑ<EFBFBD>лонок
|
|
||||||
void tclacClimate::set_supported_swing_modes(const std::set<climate::ClimateSwingMode> &modes) {
|
void tclacClimate::set_supported_swing_modes(const std::set<climate::ClimateSwingMode> &modes) {
|
||||||
this->supported_swing_modes_ = modes;
|
this->supported_swing_modes_ = modes;
|
||||||
}
|
}
|
||||||
// Получение доÑ<C2BE>тупныÑ
|
// Register supported presets.
|
||||||
предуÑ<EFBFBD>тановок
|
|
||||||
void tclacClimate::set_supported_presets(const std::set<climate::ClimatePreset> &presets) {
|
void tclacClimate::set_supported_presets(const std::set<climate::ClimatePreset> &presets) {
|
||||||
this->supported_presets_ = presets;
|
this->supported_presets_ = presets;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,8 @@
|
|||||||
/**
|
/**
|
||||||
* Create by Miguel Ángel López on 20/07/19
|
* Created by Miguel Angel Lopez on 20/07/19
|
||||||
* and modify by xaxexa
|
* Modified by xaxexa
|
||||||
* Refactoring & component making:
|
* ESPHome component refactor completed on 15.03.2024
|
||||||
* Соловей с паяльником 15.03.2024
|
*/
|
||||||
**/
|
|
||||||
|
|
||||||
#ifndef TCL_ESP_TCL_H
|
#ifndef TCL_ESP_TCL_H
|
||||||
#define TCL_ESP_TCL_H
|
#define TCL_ESP_TCL_H
|
||||||
@@ -96,13 +95,13 @@ class tclacClimate : public climate::Climate, public esphome::uart::UARTDevice,
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
uint8_t checksum;
|
uint8_t checksum;
|
||||||
// dataTX с управлением состоит из 38 байт
|
// dataTX holds the 38-byte control frame payload
|
||||||
uint8_t dataTX[38];
|
uint8_t dataTX[38];
|
||||||
// А dataRX по прежнему из 61 байта
|
// dataRX still contains the 61-byte status frame payload
|
||||||
uint8_t dataRX[61];
|
uint8_t dataRX[61];
|
||||||
// Команда запроса состояния
|
// Command frame that requests the current AC state
|
||||||
uint8_t poll_message_[8] = {0xBB,0x00,0x01,0x04,0x02,0x01,0x00,0xBD};
|
uint8_t poll_message_[8] = {0xBB,0x00,0x01,0x04,0x02,0x01,0x00,0xBD};
|
||||||
// Инициализация и начальное наполнение переменных состоянй переключателей
|
// Initialize and seed the state-tracking fields
|
||||||
bool beeper_status_;
|
bool beeper_status_;
|
||||||
bool display_status_;
|
bool display_status_;
|
||||||
bool force_mode_status_;
|
bool force_mode_status_;
|
||||||
|
|||||||
Reference in New Issue
Block a user