mirror of
https://github.com/esphome/esphome.git
synced 2024-11-28 12:46:22 +01:00
Lint
This commit is contained in:
parent
521c080989
commit
1ee85295f2
@ -60,7 +60,7 @@ void ADS1115Component::setup() {
|
|||||||
for (auto *sensor : this->sensors_) {
|
for (auto *sensor : this->sensors_) {
|
||||||
this->set_interval(sensor->get_name(), sensor->update_interval(),
|
this->set_interval(sensor->get_name(), sensor->update_interval(),
|
||||||
[this, sensor] {
|
[this, sensor] {
|
||||||
this->request_measurement_(sensor);
|
this->request_measurement(sensor);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -78,7 +78,7 @@ void ADS1115Component::dump_config() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
float ADS1115Component::get_setup_priority() const { return setup_priority::DATA; }
|
float ADS1115Component::get_setup_priority() const { return setup_priority::DATA; }
|
||||||
float ADS1115Component::request_measurement_(ADS1115Sensor *sensor) {
|
float ADS1115Component::request_measurement(ADS1115Sensor *sensor) {
|
||||||
uint16_t config;
|
uint16_t config;
|
||||||
if (!this->read_byte_16(ADS1115_REGISTER_CONFIG, &config)) {
|
if (!this->read_byte_16(ADS1115_REGISTER_CONFIG, &config)) {
|
||||||
this->status_set_warning();
|
this->status_set_warning();
|
||||||
@ -154,10 +154,10 @@ void ADS1115Sensor::set_multiplexer(ADS1115Multiplexer multiplexer) { this->mult
|
|||||||
uint8_t ADS1115Sensor::get_gain() const { return this->gain_; }
|
uint8_t ADS1115Sensor::get_gain() const { return this->gain_; }
|
||||||
void ADS1115Sensor::set_gain(ADS1115Gain gain) { this->gain_ = gain; }
|
void ADS1115Sensor::set_gain(ADS1115Gain gain) { this->gain_ = gain; }
|
||||||
float ADS1115Sensor::sample() {
|
float ADS1115Sensor::sample() {
|
||||||
return this->parent_->request_measurement_(this);
|
return this->parent_->request_measurement(this);
|
||||||
}
|
}
|
||||||
void ADS1115Sensor::update() {
|
void ADS1115Sensor::update() {
|
||||||
float v = this->parent_->request_measurement_(this);
|
float v = this->parent_->request_measurement(this);
|
||||||
if (!isnan(v)) {
|
if (!isnan(v)) {
|
||||||
ESP_LOGD(TAG, "'%s': Got Voltage=%fV", this->get_name().c_str(), v);
|
ESP_LOGD(TAG, "'%s': Got Voltage=%fV", this->get_name().c_str(), v);
|
||||||
this->publish_state(v);
|
this->publish_state(v);
|
||||||
|
@ -40,7 +40,7 @@ class ADS1115Component : public Component, public i2c::I2CDevice {
|
|||||||
float get_setup_priority() const override;
|
float get_setup_priority() const override;
|
||||||
|
|
||||||
/// Helper method to request a measurement from a sensor.
|
/// Helper method to request a measurement from a sensor.
|
||||||
float request_measurement_(ADS1115Sensor *sensor);
|
float request_measurement(ADS1115Sensor *sensor);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
std::vector<ADS1115Sensor *> sensors_;
|
std::vector<ADS1115Sensor *> sensors_;
|
||||||
|
@ -13,7 +13,7 @@ BH1750_RESOLUTIONS = {
|
|||||||
0.5: BH1750Resolution.BH1750_RESOLUTION_0P5_LX,
|
0.5: BH1750Resolution.BH1750_RESOLUTION_0P5_LX,
|
||||||
}
|
}
|
||||||
|
|
||||||
BH1750Sensor = bh1750_ns.class_('BH1750Sensor', sensor.PollingSensorComponent, i2c.I2CDevice)
|
BH1750Sensor = bh1750_ns.class_('BH1750Sensor', sensor.Sensor, cg.PollingComponent, i2c.I2CDevice)
|
||||||
|
|
||||||
CONFIG_SCHEMA = sensor.sensor_schema(UNIT_LUX, ICON_BRIGHTNESS_5, 1).extend({
|
CONFIG_SCHEMA = sensor.sensor_schema(UNIT_LUX, ICON_BRIGHTNESS_5, 1).extend({
|
||||||
cv.GenerateID(): cv.declare_id(BH1750Sensor),
|
cv.GenerateID(): cv.declare_id(BH1750Sensor),
|
||||||
|
@ -5,7 +5,7 @@ from esphome.components import sensor
|
|||||||
from esphome.const import CONF_ID, CONF_PIN, UNIT_PERCENT, ICON_PERCENT
|
from esphome.const import CONF_ID, CONF_PIN, UNIT_PERCENT, ICON_PERCENT
|
||||||
|
|
||||||
duty_cycle_ns = cg.esphome_ns.namespace('duty_cycle')
|
duty_cycle_ns = cg.esphome_ns.namespace('duty_cycle')
|
||||||
DutyCycleSensor = duty_cycle_ns.class_('DutyCycleSensor', sensor.PollingSensorComponent)
|
DutyCycleSensor = duty_cycle_ns.class_('DutyCycleSensor', sensor.Sensor, cg.PollingComponent)
|
||||||
|
|
||||||
CONFIG_SCHEMA = sensor.sensor_schema(UNIT_PERCENT, ICON_PERCENT, 1).extend({
|
CONFIG_SCHEMA = sensor.sensor_schema(UNIT_PERCENT, ICON_PERCENT, 1).extend({
|
||||||
cv.GenerateID(): cv.declare_id(DutyCycleSensor),
|
cv.GenerateID(): cv.declare_id(DutyCycleSensor),
|
||||||
|
@ -8,11 +8,8 @@
|
|||||||
namespace esphome {
|
namespace esphome {
|
||||||
namespace esp32_hall {
|
namespace esp32_hall {
|
||||||
|
|
||||||
class ESP32HallSensor : public sensor::PollingSensorComponent {
|
class ESP32HallSensor : public sensor::Sensor, public PollingComponent {
|
||||||
public:
|
public:
|
||||||
explicit ESP32HallSensor(const std::string &name, uint32_t update_interval)
|
|
||||||
: sensor::PollingSensorComponent(name, update_interval) {}
|
|
||||||
|
|
||||||
void dump_config() override;
|
void dump_config() override;
|
||||||
|
|
||||||
void update() override;
|
void update() override;
|
||||||
|
@ -1,21 +1,19 @@
|
|||||||
import esphome.codegen as cg
|
import esphome.codegen as cg
|
||||||
import esphome.config_validation as cv
|
import esphome.config_validation as cv
|
||||||
from esphome.components import sensor
|
from esphome.components import sensor
|
||||||
from esphome.const import CONF_ID, CONF_NAME, CONF_UPDATE_INTERVAL, ESP_PLATFORM_ESP32, \
|
from esphome.const import CONF_ID, ESP_PLATFORM_ESP32, UNIT_MICROTESLA, ICON_MAGNET
|
||||||
UNIT_MICROTESLA, ICON_MAGNET
|
|
||||||
|
|
||||||
ESP_PLATFORMS = [ESP_PLATFORM_ESP32]
|
ESP_PLATFORMS = [ESP_PLATFORM_ESP32]
|
||||||
|
|
||||||
esp32_hall_ns = cg.esphome_ns.namespace('esp32_hall')
|
esp32_hall_ns = cg.esphome_ns.namespace('esp32_hall')
|
||||||
ESP32HallSensor = esp32_hall_ns.class_('ESP32HallSensor', sensor.PollingSensorComponent)
|
ESP32HallSensor = esp32_hall_ns.class_('ESP32HallSensor', sensor.Sensor, cg.PollingComponent)
|
||||||
|
|
||||||
CONFIG_SCHEMA = sensor.sensor_schema(UNIT_MICROTESLA, ICON_MAGNET, 1).extend({
|
CONFIG_SCHEMA = sensor.sensor_schema(UNIT_MICROTESLA, ICON_MAGNET, 1).extend({
|
||||||
cv.GenerateID(): cv.declare_id(ESP32HallSensor),
|
cv.GenerateID(): cv.declare_id(ESP32HallSensor),
|
||||||
cv.Optional(CONF_UPDATE_INTERVAL, default='60s'): cv.update_interval,
|
}).extend(cv.polling_component_schema('60s'))
|
||||||
}).extend(cv.COMPONENT_SCHEMA)
|
|
||||||
|
|
||||||
|
|
||||||
def to_code(config):
|
def to_code(config):
|
||||||
var = cg.new_Pvariable(config[CONF_ID], config[CONF_NAME], config[CONF_UPDATE_INTERVAL])
|
var = cg.new_Pvariable(config[CONF_ID])
|
||||||
yield cg.register_component(var, config)
|
yield cg.register_component(var, config)
|
||||||
yield sensor.register_sensor(var, config)
|
yield sensor.register_sensor(var, config)
|
||||||
|
@ -5,7 +5,7 @@ from esphome.components import sensor
|
|||||||
from esphome.const import CONF_CLK_PIN, CONF_GAIN, CONF_ID, ICON_SCALE
|
from esphome.const import CONF_CLK_PIN, CONF_GAIN, CONF_ID, ICON_SCALE
|
||||||
|
|
||||||
hx711_ns = cg.esphome_ns.namespace('hx711')
|
hx711_ns = cg.esphome_ns.namespace('hx711')
|
||||||
HX711Sensor = hx711_ns.class_('HX711Sensor', sensor.PollingSensorComponent)
|
HX711Sensor = hx711_ns.class_('HX711Sensor', sensor.Sensor, cg.PollingComponent)
|
||||||
|
|
||||||
CONF_DOUT_PIN = 'dout_pin'
|
CONF_DOUT_PIN = 'dout_pin'
|
||||||
|
|
||||||
|
@ -128,7 +128,10 @@ def light_addressable_set_to_code(config, action_id, template_arg, args):
|
|||||||
if CONF_RANGE_TO in config:
|
if CONF_RANGE_TO in config:
|
||||||
templ = yield cg.templatable(config[CONF_RANGE_TO], args, cg.int32)
|
templ = yield cg.templatable(config[CONF_RANGE_TO], args, cg.int32)
|
||||||
cg.add(var.set_range_to(templ))
|
cg.add(var.set_range_to(templ))
|
||||||
rgbw_to_exp = lambda x: int(round(x * 255))
|
|
||||||
|
def rgbw_to_exp(x):
|
||||||
|
return int(round(x * 255))
|
||||||
|
|
||||||
if CONF_RED in config:
|
if CONF_RED in config:
|
||||||
templ = yield cg.templatable(config[CONF_RED], args, cg.uint8, to_exp=rgbw_to_exp)
|
templ = yield cg.templatable(config[CONF_RED], args, cg.uint8, to_exp=rgbw_to_exp)
|
||||||
cg.add(var.set_red(templ))
|
cg.add(var.set_red(templ))
|
||||||
|
@ -4,7 +4,8 @@ from esphome.components import sensor, spi
|
|||||||
from esphome.const import CONF_ID, ICON_THERMOMETER, UNIT_CELSIUS
|
from esphome.const import CONF_ID, ICON_THERMOMETER, UNIT_CELSIUS
|
||||||
|
|
||||||
max31855_ns = cg.esphome_ns.namespace('max31855')
|
max31855_ns = cg.esphome_ns.namespace('max31855')
|
||||||
MAX31855Sensor = max31855_ns.class_('MAX31855Sensor', sensor.PollingSensorComponent, spi.SPIDevice)
|
MAX31855Sensor = max31855_ns.class_('MAX31855Sensor', sensor.Sensor, cg.PollingComponent,
|
||||||
|
spi.SPIDevice)
|
||||||
|
|
||||||
CONFIG_SCHEMA = sensor.sensor_schema(UNIT_CELSIUS, ICON_THERMOMETER, 1).extend({
|
CONFIG_SCHEMA = sensor.sensor_schema(UNIT_CELSIUS, ICON_THERMOMETER, 1).extend({
|
||||||
cv.GenerateID(): cv.declare_id(MAX31855Sensor),
|
cv.GenerateID(): cv.declare_id(MAX31855Sensor),
|
||||||
|
@ -4,7 +4,7 @@ from esphome.components import sensor, spi
|
|||||||
from esphome.const import CONF_ID, ICON_THERMOMETER, UNIT_CELSIUS
|
from esphome.const import CONF_ID, ICON_THERMOMETER, UNIT_CELSIUS
|
||||||
|
|
||||||
max6675_ns = cg.esphome_ns.namespace('max6675')
|
max6675_ns = cg.esphome_ns.namespace('max6675')
|
||||||
MAX6675Sensor = max6675_ns.class_('MAX6675Sensor', sensor.PollingSensorComponent,
|
MAX6675Sensor = max6675_ns.class_('MAX6675Sensor', sensor.Sensor, cg.PollingComponent,
|
||||||
spi.SPIDevice)
|
spi.SPIDevice)
|
||||||
|
|
||||||
CONFIG_SCHEMA = sensor.sensor_schema(UNIT_CELSIUS, ICON_THERMOMETER, 1).extend({
|
CONFIG_SCHEMA = sensor.sensor_schema(UNIT_CELSIUS, ICON_THERMOMETER, 1).extend({
|
||||||
|
@ -152,7 +152,7 @@ class NeoPixelRGBLightOutput : public NeoPixelBusLightOutputBase<T_METHOD, T_COL
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
light::ESPColorView get_view_internal(int32_t index) const override {
|
light::ESPColorView get_view_internal(int32_t index) const override { // NOLINT
|
||||||
uint8_t *base = this->controller_->Pixels() + 3ULL * index;
|
uint8_t *base = this->controller_->Pixels() + 3ULL * index;
|
||||||
return light::ESPColorView(base + this->rgb_offsets_[0], base + this->rgb_offsets_[1], base + this->rgb_offsets_[2],
|
return light::ESPColorView(base + this->rgb_offsets_[0], base + this->rgb_offsets_[1], base + this->rgb_offsets_[2],
|
||||||
nullptr, this->effect_data_ + index, &this->correction_);
|
nullptr, this->effect_data_ + index, &this->correction_);
|
||||||
@ -171,7 +171,7 @@ class NeoPixelRGBWLightOutput : public NeoPixelBusLightOutputBase<T_METHOD, T_CO
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
light::ESPColorView get_view_internal(int32_t index) const override {
|
light::ESPColorView get_view_internal(int32_t index) const override { // NOLINT
|
||||||
uint8_t *base = this->controller_->Pixels() + 4ULL * index;
|
uint8_t *base = this->controller_->Pixels() + 4ULL * index;
|
||||||
return light::ESPColorView(base + this->rgb_offsets_[0], base + this->rgb_offsets_[1], base + this->rgb_offsets_[2],
|
return light::ESPColorView(base + this->rgb_offsets_[0], base + this->rgb_offsets_[1], base + this->rgb_offsets_[2],
|
||||||
base + this->rgb_offsets_[3], this->effect_data_ + index, &this->correction_);
|
base + this->rgb_offsets_[3], this->effect_data_ + index, &this->correction_);
|
||||||
|
@ -37,7 +37,23 @@ class PartitionLightOutput : public light::AddressableLight, public Component {
|
|||||||
auto &last_seg = this->segments_[this->segments_.size() - 1];
|
auto &last_seg = this->segments_[this->segments_.size() - 1];
|
||||||
return last_seg.get_dst_offset() + last_seg.get_size();
|
return last_seg.get_dst_offset() + last_seg.get_size();
|
||||||
}
|
}
|
||||||
light::ESPColorView operator[](int32_t index) const override {
|
void clear_effect_data() override {
|
||||||
|
for (auto &seg : this->segments_) {
|
||||||
|
seg.get_src()->clear_effect_data();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
light::LightTraits get_traits() override { return this->segments_[0].get_src()->get_traits(); }
|
||||||
|
void loop() override {
|
||||||
|
if (this->should_show_()) {
|
||||||
|
for (auto seg : this->segments_) {
|
||||||
|
seg.get_src()->schedule_show();
|
||||||
|
}
|
||||||
|
this->mark_shown_();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected:
|
||||||
|
light::ESPColorView get_view_internal(int32_t index) const override {
|
||||||
uint32_t lo = 0;
|
uint32_t lo = 0;
|
||||||
uint32_t hi = this->segments_.size() - 1;
|
uint32_t hi = this->segments_.size() - 1;
|
||||||
while (lo < hi) {
|
while (lo < hi) {
|
||||||
@ -61,22 +77,7 @@ class PartitionLightOutput : public light::AddressableLight, public Component {
|
|||||||
view.raw_set_color_correction(&this->correction_);
|
view.raw_set_color_correction(&this->correction_);
|
||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
void clear_effect_data() override {
|
|
||||||
for (auto &seg : this->segments_) {
|
|
||||||
seg.get_src()->clear_effect_data();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
light::LightTraits get_traits() override { return this->segments_[0].get_src()->get_traits(); }
|
|
||||||
void loop() override {
|
|
||||||
if (this->should_show_()) {
|
|
||||||
for (auto seg : this->segments_) {
|
|
||||||
seg.get_src()->schedule_show();
|
|
||||||
}
|
|
||||||
this->mark_shown_();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected:
|
|
||||||
std::vector<AddressableSegment> segments_;
|
std::vector<AddressableSegment> segments_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -18,7 +18,7 @@ COUNT_MODES = {
|
|||||||
COUNT_MODE_SCHEMA = cv.enum(COUNT_MODES, upper=True)
|
COUNT_MODE_SCHEMA = cv.enum(COUNT_MODES, upper=True)
|
||||||
|
|
||||||
PulseCounterSensor = pulse_counter_ns.class_('PulseCounterSensor',
|
PulseCounterSensor = pulse_counter_ns.class_('PulseCounterSensor',
|
||||||
sensor.PollingSensorComponent)
|
sensor.Sensor, cg.PollingComponent)
|
||||||
|
|
||||||
|
|
||||||
def validate_internal_filter(value):
|
def validate_internal_filter(value):
|
||||||
|
@ -6,7 +6,7 @@ from esphome.const import CONF_ID, CONF_PIN, UNIT_SECOND, ICON_TIMER
|
|||||||
|
|
||||||
pulse_width_ns = cg.esphome_ns.namespace('pulse_width')
|
pulse_width_ns = cg.esphome_ns.namespace('pulse_width')
|
||||||
|
|
||||||
PulseWidthSensor = pulse_width_ns.class_('PulseWidthSensor', sensor.PollingSensorComponent)
|
PulseWidthSensor = pulse_width_ns.class_('PulseWidthSensor', sensor.Sensor, cg.PollingComponent)
|
||||||
|
|
||||||
CONFIG_SCHEMA = sensor.sensor_schema(UNIT_SECOND, ICON_TIMER, 3).extend({
|
CONFIG_SCHEMA = sensor.sensor_schema(UNIT_SECOND, ICON_TIMER, 3).extend({
|
||||||
cv.GenerateID(): cv.declare_id(PulseWidthSensor),
|
cv.GenerateID(): cv.declare_id(PulseWidthSensor),
|
||||||
|
@ -5,7 +5,7 @@ from esphome.components import sensor
|
|||||||
from esphome.const import CONF_ID, CONF_LAMBDA, CONF_STATE, UNIT_EMPTY, ICON_EMPTY
|
from esphome.const import CONF_ID, CONF_LAMBDA, CONF_STATE, UNIT_EMPTY, ICON_EMPTY
|
||||||
from .. import template_ns
|
from .. import template_ns
|
||||||
|
|
||||||
TemplateSensor = template_ns.class_('TemplateSensor', sensor.PollingSensorComponent)
|
TemplateSensor = template_ns.class_('TemplateSensor', sensor.Sensor, cg.PollingComponent)
|
||||||
|
|
||||||
CONFIG_SCHEMA = sensor.sensor_schema(UNIT_EMPTY, ICON_EMPTY, 1).extend({
|
CONFIG_SCHEMA = sensor.sensor_schema(UNIT_EMPTY, ICON_EMPTY, 1).extend({
|
||||||
cv.GenerateID(): cv.declare_id(TemplateSensor),
|
cv.GenerateID(): cv.declare_id(TemplateSensor),
|
||||||
|
@ -27,7 +27,8 @@ def validate_integration_time(value):
|
|||||||
return cv.enum(INTEGRATION_TIMES, int=True)(value)
|
return cv.enum(INTEGRATION_TIMES, int=True)(value)
|
||||||
|
|
||||||
|
|
||||||
TSL2561Sensor = tsl2561_ns.class_('TSL2561Sensor', sensor.PollingSensorComponent, i2c.I2CDevice)
|
TSL2561Sensor = tsl2561_ns.class_('TSL2561Sensor', sensor.Sensor, cg.PollingComponent,
|
||||||
|
i2c.I2CDevice)
|
||||||
|
|
||||||
CONFIG_SCHEMA = sensor.sensor_schema(UNIT_LUX, ICON_BRIGHTNESS_5, 1).extend({
|
CONFIG_SCHEMA = sensor.sensor_schema(UNIT_LUX, ICON_BRIGHTNESS_5, 1).extend({
|
||||||
cv.GenerateID(): cv.declare_id(TSL2561Sensor),
|
cv.GenerateID(): cv.declare_id(TSL2561Sensor),
|
||||||
|
@ -9,7 +9,7 @@ CONF_PULSE_TIME = 'pulse_time'
|
|||||||
|
|
||||||
ultrasonic_ns = cg.esphome_ns.namespace('ultrasonic')
|
ultrasonic_ns = cg.esphome_ns.namespace('ultrasonic')
|
||||||
UltrasonicSensorComponent = ultrasonic_ns.class_('UltrasonicSensorComponent',
|
UltrasonicSensorComponent = ultrasonic_ns.class_('UltrasonicSensorComponent',
|
||||||
sensor.PollingSensorComponent)
|
sensor.Sensor, cg.PollingComponent)
|
||||||
|
|
||||||
CONFIG_SCHEMA = sensor.sensor_schema(UNIT_METER, ICON_ARROW_EXPAND_VERTICAL, 2).extend({
|
CONFIG_SCHEMA = sensor.sensor_schema(UNIT_METER, ICON_ARROW_EXPAND_VERTICAL, 2).extend({
|
||||||
cv.GenerateID(): cv.declare_id(UltrasonicSensorComponent),
|
cv.GenerateID(): cv.declare_id(UltrasonicSensorComponent),
|
||||||
|
@ -4,7 +4,7 @@ from esphome.components import sensor
|
|||||||
from esphome.const import CONF_ID, UNIT_SECOND, ICON_TIMER
|
from esphome.const import CONF_ID, UNIT_SECOND, ICON_TIMER
|
||||||
|
|
||||||
uptime_ns = cg.esphome_ns.namespace('uptime')
|
uptime_ns = cg.esphome_ns.namespace('uptime')
|
||||||
UptimeSensor = uptime_ns.class_('UptimeSensor', sensor.PollingSensorComponent)
|
UptimeSensor = uptime_ns.class_('UptimeSensor', sensor.Sensor, cg.PollingComponent)
|
||||||
|
|
||||||
CONFIG_SCHEMA = sensor.sensor_schema(UNIT_SECOND, ICON_TIMER, 0).extend({
|
CONFIG_SCHEMA = sensor.sensor_schema(UNIT_SECOND, ICON_TIMER, 0).extend({
|
||||||
cv.GenerateID(): cv.declare_id(UptimeSensor),
|
cv.GenerateID(): cv.declare_id(UptimeSensor),
|
||||||
|
@ -5,7 +5,7 @@ from esphome.const import CONF_ID, ICON_WIFI, UNIT_DECIBEL
|
|||||||
|
|
||||||
DEPENDENCIES = ['wifi']
|
DEPENDENCIES = ['wifi']
|
||||||
wifi_signal_ns = cg.esphome_ns.namespace('wifi_signal')
|
wifi_signal_ns = cg.esphome_ns.namespace('wifi_signal')
|
||||||
WiFiSignalSensor = wifi_signal_ns.class_('WiFiSignalSensor', sensor.PollingSensorComponent)
|
WiFiSignalSensor = wifi_signal_ns.class_('WiFiSignalSensor', sensor.Sensor, cg.PollingComponent)
|
||||||
|
|
||||||
CONFIG_SCHEMA = sensor.sensor_schema(UNIT_DECIBEL, ICON_WIFI, 0).extend({
|
CONFIG_SCHEMA = sensor.sensor_schema(UNIT_DECIBEL, ICON_WIFI, 0).extend({
|
||||||
cv.GenerateID(): cv.declare_id(WiFiSignalSensor),
|
cv.GenerateID(): cv.declare_id(WiFiSignalSensor),
|
||||||
|
@ -7,6 +7,7 @@ import sys
|
|||||||
|
|
||||||
root_path = os.path.abspath(os.path.normpath(os.path.join(__file__, '..', '..')))
|
root_path = os.path.abspath(os.path.normpath(os.path.join(__file__, '..', '..')))
|
||||||
basepath = os.path.join(root_path, 'esphome')
|
basepath = os.path.join(root_path, 'esphome')
|
||||||
|
temp_header_file = os.path.join(root_path, '.temp-clang-tidy.cpp')
|
||||||
|
|
||||||
|
|
||||||
def walk_files(path):
|
def walk_files(path):
|
||||||
@ -24,6 +25,24 @@ def shlex_quote(s):
|
|||||||
return u"'" + s.replace(u"'", u"'\"'\"'") + u"'"
|
return u"'" + s.replace(u"'", u"'\"'\"'") + u"'"
|
||||||
|
|
||||||
|
|
||||||
|
def build_all_include():
|
||||||
|
# Build a cpp file that includes all header files in this repo.
|
||||||
|
# Otherwise header-only integrations would not be tested by clang-tidy
|
||||||
|
headers = []
|
||||||
|
for path in walk_files(basepath):
|
||||||
|
filetypes = ('.h',)
|
||||||
|
ext = os.path.splitext(path)[1]
|
||||||
|
if ext in filetypes:
|
||||||
|
path = os.path.relpath(path, root_path)
|
||||||
|
include_p = path.replace(os.path.sep, '/')
|
||||||
|
headers.append('#include "{}"'.format(include_p))
|
||||||
|
headers.sort()
|
||||||
|
headers.append('')
|
||||||
|
content = '\n'.join(headers)
|
||||||
|
with codecs.open(temp_header_file, 'w', encoding='utf-8') as f:
|
||||||
|
f.write(content)
|
||||||
|
|
||||||
|
|
||||||
def build_compile_commands():
|
def build_compile_commands():
|
||||||
gcc_flags_json = os.path.join(root_path, '.gcc-flags.json')
|
gcc_flags_json = os.path.join(root_path, '.gcc-flags.json')
|
||||||
if not os.path.isfile(gcc_flags_json):
|
if not os.path.isfile(gcc_flags_json):
|
||||||
@ -52,6 +71,7 @@ def build_compile_commands():
|
|||||||
ext = os.path.splitext(path)[1]
|
ext = os.path.splitext(path)[1]
|
||||||
if ext in filetypes:
|
if ext in filetypes:
|
||||||
source_files.append(os.path.abspath(path))
|
source_files.append(os.path.abspath(path))
|
||||||
|
source_files.append(temp_header_file)
|
||||||
source_files.sort()
|
source_files.sort()
|
||||||
compile_commands = [{
|
compile_commands = [{
|
||||||
'directory': root_path,
|
'directory': root_path,
|
||||||
@ -71,6 +91,7 @@ def build_compile_commands():
|
|||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
build_all_include()
|
||||||
build_compile_commands()
|
build_compile_commands()
|
||||||
print("Done.")
|
print("Done.")
|
||||||
|
|
||||||
|
@ -264,8 +264,6 @@ def main():
|
|||||||
print('Ctrl-C detected, goodbye.')
|
print('Ctrl-C detected, goodbye.')
|
||||||
if tmpdir:
|
if tmpdir:
|
||||||
shutil.rmtree(tmpdir)
|
shutil.rmtree(tmpdir)
|
||||||
if os.path.exists(temp_header_file):
|
|
||||||
os.remove(temp_header_file)
|
|
||||||
os.kill(0, 9)
|
os.kill(0, 9)
|
||||||
|
|
||||||
if args.fix and failed_files:
|
if args.fix and failed_files:
|
||||||
@ -274,12 +272,8 @@ def main():
|
|||||||
subprocess.call(['clang-apply-replacements-7', tmpdir])
|
subprocess.call(['clang-apply-replacements-7', tmpdir])
|
||||||
except:
|
except:
|
||||||
print('Error applying fixes.\n', file=sys.stderr)
|
print('Error applying fixes.\n', file=sys.stderr)
|
||||||
if os.path.exists(temp_header_file):
|
|
||||||
os.remove(temp_header_file)
|
|
||||||
raise
|
raise
|
||||||
|
|
||||||
if os.path.exists(temp_header_file):
|
|
||||||
os.remove(temp_header_file)
|
|
||||||
sys.exit(return_code)
|
sys.exit(return_code)
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user