diff --git a/components/aux_ac/aux_ac.h b/components/aux_ac/aux_ac.h index 98308c5..a58364f 100644 --- a/components/aux_ac/aux_ac.h +++ b/components/aux_ac/aux_ac.h @@ -47,7 +47,6 @@ public: static const std::string MUTE; static const std::string TURBO; static const std::string CLEAN; - static const std::string FEEL; static const std::string HEALTH; static const std::string ANTIFUNGUS; @@ -72,7 +71,6 @@ const std::string Constants::TURBO = "turbo"; // custom presets const std::string Constants::CLEAN = "Clean"; -const std::string Constants::FEEL = "Feel"; const std::string Constants::HEALTH = "Health"; const std::string Constants::ANTIFUNGUS = "Antifungus"; @@ -278,7 +276,7 @@ struct packet_big_info_body_t { // байт 14 тела (байт 22 пакета) // https://github.com/GrKoR/AUX_HVAC_Protocol#packet_cmd_21_b22 - uint8_t strange_temperature_int; // от режима не зависит, растет при включении инвертора; температура двигателя? + uint8_t compressor_temperature_int; // от режима не зависит, растет при включении инвертора; температура двигателя? // байт 15 тела (байт 23 пакета) // https://github.com/GrKoR/AUX_HVAC_Protocol#packet_cmd_21_b23 @@ -389,10 +387,6 @@ enum ac_mode : uint8_t { AC_MODE_AUTO = 0x00, AC_MODE_COOL = 0x20, AC_MODE_DRY = #define AC_SLEEP_MASK 0b00000100 enum ac_sleep : uint8_t { AC_SLEEP_OFF = 0x00, AC_SLEEP_ON = 0x04, AC_SLEEP_UNTOUCHED = 0xFF }; -// функция iFeel - поддерживате температуру по датчику в пульте ДУ, а не во внутреннем блоке кондиционера -#define AC_IFEEL_MASK 0b00001000 -enum ac_ifeel : uint8_t { AC_IFEEL_OFF = 0x00, AC_IFEEL_ON = 0x08, AC_IFEEL_UNTOUCHED = 0xFF }; - // Вертикальные жалюзи. В протоколе зашита возможность двигать ими по всякому, но должна быть такая возможность на уровне железа. // TODO: надо протестировать значения 0x01, 0x02, 0x03, 0x04, 0x05, 0x06 для ac_louver_V #define AC_LOUVERV_MASK 0b00000111 @@ -453,7 +447,6 @@ enum ac_mildew : uint8_t { AC_MILDEW_OFF = 0x00, AC_MILDEW_ON = 0x08, AC_MILDEW_ ac_health health;\ ac_mode mode;\ ac_sleep sleep;\ - ac_ifeel iFeel;\ ac_louver louver;\ ac_fanspeed fanSpeed;\ ac_fanturbo fanTurbo;\ @@ -467,7 +460,7 @@ enum ac_mildew : uint8_t { AC_MILDEW_OFF = 0x00, AC_MILDEW_ON = 0x08, AC_MILDEW_ // чистый размер этой структуры 20 байт, скорее всего из-за выравнивания, она будет больше // из-за такого приема нужно контролировать размер копируемых данных руками -#define AC_COMMAND_BASE_SIZE 21 +#define AC_COMMAND_BASE_SIZE 20 #if defined(PRESETS_SAVING) // структура для сохранения данных @@ -494,10 +487,9 @@ struct ac_command_t { int8_t temp_outdoor; // внешняя температура int8_t temp_inbound; // температура входящая int8_t temp_outbound; // температура исходящая - int8_t temp_strange; // непонятная температура, понаблюдаем + int8_t temp_compressor; // температура компрессора ac_realFan realFanSpeed; // текущая скорость вентилятора uint8_t invertor_power; // мощность инвертора - uint8_t pressure; // предположительно давление bool defrost; // режим разморозки внешнего блока (накопление тепла + прогрев испарителя) }; @@ -618,6 +610,10 @@ class AirCon : public esphome::Component, public esphome::climate::Climate { std::set _supported_presets{}; std::set _supported_custom_presets{}; std::set _supported_custom_fan_modes{}; + + // The capabilities of the climate device + // Шаблон параметров отображения виджета + esphome::climate::ClimateTraits _traits; // состояние конечного автомата acsm_state _ac_state = ACSM_IDLE; @@ -660,6 +656,18 @@ class AirCon : public esphome::Component, public esphome::climate::Climate { // флаг успешного выполнения стартовой последовательности команд bool _startupSequenceComlete = false; + + // нормализация показаний температуры, приведение в диапазон + float _temp_target_normalise(float temp){ + auto traits = this->get_traits(); + float temp_min = traits.get_visual_min_temperature(); + float temp_max = traits.get_visual_max_temperature(); + if (temp < temp_min) temp = temp_min; + if (temp > temp_max) temp = temp_max; + if (temp < Constants::AC_MIN_TEMPERATURE) temp = Constants::AC_MIN_TEMPERATURE; + if (temp > Constants::AC_MAX_TEMPERATURE) temp = Constants::AC_MAX_TEMPERATURE; + return temp; + } // очистка последовательности команд void _clearSequence(){ @@ -819,7 +827,6 @@ class AirCon : public esphome::Component, public esphome::climate::Climate { cmd->fanTurbo = AC_FANTURBO_UNTOUCHED; cmd->health = AC_HEALTH_UNTOUCHED; cmd->health_status = AC_HEALTH_STATUS_UNTOUCHED; - cmd->iFeel = AC_IFEEL_UNTOUCHED; cmd->louver.louver_h = AC_LOUVERH_UNTOUCHED; cmd->louver.louver_v = AC_LOUVERV_UNTOUCHED; cmd->mildew = AC_MILDEW_UNTOUCHED; @@ -835,7 +842,7 @@ class AirCon : public esphome::Component, public esphome::climate::Climate { cmd->temp_outdoor = 0; cmd->temp_inbound = 0; cmd->temp_outbound = 0; - cmd->temp_strange = 0; + cmd->temp_compressor = 0; cmd->realFanSpeed = AC_REAL_FAN_UNTOUCHED; }; @@ -1135,10 +1142,6 @@ class AirCon : public esphome::Component, public esphome::climate::Climate { stateChangedFlag = stateChangedFlag || (_current_ac_state.sleep != (ac_sleep)stateByte); _current_ac_state.sleep = (ac_sleep)stateByte; - stateByte = small_info_body->mode & AC_IFEEL_MASK; - stateChangedFlag = stateChangedFlag || (_current_ac_state.iFeel != (ac_ifeel)stateByte); - _current_ac_state.iFeel = (ac_ifeel)stateByte; - stateByte = small_info_body->status & AC_POWER_MASK; stateChangedFlag = stateChangedFlag || (_current_ac_state.power != (ac_power)stateByte); _current_ac_state.power = (ac_power)stateByte; @@ -1203,10 +1206,10 @@ class AirCon : public esphome::Component, public esphome::climate::Climate { stateChangedFlag = stateChangedFlag || (_current_ac_state.temp_outbound != stateFloat); _current_ac_state.temp_outbound = stateFloat; - // температура непонятная температура - stateFloat = big_info_body->strange_temperature_int - 0x20; - stateChangedFlag = stateChangedFlag || (_current_ac_state.temp_strange != stateFloat); - _current_ac_state.temp_strange = stateFloat; + // температура компрессора внешнего блока + stateFloat = big_info_body->compressor_temperature_int - 0x20; + stateChangedFlag = stateChangedFlag || (_current_ac_state.temp_compressor != stateFloat); + _current_ac_state.temp_compressor = stateFloat; // реальная скорость проперлера stateFloat = big_info_body->realFanSpeed; @@ -1515,9 +1518,7 @@ class AirCon : public esphome::Component, public esphome::climate::Climate { // целевая температура кондиционера if (cmd->temp_target_matter){ // устраняем выход за границы диапазона (это ограничение самого кондиционера) - if (cmd->temp_target < Constants::AC_MIN_TEMPERATURE) cmd->temp_target = Constants::AC_MIN_TEMPERATURE; - if (cmd->temp_target > Constants::AC_MAX_TEMPERATURE) cmd->temp_target = Constants::AC_MAX_TEMPERATURE; - + cmd->temp_target = _temp_target_normalise(cmd->temp_target); // целая часть температуры pack->body[2] = (pack->body[2] & ~AC_TEMP_TARGET_INT_PART_MASK) | (((uint8_t)(cmd->temp_target) - 8) << 3); @@ -1565,9 +1566,6 @@ class AirCon : public esphome::Component, public esphome::climate::Climate { if (cmd->sleep != AC_SLEEP_UNTOUCHED){ pack->body[7] = (pack->body[7] & ~AC_SLEEP_MASK) | cmd->sleep; } - if (cmd->iFeel != AC_IFEEL_UNTOUCHED){ - pack->body[7] = (pack->body[7] & ~AC_IFEEL_MASK) | cmd->iFeel; - } // питание вкл/выкл if (cmd->power != AC_POWER_UNTOUCHED){ @@ -1786,7 +1784,7 @@ class AirCon : public esphome::Component, public esphome::climate::Climate { esphome::sensor::Sensor *sensor_outdoor_temperature_ = nullptr; esphome::sensor::Sensor *sensor_inbound_temperature_ =nullptr; esphome::sensor::Sensor *sensor_outbound_temperature_ =nullptr; - esphome::sensor::Sensor *sensor_strange_temperature_ =nullptr; + esphome::sensor::Sensor *sensor_compressor_temperature_ =nullptr; // текущая мощность компрессора esphome::sensor::Sensor *sensor_invertor_power_ = nullptr; // бинарный сенсор, отображающий состояние дисплея @@ -1888,6 +1886,15 @@ class AirCon : public esphome::Component, public esphome::climate::Climate { // выполнена ли уже стартовая последовательность команд (сбор информации о статусе кондея) _startupSequenceComlete = false; + + // первоначальная инициализация + // TODO: вроде бы введено Brokly, но было в setup(). Надо узнать, зачем оно нам вообще? + this->preset = climate::CLIMATE_PRESET_NONE; + this->custom_preset = (std::string)""; + this->mode = climate::CLIMATE_MODE_OFF; + this->action = climate::CLIMATE_ACTION_IDLE; + this->fan_mode = climate::CLIMATE_FAN_LOW; + this->custom_fan_mode = (std::string)""; }; float get_setup_priority() const override { return esphome::setup_priority::DATA; } @@ -1896,7 +1903,7 @@ class AirCon : public esphome::Component, public esphome::climate::Climate { void set_outdoor_temperature_sensor(sensor::Sensor *temperature_sensor) { sensor_outdoor_temperature_ = temperature_sensor; } void set_inbound_temperature_sensor(sensor::Sensor *temperature_sensor) { sensor_inbound_temperature_ = temperature_sensor; } void set_outbound_temperature_sensor(sensor::Sensor *temperature_sensor) { sensor_outbound_temperature_ = temperature_sensor; } - void set_strange_temperature_sensor(sensor::Sensor *temperature_sensor) { sensor_strange_temperature_ = temperature_sensor; } + void set_compressor_temperature_sensor(sensor::Sensor *temperature_sensor) { sensor_compressor_temperature_ = temperature_sensor; } void set_defrost_state(binary_sensor::BinarySensor *defrost_state_sensor) { sensor_defrost_ = defrost_state_sensor; } void set_display_sensor(binary_sensor::BinarySensor *display_sensor) { sensor_display_ = display_sensor; } void set_invertor_power_sensor(sensor::Sensor *invertor_power_sensor) { sensor_invertor_power_ = invertor_power_sensor; } @@ -2086,23 +2093,6 @@ class AirCon : public esphome::Component, public esphome::climate::Climate { _debugMsg(F("Climate fan MUTE mode: %i"), ESPHOME_LOG_LEVEL_VERBOSE, __LINE__, _current_ac_state.fanMute); //======================== ОТОБРАЖЕНИЕ ПРЕСЕТОВ ================================ - /*************************** iFEEL CUSTOM PRESET ***************************/ - // режим поддержки температуры в районе пульта, работает только при включенном конедее - if( _current_ac_state.iFeel == AC_IFEEL_ON && - _current_ac_state.power == AC_POWER_ON ) { - - this->custom_preset = Constants::FEEL; - - } else if ( this->custom_preset == Constants::FEEL ) { - - // AC_IFEEL_OFF - // только в том случае, если до этого пресет был установлен - this->custom_preset = (std::string)""; - - } - - _debugMsg(F("Climate iFEEL preset: %i"), ESPHOME_LOG_LEVEL_VERBOSE, __LINE__, _current_ac_state.iFeel); - /*************************** HEALTH CUSTOM PRESET ***************************/ // режим работы ионизатора if( _current_ac_state.health == AC_HEALTH_ON && @@ -2233,8 +2223,8 @@ class AirCon : public esphome::Component, public esphome::climate::Climate { if (sensor_outbound_temperature_ != nullptr) sensor_outbound_temperature_->publish_state(_current_ac_state.temp_outbound); // температура странного датчика - if (sensor_strange_temperature_ != nullptr) - sensor_strange_temperature_->publish_state(_current_ac_state.temp_strange); + if (sensor_compressor_temperature_ != nullptr) + sensor_compressor_temperature_->publish_state(_current_ac_state.temp_compressor); // мощность инвертора if (sensor_invertor_power_ != nullptr) sensor_invertor_power_->publish_state(_current_ac_state.invertor_power); @@ -2357,21 +2347,21 @@ class AirCon : public esphome::Component, public esphome::climate::Climate { } } - if ((this->sensor_strange_temperature_) != nullptr) { - ESP_LOGCONFIG(Constants::TAG, "%s%s '%s'", " ", LOG_STR_LITERAL("Strange Temperature"), (this->sensor_strange_temperature_)->get_name().c_str()); - if (!(this->sensor_strange_temperature_)->get_device_class().empty()) { - ESP_LOGCONFIG(Constants::TAG, "%s Device Class: '%s'", " ", (this->sensor_strange_temperature_)->get_device_class().c_str()); + if ((this->sensor_compressor_temperature_) != nullptr) { + ESP_LOGCONFIG(Constants::TAG, "%s%s '%s'", " ", LOG_STR_LITERAL("Compressor Temperature"), (this->sensor_compressor_temperature_)->get_name().c_str()); + if (!(this->sensor_compressor_temperature_)->get_device_class().empty()) { + ESP_LOGCONFIG(Constants::TAG, "%s Device Class: '%s'", " ", (this->sensor_compressor_temperature_)->get_device_class().c_str()); } - ESP_LOGCONFIG(Constants::TAG, "%s State Class: '%s'", " ", state_class_to_string((this->sensor_strange_temperature_)->get_state_class()).c_str()); - ESP_LOGCONFIG(Constants::TAG, "%s Unit of Measurement: '%s'", " ", (this->sensor_strange_temperature_)->get_unit_of_measurement().c_str()); - ESP_LOGCONFIG(Constants::TAG, "%s Accuracy Decimals: %d", " ", (this->sensor_strange_temperature_)->get_accuracy_decimals()); - if (!(this->sensor_strange_temperature_)->get_icon().empty()) { - ESP_LOGCONFIG(Constants::TAG, "%s Icon: '%s'", " ", (this->sensor_strange_temperature_)->get_icon().c_str()); + ESP_LOGCONFIG(Constants::TAG, "%s State Class: '%s'", " ", state_class_to_string((this->sensor_compressor_temperature_)->get_state_class()).c_str()); + ESP_LOGCONFIG(Constants::TAG, "%s Unit of Measurement: '%s'", " ", (this->sensor_compressor_temperature_)->get_unit_of_measurement().c_str()); + ESP_LOGCONFIG(Constants::TAG, "%s Accuracy Decimals: %d", " ", (this->sensor_compressor_temperature_)->get_accuracy_decimals()); + if (!(this->sensor_compressor_temperature_)->get_icon().empty()) { + ESP_LOGCONFIG(Constants::TAG, "%s Icon: '%s'", " ", (this->sensor_compressor_temperature_)->get_icon().c_str()); } - if (!(this->sensor_strange_temperature_)->unique_id().empty()) { - ESP_LOGV(Constants::TAG, "%s Unique ID: '%s'", " ", (this->sensor_strange_temperature_)->unique_id().c_str()); + if (!(this->sensor_compressor_temperature_)->unique_id().empty()) { + ESP_LOGV(Constants::TAG, "%s Unique ID: '%s'", " ", (this->sensor_compressor_temperature_)->unique_id().c_str()); } - if ((this->sensor_strange_temperature_)->get_force_update()) { + if ((this->sensor_compressor_temperature_)->get_force_update()) { ESP_LOGV(Constants::TAG, "%s Force Update: YES", " "); } } @@ -2654,7 +2644,6 @@ class AirCon : public esphome::Component, public esphome::climate::Climate { cmd.sleep = AC_SLEEP_OFF; cmd.mildew = AC_MILDEW_OFF; cmd.clean = AC_CLEAN_OFF; - cmd.iFeel = AC_IFEEL_OFF; // хоть и не реализован, но отрубим. А то потом забудем указать. this->preset = preset; _debugMsg(F("Clear all builtin presets."), ESPHOME_LOG_LEVEL_VERBOSE, __LINE__); @@ -2683,12 +2672,6 @@ class AirCon : public esphome::Component, public esphome::climate::Climate { _debugMsg(F("CLEAN preset is suitable in POWER_OFF mode only."), ESPHOME_LOG_LEVEL_WARN, __LINE__); } - } else if (custom_preset == Constants::FEEL) { - _debugMsg(F("iFEEL preset has not been implemented yet."), ESPHOME_LOG_LEVEL_INFO, __LINE__); - // TODO: надо подумать, как заставить этот режим работать без пульта - //hasCommand = true; - //this->custom_preset = custom_preset; - } else if ( custom_preset == Constants::HEALTH ) { if ( cmd.power == AC_POWER_ON || @@ -2788,11 +2771,7 @@ class AirCon : public esphome::Component, public esphome::climate::Climate { // выставлять температуру в режиме FAN не нужно if ( cmd.mode != AC_MODE_FAN && _current_ac_state.mode != AC_MODE_FAN ) { hasCommand = true; - float temp = *call.get_target_temperature(); - // Send target temp to climate - if (temp > Constants::AC_MAX_TEMPERATURE) temp = Constants::AC_MAX_TEMPERATURE; - if (temp < Constants::AC_MIN_TEMPERATURE) temp = Constants::AC_MIN_TEMPERATURE; - cmd.temp_target = temp; + cmd.temp_target = _temp_target_normalise(*call.get_target_temperature());// Send target temp to climate cmd.temp_target_matter = true; } } @@ -2808,43 +2787,10 @@ class AirCon : public esphome::Component, public esphome::climate::Climate { } } + // как оказалось сюда обращаются каждый раз для получения любого параметра + // по этому имеет смысл держать готовый объект esphome::climate::ClimateTraits traits() override { - // The capabilities of the climate device - auto traits = climate::ClimateTraits(); - - traits.set_supports_current_temperature(true); - - // if the climate device's target temperature should be split in target_temperature_low and target_temperature_high instead of just the single target_temperature - traits.set_supports_two_point_target_temperature(false); - - // tells the frontend what range of temperatures the climate device should display (gauge min/max values) - traits.set_visual_min_temperature(Constants::AC_MIN_TEMPERATURE); - traits.set_visual_max_temperature(Constants::AC_MAX_TEMPERATURE); - // the step with which to increase/decrease target temperature. This also affects with how many decimal places the temperature is shown. - traits.set_visual_temperature_step(Constants::AC_TEMPERATURE_STEP); - - traits.set_supported_modes(this->_supported_modes); - traits.set_supported_swing_modes(this->_supported_swing_modes); - traits.set_supported_presets(this->_supported_presets); - traits.set_supported_custom_presets(this->_supported_custom_presets); - traits.set_supported_custom_fan_modes(this->_supported_custom_fan_modes); - - /* + MINIMAL SET */ - traits.add_supported_mode(ClimateMode::CLIMATE_MODE_OFF); - traits.add_supported_mode(ClimateMode::CLIMATE_MODE_FAN_ONLY); - traits.add_supported_fan_mode(ClimateFanMode::CLIMATE_FAN_AUTO); - traits.add_supported_fan_mode(ClimateFanMode::CLIMATE_FAN_LOW); - traits.add_supported_fan_mode(ClimateFanMode::CLIMATE_FAN_MEDIUM); - traits.add_supported_fan_mode(ClimateFanMode::CLIMATE_FAN_HIGH); - traits.add_supported_swing_mode(ClimateSwingMode::CLIMATE_SWING_OFF); - //traits.add_supported_swing_mode(ClimateSwingMode::CLIMATE_SWING_VERTICAL); - //traits.add_supported_swing_mode(ClimateSwingMode::CLIMATE_SWING_BOTH); - traits.add_supported_preset(ClimatePreset::CLIMATE_PRESET_NONE); - //traits.add_supported_preset(ClimatePreset::CLIMATE_PRESET_SLEEP); - - traits.set_supports_action(this->_show_action); - - return traits; + return _traits; } // запрос маленького пакета статуса кондиционера @@ -3111,11 +3057,21 @@ class AirCon : public esphome::Component, public esphome::climate::Climate { void set_display_inverted(bool display_inverted) { this->_display_inverted = display_inverted; } bool get_display_inverted() { return this->_display_inverted; } - void set_supported_modes(const std::set &modes) { this->_supported_modes = modes; } - void set_supported_swing_modes(const std::set &modes) { this->_supported_swing_modes = modes; } - void set_supported_presets(const std::set &presets) { this->_supported_presets = presets; } - void set_custom_presets(const std::set &presets) { this->_supported_custom_presets = presets; } - void set_custom_fan_modes(const std::set &modes) { this->_supported_custom_fan_modes = modes; } + // возможно функции get и не нужны, но вроде как должны быть + void set_supported_modes(const std::set &modes) { this->_supported_modes = modes;} + std::setget_supported_modes(){return this->_supported_modes;} + + void set_supported_swing_modes(const std::set &modes) { this->_supported_swing_modes = modes;} + std::set get_supported_swing_modes(){return this->_supported_swing_modes;} + + void set_supported_presets(const std::set &presets) { this->_supported_presets = presets;} + const std::set& get_supported_presets(){return this->_supported_presets;} + + void set_custom_presets(const std::set &presets) { this->_supported_custom_presets = presets;} + const std::set& get_supported_custom_presets(){return this->_supported_custom_presets;} + + void set_custom_fan_modes(const std::set &modes) { this->_supported_custom_fan_modes = modes;} + const std::set& get_supported_custom_fan_modes(){return this->_supported_custom_fan_modes;} #if defined(PRESETS_SAVING) void set_store_settings(bool store_settings) { this->_store_settings = store_settings; } @@ -3129,16 +3085,43 @@ class AirCon : public esphome::Component, public esphome::climate::Climate { #if defined(PRESETS_SAVING) load_presets_result = storage.load(global_presets); // читаем все пресеты из флеша _debugMsg(F("Preset base read from NVRAM, result %02d."), ESPHOME_LOG_LEVEL_WARN, __LINE__, load_presets_result); - - // TODO: Может это надо вынести за пределы дефайна пресетов? - // если это всё же нужно при инициализации объекта, то надо закинуть в initAC() - this->preset = climate::CLIMATE_PRESET_NONE; - this->custom_preset = (std::string)""; - this->mode = climate::CLIMATE_MODE_OFF; - this->action = climate::CLIMATE_ACTION_IDLE; - this->fan_mode = climate::CLIMATE_FAN_LOW; - this->custom_fan_mode = (std::string)""; #endif + + // заполнение шаблона параметров отображения виджета + // GK: всё же похоже правильнее это делать тут, а не в initAC() + // initAC() в формируемом питоном коде вызывается до вызова aux_ac.set_supported_***() с установленными пользователем в конфиге параметрами + _traits.set_supports_current_temperature(true); + _traits.set_supports_two_point_target_temperature(false); // if the climate device's target temperature should be split in target_temperature_low and target_temperature_high instead of just the single target_temperature + + _traits.set_supported_modes(this->_supported_modes); + _traits.set_supported_swing_modes(this->_supported_swing_modes); + _traits.set_supported_presets(this->_supported_presets); + _traits.set_supported_custom_presets(this->_supported_custom_presets); + _traits.set_supported_custom_fan_modes(this->_supported_custom_fan_modes); + + // tells the frontend what range of temperatures the climate device should display (gauge min/max values) + // TODO: GK: а вот здесь похоже неправильно. Похоже, так мы не сможем выставить в конфиге свой диапазон температур - всегда будет от AC_MIN_TEMPERATURE до AC_MAX_TEMPERATURE + _traits.set_visual_min_temperature(Constants::AC_MIN_TEMPERATURE); + _traits.set_visual_max_temperature(Constants::AC_MAX_TEMPERATURE); + // the step with which to increase/decrease target temperature. This also affects with how many decimal places the temperature is shown. + _traits.set_visual_temperature_step(Constants::AC_TEMPERATURE_STEP); + + /* + MINIMAL SET */ + _traits.add_supported_mode(ClimateMode::CLIMATE_MODE_OFF); + _traits.add_supported_mode(ClimateMode::CLIMATE_MODE_FAN_ONLY); + _traits.add_supported_fan_mode(ClimateFanMode::CLIMATE_FAN_AUTO); + _traits.add_supported_fan_mode(ClimateFanMode::CLIMATE_FAN_LOW); + _traits.add_supported_fan_mode(ClimateFanMode::CLIMATE_FAN_MEDIUM); + _traits.add_supported_fan_mode(ClimateFanMode::CLIMATE_FAN_HIGH); + _traits.add_supported_swing_mode(ClimateSwingMode::CLIMATE_SWING_OFF); + //_traits.add_supported_swing_mode(ClimateSwingMode::CLIMATE_SWING_VERTICAL); + //_traits.add_supported_swing_mode(ClimateSwingMode::CLIMATE_SWING_BOTH); + _traits.add_supported_preset(ClimatePreset::CLIMATE_PRESET_NONE); + //_traits.add_supported_preset(ClimatePreset::CLIMATE_PRESET_SLEEP); + + // if the climate device supports reporting the active current action of the device with the action property. + _traits.set_supports_action(this->_show_action); + }; void loop() override { diff --git a/components/aux_ac/climate.py b/components/aux_ac/climate.py index 02e9305..6096ebb 100644 --- a/components/aux_ac/climate.py +++ b/components/aux_ac/climate.py @@ -47,8 +47,8 @@ CONF_INBOUND_TEMPERATURE = 'inbound_temperature' ICON_INBOUND_TEMPERATURE = 'mdi:thermometer-plus' CONF_OUTBOUND_TEMPERATURE = 'outbound_temperature' ICON_OUTBOUND_TEMPERATURE = 'mdi:thermometer-minus' -CONF_STRANGE_TEMPERATURE = 'strange_temperature' -ICON_STRANGE_TEMPERATURE = 'mdi:thermometer-lines' +CONF_COMPRESSOR_TEMPERATURE = 'compressor_temperature' +ICON_COMPRESSOR_TEMPERATURE = 'mdi:thermometer-lines' CONF_DISPLAY_STATE = 'display_state' CONF_INVERTOR_POWER = 'invertor_power' CONF_DEFROST_STATE = 'defrost_state' @@ -56,6 +56,7 @@ ICON_DEFROST = "mdi:snowflake-melt" CONF_DISPLAY_INVERTED = 'display_inverted' ICON_DISPLAY = "mdi:clock-digital" + aux_ac_ns = cg.esphome_ns.namespace("aux_ac") AirCon = aux_ac_ns.class_("AirCon", climate.Climate, cg.Component) Capabilities = aux_ac_ns.namespace("Constants") @@ -93,7 +94,6 @@ validate_custom_fan_modes = cv.enum(CUSTOM_FAN_MODES, upper=True) CUSTOM_PRESETS = { "CLEAN": Capabilities.CLEAN, - "FEEL": Capabilities.FEEL, "HEALTH": Capabilities.HEALTH, "ANTIFUNGUS": Capabilities.ANTIFUNGUS, } @@ -156,7 +156,7 @@ CONFIG_SCHEMA = cv.All( cv.Optional(CONF_INBOUND_TEMPERATURE): sensor.sensor_schema( unit_of_measurement=UNIT_CELSIUS, icon=ICON_INBOUND_TEMPERATURE, - accuracy_decimals=1, + accuracy_decimals=0, device_class=DEVICE_CLASS_TEMPERATURE, state_class=STATE_CLASS_MEASUREMENT, ).extend( @@ -175,9 +175,9 @@ CONFIG_SCHEMA = cv.All( cv.Optional(CONF_INTERNAL, default="true"): cv.boolean, } ), - cv.Optional(CONF_STRANGE_TEMPERATURE): sensor.sensor_schema( + cv.Optional(CONF_COMPRESSOR_TEMPERATURE): sensor.sensor_schema( unit_of_measurement=UNIT_CELSIUS, - icon=ICON_STRANGE_TEMPERATURE, + icon=ICON_COMPRESSOR_TEMPERATURE, accuracy_decimals=0, device_class=DEVICE_CLASS_TEMPERATURE, state_class=STATE_CLASS_MEASUREMENT, @@ -246,10 +246,10 @@ async def to_code(config): sens = await sensor.new_sensor(conf) cg.add(var.set_inbound_temperature_sensor(sens)) - if CONF_STRANGE_TEMPERATURE in config: - conf = config[CONF_STRANGE_TEMPERATURE] + if CONF_COMPRESSOR_TEMPERATURE in config: + conf = config[CONF_COMPRESSOR_TEMPERATURE] sens = await sensor.new_sensor(conf) - cg.add(var.set_strange_temperature_sensor(sens)) + cg.add(var.set_compressor_temperature_sensor(sens)) if CONF_DISPLAY_STATE in config: conf = config[CONF_DISPLAY_STATE] @@ -280,6 +280,8 @@ async def to_code(config): if CONF_CUSTOM_FAN_MODES in config: cg.add(var.set_custom_fan_modes(config[CONF_CUSTOM_FAN_MODES])) + + DISPLAY_ACTION_SCHEMA = maybe_simple_id( { cv.Required(CONF_ID): cv.use_id(AirCon), @@ -297,7 +299,6 @@ async def display_on_to_code(config, action_id, template_arg, args): return cg.new_Pvariable(action_id, template_arg, paren) - SEND_TEST_PACKET_ACTION_SCHEMA = maybe_simple_id( { cv.Required(CONF_ID): cv.use_id(AirCon), @@ -331,4 +332,4 @@ async def send_packet_to_code(config, action_id, template_arg, args): else: cg.add(var.set_data_static(data)) - return var \ No newline at end of file + return var \ No newline at end of file