This commit is contained in:
Otto Winter 2019-05-08 14:56:54 +02:00
parent 95428b4cfe
commit 3fe9c20188
No known key found for this signature in database
GPG key ID: DB66C0BE6013F97E
8 changed files with 11 additions and 31 deletions

View file

@ -12,8 +12,7 @@ namespace adc {
ADC_MODE(ADC_VCC)
#endif
class ADCSensor : public sensor::Sensor, public PollingComponent,
public voltage_sampler::VoltageSampler {
class ADCSensor : public sensor::Sensor, public PollingComponent, public voltage_sampler::VoltageSampler {
public:
#ifdef ARDUINO_ARCH_ESP32
/// Set the attenuation for this pin. Only available on the ESP32.

View file

@ -59,9 +59,7 @@ void ADS1115Component::setup() {
}
for (auto *sensor : this->sensors_) {
this->set_interval(sensor->get_name(), sensor->update_interval(),
[this, sensor] {
this->request_measurement(sensor);
});
[this, sensor] { this->request_measurement(sensor); });
}
}
void ADS1115Component::dump_config() {
@ -153,9 +151,7 @@ uint8_t ADS1115Sensor::get_multiplexer() const { return this->multiplexer_; }
void ADS1115Sensor::set_multiplexer(ADS1115Multiplexer multiplexer) { this->multiplexer_ = multiplexer; }
uint8_t ADS1115Sensor::get_gain() const { return this->gain_; }
void ADS1115Sensor::set_gain(ADS1115Gain gain) { this->gain_ = gain; }
float ADS1115Sensor::sample() {
return this->parent_->request_measurement(this);
}
float ADS1115Sensor::sample() { return this->parent_->request_measurement(this); }
void ADS1115Sensor::update() {
float v = this->parent_->request_measurement(this);
if (!isnan(v)) {

View file

@ -47,8 +47,7 @@ class ADS1115Component : public Component, public i2c::I2CDevice {
};
/// Internal holder class that is in instance of Sensor so that the hub can create individual sensors.
class ADS1115Sensor : public sensor::Sensor, public PollingComponent,
public voltage_sampler::VoltageSampler {
class ADS1115Sensor : public sensor::Sensor, public PollingComponent, public voltage_sampler::VoltageSampler {
public:
ADS1115Sensor(ADS1115Component *parent) : parent_(parent) {}
void update() override;

View file

@ -13,9 +13,7 @@ class BLEPresenceDevice : public binary_sensor::BinarySensor,
public esp32_ble_tracker::ESPBTDeviceListener,
public Component {
public:
void set_address(uint64_t address) {
address_ = address;
}
void set_address(uint64_t address) { address_ = address; }
void on_scan_end() override {
if (!this->found_)
this->publish_state(false);

View file

@ -11,9 +11,7 @@ namespace ble_rssi {
class BLERSSISensor : public sensor::Sensor, public esp32_ble_tracker::ESPBTDeviceListener, public Component {
public:
void set_address(uint64_t address) {
address_ = address;
}
void set_address(uint64_t address) { address_ = address; }
void on_scan_end() override {
if (!this->found_)
this->publish_state(NAN);

View file

@ -100,19 +100,13 @@ class RealTimeClock : public Component {
std::string get_timezone() { return this->timezone_; }
/// Get the time in the currently defined timezone.
ESPTime now() {
return ESPTime::from_epoch_utc(this->timestamp_now());
}
ESPTime now() { return ESPTime::from_epoch_utc(this->timestamp_now()); }
/// Get the time without any time zone or DST corrections.
ESPTime utcnow() {
return ESPTime::from_epoch_local(this->timestamp_now());
}
ESPTime utcnow() { return ESPTime::from_epoch_local(this->timestamp_now()); }
/// Get the current time as the UTC epoch since January 1st 1970.
time_t timestamp_now() {
return ::time(nullptr);
}
time_t timestamp_now() { return ::time(nullptr); }
void call_setup() override;

View file

@ -12,9 +12,7 @@ namespace xiaomi_miflora {
class XiaomiMiflora : public Component, public esp32_ble_tracker::ESPBTDeviceListener {
public:
void set_address(uint64_t address) {
address_ = address;
}
void set_address(uint64_t address) { address_ = address; }
bool parse_device(const esp32_ble_tracker::ESPBTDevice &device) override {
if (device.address_uint64() != this->address_)

View file

@ -12,9 +12,7 @@ namespace xiaomi_mijia {
class XiaomiMijia : public Component, public esp32_ble_tracker::ESPBTDeviceListener {
public:
void set_address(uint64_t address) {
address_ = address;
}
void set_address(uint64_t address) { address_ = address; }
bool parse_device(const esp32_ble_tracker::ESPBTDevice &device) override {
if (device.address_uint64() != this->address_)