From 8cd7a78786b1a808ab821dde5b81ea694019f0f6 Mon Sep 17 00:00:00 2001 From: Guido Schreuder Date: Sun, 25 Feb 2024 14:30:37 +0100 Subject: [PATCH] remove EbusSender --- esphome/components/ebus/ebus_component.cpp | 10 ++-------- esphome/components/ebus/ebus_component.h | 14 ++++---------- 2 files changed, 6 insertions(+), 18 deletions(-) diff --git a/esphome/components/ebus/ebus_component.cpp b/esphome/components/ebus/ebus_component.cpp index df19901ef4..13bf0a3a66 100644 --- a/esphome/components/ebus/ebus_component.cpp +++ b/esphome/components/ebus/ebus_component.cpp @@ -45,12 +45,6 @@ void EbusComponent::set_command_queue_size(uint8_t command_queue_size) { this->command_queue_size_ = command_queue_size; } -void EbusComponent::add_sender(EbusSender *sender) { - if (this->primary_address_ == SYN) { - return; - } - this->senders_.push_back(sender); -} void EbusComponent::add_receiver(EbusReceiver *receiver) { this->receivers_.push_back(receiver); } void EbusComponent::setup_queues_() { @@ -172,8 +166,8 @@ void EbusComponent::update() { if (this->primary_address_ == SYN) { return; } - for (auto const &sender : this->senders_) { - optional command = sender->prepare_command(); + for (auto const &item : this->items_) { + optional command = item->prepare_command(); if (command.has_value()) { xQueueSendToBack(this->command_queue_, &command.value(), portMAX_DELAY); } diff --git a/esphome/components/ebus/ebus_component.h b/esphome/components/ebus/ebus_component.h index a69f54347a..6a7682ecfc 100644 --- a/esphome/components/ebus/ebus_component.h +++ b/esphome/components/ebus/ebus_component.h @@ -29,12 +29,7 @@ class EbusReceiver { }; }; -class EbusSender { - public: - virtual optional prepare_command() = 0; -}; - -class EbusItem : public EbusReceiver, public EbusSender, public Component { +class EbusItem : public EbusReceiver, public Component { public: void dump_config() override; @@ -45,7 +40,7 @@ class EbusItem : public EbusReceiver, public EbusSender, public Component { void set_payload(const std::vector &payload) { this->payload_ = payload; } void set_response_read_position(uint8_t response_position) { this->response_position_ = response_position; } - optional prepare_command() override; + virtual optional prepare_command(); // TODO: refactor these uint32_t get_response_bytes(Telegram &telegram, uint8_t start, uint8_t length); @@ -77,10 +72,9 @@ class EbusComponent : public PollingComponent { void set_history_queue_size(uint8_t /*history_queue_size*/); void set_command_queue_size(uint8_t /*command_queue_size*/); - void add_sender(EbusSender * /*sender*/); void add_receiver(EbusReceiver * /*receiver*/); void add_item(EbusItem *item) { - this->add_sender(item); + this->items_.push_back(item); this->add_receiver(item); }; @@ -101,7 +95,7 @@ class EbusComponent : public PollingComponent { QueueHandle_t command_queue_; #endif - std::list senders_; + std::list items_; std::list receivers_; std::unique_ptr ebus_;