mirror of
https://github.com/GrKoR/esphome_aux_ac_component.git
synced 2025-12-06 19:46:57 +03:00
display state sensor was added; Idea HVAC was tested
This commit is contained in:
17
README-EN.md
17
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 ##
|
||||
|
||||
17
README.md
17
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`.
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
}
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
+ Centek (models: CT-65Q09, CT-65Z10)
|
||||
+ Energolux (models: SAS09Z4-AI, SASxxBN1-AI 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)
|
||||
|
||||
Reference in New Issue
Block a user