Compare commits

...
Author SHA1 Message Date
J. Nick Koston 047e08980f [hdc2080] Declare child sensors with SUB_SENSOR 2026-10-28 09:03:20 -10:00
2 changed files with 5 additions and 9 deletions

No files matched your search

+3 -7
View File
@@ -7,18 +7,14 @@
namespace esphome::hdc2080 {
class HDC2080Component final : public PollingComponent, public i2c::I2CDevice {
public:
void set_temperature(sensor::Sensor *temperature) { this->temperature_sensor_ = temperature; }
void set_humidity(sensor::Sensor *humidity) { this->humidity_sensor_ = humidity; }
SUB_SENSOR(temperature)
SUB_SENSOR(humidity)
public:
/// Setup the sensor and check for connection.
void setup() override;
void dump_config() override;
void update() override;
protected:
sensor::Sensor *temperature_sensor_{nullptr};
sensor::Sensor *humidity_sensor_{nullptr};
};
} // namespace esphome::hdc2080
+2 -2
View File
@@ -47,5 +47,5 @@ async def to_code(config: ConfigType) -> None:
var = await i2c.new_i2c_component(config)
sensors = sensor.sub_sensors(config)
await sensors(CONF_TEMPERATURE, var.set_temperature)
await sensors(CONF_HUMIDITY, var.set_humidity)
await sensors(CONF_TEMPERATURE, var.set_temperature_sensor)
await sensors(CONF_HUMIDITY, var.set_humidity_sensor)