smaller changes based on comments from review

This commit is contained in:
j0ta29 2024-03-24 08:16:21 +00:00
parent cae27ccd29
commit bc00df307e
3 changed files with 8 additions and 12 deletions

View file

@ -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)

View file

@ -4,13 +4,7 @@
#include "esphome/core/log.h"
#include "optolink.h"
#if defined(VITOWIFI_PROTOCOL)
// NOLINTNEXTLINE
VitoWiFiClass<VITOWIFI_PROTOCOL> VitoWiFi; // VITOWIFI_PROTOCOL always is set
#else
// NOLINTNEXTLINE
VitoWiFiClass<P300> VitoWiFi; // this is not really a fallback but dedicated to clang-lint
#endif
VitoWiFiClass<USE_OPTOLINK_VITOWIFI_PROTOCOL> VitoWiFi; // NOLINT
namespace esphome {
namespace optolink {

View file

@ -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