From b5975651650677e4b3478b57317d5288dd94b065 Mon Sep 17 00:00:00 2001 From: Pat Satyshur Date: Wed, 30 Apr 2025 20:14:29 -0500 Subject: [PATCH] Add a function to return the I2C address from an I2CDevice object (#8454) Co-authored-by: Djordje Mandic <6750655+DjordjeMandic@users.noreply.github.com> --- esphome/components/i2c/i2c.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/esphome/components/i2c/i2c.h b/esphome/components/i2c/i2c.h index 8d8e139c61..15f786245b 100644 --- a/esphome/components/i2c/i2c.h +++ b/esphome/components/i2c/i2c.h @@ -139,6 +139,10 @@ class I2CDevice { /// @param address of the device void set_i2c_address(uint8_t address) { address_ = address; } + /// @brief Returns the I2C address of the object. + /// @return the I2C address + uint8_t get_i2c_address() const { return this->address_; } + /// @brief we store the pointer to the I2CBus to use /// @param bus pointer to the I2CBus object void set_i2c_bus(I2CBus *bus) { bus_ = bus; }