mirror of
https://github.com/GrKoR/esphome_aux_ac_component.git
synced 2025-12-12 22:47:06 +03:00
Merge pull request #28 from GrKoR/GrKoR/issue15
This commit is contained in:
30
README-EN.md
30
README-EN.md
@@ -89,6 +89,10 @@ climate:
|
|||||||
name: AC Indoor Temperature
|
name: AC Indoor Temperature
|
||||||
id: ac_indoor_temp
|
id: ac_indoor_temp
|
||||||
internal: true
|
internal: true
|
||||||
|
display_state:
|
||||||
|
name: AC Display
|
||||||
|
id: ac_display
|
||||||
|
internal: false
|
||||||
visual:
|
visual:
|
||||||
min_temperature: 16
|
min_temperature: 16
|
||||||
max_temperature: 32
|
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.
|
- **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.
|
- **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).
|
- 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``.
|
- **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.
|
- **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.
|
- **supported_presets** (*Optional*, list): List of supported presets. Possible values are: ``SLEEP``. No presets by default.
|
||||||
@@ -137,6 +146,27 @@ climate:
|
|||||||
- **supported_swing_modes** (*Optional*, list): List of supported swing modes. Possible values are: ``VERTICAL``, ``HORIZONTAL``, ``BOTH``. No swing modes by default.
|
- **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).
|
- 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_id
|
||||||
|
```
|
||||||
|
- **aux_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_id
|
||||||
|
```
|
||||||
|
- **aux_id** (**Requared**, string): ID of `aux_ac` component.
|
||||||
|
|
||||||
|
|
||||||
## Simple example ##
|
## 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.
|
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.
|
||||||
|
|||||||
32
README.md
32
README.md
@@ -91,6 +91,10 @@ climate:
|
|||||||
name: AC Indoor Temperature
|
name: AC Indoor Temperature
|
||||||
id: ac_indoor_temp
|
id: ac_indoor_temp
|
||||||
internal: true
|
internal: true
|
||||||
|
display_state:
|
||||||
|
name: AC Display
|
||||||
|
id: ac_display
|
||||||
|
internal: false
|
||||||
visual:
|
visual:
|
||||||
min_temperature: 16
|
min_temperature: 16
|
||||||
max_temperature: 32
|
max_temperature: 32
|
||||||
@@ -132,6 +136,11 @@ climate:
|
|||||||
- **id** (*Опциональный*, [ID](https://esphome.io/guides/configuration-types.html#config-id)): Можно указать свой ID для датчика для использования в лямбдах.
|
- **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` для сенсора.
|
- **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.
|
- Все остальные параметры [сенсора](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``.
|
- **supported_modes** (*Опциональный*, список): Список поддерживаемых режимов работы. Возможные значения: ``HEAT_COOL``, ``COOL``, ``HEAT``, ``DRY``, ``FAN_ONLY``. Обратите внимание: некоторые производители кондиционеров указывают на пульте режим AUTO, хотя по факту этот режим не работает по расписанию и только лишь поддерживает целевую температуру. Такой режим в ESPHome называется HEAT_COOL. По умолчанию список содержит только значение ``FAN_ONLY``.
|
||||||
- **custom_fan_modes** (*Опциональный*, список): Список поддерживаемых дополнительных режимов вентилятора. Возможные значения: ``MUTE``, ``TURBO``. По умолчанию никакие дополнительные режимы не установлены.
|
- **custom_fan_modes** (*Опциональный*, список): Список поддерживаемых дополнительных режимов вентилятора. Возможные значения: ``MUTE``, ``TURBO``. По умолчанию никакие дополнительные режимы не установлены.
|
||||||
- **supported_presets** (*Опциональный*, список): Список поддерживаемых базовых функций кондиционера. Возможные значения: ``SLEEP``. По умолчанию никакие базовые функции не установлены.
|
- **supported_presets** (*Опциональный*, список): Список поддерживаемых базовых функций кондиционера. Возможные значения: ``SLEEP``. По умолчанию никакие базовые функции не установлены.
|
||||||
@@ -139,6 +148,29 @@ climate:
|
|||||||
- **supported_swing_modes** (*Опциональный*, список): Список поддерживаемых режимов качания шторки. Возможные значения: ``VERTICAL``, ``HORIZONTAL``, ``BOTH``. По умолчанию устанавливается, что качание шторки кондиционером не поддерживается.
|
- **supported_swing_modes** (*Опциональный*, список): Список поддерживаемых режимов качания шторки. Возможные значения: ``VERTICAL``, ``HORIZONTAL``, ``BOTH``. По умолчанию устанавливается, что качание шторки кондиционером не поддерживается.
|
||||||
- Все остальные параметры [климатического устройства](https://esphome.io/components/climate/index.html#base-climate-configuration) ESPHome.
|
- Все остальные параметры [климатического устройства](https://esphome.io/components/climate/index.html#base-climate-configuration) ESPHome.
|
||||||
|
|
||||||
|
## Действия: ##
|
||||||
|
### ``aux_ac.display_on`` ###
|
||||||
|
Включение экрана температуры на лицевой панели кондиционера.
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
on_...:
|
||||||
|
then:
|
||||||
|
- aux_ac.display_on: aux_id
|
||||||
|
```
|
||||||
|
- **aux_id** (**Обязательный**, строка): ID компонента `aux_ac`.
|
||||||
|
|
||||||
|
### ``aux_ac.display_off`` ###
|
||||||
|
Выключение экрана температуры на лицевой панели кондиционера.
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
on_...:
|
||||||
|
then:
|
||||||
|
- aux_ac.display_off: aux_id
|
||||||
|
```
|
||||||
|
- **aux_id** (**Обязательный**, строка): ID компонента `aux_ac`.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## Простейший пример ##
|
## Простейший пример ##
|
||||||
Исходный код простейшего примера можно найти в файле [aux_ac_simple.yaml](https://github.com/GrKoR/esphome_aux_ac_component/blob/master/examples/simple/aux_ac_simple.yaml).
|
Исходный код простейшего примера можно найти в файле [aux_ac_simple.yaml](https://github.com/GrKoR/esphome_aux_ac_component/blob/master/examples/simple/aux_ac_simple.yaml).
|
||||||
|
|||||||
35
components/aux_ac/automation.h
Normal file
35
components/aux_ac/automation.h
Normal file
@@ -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 <typename... Ts>
|
||||||
|
class AirConDisplayOffAction : public Action<Ts...>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
explicit AirConDisplayOffAction(AirCon *ac) : ac_(ac) {}
|
||||||
|
|
||||||
|
void play(Ts... x) override { this->ac_->displaySequence(AC_DISPLAY_OFF); }
|
||||||
|
|
||||||
|
protected:
|
||||||
|
AirCon *ac_;
|
||||||
|
};
|
||||||
|
|
||||||
|
template <typename... Ts>
|
||||||
|
class AirConDisplayOnAction : public Action<Ts...>
|
||||||
|
{
|
||||||
|
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
|
||||||
@@ -11,6 +11,7 @@
|
|||||||
#include "esphome/components/climate/climate.h"
|
#include "esphome/components/climate/climate.h"
|
||||||
#include "esphome/components/uart/uart.h"
|
#include "esphome/components/uart/uart.h"
|
||||||
#include "esphome/components/sensor/sensor.h"
|
#include "esphome/components/sensor/sensor.h"
|
||||||
|
#include "esphome/components/binary_sensor/binary_sensor.h"
|
||||||
#include "esphome/core/helpers.h"
|
#include "esphome/core/helpers.h"
|
||||||
|
|
||||||
namespace esphome {
|
namespace esphome {
|
||||||
@@ -26,7 +27,7 @@ using climate::ClimateFanMode;
|
|||||||
|
|
||||||
class Constants {
|
class Constants {
|
||||||
public:
|
public:
|
||||||
static const std::string AC_ROVEX_FIRMWARE_VERSION;
|
static const std::string AC_FIRMWARE_VERSION;
|
||||||
|
|
||||||
static const char *const TAG;
|
static const char *const TAG;
|
||||||
static const std::string MUTE;
|
static const std::string MUTE;
|
||||||
@@ -48,7 +49,7 @@ public:
|
|||||||
static const uint32_t AC_STATES_REQUEST_INTERVAL;
|
static const uint32_t AC_STATES_REQUEST_INTERVAL;
|
||||||
};
|
};
|
||||||
|
|
||||||
const std::string Constants::AC_ROVEX_FIRMWARE_VERSION = "0.2.0";
|
const std::string Constants::AC_FIRMWARE_VERSION = "0.2.1";
|
||||||
const char *const Constants::TAG = "AirCon";
|
const char *const Constants::TAG = "AirCon";
|
||||||
const std::string Constants::MUTE = "mute";
|
const std::string Constants::MUTE = "mute";
|
||||||
const std::string Constants::TURBO = "turbo";
|
const std::string Constants::TURBO = "turbo";
|
||||||
@@ -1575,6 +1576,9 @@ class AirCon : public esphome::Component, public esphome::climate::Climate {
|
|||||||
// TODO: если расшифруем формулу для уличной температуры, то можно будет вернуть
|
// TODO: если расшифруем формулу для уличной температуры, то можно будет вернуть
|
||||||
//esphome::sensor::Sensor *sensor_outdoor_temperature = new esphome::sensor::Sensor();
|
//esphome::sensor::Sensor *sensor_outdoor_temperature = new esphome::sensor::Sensor();
|
||||||
|
|
||||||
|
// бинарный сенсор, отображающий состояние дисплея
|
||||||
|
esphome::binary_sensor::BinarySensor *sensor_display_ = nullptr;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// инициализация объекта
|
// инициализация объекта
|
||||||
void initAC(esphome::uart::UARTComponent *parent = nullptr){
|
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; }
|
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_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_hw_initialized(){ return _hw_initialized; };
|
||||||
bool get_has_connection(){ return _has_connection; };
|
bool get_has_connection(){ return _has_connection; };
|
||||||
@@ -1848,12 +1853,28 @@ class AirCon : public esphome::Component, public esphome::climate::Climate {
|
|||||||
// температура уличного блока
|
// температура уличного блока
|
||||||
// TODO: если расшифруем формулу для уличной температуры, то можно будет вернуть
|
// TODO: если расшифруем формулу для уличной температуры, то можно будет вернуть
|
||||||
//sensor_outdoor_temperature->publish_state(_current_ac_state.temp_outdoor);
|
//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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// вывод в дебаг текущей конфигурации компонента
|
// вывод в дебаг текущей конфигурации компонента
|
||||||
void dump_config() {
|
void dump_config() {
|
||||||
ESP_LOGCONFIG(Constants::TAG, "AUX HVAC:");
|
ESP_LOGCONFIG(Constants::TAG, "AUX HVAC:");
|
||||||
ESP_LOGCONFIG(Constants::TAG, " [x] Firmware version: %s", Constants::AC_ROVEX_FIRMWARE_VERSION.c_str());
|
ESP_LOGCONFIG(Constants::TAG, " [x] Firmware version: %s", Constants::AC_FIRMWARE_VERSION.c_str());
|
||||||
ESP_LOGCONFIG(Constants::TAG, " [x] Period: %dms", this->get_period());
|
ESP_LOGCONFIG(Constants::TAG, " [x] Period: %dms", this->get_period());
|
||||||
ESP_LOGCONFIG(Constants::TAG, " [x] Show action: %s", this->get_show_action() ? "true" : "false");
|
ESP_LOGCONFIG(Constants::TAG, " [x] Show action: %s", this->get_show_action() ? "true" : "false");
|
||||||
if ((this->sensor_indoor_temperature_) != nullptr) {
|
if ((this->sensor_indoor_temperature_) != nullptr) {
|
||||||
@@ -1874,6 +1895,18 @@ class AirCon : public esphome::Component, public esphome::climate::Climate {
|
|||||||
ESP_LOGV(Constants::TAG, "%s Force Update: YES", " ");
|
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);
|
this->dump_traits_(Constants::TAG);
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -2352,6 +2385,36 @@ class AirCon : public esphome::Component, public esphome::climate::Climate {
|
|||||||
return true;
|
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; };
|
void set_period(uint32_t ms) { this->_update_period = ms; };
|
||||||
uint32_t get_period() { return this->_update_period; };
|
uint32_t get_period() { return this->_update_period; };
|
||||||
void set_show_action(bool show_action) { this->_show_action = show_action; };
|
void set_show_action(bool show_action) { this->_show_action = show_action; };
|
||||||
@@ -2401,16 +2464,6 @@ class AirCon : public esphome::Component, public esphome::climate::Climate {
|
|||||||
if (get_has_connection()) getStatusBigAndSmall();
|
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);
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
import logging
|
import logging
|
||||||
import esphome.config_validation as cv
|
import esphome.config_validation as cv
|
||||||
import esphome.codegen as cg
|
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 (
|
from esphome.const import (
|
||||||
CONF_ID,
|
CONF_ID,
|
||||||
CONF_UART_ID,
|
CONF_UART_ID,
|
||||||
@@ -19,22 +21,29 @@ from esphome.components.climate import (
|
|||||||
ClimatePreset,
|
ClimatePreset,
|
||||||
ClimateSwingMode,
|
ClimateSwingMode,
|
||||||
)
|
)
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
CODEOWNERS = ["@GrKoR"]
|
CODEOWNERS = ["@GrKoR"]
|
||||||
DEPENDENCIES = ["climate", "uart"]
|
DEPENDENCIES = ["climate", "uart"]
|
||||||
AUTO_LOAD = ["sensor"]
|
AUTO_LOAD = ["sensor", "binary_sensor"]
|
||||||
|
|
||||||
CONF_SUPPORTED_MODES = 'supported_modes'
|
CONF_SUPPORTED_MODES = 'supported_modes'
|
||||||
CONF_SUPPORTED_SWING_MODES = 'supported_swing_modes'
|
CONF_SUPPORTED_SWING_MODES = 'supported_swing_modes'
|
||||||
CONF_SUPPORTED_PRESETS = 'supported_presets'
|
CONF_SUPPORTED_PRESETS = 'supported_presets'
|
||||||
CONF_SHOW_ACTION = 'show_action'
|
CONF_SHOW_ACTION = 'show_action'
|
||||||
CONF_INDOOR_TEMPERATURE = 'indoor_temperature'
|
CONF_INDOOR_TEMPERATURE = 'indoor_temperature'
|
||||||
|
CONF_DISPLAY_STATE = 'display_state'
|
||||||
|
|
||||||
|
ICON_DISPLAY = "mdi:numeric"
|
||||||
|
|
||||||
aux_ac_ns = cg.esphome_ns.namespace("aux_ac")
|
aux_ac_ns = cg.esphome_ns.namespace("aux_ac")
|
||||||
AirCon = aux_ac_ns.class_("AirCon", climate.Climate, cg.Component)
|
AirCon = aux_ac_ns.class_("AirCon", climate.Climate, cg.Component)
|
||||||
Capabilities = aux_ac_ns.namespace("Constants")
|
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 = {
|
ALLOWED_CLIMATE_MODES = {
|
||||||
"HEAT_COOL": ClimateMode.CLIMATE_MODE_HEAT_COOL,
|
"HEAT_COOL": ClimateMode.CLIMATE_MODE_HEAT_COOL,
|
||||||
"COOL": ClimateMode.CLIMATE_MODE_COOL,
|
"COOL": ClimateMode.CLIMATE_MODE_COOL,
|
||||||
@@ -91,6 +100,13 @@ CONFIG_SCHEMA = cv.All(
|
|||||||
cv.Optional(CONF_INTERNAL, default="true"): cv.boolean,
|
cv.Optional(CONF_INTERNAL, default="true"): cv.boolean,
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
|
cv.Optional(CONF_DISPLAY_STATE): binary_sensor.binary_sensor_schema(
|
||||||
|
icon=ICON_DISPLAY
|
||||||
|
).extend(
|
||||||
|
{
|
||||||
|
cv.Optional(CONF_INTERNAL, default="true"): cv.boolean
|
||||||
|
}
|
||||||
|
),
|
||||||
cv.Optional(CONF_SUPPORTED_MODES): cv.ensure_list(validate_modes),
|
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_SWING_MODES): cv.ensure_list(validate_swing_modes),
|
||||||
cv.Optional(CONF_SUPPORTED_PRESETS): cv.ensure_list(validate_presets),
|
cv.Optional(CONF_SUPPORTED_PRESETS): cv.ensure_list(validate_presets),
|
||||||
@@ -118,6 +134,11 @@ async def to_code(config):
|
|||||||
sens = await sensor.new_sensor(conf)
|
sens = await sensor.new_sensor(conf)
|
||||||
cg.add(var.set_indoor_temperature_sensor(sens))
|
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_period(config[CONF_PERIOD].total_milliseconds))
|
||||||
cg.add(var.set_show_action(config[CONF_SHOW_ACTION]))
|
cg.add(var.set_show_action(config[CONF_SHOW_ACTION]))
|
||||||
if CONF_SUPPORTED_MODES in config:
|
if CONF_SUPPORTED_MODES in config:
|
||||||
@@ -130,4 +151,21 @@ async def to_code(config):
|
|||||||
cg.add(var.set_custom_presets(config[CONF_CUSTOM_PRESETS]))
|
cg.add(var.set_custom_presets(config[CONF_CUSTOM_PRESETS]))
|
||||||
if CONF_CUSTOM_FAN_MODES in config:
|
if CONF_CUSTOM_FAN_MODES in config:
|
||||||
cg.add(var.set_custom_fan_modes(config[CONF_CUSTOM_FAN_MODES]))
|
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),
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
@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)
|
||||||
@@ -6,6 +6,7 @@
|
|||||||
+ Centek (models: CT-65Q09, CT-65Z10)
|
+ Centek (models: CT-65Q09, CT-65Z10)
|
||||||
+ Energolux (models: SAS09Z4-AI, SASxxBN1-AI see Note below)
|
+ Energolux (models: SAS09Z4-AI, SASxxBN1-AI see Note below)
|
||||||
+ Hyundai (models: H-AR21-07H, H-AR21-09H)
|
+ Hyundai (models: H-AR21-07H, H-AR21-09H)
|
||||||
|
+ Idea (models: ISR-12HR-SA7-DN1 ION)
|
||||||
+ IGC (models: RAK-07NH multysplit)
|
+ IGC (models: RAK-07NH multysplit)
|
||||||
+ Roda (models: RS-AL09F)
|
+ Roda (models: RS-AL09F)
|
||||||
+ Rovex (models: RS-07ALS1, RS-09ALS1, RS-12ALS1)
|
+ Rovex (models: RS-07ALS1, RS-09ALS1, RS-12ALS1)
|
||||||
|
|||||||
@@ -65,8 +65,12 @@ climate:
|
|||||||
show_action: true
|
show_action: true
|
||||||
indoor_temperature:
|
indoor_temperature:
|
||||||
name: ${upper_devicename} AC Indoor Temperature
|
name: ${upper_devicename} AC Indoor Temperature
|
||||||
id: ac_indoor_temp
|
id: ${devicename}_indoor_temp
|
||||||
internal: true
|
internal: false
|
||||||
|
display_state:
|
||||||
|
name: $upper_devicename Display State
|
||||||
|
id: ${devicename}_display_state
|
||||||
|
internal: false
|
||||||
visual:
|
visual:
|
||||||
min_temperature: 16
|
min_temperature: 16
|
||||||
max_temperature: 32
|
max_temperature: 32
|
||||||
@@ -100,3 +104,18 @@ sensor:
|
|||||||
update_interval: 30s
|
update_interval: 30s
|
||||||
unit_of_measurement: "dBa"
|
unit_of_measurement: "dBa"
|
||||||
accuracy_decimals: 0
|
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
|
||||||
@@ -60,6 +60,10 @@ climate:
|
|||||||
name: AC Indoor Temperature
|
name: AC Indoor Temperature
|
||||||
id: ac_indoor_temp
|
id: ac_indoor_temp
|
||||||
internal: false # сенсор установлен как внутренний по дефолту (не попадёт в Home Assistant)
|
internal: false # сенсор установлен как внутренний по дефолту (не попадёт в Home Assistant)
|
||||||
|
display_state:
|
||||||
|
name: AC Display State
|
||||||
|
id: ac_display_state
|
||||||
|
internal: false # сенсор установлен как внутренний по дефолту (не попадёт в Home Assistant)
|
||||||
visual:
|
visual:
|
||||||
min_temperature: 16
|
min_temperature: 16
|
||||||
max_temperature: 32
|
max_temperature: 32
|
||||||
@@ -83,4 +87,19 @@ climate:
|
|||||||
supported_swing_modes:
|
supported_swing_modes:
|
||||||
- VERTICAL
|
- VERTICAL
|
||||||
- HORIZONTAL
|
- HORIZONTAL
|
||||||
- BOTH
|
- 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
|
||||||
Reference in New Issue
Block a user