From bc00df307e9112a62a2c3786a1b9b7b9c930871c Mon Sep 17 00:00:00 2001 From: j0ta29 Date: Sun, 24 Mar 2024 08:16:21 +0000 Subject: [PATCH] smaller changes based on comments from review --- esphome/components/optolink/__init__.py | 11 ++++++----- esphome/components/optolink/optolink.cpp | 8 +------- esphome/core/defines.h | 1 + 3 files changed, 8 insertions(+), 12 deletions(-) diff --git a/esphome/components/optolink/__init__.py b/esphome/components/optolink/__init__.py index 2bdb253adb..1fba368228 100644 --- a/esphome/components/optolink/__init__.py +++ b/esphome/components/optolink/__init__.py @@ -55,11 +55,11 @@ CONFIG_SCHEMA = cv.All( cv.Required(CONF_PROTOCOL): cv.one_of("P300", "KW"), cv.Optional(CONF_RX_PIN): cv.All( cv.only_on_esp32, - pins.internal_gpio_input_pin_schema, + pins.internal_gpio_input_pin_number, ), cv.Optional(CONF_TX_PIN): cv.All( cv.only_on_esp32, - pins.internal_gpio_output_pin_schema, + pins.internal_gpio_input_pin_number, ), cv.Optional(CONF_LOGGER, default=False): cv.boolean, } @@ -75,14 +75,15 @@ async def to_code(config): cg.add_library("VitoWiFi", "1.1.2") cg.add_define( - "VITOWIFI_PROTOCOL", cg.RawExpression(f"Optolink{config[CONF_PROTOCOL]}") + "USE_OPTOLINK_VITOWIFI_PROTOCOL", + cg.RawExpression(f"Optolink{config[CONF_PROTOCOL]}"), ) var = cg.new_Pvariable(config[CONF_ID]) cg.add(var.set_logger_enabled(config[CONF_LOGGER])) if CORE.is_esp32: - cg.add(var.set_rx_pin(config[CONF_RX_PIN]["number"])) - cg.add(var.set_tx_pin(config[CONF_TX_PIN]["number"])) + cg.add(var.set_rx_pin(config[CONF_RX_PIN])) + cg.add(var.set_tx_pin(config[CONF_TX_PIN])) await cg.register_component(var, config) diff --git a/esphome/components/optolink/optolink.cpp b/esphome/components/optolink/optolink.cpp index c9c8facd29..825ff58618 100644 --- a/esphome/components/optolink/optolink.cpp +++ b/esphome/components/optolink/optolink.cpp @@ -4,13 +4,7 @@ #include "esphome/core/log.h" #include "optolink.h" -#if defined(VITOWIFI_PROTOCOL) -// NOLINTNEXTLINE -VitoWiFiClass VitoWiFi; // VITOWIFI_PROTOCOL always is set -#else -// NOLINTNEXTLINE -VitoWiFiClass VitoWiFi; // this is not really a fallback but dedicated to clang-lint -#endif +VitoWiFiClass VitoWiFi; // NOLINT namespace esphome { namespace optolink { diff --git a/esphome/core/defines.h b/esphome/core/defines.h index 501dccc6fa..f4aad7e422 100644 --- a/esphome/core/defines.h +++ b/esphome/core/defines.h @@ -64,6 +64,7 @@ #define USE_WEBSERVER #define USE_WEBSERVER_PORT 80 // NOLINT #define USE_WIFI_WPA2_EAP +#define USE_OPTOLINK_VITOWIFI_PROTOCOL P300 #endif // IDF-specific feature flags