diff --git a/esphome/components/ebus/__init__.py b/esphome/components/ebus/__init__.py index c631660947..29dcb4d80f 100644 --- a/esphome/components/ebus/__init__.py +++ b/esphome/components/ebus/__init__.py @@ -125,16 +125,16 @@ async def to_code(config): cg.add(var.set_update_interval(config[CONF_POLL_INTERVAL].total_milliseconds)) -def sensor_base_config(ebus, sensor_base, config): - cg.add(sensor_base.set_parent(ebus)) - cg.add(ebus.add_sensor(sensor_base)), - cg.add(sensor_base.set_send_poll(config[CONF_TELEGRAM][CONF_SEND_POLL])) +def item_config(ebus, item, config): + cg.add(item.set_parent(ebus)) + cg.add(ebus.add_item(item)), + cg.add(item.set_send_poll(config[CONF_TELEGRAM][CONF_SEND_POLL])) if CONF_ADDRESS in config[CONF_TELEGRAM]: - cg.add(sensor_base.set_address(config[CONF_TELEGRAM][CONF_ADDRESS])) - cg.add(sensor_base.set_command(config[CONF_TELEGRAM][CONF_COMMAND])) - cg.add(sensor_base.set_payload(config[CONF_TELEGRAM][CONF_PAYLOAD])) + cg.add(item.set_address(config[CONF_TELEGRAM][CONF_ADDRESS])) + cg.add(item.set_command(config[CONF_TELEGRAM][CONF_COMMAND])) + cg.add(item.set_payload(config[CONF_TELEGRAM][CONF_PAYLOAD])) cg.add( - sensor_base.set_response_read_position( + item.set_response_read_position( config[CONF_TELEGRAM][CONF_DECODE][CONF_POSITION] ) ) diff --git a/esphome/components/ebus/binary_sensor/__init__.py b/esphome/components/ebus/binary_sensor/__init__.py index fb1290fb42..08075c485f 100644 --- a/esphome/components/ebus/binary_sensor/__init__.py +++ b/esphome/components/ebus/binary_sensor/__init__.py @@ -8,7 +8,7 @@ from .. import ( CONF_DECODE, ebus_ns, create_telegram_schema, - sensor_base_config, + item_config, ) AUTO_LOAD = ["ebus"] @@ -32,5 +32,5 @@ async def to_code(config): ebus = await cg.get_variable(config[CONF_EBUS_ID]) sens = await binary_sensor.new_binary_sensor(config) - sensor_base_config(ebus, sens, config) + item_config(ebus, sens, config) cg.add(sens.set_response_read_mask(config[CONF_TELEGRAM][CONF_DECODE][CONF_MASK])) diff --git a/esphome/components/ebus/binary_sensor/ebus_binary_sensor.h b/esphome/components/ebus/binary_sensor/ebus_binary_sensor.h index 8aad16e217..4f1d8180cb 100644 --- a/esphome/components/ebus/binary_sensor/ebus_binary_sensor.h +++ b/esphome/components/ebus/binary_sensor/ebus_binary_sensor.h @@ -6,7 +6,7 @@ namespace esphome { namespace ebus { -class EbusBinarySensor : public EbusSensorBase, public binary_sensor::BinarySensor { +class EbusBinarySensor : public EbusItem, public binary_sensor::BinarySensor { public: EbusBinarySensor() {} diff --git a/esphome/components/ebus/ebus_component.cpp b/esphome/components/ebus/ebus_component.cpp index d68c8e6f08..df19901ef4 100644 --- a/esphome/components/ebus/ebus_component.cpp +++ b/esphome/components/ebus/ebus_component.cpp @@ -180,7 +180,7 @@ void EbusComponent::update() { } } -void EbusSensorBase::dump_config() { +void EbusItem::dump_config() { ESP_LOGCONFIG(TAG, "EbusSensor"); ESP_LOGCONFIG(TAG, " message:"); ESP_LOGCONFIG(TAG, " send_poll: %s", this->send_poll_ ? "true" : "false"); @@ -192,7 +192,7 @@ void EbusSensorBase::dump_config() { ESP_LOGCONFIG(TAG, " command: 0x%04x", this->command_); }; -optional EbusSensorBase::prepare_command() { +optional EbusItem::prepare_command() { optional command; if (this->send_poll_) { @@ -202,7 +202,7 @@ optional EbusSensorBase::prepare_command() { return command; } -uint32_t EbusSensorBase::get_response_bytes(Telegram &telegram, uint8_t start, uint8_t length) { +uint32_t EbusItem::get_response_bytes(Telegram &telegram, uint8_t start, uint8_t length) { uint32_t result = 0; for (uint8_t i = 0; i < 4 && i < length; i++) { result = result | (telegram.get_response_byte(start + i) << (i * 8)); @@ -210,7 +210,7 @@ uint32_t EbusSensorBase::get_response_bytes(Telegram &telegram, uint8_t start, u return result; } -bool EbusSensorBase::is_mine(Telegram &telegram) { +bool EbusItem::is_mine(Telegram &telegram) { if (this->address_ != SYN && this->address_ != telegram.get_zz()) { return false; } diff --git a/esphome/components/ebus/ebus_component.h b/esphome/components/ebus/ebus_component.h index ef7a2ab087..a69f54347a 100644 --- a/esphome/components/ebus/ebus_component.h +++ b/esphome/components/ebus/ebus_component.h @@ -34,7 +34,7 @@ class EbusSender { virtual optional prepare_command() = 0; }; -class EbusSensorBase : public EbusReceiver, public EbusSender, public Component { +class EbusItem : public EbusReceiver, public EbusSender, public Component { public: void dump_config() override; @@ -79,9 +79,9 @@ class EbusComponent : public PollingComponent { void add_sender(EbusSender * /*sender*/); void add_receiver(EbusReceiver * /*receiver*/); - void add_sensor(EbusSensorBase *sensor) { - this->add_sender(sensor); - this->add_receiver(sensor); + void add_item(EbusItem *item) { + this->add_sender(item); + this->add_receiver(item); }; void update() override; diff --git a/esphome/components/ebus/sensor/__init__.py b/esphome/components/ebus/sensor/__init__.py index bd70275b20..629b025ba3 100644 --- a/esphome/components/ebus/sensor/__init__.py +++ b/esphome/components/ebus/sensor/__init__.py @@ -12,7 +12,7 @@ from .. import ( CONF_DECODE, ebus_ns, create_telegram_schema, - sensor_base_config, + item_config, ) AUTO_LOAD = ["ebus"] @@ -37,7 +37,7 @@ async def to_code(config): ebus = await cg.get_variable(config[CONF_EBUS_ID]) sens = await sensor.new_sensor(config) - sensor_base_config(ebus, sens, config) + item_config(ebus, sens, config) cg.add(sens.set_response_read_bytes(config[CONF_TELEGRAM][CONF_DECODE][CONF_BYTES])) cg.add( diff --git a/esphome/components/ebus/sensor/ebus_sensor.h b/esphome/components/ebus/sensor/ebus_sensor.h index 14f1fa2fe9..fdb9960eb9 100644 --- a/esphome/components/ebus/sensor/ebus_sensor.h +++ b/esphome/components/ebus/sensor/ebus_sensor.h @@ -6,7 +6,7 @@ namespace esphome { namespace ebus { -class EbusSensor : public EbusSensorBase, public sensor::Sensor { +class EbusSensor : public EbusItem, public sensor::Sensor { public: EbusSensor() {}