From 9df49c72b399a58af12ae8aa64689168cf6d1bec Mon Sep 17 00:00:00 2001 From: GrKoR Date: Fri, 8 Apr 2022 01:31:43 +0300 Subject: [PATCH 1/6] Display ON, OFF and TOGGLE action Fixes #15 --- components/aux_ac/automation.h | 35 +++++++++++++++++++++++++++++ components/aux_ac/aux_ac.h | 40 +++++++++++++++++++++++++--------- components/aux_ac/climate.py | 25 ++++++++++++++++++++- 3 files changed, 89 insertions(+), 11 deletions(-) create mode 100644 components/aux_ac/automation.h diff --git a/components/aux_ac/automation.h b/components/aux_ac/automation.h new file mode 100644 index 0000000..c41aea3 --- /dev/null +++ b/components/aux_ac/automation.h @@ -0,0 +1,35 @@ +#pragma once + +#include "esphome/core/component.h" +#include "esphome/core/automation.h" +#include "aux_ac.h" + +namespace esphome { +namespace aux_ac { + + template + class AirConDisplayOffAction : public Action + { + public: + explicit AirConDisplayOffAction(AirCon *ac) : ac_(ac) {} + + void play(Ts... x) override { this->ac_->displaySequence(AC_DISPLAY_OFF); } + + protected: + AirCon *ac_; + }; + + template + class AirConDisplayOnAction : public Action + { + public: + explicit AirConDisplayOnAction(AirCon *ac) : ac_(ac) {} + + void play(Ts... x) override { this->ac_->displaySequence(AC_DISPLAY_ON); } + + protected: + AirCon *ac_; + }; + +} // namespace aux_ac +} // namespace esphome \ No newline at end of file diff --git a/components/aux_ac/aux_ac.h b/components/aux_ac/aux_ac.h index 34c80d2..23150a0 100644 --- a/components/aux_ac/aux_ac.h +++ b/components/aux_ac/aux_ac.h @@ -2352,6 +2352,36 @@ class AirCon : public esphome::Component, public esphome::climate::Climate { return true; } + // загружает на выполнение последовательность команд на включение/выключение табло с температурой + bool displaySequence(ac_display dsp = AC_DISPLAY_ON){ + // нет смысла в последовательности, если нет коннекта с кондиционером + if (!get_has_connection()) { + _debugMsg(F("displaySequence: no pings from HVAC. It seems like no AC connected."), ESPHOME_LOG_LEVEL_ERROR, __LINE__); + return false; + } + if (dsp == AC_DISPLAY_UNTOUCHED) return false; // выходим, чтобы не тратить время + + // формируем команду + ac_command_t cmd; + _clearCommand(&cmd); // не забываем очищать, а то будет мусор + cmd.display = dsp; + // добавляем команду в последовательность + if (!commandSequence(&cmd)) return false; + + _debugMsg(F("displaySequence: loaded (display = %02X)"), ESPHOME_LOG_LEVEL_VERBOSE, __LINE__, dsp); + return true; + } + + // выключает экран + bool displayOffSequence(){ + return displaySequence(AC_DISPLAY_OFF); + } + + // включает экран + bool displayOnSequence(){ + return displaySequence(AC_DISPLAY_ON); + } + void set_period(uint32_t ms) { this->_update_period = ms; }; uint32_t get_period() { return this->_update_period; }; void set_show_action(bool show_action) { this->_show_action = show_action; }; @@ -2401,16 +2431,6 @@ class AirCon : public esphome::Component, public esphome::climate::Climate { if (get_has_connection()) getStatusBigAndSmall(); } - /* - // это экспериментальная секция для отладки функционала - static uint32_t debug_millis = millis(); - if (millis()-debug_millis > 10000){ - debug_millis = millis(); - //_debugMsg(F("Test!"), ESPHOME_LOG_LEVEL_WARN, __LINE__); - //if (_current_ac_state.power == AC_POWER_OFF) powerSequence(AC_POWER_ON); - //else powerSequence(AC_POWER_OFF); - } - */ }; }; diff --git a/components/aux_ac/climate.py b/components/aux_ac/climate.py index d5180c6..b9eec4e 100644 --- a/components/aux_ac/climate.py +++ b/components/aux_ac/climate.py @@ -2,6 +2,8 @@ import logging import esphome.config_validation as cv import esphome.codegen as cg from esphome.components import climate, uart, sensor +from esphome import automation +from esphome.automation import maybe_simple_id from esphome.const import ( CONF_ID, CONF_UART_ID, @@ -19,6 +21,7 @@ from esphome.components.climate import ( ClimatePreset, ClimateSwingMode, ) + _LOGGER = logging.getLogger(__name__) CODEOWNERS = ["@GrKoR"] @@ -35,6 +38,9 @@ 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") +AirConDisplayOffAction = aux_ac_ns.class_("AirConDisplayOffAction", automation.Action) +AirConDisplayOnAction = aux_ac_ns.class_("AirConDisplayOnAction", automation.Action) + ALLOWED_CLIMATE_MODES = { "HEAT_COOL": ClimateMode.CLIMATE_MODE_HEAT_COOL, "COOL": ClimateMode.CLIMATE_MODE_COOL, @@ -130,4 +136,21 @@ async def to_code(config): cg.add(var.set_custom_presets(config[CONF_CUSTOM_PRESETS])) if CONF_CUSTOM_FAN_MODES in config: cg.add(var.set_custom_fan_modes(config[CONF_CUSTOM_FAN_MODES])) - \ No newline at end of file + + + +DISPLAY_ACTION_SCHEMA = maybe_simple_id( + { + cv.Required(CONF_ID): cv.use_id(AirCon), + } +) + +@automation.register_action("aux_ac.display_off", AirConDisplayOffAction, DISPLAY_ACTION_SCHEMA) +async def switch_toggle_to_code(config, action_id, template_arg, args): + paren = await cg.get_variable(config[CONF_ID]) + return cg.new_Pvariable(action_id, template_arg, paren) + +@automation.register_action("aux_ac.display_on", AirConDisplayOnAction, DISPLAY_ACTION_SCHEMA) +async def switch_toggle_to_code(config, action_id, template_arg, args): + paren = await cg.get_variable(config[CONF_ID]) + return cg.new_Pvariable(action_id, template_arg, paren) \ No newline at end of file From 699e8e24a39537d954ad0bcbfdb9e2c87235e2bc Mon Sep 17 00:00:00 2001 From: GrKoR Date: Fri, 8 Apr 2022 16:37:17 +0300 Subject: [PATCH 2/6] russian readme updated with display_on & display_off actions --- README.md | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/README.md b/README.md index 7f6b5a1..3b5a2a8 100644 --- a/README.md +++ b/README.md @@ -139,6 +139,29 @@ climate: - **supported_swing_modes** (*Опциональный*, список): Список поддерживаемых режимов качания шторки. Возможные значения: ``VERTICAL``, ``HORIZONTAL``, ``BOTH``. По умолчанию устанавливается, что качание шторки кондиционером не поддерживается. - Все остальные параметры [климатического устройства](https://esphome.io/components/climate/index.html#base-climate-configuration) ESPHome. +## Действия: ## +### ``aux_ac.display_on`` ### +Включение экрана температуры на лицевой панели кондиционера. + +```yaml +on_...: + then: + - aux_ac.display_on: aux_ac_id +``` +- **aux_ac_id** (**Обязательный**, строка): ID компонента `aux_ac`. + +### ``aux_ac.display_off`` ### +Выключение экрана температуры на лицевой панели кондиционера. + +```yaml +on_...: + then: + - aux_ac.display_off: aux_ac_id +``` +- **aux_ac_id** (**Обязательный**, строка): ID компонента `aux_ac`. + + + ## Простейший пример ## Исходный код простейшего примера можно найти в файле [aux_ac_simple.yaml](https://github.com/GrKoR/esphome_aux_ac_component/blob/master/examples/simple/aux_ac_simple.yaml). From dc91e7b19efcdb40584dcac28ed3626be671c345 Mon Sep 17 00:00:00 2001 From: GrKoR Date: Fri, 8 Apr 2022 16:44:25 +0300 Subject: [PATCH 3/6] Docs for actions display_on & display_off --- README-EN.md | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/README-EN.md b/README-EN.md index 387b71a..08282d5 100644 --- a/README-EN.md +++ b/README-EN.md @@ -137,6 +137,27 @@ climate: - **supported_swing_modes** (*Optional*, list): List of supported swing modes. Possible values are: ``VERTICAL``, ``HORIZONTAL``, ``BOTH``. No swing modes by default. - All other options from [Climate](https://esphome.io/components/climate/index.html#base-climate-configuration). +## Actions: ## +### ``aux_ac.display_on`` ### +This action turns a HVAC temperature display on when executed. + +```yaml +on_...: + then: + - aux_ac.display_on: aux_ac_id +``` +- **aux_ac_id** (**Requared**, string): ID of `aux_ac` component. + +### ``aux_ac.display_off`` ### +This action turns a HVAC temperature display off when executed. + +```yaml +on_...: + then: + - aux_ac.display_off: aux_ac_id +``` +- **aux_ac_id** (**Requared**, string): ID of `aux_ac` component. + ## Simple example ## The source code of this example is located in the [aux_ac_simple.yaml](https://github.com/GrKoR/esphome_aux_ac_component/blob/master/examples/simple/aux_ac_simple.yaml) file. From 1a9a91ef93efb873b3757139eb61759b7ea153cb Mon Sep 17 00:00:00 2001 From: GrKoR Date: Mon, 18 Apr 2022 00:04:24 +0300 Subject: [PATCH 4/6] display state sensor was added; Idea HVAC was tested --- README-EN.md | 17 +++++++++++++---- README.md | 17 +++++++++++++---- components/aux_ac/aux_ac.h | 33 +++++++++++++++++++++++++++++++++ components/aux_ac/climate.py | 21 +++++++++++++++++++-- docs/AC_TESTED.md | 1 + 5 files changed, 79 insertions(+), 10 deletions(-) diff --git a/README-EN.md b/README-EN.md index 08282d5..2a0ca72 100644 --- a/README-EN.md +++ b/README-EN.md @@ -89,6 +89,10 @@ climate: name: AC Indoor Temperature id: ac_indoor_temp internal: true + display_state: + name: AC Display + id: ac_display + internal: false visual: min_temperature: 16 max_temperature: 32 @@ -130,6 +134,11 @@ climate: - **id** (*Optional*, [ID](https://esphome.io/guides/configuration-types.html#config-id)): Set the ID of this sensor for use in lambdas. - **internal** (*Optional*, boolean): Mark this component as internal. Internal components will not be exposed to the frontend (like Home Assistant). As opposed to default [Sensor](https://esphome.io/components/sensor/index.html#base-sensor-configuration) behaviour this variable is **always true** except in cases where the user has set it directly. - All other options from [Sensor](https://esphome.io/components/sensor/index.html#base-sensor-configuration). +- **display_state** (*Optional*): The information for the HVAC display state sensor (is display ON or OFF) + - **name** (**Required**, string): The name for the display state sensor. + - **id** (*Optional*, [ID](https://esphome.io/guides/configuration-types.html#config-id)): Set the ID of this sensor for use in lambdas. + - **internal** (*Optional*, boolean): Mark this component as internal. Internal components will not be exposed to the frontend (like Home Assistant). As opposed to default [Binary Sensor](https://esphome.io/components/binary_sensor/index.html#base-binary-sensor-configuration) behaviour this variable is **always true** except in cases where the user has set it directly. + - All other options from [Binary Sensor](https://esphome.io/components/binary_sensor/index.html#base-binary-sensor-configuration). - **supported_modes** (*Optional*, list): List of supported modes. Possible values are: ``HEAT_COOL``, ``COOL``, ``HEAT``, ``DRY``, ``FAN_ONLY``. Please note: some manufacturers call AUTO mode instead of HEAT_COOL. Defaults to ``FAN_ONLY``. - **custom_fan_modes** (*Optional*, list): List of supported custom fan modes. Possible values are: ``MUTE``, ``TURBO``. No custom fan modes by default. - **supported_presets** (*Optional*, list): List of supported presets. Possible values are: ``SLEEP``. No presets by default. @@ -144,9 +153,9 @@ This action turns a HVAC temperature display on when executed. ```yaml on_...: then: - - aux_ac.display_on: aux_ac_id + - aux_ac.display_on: aux_id ``` -- **aux_ac_id** (**Requared**, string): ID of `aux_ac` component. +- **aux_id** (**Requared**, string): ID of `aux_ac` component. ### ``aux_ac.display_off`` ### This action turns a HVAC temperature display off when executed. @@ -154,9 +163,9 @@ This action turns a HVAC temperature display off when executed. ```yaml on_...: then: - - aux_ac.display_off: aux_ac_id + - aux_ac.display_off: aux_id ``` -- **aux_ac_id** (**Requared**, string): ID of `aux_ac` component. +- **aux_id** (**Requared**, string): ID of `aux_ac` component. ## Simple example ## diff --git a/README.md b/README.md index 3b5a2a8..26dc263 100644 --- a/README.md +++ b/README.md @@ -91,6 +91,10 @@ climate: name: AC Indoor Temperature id: ac_indoor_temp internal: true + display_state: + name: AC Display + id: ac_display + internal: false visual: min_temperature: 16 max_temperature: 32 @@ -132,6 +136,11 @@ climate: - **id** (*Опциональный*, [ID](https://esphome.io/guides/configuration-types.html#config-id)): Можно указать свой ID для датчика для использования в лямбдах. - **internal** (*Опциональный*, логическое): Пометить данный датчик как внутренний. Внутренний датчик не будет передаваться во фронтэнд (такой как Home Assistant). В противоположность стандартному поведению [сенсоров](https://esphome.io/components/sensor/index.html#base-sensor-configuration) этот параметр для датчика в кондиционере **всегда выставлен в true** за исключением случаев, когда пользователь не установил его в `false`. То есть по умолчанию значение сенсора не будет передаваться во фронтенд даже если указано `name` для сенсора. - Все остальные параметры [сенсора](https://esphome.io/components/sensor/index.html#base-sensor-configuration) ESPHome. +- **display_state** (*Опциональный*): Параметры создаваемого датчика дисплея (включен или выключен), если такой датчик нужен. + - **name** (**Обязательный**, строка): Имя датчика дисплея. + - **id** (*Опциональный*, [ID](https://esphome.io/guides/configuration-types.html#config-id)): Можно указать свой ID для датчика для использования в лямбдах. + - **internal** (*Опциональный*, логическое): Пометить данный датчик как внутренний. Внутренний датчик не будет передаваться во фронтэнд (такой как Home Assistant). В противоположность стандартному поведению [бинарных сенсоров](https://esphome.io/components/binary_sensor/index.html#base-binary-sensor-configuration) этот параметр для датчика в кондиционере **всегда выставлен в true** за исключением случаев, когда пользователь не установил его в `false`. То есть по умолчанию значение сенсора не будет передаваться во фронтенд даже если указано `name` для сенсора. + - Все остальные параметры [бинарного сенсора](https://esphome.io/components/binary_sensor/index.html#base-binary-sensor-configuration) ESPHome. - **supported_modes** (*Опциональный*, список): Список поддерживаемых режимов работы. Возможные значения: ``HEAT_COOL``, ``COOL``, ``HEAT``, ``DRY``, ``FAN_ONLY``. Обратите внимание: некоторые производители кондиционеров указывают на пульте режим AUTO, хотя по факту этот режим не работает по расписанию и только лишь поддерживает целевую температуру. Такой режим в ESPHome называется HEAT_COOL. По умолчанию список содержит только значение ``FAN_ONLY``. - **custom_fan_modes** (*Опциональный*, список): Список поддерживаемых дополнительных режимов вентилятора. Возможные значения: ``MUTE``, ``TURBO``. По умолчанию никакие дополнительные режимы не установлены. - **supported_presets** (*Опциональный*, список): Список поддерживаемых базовых функций кондиционера. Возможные значения: ``SLEEP``. По умолчанию никакие базовые функции не установлены. @@ -146,9 +155,9 @@ climate: ```yaml on_...: then: - - aux_ac.display_on: aux_ac_id + - aux_ac.display_on: aux_id ``` -- **aux_ac_id** (**Обязательный**, строка): ID компонента `aux_ac`. +- **aux_id** (**Обязательный**, строка): ID компонента `aux_ac`. ### ``aux_ac.display_off`` ### Выключение экрана температуры на лицевой панели кондиционера. @@ -156,9 +165,9 @@ on_...: ```yaml on_...: then: - - aux_ac.display_off: aux_ac_id + - aux_ac.display_off: aux_id ``` -- **aux_ac_id** (**Обязательный**, строка): ID компонента `aux_ac`. +- **aux_id** (**Обязательный**, строка): ID компонента `aux_ac`. diff --git a/components/aux_ac/aux_ac.h b/components/aux_ac/aux_ac.h index 23150a0..850e57c 100644 --- a/components/aux_ac/aux_ac.h +++ b/components/aux_ac/aux_ac.h @@ -11,6 +11,7 @@ #include "esphome/components/climate/climate.h" #include "esphome/components/uart/uart.h" #include "esphome/components/sensor/sensor.h" +#include "esphome/components/binary_sensor/binary_sensor.h" #include "esphome/core/helpers.h" namespace esphome { @@ -1575,6 +1576,9 @@ class AirCon : public esphome::Component, public esphome::climate::Climate { // TODO: если расшифруем формулу для уличной температуры, то можно будет вернуть //esphome::sensor::Sensor *sensor_outdoor_temperature = new esphome::sensor::Sensor(); + // бинарный сенсор, отображающий состояние дисплея + esphome::binary_sensor::BinarySensor *sensor_display_ = nullptr; + public: // инициализация объекта void initAC(esphome::uart::UARTComponent *parent = nullptr){ @@ -1600,6 +1604,7 @@ class AirCon : public esphome::Component, public esphome::climate::Climate { float get_setup_priority() const override { return esphome::setup_priority::DATA; } void set_indoor_temperature_sensor(sensor::Sensor *temperature_sensor) { sensor_indoor_temperature_ = temperature_sensor; } + void set_display_sensor(binary_sensor::BinarySensor *display_sensor) { sensor_display_ = display_sensor; } bool get_hw_initialized(){ return _hw_initialized; }; bool get_has_connection(){ return _has_connection; }; @@ -1848,6 +1853,22 @@ class AirCon : public esphome::Component, public esphome::climate::Climate { // температура уличного блока // TODO: если расшифруем формулу для уличной температуры, то можно будет вернуть //sensor_outdoor_temperature->publish_state(_current_ac_state.temp_outdoor); + + // состояние дисплея + if (sensor_display_ != nullptr) + switch (_current_ac_state.display) { + case AC_DISPLAY_ON: + sensor_display_->publish_state(true); + break; + + case AC_DISPLAY_OFF: + sensor_display_->publish_state(false); + break; + + default: + // могут быть и другие состояния, поэтому так + break; + } } // вывод в дебаг текущей конфигурации компонента @@ -1874,6 +1895,18 @@ class AirCon : public esphome::Component, public esphome::climate::Climate { ESP_LOGV(Constants::TAG, "%s Force Update: YES", " "); } } + if ((this->sensor_display_) != nullptr) { + ESP_LOGCONFIG(Constants::TAG, "%s%s '%s'", " ", LOG_STR_LITERAL("Display"), (this->sensor_display_)->get_name().c_str()); + if (!(this->sensor_display_)->get_device_class().empty()) { + ESP_LOGCONFIG(Constants::TAG, "%s Device Class: '%s'", " ", (this->sensor_display_)->get_device_class().c_str()); + } + if (!(this->sensor_display_)->get_icon().empty()) { + ESP_LOGCONFIG(Constants::TAG, "%s Icon: '%s'", " ", (this->sensor_display_)->get_icon().c_str()); + } + if (!(this->sensor_display_)->get_object_id().empty()) { + ESP_LOGV(Constants::TAG, "%s Object ID: '%s'", " ", (this->sensor_display_)->get_object_id().c_str()); + } + } this->dump_traits_(Constants::TAG); } diff --git a/components/aux_ac/climate.py b/components/aux_ac/climate.py index b9eec4e..0b7b0d9 100644 --- a/components/aux_ac/climate.py +++ b/components/aux_ac/climate.py @@ -1,7 +1,7 @@ import logging import esphome.config_validation as cv import esphome.codegen as cg -from esphome.components import climate, uart, sensor +from esphome.components import climate, uart, sensor, binary_sensor from esphome import automation from esphome.automation import maybe_simple_id from esphome.const import ( @@ -15,6 +15,7 @@ from esphome.const import ( ICON_THERMOMETER, DEVICE_CLASS_TEMPERATURE, STATE_CLASS_MEASUREMENT, + DEVICE_CLASS_EMPTY, ) from esphome.components.climate import ( ClimateMode, @@ -26,13 +27,16 @@ _LOGGER = logging.getLogger(__name__) CODEOWNERS = ["@GrKoR"] DEPENDENCIES = ["climate", "uart"] -AUTO_LOAD = ["sensor"] +AUTO_LOAD = ["sensor", "binary_sensor"] CONF_SUPPORTED_MODES = 'supported_modes' CONF_SUPPORTED_SWING_MODES = 'supported_swing_modes' CONF_SUPPORTED_PRESETS = 'supported_presets' CONF_SHOW_ACTION = 'show_action' CONF_INDOOR_TEMPERATURE = 'indoor_temperature' +CONF_DISPLAY_STATE = 'display_state' + +ICON_DISPLAY = "mdi:numeric" aux_ac_ns = cg.esphome_ns.namespace("aux_ac") AirCon = aux_ac_ns.class_("AirCon", climate.Climate, cg.Component) @@ -97,6 +101,14 @@ CONFIG_SCHEMA = cv.All( cv.Optional(CONF_INTERNAL, default="true"): cv.boolean, } ), + cv.Optional(CONF_DISPLAY_STATE): binary_sensor.binary_sensor_schema( + icon=ICON_DISPLAY, + device_class=DEVICE_CLASS_EMPTY, + ).extend( + { + cv.Optional(CONF_INTERNAL, default="true"): cv.boolean, + } + ), cv.Optional(CONF_SUPPORTED_MODES): cv.ensure_list(validate_modes), cv.Optional(CONF_SUPPORTED_SWING_MODES): cv.ensure_list(validate_swing_modes), cv.Optional(CONF_SUPPORTED_PRESETS): cv.ensure_list(validate_presets), @@ -124,6 +136,11 @@ async def to_code(config): sens = await sensor.new_sensor(conf) cg.add(var.set_indoor_temperature_sensor(sens)) + if CONF_DISPLAY_STATE in config: + conf = config[CONF_DISPLAY_STATE] + sens = await binary_sensor.new_binary_sensor(conf) + cg.add(var.set_display_sensor(sens)) + cg.add(var.set_period(config[CONF_PERIOD].total_milliseconds)) cg.add(var.set_show_action(config[CONF_SHOW_ACTION])) if CONF_SUPPORTED_MODES in config: diff --git a/docs/AC_TESTED.md b/docs/AC_TESTED.md index 3192cc7..9d0553a 100644 --- a/docs/AC_TESTED.md +++ b/docs/AC_TESTED.md @@ -6,6 +6,7 @@ + Centek (models: CT-65Q09, CT-65Z10) + Energolux (models: SASxxBN1-Al see Note below) + Hyundai (models: H-AR21-07H, H-AR21-09H) ++ Idea (models: ISR-12HR-SA7-DN1 ION) + IGC (models: RAK-07NH multysplit) + Roda (models: RS-AL09F) + Rovex (models: RS-07ALS1, RS-09ALS1, RS-12ALS1) From 6f4fe78732045aa8e76badb6e5e1148aadd3270f Mon Sep 17 00:00:00 2001 From: GrKoR Date: Mon, 18 Apr 2022 01:42:44 +0300 Subject: [PATCH 5/6] v.0.2.1 - display state --- components/aux_ac/aux_ac.h | 2 +- components/aux_ac/climate.py | 6 ++---- tests/test-ext.yaml | 21 ++++++++++++++++++++- 3 files changed, 23 insertions(+), 6 deletions(-) diff --git a/components/aux_ac/aux_ac.h b/components/aux_ac/aux_ac.h index 850e57c..baa9133 100644 --- a/components/aux_ac/aux_ac.h +++ b/components/aux_ac/aux_ac.h @@ -49,7 +49,7 @@ public: static const uint32_t AC_STATES_REQUEST_INTERVAL; }; -const std::string Constants::AC_ROVEX_FIRMWARE_VERSION = "0.2.0"; +const std::string Constants::AC_ROVEX_FIRMWARE_VERSION = "0.2.1"; const char *const Constants::TAG = "AirCon"; const std::string Constants::MUTE = "mute"; const std::string Constants::TURBO = "turbo"; diff --git a/components/aux_ac/climate.py b/components/aux_ac/climate.py index 0b7b0d9..c781771 100644 --- a/components/aux_ac/climate.py +++ b/components/aux_ac/climate.py @@ -15,7 +15,6 @@ from esphome.const import ( ICON_THERMOMETER, DEVICE_CLASS_TEMPERATURE, STATE_CLASS_MEASUREMENT, - DEVICE_CLASS_EMPTY, ) from esphome.components.climate import ( ClimateMode, @@ -102,11 +101,10 @@ CONFIG_SCHEMA = cv.All( } ), cv.Optional(CONF_DISPLAY_STATE): binary_sensor.binary_sensor_schema( - icon=ICON_DISPLAY, - device_class=DEVICE_CLASS_EMPTY, + icon=ICON_DISPLAY ).extend( { - cv.Optional(CONF_INTERNAL, default="true"): cv.boolean, + cv.Optional(CONF_INTERNAL, default="true"): cv.boolean } ), cv.Optional(CONF_SUPPORTED_MODES): cv.ensure_list(validate_modes), diff --git a/tests/test-ext.yaml b/tests/test-ext.yaml index b31e10e..718bb64 100644 --- a/tests/test-ext.yaml +++ b/tests/test-ext.yaml @@ -60,6 +60,10 @@ climate: name: AC Indoor Temperature id: ac_indoor_temp internal: false # сенсор установлен как внутренний по дефолту (не попадёт в Home Assistant) + display_state: + name: AC Display State + id: ac_display_state + internal: false # сенсор установлен как внутренний по дефолту (не попадёт в Home Assistant) visual: min_temperature: 16 max_temperature: 32 @@ -83,4 +87,19 @@ climate: supported_swing_modes: - VERTICAL - HORIZONTAL - - BOTH \ No newline at end of file + - BOTH + + +switch: + - platform: template + name: AC Display + lambda: |- + if (ac_display_state).state) { + return true; + } else { + return false; + } + turn_on_action: + - aux_ac.display_on: aux_id + turn_off_action: + - aux_ac.display_off: aux_id \ No newline at end of file From dc592ef678202b3aebd040117605ded2fabd9ea5 Mon Sep 17 00:00:00 2001 From: GrKoR Date: Mon, 18 Apr 2022 01:50:30 +0300 Subject: [PATCH 6/6] advanced example for v.0.2.1 updated --- examples/advanced/ac_common.yaml | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/examples/advanced/ac_common.yaml b/examples/advanced/ac_common.yaml index 666b8a0..b10d636 100644 --- a/examples/advanced/ac_common.yaml +++ b/examples/advanced/ac_common.yaml @@ -65,8 +65,12 @@ climate: show_action: true indoor_temperature: name: ${upper_devicename} AC Indoor Temperature - id: ac_indoor_temp - internal: true + id: ${devicename}_indoor_temp + internal: false + display_state: + name: $upper_devicename Display State + id: ${devicename}_display_state + internal: false visual: min_temperature: 16 max_temperature: 32 @@ -100,3 +104,18 @@ sensor: update_interval: 30s unit_of_measurement: "dBa" accuracy_decimals: 0 + + +switch: + - platform: template + name: $upper_devicename Display + lambda: |- + if (id(${devicename}_display_state).state) { + return true; + } else { + return false; + } + turn_on_action: + - aux_ac.display_on: aux_id + turn_off_action: + - aux_ac.display_off: aux_id \ No newline at end of file