diff --git a/esphome/components/sen0501/__init__.py b/esphome/components/sen0501_i2c/__init__.py similarity index 100% rename from esphome/components/sen0501/__init__.py rename to esphome/components/sen0501_i2c/__init__.py diff --git a/esphome/components/sen0501/sen0501.cpp b/esphome/components/sen0501_i2c/sen0501_i2c.cpp similarity index 89% rename from esphome/components/sen0501/sen0501.cpp rename to esphome/components/sen0501_i2c/sen0501_i2c.cpp index f5b3c06b6b..a4a96eec4e 100644 --- a/esphome/components/sen0501/sen0501.cpp +++ b/esphome/components/sen0501_i2c/sen0501_i2c.cpp @@ -1,11 +1,11 @@ -#include "sen0501.h" +#include "sen0501_i2c.h" #include "esphome/core/log.h" #include "esphome/core/hal.h" namespace esphome { -namespace sen0501 { +namespace sen0501_i2c { -static const char *const TAG = "sen0501"; +static const char *const TAG = "sen0501_i2c"; // Device Address static const uint8_t SEN050X_DEFAULT_DEVICE_ADDRESS = 0x22; @@ -29,7 +29,7 @@ static const uint16_t REG_ATMOSPHERIC_PRESSURE = 0x0018; // PUBLIC -void Sen0501Component::setup() { +void Sen0501_i2cComponent::setup() { ESP_LOGCONFIG(TAG, "Setting up sen0501..."); uint8_t product_id_first_byte; if (!this->read_byte(REG_PID, &product_id_first_byte)) { @@ -55,7 +55,7 @@ void Sen0501Component::setup() { } } -void Sen0501Component::update() { +void Sen0501_i2cComponent::update() { this->read_temperature_(); this->read_humidity_(); this->read_uv_intensity_(); @@ -63,7 +63,7 @@ void Sen0501Component::update() { this->read_atmospheric_pressure_(); } -void Sen0501Component::dump_config() { +void Sen0501_i2cComponent::dump_config() { ESP_LOGCONFIG(TAG, "DFRobot Environmental Sensor - sen0501:"); LOG_I2C_DEVICE(this); switch (this->error_code_) { @@ -89,11 +89,11 @@ void Sen0501Component::dump_config() { LOG_SENSOR(" ", "Elevation", this->elevation_); } -float Sen0501Component::get_setup_priority() const { return setup_priority::DATA; } +float Sen0501_i2cComponent::get_setup_priority() const { return setup_priority::DATA; } // PROTECTED -void Sen0501Component::read_temperature_() { +void Sen0501_i2cComponent::read_temperature_() { if (this->temperature_ == nullptr) return; uint8_t buffer[2]; @@ -104,7 +104,7 @@ void Sen0501Component::read_temperature_() { this->temperature_->publish_state(temp); } -void Sen0501Component::read_humidity_() { +void Sen0501_i2cComponent::read_humidity_() { if (this->humidity_ == nullptr) return; uint8_t buffer[2]; @@ -115,7 +115,7 @@ void Sen0501Component::read_humidity_() { this->humidity_->publish_state(humidity); } -void Sen0501Component::read_uv_intensity_() { +void Sen0501_i2cComponent::read_uv_intensity_() { if (this->uv_intensity_ == nullptr) return; uint8_t buffer[2]; @@ -141,7 +141,7 @@ void Sen0501Component::read_uv_intensity_() { this->uv_intensity_->publish_state(ultra_violet); } -void Sen0501Component::read_luminous_intensity_() { +void Sen0501_i2cComponent::read_luminous_intensity_() { if (this->luminous_intensity_ == nullptr) return; uint8_t buffer[2]; @@ -152,7 +152,7 @@ void Sen0501Component::read_luminous_intensity_() { this->luminous_intensity_->publish_state(luminous); } -void Sen0501Component::read_atmospheric_pressure_() { +void Sen0501_i2cComponent::read_atmospheric_pressure_() { if (this->atmospheric_pressure_ == nullptr && this->elevation_ == nullptr) return; uint8_t buffer[2]; @@ -166,5 +166,5 @@ void Sen0501Component::read_atmospheric_pressure_() { } } -} // namespace sen0501 +} // namespace sen0501_i2c } // namespace esphome diff --git a/esphome/components/sen0501/sen0501.h b/esphome/components/sen0501_i2c/sen0501_i2c.h similarity index 92% rename from esphome/components/sen0501/sen0501.h rename to esphome/components/sen0501_i2c/sen0501_i2c.h index 8ff10b15e6..175805d969 100644 --- a/esphome/components/sen0501/sen0501.h +++ b/esphome/components/sen0501_i2c/sen0501_i2c.h @@ -8,9 +8,9 @@ // https://github.com/DFRobot/DFRobot_EnvironmentalSensor namespace esphome { -namespace sen0501 { +namespace sen0501_i2c { -class Sen0501Component : public PollingComponent, public i2c::I2CDevice { +class Sen0501_i2cComponent : public PollingComponent, public i2c::I2CDevice { public: void set_temperature(sensor::Sensor *temperature) { this->temperature_ = temperature; } void set_humidity(sensor::Sensor *humidity) { this->humidity_ = humidity; } @@ -48,5 +48,5 @@ class Sen0501Component : public PollingComponent, public i2c::I2CDevice { } error_code_{NONE}; }; -} // namespace sen0501 +} // namespace sen0501_i2c } // namespace esphome diff --git a/esphome/components/sen0501/sensor.py b/esphome/components/sen0501_i2c/sensor.py similarity index 94% rename from esphome/components/sen0501/sensor.py rename to esphome/components/sen0501_i2c/sensor.py index 3379503fbd..553a413a5a 100644 --- a/esphome/components/sen0501/sensor.py +++ b/esphome/components/sen0501_i2c/sensor.py @@ -33,15 +33,15 @@ CONF_ELEVATION = "elevation" DEPENDENCIES = ["i2c"] -sen0501_ns = cg.esphome_ns.namespace("sen0501") -Sen0501Component = sen0501_ns.class_( - "Sen0501Component", cg.PollingComponent, i2c.I2CDevice +sen0501_ns = cg.esphome_ns.namespace("sen0501_i2c") +Sen0501_i2cComponent = sen0501_ns.class_( + "Sen0501_i2cComponent", cg.PollingComponent, i2c.I2CDevice ) CONFIG_SCHEMA = ( cv.Schema( { - cv.GenerateID(): cv.declare_id(Sen0501Component), + cv.GenerateID(): cv.declare_id(Sen0501_i2cComponent), cv.Optional(CONF_TEMPERATURE): sensor.sensor_schema( unit_of_measurement=UNIT_CELSIUS, icon=ICON_THERMOMETER,