From fc2fd99cec4f7f2125ffe9630c16432e89df77c7 Mon Sep 17 00:00:00 2001 From: GrKoR Date: Thu, 2 Jun 2022 18:48:49 +0300 Subject: [PATCH] new actions: set vertical louver position --- components/aux_ac/automation.h | 91 ++++++++++++++++++ components/aux_ac/aux_ac.h | 46 ++++++++- components/aux_ac/climate.py | 73 +++++++++++--- tests/test-ext-esp32.yaml | 59 +++++++++--- tests/test-ext-for-engineer.yaml | 61 +++++++++--- tests/test-local-arflow-dir.yaml | 159 +++++++++++++++++++++++++++++++ tests/test-local.yaml | 58 ++++++++--- tests/test-minimal.yaml | 8 +- 8 files changed, 497 insertions(+), 58 deletions(-) create mode 100644 tests/test-local-arflow-dir.yaml diff --git a/components/aux_ac/automation.h b/components/aux_ac/automation.h index a62fb27..3af1b52 100644 --- a/components/aux_ac/automation.h +++ b/components/aux_ac/automation.h @@ -7,6 +7,7 @@ namespace esphome { namespace aux_ac { +// **************************************** DISPLAY ACTIONS **************************************** template class AirConDisplayOffAction : public Action { @@ -31,6 +32,96 @@ namespace aux_ac { AirCon *ac_; }; + + +// **************************************** VERTICAL LOUVER ACTIONS **************************************** + template + class AirConVLouverSwingAction : public Action + { + public: + explicit AirConVLouverSwingAction(AirCon *ac) : ac_(ac) {} + + void play(Ts... x) override { this->ac_->setVLouverSwingSequence(); } + + protected: + AirCon *ac_; + }; + + template + class AirConVLouverStopAction : public Action + { + public: + explicit AirConVLouverStopAction(AirCon *ac) : ac_(ac) {} + + void play(Ts... x) override { this->ac_->setVLouverStopSequence(); } + + protected: + AirCon *ac_; + }; + + template + class AirConVLouverTopAction : public Action + { + public: + explicit AirConVLouverTopAction(AirCon *ac) : ac_(ac) {} + + void play(Ts... x) override { this->ac_->setVLouverTopSequence(); } + + protected: + AirCon *ac_; + }; + + template + class AirConVLouverMiddleAboveAction : public Action + { + public: + explicit AirConVLouverMiddleAboveAction(AirCon *ac) : ac_(ac) {} + + void play(Ts... x) override { this->ac_->setVLouverMiddleAboveSequence(); } + + protected: + AirCon *ac_; + }; + + template + class AirConVLouverMiddleAction : public Action + { + public: + explicit AirConVLouverMiddleAction(AirCon *ac) : ac_(ac) {} + + void play(Ts... x) override { this->ac_->setVLouverMiddleSequence(); } + + protected: + AirCon *ac_; + }; + + template + class AirConVLouverMiddleBelowAction : public Action + { + public: + explicit AirConVLouverMiddleBelowAction(AirCon *ac) : ac_(ac) {} + + void play(Ts... x) override { this->ac_->setVLouverMiddleBelowSequence(); } + + protected: + AirCon *ac_; + }; + + template + class AirConVLouverBottomAction : public Action + { + public: + explicit AirConVLouverBottomAction(AirCon *ac) : ac_(ac) {} + + void play(Ts... x) override { this->ac_->setVLouverBottomSequence(); } + + protected: + AirCon *ac_; + }; + + + +// **************************************** SEND TEST PACKET ACTION **************************************** template class AirConSendTestPacketAction : public Action { diff --git a/components/aux_ac/aux_ac.h b/components/aux_ac/aux_ac.h index 2c17922..ab0bca7 100644 --- a/components/aux_ac/aux_ac.h +++ b/components/aux_ac/aux_ac.h @@ -391,7 +391,16 @@ enum ac_sleep : uint8_t { AC_SLEEP_OFF = 0x00, AC_SLEEP_ON = 0x04, AC_SLEEP_UNTO // Вертикальные жалюзи. В протоколе зашита возможность двигать ими по всякому, но должна быть такая возможность на уровне железа. // TODO: надо протестировать значения 0x01, 0x02, 0x03, 0x04, 0x05, 0x06 для ac_louver_V #define AC_LOUVERV_MASK 0b00000111 -enum ac_louver_V : uint8_t { AC_LOUVERV_SWING_UPDOWN = 0x00, AC_LOUVERV_OFF = 0x07, AC_LOUVERV_UNTOUCHED = 0xFF }; +enum ac_louver_V : uint8_t { + AC_LOUVERV_SWING_UPDOWN = 0x00, + AC_LOUVERV_SWING_TOP = 0x01, + AC_LOUVERV_SWING_MIDDLE_ABOVE = 0x02, + AC_LOUVERV_SWING_MIDDLE = 0x03, + AC_LOUVERV_SWING_MIDDLE_BELOW = 0x04, + AC_LOUVERV_SWING_BOTTOM = 0x05, + AC_LOUVERV_OFF = 0x07, + AC_LOUVERV_UNTOUCHED = 0xFF +}; // Горизонтальные жалюзи. В протоколе зашита возможность двигать ими по всякому, но должна быть такая возможность на уровне железа. // TODO: надо протестировать значения 0x20, 0x40, 0x60, 0x80, 0xA0, 0xC0 для ac_louver_H @@ -2945,12 +2954,12 @@ class AirCon : public esphome::Component, public esphome::climate::Climate { /*************************************** set params request ***********************************************/ if (!_addSequenceFuncStep(&AirCon::sq_requestDoCommand, cmd)) { - _debugMsg(F("commandSequence: getBigInfo request sequence step fail."), ESPHOME_LOG_LEVEL_WARN, __LINE__); + _debugMsg(F("commandSequence: request sequence step fail."), ESPHOME_LOG_LEVEL_WARN, __LINE__); return false; } /*************************************** set params control ***********************************************/ if (!_addSequenceFuncStep(&AirCon::sq_controlDoCommand)) { - _debugMsg(F("commandSequence: getBigInfo control sequence step fail."), ESPHOME_LOG_LEVEL_WARN, __LINE__); + _debugMsg(F("commandSequence: control sequence step fail."), ESPHOME_LOG_LEVEL_WARN, __LINE__); return false; } /**************************************************************************************/ @@ -3070,6 +3079,37 @@ class AirCon : public esphome::Component, public esphome::climate::Climate { return true; } + // устанавливает жалюзи в нужное положение + bool setVLouverSequence(const ac_louver_V vLouver){ + // нет смысла в последовательности, если нет коннекта с кондиционером + if (!get_has_connection()) { + _debugMsg(F("setVLouverSequence: no pings from HVAC. It seems like no AC connected."), ESPHOME_LOG_LEVEL_ERROR, __LINE__); + return false; + } + if (vLouver == AC_LOUVERV_UNTOUCHED) return false; // выходим, чтобы не тратить время + + if ((vLouver > AC_LOUVERV_OFF) || (vLouver == 0x06)) return false; // нет таких команд + + // формируем команду + ac_command_t cmd; + _clearCommand(&cmd); // не забываем очищать, а то будет мусор + cmd.louver.louver_v = vLouver; + // добавляем команду в последовательность + if (!commandSequence(&cmd)) return false; + + _debugMsg(F("setVLouverSequence: loaded (power = %02X)"), ESPHOME_LOG_LEVEL_VERBOSE, __LINE__, vLouver); + return true; + } + + // установка жалюзи в определенные положения + bool setVLouverSwingSequence() { return setVLouverSequence(AC_LOUVERV_SWING_UPDOWN); } + bool setVLouverStopSequence() { return setVLouverSequence(AC_LOUVERV_OFF); } + bool setVLouverTopSequence() { return setVLouverSequence(AC_LOUVERV_SWING_TOP); } + bool setVLouverMiddleAboveSequence() { return setVLouverSequence(AC_LOUVERV_SWING_MIDDLE_ABOVE); } + bool setVLouverMiddleSequence() { return setVLouverSequence(AC_LOUVERV_SWING_MIDDLE); } + bool setVLouverMiddleBelowSequence() { return setVLouverSequence(AC_LOUVERV_SWING_MIDDLE_BELOW); } + bool setVLouverBottomSequence() { return setVLouverSequence(AC_LOUVERV_SWING_BOTTOM); } + void set_period(uint32_t ms) { this->_update_period = ms; } uint32_t get_period() { return this->_update_period; } diff --git a/components/aux_ac/climate.py b/components/aux_ac/climate.py index 1a6e0cf..a54362e 100644 --- a/components/aux_ac/climate.py +++ b/components/aux_ac/climate.py @@ -65,6 +65,13 @@ Capabilities = aux_ac_ns.namespace("Constants") AirConDisplayOffAction = aux_ac_ns.class_("AirConDisplayOffAction", automation.Action) AirConDisplayOnAction = aux_ac_ns.class_("AirConDisplayOnAction", automation.Action) +AirConVLouverSwingAction = aux_ac_ns.class_("AirConVLouverSwingAction", automation.Action) +AirConVLouverStopAction = aux_ac_ns.class_("AirConVLouverStopAction", automation.Action) +AirConVLouverTopAction = aux_ac_ns.class_("AirConVLouverTopAction", automation.Action) +AirConVLouverMiddleAboveAction = aux_ac_ns.class_("AirConVLouverMiddleAboveAction", automation.Action) +AirConVLouverMiddleAction = aux_ac_ns.class_("AirConVLouverMiddleAction", automation.Action) +AirConVLouverMiddleBelowAction = aux_ac_ns.class_("AirConVLouverMiddleBelowAction", automation.Action) +AirConVLouverBottomAction = aux_ac_ns.class_("AirConVLouverBottomAction", automation.Action) AirConSendTestPacketAction = aux_ac_ns.class_("AirConSendTestPacketAction", automation.Action) ALLOWED_CLIMATE_MODES = { @@ -121,7 +128,6 @@ CONFIG_SCHEMA = cv.All( cv.Optional(CONF_PERIOD, default="7s"): cv.time_period, cv.Optional(CONF_SHOW_ACTION, default="true"): cv.boolean, cv.Optional(CONF_DISPLAY_INVERTED, default="false"): cv.boolean, - cv.Optional(CONF_DEFROST_STATE, default="false"): cv.boolean, cv.Optional(CONF_INVERTOR_POWER): sensor.sensor_schema( unit_of_measurement=UNIT_PERCENT, icon=ICON_POWER, @@ -188,32 +194,27 @@ 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 + icon=ICON_DISPLAY, ).extend( { - cv.Optional(CONF_INTERNAL, default="true"): cv.boolean + cv.Optional(CONF_INTERNAL, default="true"): cv.boolean, } ), - cv.Optional(CONF_DEFROST_STATE): binary_sensor.binary_sensor_schema( - icon=ICON_DEFROST + icon=ICON_DEFROST, ).extend( { - cv.Optional(CONF_INTERNAL, default="true"): cv.boolean + cv.Optional(CONF_INTERNAL, default="true"): cv.boolean, } ), - cv.Optional(CONF_PRESET_REPORTER): text_sensor.text_sensor_schema( - icon=ICON_PRESET_REPORTER + icon=ICON_PRESET_REPORTER, ).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), cv.Optional(CONF_SUPPORTED_SWING_MODES): cv.ensure_list(validate_swing_modes), cv.Optional(CONF_SUPPORTED_PRESETS): cv.ensure_list(validate_presets), @@ -265,7 +266,7 @@ async def to_code(config): conf = config[CONF_DISPLAY_STATE] sens = await binary_sensor.new_binary_sensor(conf) cg.add(var.set_display_sensor(sens)) - + if CONF_DEFROST_STATE in config: conf = config[CONF_DEFROST_STATE] sens = await binary_sensor.new_binary_sensor(conf) @@ -314,13 +315,48 @@ 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( +VLOUVER_ACTION_SCHEMA = maybe_simple_id( { cv.Required(CONF_ID): cv.use_id(AirCon), - cv.Required(CONF_DATA): cv.templatable(validate_raw_data), } ) +@automation.register_action("aux_ac.vlouver_stop", AirConVLouverStopAction, VLOUVER_ACTION_SCHEMA) +async def vlouver_stop_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.vlouver_swing", AirConVLouverSwingAction, VLOUVER_ACTION_SCHEMA) +async def vlouver_swing_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.vlouver_top", AirConVLouverTopAction, VLOUVER_ACTION_SCHEMA) +async def vlouver_top_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.vlouver_middle_above", AirConVLouverMiddleAboveAction, VLOUVER_ACTION_SCHEMA) +async def vlouver_middle_above_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.vlouver_middle", AirConVLouverMiddleAction, VLOUVER_ACTION_SCHEMA) +async def vlouver_middle_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.vlouver_middle_below", AirConVLouverMiddleBelowAction, VLOUVER_ACTION_SCHEMA) +async def vlouver_middle_below_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.vlouver_bottom", AirConVLouverBottomAction, VLOUVER_ACTION_SCHEMA) +async def vlouver_bottom_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) + # ********************************************************************************************************* # ВАЖНО! Только для инженеров! @@ -328,6 +364,13 @@ SEND_TEST_PACKET_ACTION_SCHEMA = maybe_simple_id( # кондиционеру всё как есть. Какой эффект получится от передачи кондиционеру рандомных байт, никто не знает. # Вы действуете на свой страх и риск. # ********************************************************************************************************* +SEND_TEST_PACKET_ACTION_SCHEMA = maybe_simple_id( + { + cv.Required(CONF_ID): cv.use_id(AirCon), + cv.Required(CONF_DATA): cv.templatable(validate_raw_data), + } +) + @automation.register_action( "aux_ac.send_packet", AirConSendTestPacketAction, diff --git a/tests/test-ext-esp32.yaml b/tests/test-ext-esp32.yaml index 5b443fa..f8ba75a 100644 --- a/tests/test-ext-esp32.yaml +++ b/tests/test-ext-esp32.yaml @@ -3,9 +3,12 @@ external_components: components: [ aux_ac ] refresh: 0s - +substitutions: + devicename: test_aux_ac_ext_esp32 + upper_devicename: Test AUX + esphome: - name: test_aux_ac_ext_esp32 + name: $devicename platform: ESP32 board: nodemcu-32s @@ -51,21 +54,54 @@ sensor: climate: - platform: aux_ac - name: "AC Name" + name: $upper_devicename id: aux_id uart_id: ac_uart_bus - period: 7s # период опроса состояния сплита, по дефолту 7 сек - show_action: true # надо ли показывать текущий режим работы: при HEAT_COOL mode сплит может греть (HEAT), охлаждать (COOL) или бездействовать (IDLE) - indoor_temperature: # сенсор, показывающий температуру воздуха на внутреннем блоке кондиционера; имеет все те же параметры, как и любой сенсор ESPHome - name: AC Indoor Temperature - id: ac_indoor_temp - internal: true # сенсор установлен как внутренний по дефолту (не попадёт в Home Assistant) + period: 7s + show_action: true + display_inverted: true + indoor_temperature: + name: $upper_devicename Indoor Temperature + id: ${devicename}_indoor_temp + internal: false + display_state: + name: $upper_devicename Display State + id: ${devicename}_display_state + internal: false + outdoor_temperature: + name: $upper_devicename Outdoor Temperature + id: ${devicename}_outdoor_temp + internal: false + outbound_temperature: + name: $upper_devicename Colant Outbound Temperature + id: ${devicename}_outbound_temp + internal: false + inbound_temperature: + name: $upper_devicename Colant Inbound Temperature + id: ${devicename}_inbound_temp + internal: false + compressor_temperature: + name: $upper_devicename Compressor Temperature + id: ${devicename}_strange_temp + internal: false + defrost_state: + name: $upper_devicename Defrost State + id: ${devicename}_defrost_state + internal: false + invertor_power: + name: $upper_devicename Invertor Power + id: ${devicename}_invertor_power + internal: false + preset_reporter: + name: $upper_devicename Preset Reporter + id: ${devicename}_preset_reporter + internal: false visual: min_temperature: 16 max_temperature: 32 temperature_step: 0.5 supported_modes: - - HEAT_COOL # не AUTO, так как только нагревает и остужает. В доках на ESPHome говорится, что AUTO - это если у устройства есть календарь и какие-то установки по расписанию. + - HEAT_COOL - COOL - HEAT - DRY @@ -77,10 +113,9 @@ climate: - SLEEP custom_presets: - CLEAN - - FEEL - HEALTH - ANTIFUNGUS supported_swing_modes: - VERTICAL - HORIZONTAL - - BOTH \ No newline at end of file + - BOTH diff --git a/tests/test-ext-for-engineer.yaml b/tests/test-ext-for-engineer.yaml index 4561a52..e747569 100644 --- a/tests/test-ext-for-engineer.yaml +++ b/tests/test-ext-for-engineer.yaml @@ -3,8 +3,12 @@ external_components: components: [ aux_ac ] refresh: 0s +substitutions: + devicename: test_aux_ac_ext_engeneer + upper_devicename: Test AUX + esphome: - name: test_aux_ac_ext + name: $devicename platform: ESP8266 board: esp12e @@ -69,26 +73,54 @@ sensor: climate: - platform: aux_ac - name: "AC Name" + name: $upper_devicename id: aux_id uart_id: ac_uart_bus - period: 7s # период опроса состояния сплита, по дефолту 7 сек - show_action: true # надо ли показывать текущий режим работы: при HEAT_COOL mode сплит может греть (HEAT), охлаждать (COOL) или бездействовать (IDLE) - display_inverted: true # как отрабатывать вкл/выкл дисплея: у Rovex "1" выключает дисплей, у многих других "1" дисплей включает - indoor_temperature: # сенсор, показывающий температуру воздуха на внутреннем блоке кондиционера; имеет все те же параметры, как и любой сенсор ESPHome - name: AC Indoor Temperature - id: ac_indoor_temp - internal: false # сенсор установлен как внутренний по дефолту (не попадёт в Home Assistant) + period: 7s + show_action: true + display_inverted: true + indoor_temperature: + name: $upper_devicename Indoor Temperature + id: ${devicename}_indoor_temp + internal: false display_state: - name: AC Display State - id: ac_display_state - internal: false # сенсор установлен как внутренний по дефолту (не попадёт в Home Assistant) + name: $upper_devicename Display State + id: ${devicename}_display_state + internal: false + outdoor_temperature: + name: $upper_devicename Outdoor Temperature + id: ${devicename}_outdoor_temp + internal: false + outbound_temperature: + name: $upper_devicename Colant Outbound Temperature + id: ${devicename}_outbound_temp + internal: false + inbound_temperature: + name: $upper_devicename Colant Inbound Temperature + id: ${devicename}_inbound_temp + internal: false + compressor_temperature: + name: $upper_devicename Compressor Temperature + id: ${devicename}_strange_temp + internal: false + defrost_state: + name: $upper_devicename Defrost State + id: ${devicename}_defrost_state + internal: false + invertor_power: + name: $upper_devicename Invertor Power + id: ${devicename}_invertor_power + internal: false + preset_reporter: + name: $upper_devicename Preset Reporter + id: ${devicename}_preset_reporter + internal: false visual: min_temperature: 16 max_temperature: 32 temperature_step: 0.5 supported_modes: - - HEAT_COOL # не AUTO, так как только нагревает и остужает. В доках на ESPHome говорится, что AUTO - это если у устройства есть календарь и какие-то установки по расписанию. + - HEAT_COOL - COOL - HEAT - DRY @@ -100,7 +132,6 @@ climate: - SLEEP custom_presets: - CLEAN - - FEEL - HEALTH - ANTIFUNGUS supported_swing_modes: @@ -113,7 +144,7 @@ switch: - platform: template name: AC Display lambda: |- - if (id(ac_display_state).state) { + if (id(${devicename}_display_state).state) { return true; } else { return false; diff --git a/tests/test-local-arflow-dir.yaml b/tests/test-local-arflow-dir.yaml new file mode 100644 index 0000000..9487912 --- /dev/null +++ b/tests/test-local-arflow-dir.yaml @@ -0,0 +1,159 @@ +external_components: + - source: + type: local + path: ..\components + +substitutions: + devicename: test_local_airflow_dir + upper_devicename: Test AUX + +esphome: + name: $devicename + platform: ESP8266 + board: esp12e + +wifi: + ssid: !secret wifi_ssid + password: !secret wifi_pass + manual_ip: + static_ip: !secret wifi_ip + gateway: !secret wifi_gateway + subnet: !secret wifi_subnet + dns1: 8.8.8.8 + dns2: 1.1.1.1 + reboot_timeout: 0s + ap: + ssid: $upper_devicename Fallback Hotspot + password: !secret wifi_ap_pass + +logger: + level: DEBUG + baud_rate: 0 + +api: + password: !secret api_pass + reboot_timeout: 0s + +ota: + password: !secret ota_pass + +web_server: + port: 80 + +uart: + id: ac_uart_bus + tx_pin: GPIO1 + rx_pin: GPIO3 + baud_rate: 4800 + data_bits: 8 + parity: EVEN + stop_bits: 1 + + +sensor: + - platform: uptime + name: Uptime Sensor + + +climate: + - platform: aux_ac + name: $upper_devicename + id: aux_id + uart_id: ac_uart_bus + period: 7s + show_action: true + display_inverted: true + + +button: + - platform: template + name: ${upper_devicename} VLouver Stop + icon: "mdi:circle-small" + on_press: + - aux_ac.vlouver_stop: aux_id + + - platform: template + name: ${upper_devicename} VLouver Swing + icon: "mdi:pan-vertical" + on_press: + - aux_ac.vlouver_swing: aux_id + + - platform: template + name: ${upper_devicename} VLouver Top + icon: "mdi:pan-up" + on_press: + - aux_ac.vlouver_top: aux_id + + - platform: template + name: ${upper_devicename} VLouver Middle Above + icon: "mdi:pan-top-left" + on_press: + - aux_ac.vlouver_middle_above: aux_id + + - platform: template + name: ${upper_devicename} VLouver Middle + icon: "mdi:pan-left" + on_press: + - aux_ac.vlouver_middle: aux_id + + - platform: template + name: ${upper_devicename} VLouver Middle Below + icon: "mdi:pan-bottom-left" + on_press: + - aux_ac.vlouver_middle_below: aux_id + + - platform: template + name: ${upper_devicename} VLouver Bottom + icon: "mdi:pan-down" + on_press: + - aux_ac.vlouver_bottom: aux_id + + +number: + - platform: template + name: ${upper_devicename} Vertical Louver + id: ${devicename}_vlouver + icon: "mdi:circle-small" + mode: "slider" + min_value: 0 + max_value: 6 + step: 1 + set_action: + then: + - lambda: !lambda |- + auto icon = ""; + if (x == 6) x = 7; // делаем так, чтобы выключение отрабатывать корректно + + switch ( static_cast(x) ) { + case 0: // vertical swing + icon = "mdi:pan-vertical"; + break; + + case 1: // top position + icon = "mdi:pan-up"; + break; + + case 2: // middle above position + icon = "mdi:pan-top-left"; + break; + + case 3: // middle position + icon = "mdi:pan-left"; + break; + + case 4: // middle below position + icon = "mdi:pan-bottom-left"; + break; + + case 5: // bottom position + icon = "mdi:pan-down"; + break; + + case 7: // stop vertical louver + default: + icon = "mdi:circle-small"; + break; + } + + id(${devicename}_vlouver).set_icon(icon); + id(aux_id).setVLouverSequence( static_cast(x) ); diff --git a/tests/test-local.yaml b/tests/test-local.yaml index 04a71e4..216befb 100644 --- a/tests/test-local.yaml +++ b/tests/test-local.yaml @@ -3,8 +3,12 @@ external_components: type: local path: ..\components +substitutions: + devicename: test_local_airflow_dir + upper_devicename: Test AUX + esphome: - name: test_aux_ac_local + name: $devicename platform: ESP8266 board: esp12e @@ -51,21 +55,54 @@ sensor: climate: - platform: aux_ac - name: "AC Name" + name: $upper_devicename id: aux_id uart_id: ac_uart_bus - period: 7s # период опроса состояния сплита, по дефолту 7 сек - show_action: true # надо ли показывать текущий режим работы: при HEAT_COOL mode сплит может греть (HEAT), охлаждать (COOL) или бездействовать (IDLE) - indoor_temperature: # сенсор, показывающий температуру воздуха на внутреннем блоке кондиционера; имеет все те же параметры, как и любой сенсор ESPHome - name: AC Indoor Temperature - id: ac_indoor_temp - internal: true # сенсор установлен как внутренний по дефолту (не попадёт в Home Assistant) + period: 7s + show_action: true + display_inverted: true + indoor_temperature: + name: $upper_devicename Indoor Temperature + id: ${devicename}_indoor_temp + internal: false + display_state: + name: $upper_devicename Display State + id: ${devicename}_display_state + internal: false + outdoor_temperature: + name: $upper_devicename Outdoor Temperature + id: ${devicename}_outdoor_temp + internal: false + outbound_temperature: + name: $upper_devicename Colant Outbound Temperature + id: ${devicename}_outbound_temp + internal: false + inbound_temperature: + name: $upper_devicename Colant Inbound Temperature + id: ${devicename}_inbound_temp + internal: false + compressor_temperature: + name: $upper_devicename Compressor Temperature + id: ${devicename}_strange_temp + internal: false + defrost_state: + name: $upper_devicename Defrost State + id: ${devicename}_defrost_state + internal: false + invertor_power: + name: $upper_devicename Invertor Power + id: ${devicename}_invertor_power + internal: false + preset_reporter: + name: $upper_devicename Preset Reporter + id: ${devicename}_preset_reporter + internal: false visual: min_temperature: 16 max_temperature: 32 temperature_step: 0.5 supported_modes: - - HEAT_COOL # не AUTO, так как только нагревает и остужает. В доках на ESPHome говорится, что AUTO - это если у устройства есть календарь и какие-то установки по расписанию. + - HEAT_COOL - COOL - HEAT - DRY @@ -77,10 +114,9 @@ climate: - SLEEP custom_presets: - CLEAN - - FEEL - HEALTH - ANTIFUNGUS supported_swing_modes: - VERTICAL - HORIZONTAL - - BOTH \ No newline at end of file + - BOTH diff --git a/tests/test-minimal.yaml b/tests/test-minimal.yaml index 975e2ed..651ccca 100644 --- a/tests/test-minimal.yaml +++ b/tests/test-minimal.yaml @@ -6,8 +6,12 @@ external_components: #components: [ aux_ac ] #refresh: 0s +substitutions: + devicename: test_local_minimal + upper_devicename: Test AUX + esphome: - name: test_aux_ac_minimal + name: $devicename platform: ESP8266 board: esp12e @@ -41,4 +45,4 @@ uart: climate: - platform: aux_ac - name: "AC Name" \ No newline at end of file + name: $upper_devicename \ No newline at end of file