diff --git a/external_components/hoermann_door/__init__.py b/external_components/hoermann_door/__init__.py index cbfd3d6..ae6e126 100644 --- a/external_components/hoermann_door/__init__.py +++ b/external_components/hoermann_door/__init__.py @@ -14,6 +14,21 @@ HoermannDoor = hoermann_door_ns.class_('HoermannMainComponent', cg.Component) CONF_UART_ENTRY = "uart_connection" CONF_TX_PIN = "tx_pin" +CONF_LOG_LEVEL = "log_level" + +#define LL_OFF 0 +#define LL_ERROR 1 +#define LL_WARN 2 +#define LL_INFO 3 +#define LL_DEBUG 4 + +CONF_LOG_LEVELS = { + "NONE": 0, + "ERROR": 1, + "WARN": 2, + "INFO": 3, + "DEBUG": 4, +} def validate_config(config): return config @@ -23,6 +38,7 @@ CONFIG_SCHEMA = cv.All( cv.GenerateID(): cv.declare_id(HoermannDoor), cv.Required(CONF_UART_ENTRY): cv.use_id(uart.UARTComponent), cv.Required(CONF_TX_PIN): pins.internal_gpio_output_pin_schema, + cv.Optional(CONF_LOG_LEVEL, default="INFO"): cv.enum(CONF_LOG_LEVELS, upper=True), }), validate_config ) @@ -39,4 +55,7 @@ async def to_code(config): cg.add(var.set_seriel_connection(code)) code2 = await cg.gpio_pin_expression(config[CONF_TX_PIN]) - cg.add(var.set_tx_on_pin(code2)) # Needs be configured before sensor \ No newline at end of file + cg.add(var.set_tx_on_pin(code2)) # Needs be configured before sensor + + log_level = config[CONF_LOG_LEVEL] + cg.add(var.set_log_level(log_level)) \ No newline at end of file diff --git a/external_components/hoermann_door/hciemulator.cpp b/external_components/hoermann_door/hciemulator.cpp index 703edeb..4703433 100644 --- a/external_components/hoermann_door/hciemulator.cpp +++ b/external_components/hoermann_door/hciemulator.cpp @@ -123,7 +123,6 @@ HCIEmulator::HCIEmulator(esphome::InternalGPIOPin* pin, esphome::uart::UARTCompo m_port = uart; m_pin = pin; m_statusCallback = NULL; - setLogLevel(DEFAULTLOGLEVEL); }; #define TX_ON 25 diff --git a/external_components/hoermann_door/hciemulator.h b/external_components/hoermann_door/hciemulator.h index 5366500..1f27ebf 100644 --- a/external_components/hoermann_door/hciemulator.h +++ b/external_components/hoermann_door/hciemulator.h @@ -9,8 +9,6 @@ #define LL_INFO 3 #define LL_DEBUG 4 -#define DEFAULTLOGLEVEL LL_INFO - #define DEVICEID 0x02 #define BROADCASTID 0x00 #define SIMULATEKEYPRESSDELAYMS 100 diff --git a/external_components/hoermann_door/hoermann.h b/external_components/hoermann_door/hoermann.h index 22067ef..701c607 100644 --- a/external_components/hoermann_door/hoermann.h +++ b/external_components/hoermann_door/hoermann.h @@ -20,6 +20,7 @@ class HoermannMainComponent: public Component{ protected: HCIEmulator* emulator; TaskHandle_t modBusTask; + int log_level = 3; // Defaults to INFO uart::UARTComponent* _uart; InternalGPIOPin* _tx_on; @@ -36,6 +37,11 @@ class HoermannMainComponent: public Component{ void set_tx_on_pin(InternalGPIOPin* pin){ this->_tx_on = pin; } + + void set_log_level(int level){ + this->log_level = level; + } + HCIEmulator* getEmulator(){ return emulator; } @@ -44,6 +50,7 @@ class HoermannMainComponent: public Component{ this->_tx_on->setup(); this->emulator = new HCIEmulator(this->_tx_on, this->_uart); + this->emulator->setLogLevel(this->log_level); this->_tx_on->digital_write(false); this->set_continue_ = true; diff --git a/garage1.yaml b/garage1.yaml index 11654eb..3f309e8 100644 --- a/garage1.yaml +++ b/garage1.yaml @@ -50,9 +50,10 @@ uart: hoermann_door: id: door_controll_internal uart_connection: hm_connection + log_level: INFO tx_pin: number: 25 - inverted: false + inverted: false # Just for clarity, false is standard light: