diff --git a/esphome/components/ebus/__init__.py b/esphome/components/ebus/__init__.py index bd171f5f04..117e35e449 100644 --- a/esphome/components/ebus/__init__.py +++ b/esphome/components/ebus/__init__.py @@ -48,7 +48,7 @@ CONFIG_SCHEMA = cv.All( cv.Schema( { cv.GenerateID(): cv.declare_id(EbusComponent), - cv.Required(CONF_PRIMARY_ADDRESS): validate_primary_address, + cv.Optional(CONF_PRIMARY_ADDRESS): validate_primary_address, cv.Optional(CONF_MAX_TRIES, default=2): cv.hex_uint8_t, cv.Optional(CONF_MAX_LOCK_COUNTER, default=4): cv.hex_uint8_t, cv.Optional(CONF_HISTORY_QUEUE_SIZE, default=20): cv.uint8_t, @@ -70,7 +70,8 @@ async def to_code(config): var = cg.new_Pvariable(config[CONF_ID]) await cg.register_component(var, config) - cg.add(var.set_primary_address(config[CONF_PRIMARY_ADDRESS])) + if CONF_PRIMARY_ADDRESS in config: + cg.add(var.set_primary_address(config[CONF_PRIMARY_ADDRESS])) cg.add(var.set_max_tries(config[CONF_MAX_TRIES])) cg.add(var.set_max_lock_counter(config[CONF_MAX_LOCK_COUNTER])) cg.add(var.set_uart_num(config[CONF_UART][CONF_NUM])) diff --git a/esphome/components/ebus/ebus_component.cpp b/esphome/components/ebus/ebus_component.cpp index fad128da3d..b3c9a6ebe4 100644 --- a/esphome/components/ebus/ebus_component.cpp +++ b/esphome/components/ebus/ebus_component.cpp @@ -9,7 +9,11 @@ namespace ebus { void EbusComponent::dump_config() { ESP_LOGCONFIG(TAG, "EbusComponent"); - ESP_LOGCONFIG(TAG, " primary_addres: 0x%02x", this->primary_address_); + if (this->primary_address_ == SYN) { + ESP_LOGCONFIG(TAG, " primary_addres: N/A"); + } else { + ESP_LOGCONFIG(TAG, " primary_addres: 0x%02x", this->primary_address_); + } ESP_LOGCONFIG(TAG, " max_tries: %d", this->max_tries_); ESP_LOGCONFIG(TAG, " max_lock_counter: %d", this->max_lock_counter_); ESP_LOGCONFIG(TAG, " history_queue_size: %d", this->history_queue_size_); @@ -42,6 +46,10 @@ void EbusComponent::set_command_queue_size(uint8_t command_queue_size) { } void EbusComponent::add_sender(EbusSender *sender) { + if (this->primary_address_ == SYN) { + return; + } + sender->set_primary_address(this->primary_address_); this->senders_.push_back(sender); } @@ -151,6 +159,9 @@ void EbusComponent::handle_message_(Telegram &telegram) { } void EbusComponent::update() { + if (this->primary_address_ == SYN) { + return; + } for (auto const &sender : this->senders_) { optional command = sender->prepare_command(); if (command.has_value()) { diff --git a/esphome/components/ebus/ebus_component.h b/esphome/components/ebus/ebus_component.h index cfae799217..a197598e9c 100644 --- a/esphome/components/ebus/ebus_component.h +++ b/esphome/components/ebus/ebus_component.h @@ -52,7 +52,7 @@ class EbusComponent : public PollingComponent { void update() override; protected: - uint8_t primary_address_; + uint8_t primary_address_ = SYN; uint8_t max_tries_; uint8_t max_lock_counter_; uint8_t history_queue_size_;