Ruff format

This commit is contained in:
thetestspecimen 2024-10-10 21:59:36 +03:00
parent ddec962820
commit cd5c7b3f7a
No known key found for this signature in database
GPG Key ID: C88001C355A25170
3 changed files with 31 additions and 32 deletions

View File

@ -29,7 +29,7 @@ static const uint16_t REG_ATMOSPHERIC_PRESSURE = 0x0018;
// PUBLIC
void Sen0501_i2cComponent::setup() {
void Sen0501I2CComponent::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 Sen0501_i2cComponent::setup() {
}
}
void Sen0501_i2cComponent::update() {
void Sen0501I2CComponent::update() {
this->read_temperature_();
this->read_humidity_();
this->read_uv_intensity_();
@ -63,7 +63,7 @@ void Sen0501_i2cComponent::update() {
this->read_atmospheric_pressure_();
}
void Sen0501_i2cComponent::dump_config() {
void Sen0501I2CComponent::dump_config() {
ESP_LOGCONFIG(TAG, "DFRobot Environmental Sensor - sen0501:");
LOG_I2C_DEVICE(this);
switch (this->error_code_) {
@ -89,11 +89,11 @@ void Sen0501_i2cComponent::dump_config() {
LOG_SENSOR(" ", "Elevation", this->elevation_);
}
float Sen0501_i2cComponent::get_setup_priority() const { return setup_priority::DATA; }
float Sen0501I2CComponent::get_setup_priority() const { return setup_priority::DATA; }
// PROTECTED
void Sen0501_i2cComponent::read_temperature_() {
void Sen0501I2CComponent::read_temperature_() {
if (this->temperature_ == nullptr)
return;
uint8_t buffer[2];
@ -104,7 +104,7 @@ void Sen0501_i2cComponent::read_temperature_() {
this->temperature_->publish_state(temp);
}
void Sen0501_i2cComponent::read_humidity_() {
void Sen0501I2CComponent::read_humidity_() {
if (this->humidity_ == nullptr)
return;
uint8_t buffer[2];
@ -115,7 +115,7 @@ void Sen0501_i2cComponent::read_humidity_() {
this->humidity_->publish_state(humidity);
}
void Sen0501_i2cComponent::read_uv_intensity_() {
void Sen0501I2CComponent::read_uv_intensity_() {
if (this->uv_intensity_ == nullptr)
return;
uint8_t buffer[2];
@ -141,7 +141,7 @@ void Sen0501_i2cComponent::read_uv_intensity_() {
this->uv_intensity_->publish_state(ultra_violet);
}
void Sen0501_i2cComponent::read_luminous_intensity_() {
void Sen0501I2CComponent::read_luminous_intensity_() {
if (this->luminous_intensity_ == nullptr)
return;
uint8_t buffer[2];
@ -152,7 +152,7 @@ void Sen0501_i2cComponent::read_luminous_intensity_() {
this->luminous_intensity_->publish_state(luminous);
}
void Sen0501_i2cComponent::read_atmospheric_pressure_() {
void Sen0501I2CComponent::read_atmospheric_pressure_() {
if (this->atmospheric_pressure_ == nullptr && this->elevation_ == nullptr)
return;
uint8_t buffer[2];

View File

@ -10,7 +10,7 @@
namespace esphome {
namespace sen0501_i2c {
class Sen0501_i2cComponent : public PollingComponent, public i2c::I2CDevice {
class Sen0501I2CComponent : public PollingComponent, public i2c::I2CDevice {
public:
void set_temperature(sensor::Sensor *temperature) { this->temperature_ = temperature; }
void set_humidity(sensor::Sensor *humidity) { this->humidity_ = humidity; }

View File

@ -1,32 +1,32 @@
import esphome.codegen as cg
import esphome.config_validation as cv
from esphome.components import i2c, sensor
import esphome.config_validation as cv
from esphome.const import (
ICON_BRIGHTNESS_5,
ICON_ELEVATION,
ICON_GAUGE,
ICON_THERMOMETER,
ICON_UV_RADIATION,
ICON_WATER_PERCENT,
UNIT_CELSIUS,
UNIT_HECTOPASCAL,
UNIT_IRRADIANCE,
UNIT_LUX,
UNIT_METER,
UNIT_PERCENT,
CONF_HUMIDITY,
CONF_ID,
CONF_ILLUMINANCE,
CONF_PRESSURE,
CONF_TEMPERATURE,
CONF_UV_IRRADIANCE,
DEVICE_CLASS_ATMOSPHERIC_PRESSURE,
DEVICE_CLASS_DISTANCE,
DEVICE_CLASS_HUMIDITY,
DEVICE_CLASS_ILLUMINANCE,
DEVICE_CLASS_IRRADIANCE,
DEVICE_CLASS_TEMPERATURE,
CONF_HUMIDITY,
CONF_ID,
CONF_ILLUMINANCE,
CONF_TEMPERATURE,
CONF_PRESSURE,
CONF_UV_IRRADIANCE,
ICON_BRIGHTNESS_5,
ICON_ELEVATION,
ICON_GAUGE,
ICON_THERMOMETER,
ICON_UV_RADIATION,
ICON_WATER_PERCENT,
STATE_CLASS_MEASUREMENT,
UNIT_CELSIUS,
UNIT_HECTOPASCAL,
UNIT_IRRADIANCE,
UNIT_LUX,
UNIT_METER,
UNIT_PERCENT,
)
CONF_ELEVATION = "elevation"
@ -34,14 +34,14 @@ CONF_ELEVATION = "elevation"
DEPENDENCIES = ["i2c"]
sen0501_ns = cg.esphome_ns.namespace("sen0501_i2c")
Sen0501_i2cComponent = sen0501_ns.class_(
Sen0501I2CComponent = sen0501_ns.class_(
"Sen0501_i2cComponent", cg.PollingComponent, i2c.I2CDevice
)
CONFIG_SCHEMA = (
cv.Schema(
{
cv.GenerateID(): cv.declare_id(Sen0501_i2cComponent),
cv.GenerateID(): cv.declare_id(Sen0501I2CComponent),
cv.Optional(CONF_TEMPERATURE): sensor.sensor_schema(
unit_of_measurement=UNIT_CELSIUS,
icon=ICON_THERMOMETER,
@ -92,7 +92,6 @@ CONFIG_SCHEMA = (
async def to_code(config):
var = cg.new_Pvariable(config[CONF_ID])
await cg.register_component(var, config)
await i2c.register_i2c_device(var, config)