Initialize all child sensors to nullptr (#3808)

This commit is contained in:
Jesse Hills 2022-09-15 11:53:22 +12:00
parent 6b23b7cad7
commit df4d0da221
No known key found for this signature in database
GPG key ID: BEAAE804EFD8E83A
27 changed files with 93 additions and 93 deletions

View file

@ -18,8 +18,8 @@ class AHT10Component : public PollingComponent, public i2c::I2CDevice {
void set_humidity_sensor(sensor::Sensor *humidity_sensor) { humidity_sensor_ = humidity_sensor; } void set_humidity_sensor(sensor::Sensor *humidity_sensor) { humidity_sensor_ = humidity_sensor; }
protected: protected:
sensor::Sensor *temperature_sensor_; sensor::Sensor *temperature_sensor_{nullptr};
sensor::Sensor *humidity_sensor_; sensor::Sensor *humidity_sensor_{nullptr};
}; };
} // namespace aht10 } // namespace aht10

View file

@ -21,8 +21,8 @@ class AM2320Component : public PollingComponent, public i2c::I2CDevice {
bool read_data_(uint8_t *data); bool read_data_(uint8_t *data);
bool read_bytes_(uint8_t a_register, uint8_t *data, uint8_t len, uint32_t conversion = 0); bool read_bytes_(uint8_t a_register, uint8_t *data, uint8_t len, uint32_t conversion = 0);
sensor::Sensor *temperature_sensor_; sensor::Sensor *temperature_sensor_{nullptr};
sensor::Sensor *humidity_sensor_; sensor::Sensor *humidity_sensor_{nullptr};
}; };
} // namespace am2320 } // namespace am2320

View file

@ -92,9 +92,9 @@ class AS3935Component : public Component {
virtual void write_register(uint8_t reg, uint8_t mask, uint8_t bits, uint8_t start_position) = 0; virtual void write_register(uint8_t reg, uint8_t mask, uint8_t bits, uint8_t start_position) = 0;
sensor::Sensor *distance_sensor_; sensor::Sensor *distance_sensor_{nullptr};
sensor::Sensor *energy_sensor_; sensor::Sensor *energy_sensor_{nullptr};
binary_sensor::BinarySensor *thunder_alert_binary_sensor_; binary_sensor::BinarySensor *thunder_alert_binary_sensor_{nullptr};
GPIOPin *irq_pin_; GPIOPin *irq_pin_;
bool indoor_; bool indoor_;

View file

@ -75,16 +75,16 @@ class BL0939 : public PollingComponent, public uart::UARTDevice {
void dump_config() override; void dump_config() override;
protected: protected:
sensor::Sensor *voltage_sensor_; sensor::Sensor *voltage_sensor_{nullptr};
sensor::Sensor *current_sensor_1_; sensor::Sensor *current_sensor_1_{nullptr};
sensor::Sensor *current_sensor_2_; sensor::Sensor *current_sensor_2_{nullptr};
// NB This may be negative as the circuits is seemingly able to measure // NB This may be negative as the circuits is seemingly able to measure
// power in both directions // power in both directions
sensor::Sensor *power_sensor_1_; sensor::Sensor *power_sensor_1_{nullptr};
sensor::Sensor *power_sensor_2_; sensor::Sensor *power_sensor_2_{nullptr};
sensor::Sensor *energy_sensor_1_; sensor::Sensor *energy_sensor_1_{nullptr};
sensor::Sensor *energy_sensor_2_; sensor::Sensor *energy_sensor_2_{nullptr};
sensor::Sensor *energy_sensor_sum_; sensor::Sensor *energy_sensor_sum_{nullptr};
// Divide by this to turn into Watt // Divide by this to turn into Watt
float power_reference_ = BL0939_PREF; float power_reference_ = BL0939_PREF;

View file

@ -75,14 +75,14 @@ class BL0940 : public PollingComponent, public uart::UARTDevice {
void dump_config() override; void dump_config() override;
protected: protected:
sensor::Sensor *voltage_sensor_; sensor::Sensor *voltage_sensor_{nullptr};
sensor::Sensor *current_sensor_; sensor::Sensor *current_sensor_{nullptr};
// NB This may be negative as the circuits is seemingly able to measure // NB This may be negative as the circuits is seemingly able to measure
// power in both directions // power in both directions
sensor::Sensor *power_sensor_; sensor::Sensor *power_sensor_{nullptr};
sensor::Sensor *energy_sensor_; sensor::Sensor *energy_sensor_{nullptr};
sensor::Sensor *internal_temperature_sensor_; sensor::Sensor *internal_temperature_sensor_{nullptr};
sensor::Sensor *external_temperature_sensor_; sensor::Sensor *external_temperature_sensor_{nullptr};
// Max difference between two measurements of the temperature. Used to avoid noise. // Max difference between two measurements of the temperature. Used to avoid noise.
float max_temperature_diff_{0}; float max_temperature_diff_{0};

View file

@ -43,13 +43,13 @@ class BL0942 : public PollingComponent, public uart::UARTDevice {
void dump_config() override; void dump_config() override;
protected: protected:
sensor::Sensor *voltage_sensor_; sensor::Sensor *voltage_sensor_{nullptr};
sensor::Sensor *current_sensor_; sensor::Sensor *current_sensor_{nullptr};
// NB This may be negative as the circuits is seemingly able to measure // NB This may be negative as the circuits is seemingly able to measure
// power in both directions // power in both directions
sensor::Sensor *power_sensor_; sensor::Sensor *power_sensor_{nullptr};
sensor::Sensor *energy_sensor_; sensor::Sensor *energy_sensor_{nullptr};
sensor::Sensor *frequency_sensor_; sensor::Sensor *frequency_sensor_{nullptr};
// Divide by this to turn into Watt // Divide by this to turn into Watt
float power_reference_ = BL0942_PREF; float power_reference_ = BL0942_PREF;

View file

@ -96,9 +96,9 @@ class BME280Component : public PollingComponent, public i2c::I2CDevice {
BME280Oversampling pressure_oversampling_{BME280_OVERSAMPLING_16X}; BME280Oversampling pressure_oversampling_{BME280_OVERSAMPLING_16X};
BME280Oversampling humidity_oversampling_{BME280_OVERSAMPLING_16X}; BME280Oversampling humidity_oversampling_{BME280_OVERSAMPLING_16X};
BME280IIRFilter iir_filter_{BME280_IIR_FILTER_OFF}; BME280IIRFilter iir_filter_{BME280_IIR_FILTER_OFF};
sensor::Sensor *temperature_sensor_; sensor::Sensor *temperature_sensor_{nullptr};
sensor::Sensor *pressure_sensor_; sensor::Sensor *pressure_sensor_{nullptr};
sensor::Sensor *humidity_sensor_; sensor::Sensor *humidity_sensor_{nullptr};
enum ErrorCode { enum ErrorCode {
NONE = 0, NONE = 0,
COMMUNICATION_FAILED, COMMUNICATION_FAILED,

View file

@ -129,10 +129,10 @@ class BME680Component : public PollingComponent, public i2c::I2CDevice {
uint16_t heater_temperature_{320}; uint16_t heater_temperature_{320};
uint16_t heater_duration_{150}; uint16_t heater_duration_{150};
sensor::Sensor *temperature_sensor_; sensor::Sensor *temperature_sensor_{nullptr};
sensor::Sensor *pressure_sensor_; sensor::Sensor *pressure_sensor_{nullptr};
sensor::Sensor *humidity_sensor_; sensor::Sensor *humidity_sensor_{nullptr};
sensor::Sensor *gas_resistance_sensor_; sensor::Sensor *gas_resistance_sensor_{nullptr};
}; };
} // namespace bme680 } // namespace bme680

View file

@ -100,15 +100,15 @@ class BME680BSECComponent : public Component, public i2c::I2CDevice {
SampleRate pressure_sample_rate_{SAMPLE_RATE_DEFAULT}; SampleRate pressure_sample_rate_{SAMPLE_RATE_DEFAULT};
SampleRate humidity_sample_rate_{SAMPLE_RATE_DEFAULT}; SampleRate humidity_sample_rate_{SAMPLE_RATE_DEFAULT};
sensor::Sensor *temperature_sensor_; sensor::Sensor *temperature_sensor_{nullptr};
sensor::Sensor *pressure_sensor_; sensor::Sensor *pressure_sensor_{nullptr};
sensor::Sensor *humidity_sensor_; sensor::Sensor *humidity_sensor_{nullptr};
sensor::Sensor *gas_resistance_sensor_; sensor::Sensor *gas_resistance_sensor_{nullptr};
sensor::Sensor *iaq_sensor_; sensor::Sensor *iaq_sensor_{nullptr};
text_sensor::TextSensor *iaq_accuracy_text_sensor_; text_sensor::TextSensor *iaq_accuracy_text_sensor_{nullptr};
sensor::Sensor *iaq_accuracy_sensor_; sensor::Sensor *iaq_accuracy_sensor_{nullptr};
sensor::Sensor *co2_equivalent_sensor_; sensor::Sensor *co2_equivalent_sensor_{nullptr};
sensor::Sensor *breath_voc_equivalent_sensor_; sensor::Sensor *breath_voc_equivalent_sensor_{nullptr};
}; };
#endif #endif
} // namespace bme680_bsec } // namespace bme680_bsec

View file

@ -81,8 +81,8 @@ class BMP280Component : public PollingComponent, public i2c::I2CDevice {
BMP280Oversampling temperature_oversampling_{BMP280_OVERSAMPLING_16X}; BMP280Oversampling temperature_oversampling_{BMP280_OVERSAMPLING_16X};
BMP280Oversampling pressure_oversampling_{BMP280_OVERSAMPLING_16X}; BMP280Oversampling pressure_oversampling_{BMP280_OVERSAMPLING_16X};
BMP280IIRFilter iir_filter_{BMP280_IIR_FILTER_OFF}; BMP280IIRFilter iir_filter_{BMP280_IIR_FILTER_OFF};
sensor::Sensor *temperature_sensor_; sensor::Sensor *temperature_sensor_{nullptr};
sensor::Sensor *pressure_sensor_; sensor::Sensor *pressure_sensor_{nullptr};
enum ErrorCode { enum ErrorCode {
NONE = 0, NONE = 0,
COMMUNICATION_FAILED, COMMUNICATION_FAILED,

View file

@ -125,8 +125,8 @@ class BMP3XXComponent : public PollingComponent, public i2c::I2CDevice {
Oversampling pressure_oversampling_{OVERSAMPLING_X16}; Oversampling pressure_oversampling_{OVERSAMPLING_X16};
IIRFilter iir_filter_{IIR_FILTER_OFF}; IIRFilter iir_filter_{IIR_FILTER_OFF};
OperationMode operation_mode_{FORCED_MODE}; OperationMode operation_mode_{FORCED_MODE};
sensor::Sensor *temperature_sensor_; sensor::Sensor *temperature_sensor_{nullptr};
sensor::Sensor *pressure_sensor_; sensor::Sensor *pressure_sensor_{nullptr};
enum ErrorCode { enum ErrorCode {
NONE = 0, NONE = 0,
ERROR_COMMUNICATION_FAILED, ERROR_COMMUNICATION_FAILED,

View file

@ -20,8 +20,8 @@ class DHT12Component : public PollingComponent, public i2c::I2CDevice {
protected: protected:
bool read_data_(uint8_t *data); bool read_data_(uint8_t *data);
sensor::Sensor *temperature_sensor_; sensor::Sensor *temperature_sensor_{nullptr};
sensor::Sensor *humidity_sensor_; sensor::Sensor *humidity_sensor_{nullptr};
}; };
} // namespace dht12 } // namespace dht12

View file

@ -53,8 +53,8 @@ class DPS310Component : public PollingComponent, public i2c::I2CDevice {
void calculate_values_(int32_t raw_temperature, int32_t raw_pressure); void calculate_values_(int32_t raw_temperature, int32_t raw_pressure);
static int32_t twos_complement(int32_t val, uint8_t bits); static int32_t twos_complement(int32_t val, uint8_t bits);
sensor::Sensor *temperature_sensor_; sensor::Sensor *temperature_sensor_{nullptr};
sensor::Sensor *pressure_sensor_; sensor::Sensor *pressure_sensor_{nullptr};
int32_t raw_pressure_, raw_temperature_, c00_, c10_; int32_t raw_pressure_, raw_temperature_, c00_, c10_;
int16_t c0_, c1_, c01_, c11_, c20_, c21_, c30_; int16_t c0_, c1_, c01_, c11_, c20_, c21_, c30_;
uint8_t prod_rev_id_; uint8_t prod_rev_id_;

View file

@ -31,8 +31,8 @@ class ENS210Component : public PollingComponent, public i2c::I2CDevice {
bool set_low_power_(bool enable); bool set_low_power_(bool enable);
void extract_measurement_(uint32_t val, int *data, int *status); void extract_measurement_(uint32_t val, int *data, int *status);
sensor::Sensor *temperature_sensor_; sensor::Sensor *temperature_sensor_{nullptr};
sensor::Sensor *humidity_sensor_; sensor::Sensor *humidity_sensor_{nullptr};
}; };
} // namespace ens210 } // namespace ens210

View file

@ -21,8 +21,8 @@ class HDC1080Component : public PollingComponent, public i2c::I2CDevice {
float get_setup_priority() const override; float get_setup_priority() const override;
protected: protected:
sensor::Sensor *temperature_; sensor::Sensor *temperature_{nullptr};
sensor::Sensor *humidity_; sensor::Sensor *humidity_{nullptr};
}; };
} // namespace hdc1080 } // namespace hdc1080

View file

@ -54,10 +54,10 @@ class HMC5883LComponent : public PollingComponent, public i2c::I2CDevice {
HMC5883LOversampling oversampling_{HMC5883L_OVERSAMPLING_1}; HMC5883LOversampling oversampling_{HMC5883L_OVERSAMPLING_1};
HMC5883LDatarate datarate_{HMC5883L_DATARATE_15_0_HZ}; HMC5883LDatarate datarate_{HMC5883L_DATARATE_15_0_HZ};
HMC5883LRange range_{HMC5883L_RANGE_130_UT}; HMC5883LRange range_{HMC5883L_RANGE_130_UT};
sensor::Sensor *x_sensor_; sensor::Sensor *x_sensor_{nullptr};
sensor::Sensor *y_sensor_; sensor::Sensor *y_sensor_{nullptr};
sensor::Sensor *z_sensor_; sensor::Sensor *z_sensor_{nullptr};
sensor::Sensor *heading_sensor_; sensor::Sensor *heading_sensor_{nullptr};
enum ErrorCode { enum ErrorCode {
NONE = 0, NONE = 0,
COMMUNICATION_FAILED, COMMUNICATION_FAILED,

View file

@ -29,8 +29,8 @@ class HONEYWELLABPSensor : public PollingComponent,
uint8_t status_ = 0; // byte to hold status information. uint8_t status_ = 0; // byte to hold status information.
int pressure_count_ = 0; // hold raw pressure data (14 - bit, 0 - 16384) int pressure_count_ = 0; // hold raw pressure data (14 - bit, 0 - 16384)
int temperature_count_ = 0; // hold raw temperature data (11 - bit, 0 - 2048) int temperature_count_ = 0; // hold raw temperature data (11 - bit, 0 - 2048)
sensor::Sensor *pressure_sensor_; sensor::Sensor *pressure_sensor_{nullptr};
sensor::Sensor *temperature_sensor_; sensor::Sensor *temperature_sensor_{nullptr};
uint8_t readsensor_(); uint8_t readsensor_();
uint8_t readstatus_(); uint8_t readstatus_();
int rawpressure_(); int rawpressure_();

View file

@ -22,8 +22,8 @@ class MS5611Component : public PollingComponent, public i2c::I2CDevice {
void read_pressure_(uint32_t raw_temperature); void read_pressure_(uint32_t raw_temperature);
void calculate_values_(uint32_t raw_temperature, uint32_t raw_pressure); void calculate_values_(uint32_t raw_temperature, uint32_t raw_pressure);
sensor::Sensor *temperature_sensor_; sensor::Sensor *temperature_sensor_{nullptr};
sensor::Sensor *pressure_sensor_; sensor::Sensor *pressure_sensor_{nullptr};
uint16_t prom_[6]; uint16_t prom_[6];
}; };

View file

@ -23,10 +23,10 @@ class PZEM004T : public PollingComponent, public uart::UARTDevice {
void dump_config() override; void dump_config() override;
protected: protected:
sensor::Sensor *voltage_sensor_; sensor::Sensor *voltage_sensor_{nullptr};
sensor::Sensor *current_sensor_; sensor::Sensor *current_sensor_{nullptr};
sensor::Sensor *power_sensor_; sensor::Sensor *power_sensor_{nullptr};
sensor::Sensor *energy_sensor_; sensor::Sensor *energy_sensor_{nullptr};
enum PZEM004TReadState { enum PZEM004TReadState {
SET_ADDRESS = 0xB4, SET_ADDRESS = 0xB4,

View file

@ -27,12 +27,12 @@ class PZEMAC : public PollingComponent, public modbus::ModbusDevice {
protected: protected:
template<typename... Ts> friend class ResetEnergyAction; template<typename... Ts> friend class ResetEnergyAction;
sensor::Sensor *voltage_sensor_; sensor::Sensor *voltage_sensor_{nullptr};
sensor::Sensor *current_sensor_; sensor::Sensor *current_sensor_{nullptr};
sensor::Sensor *power_sensor_; sensor::Sensor *power_sensor_{nullptr};
sensor::Sensor *energy_sensor_; sensor::Sensor *energy_sensor_{nullptr};
sensor::Sensor *frequency_sensor_; sensor::Sensor *frequency_sensor_{nullptr};
sensor::Sensor *power_factor_sensor_; sensor::Sensor *power_factor_sensor_{nullptr};
void reset_energy_(); void reset_energy_();
}; };

View file

@ -22,11 +22,11 @@ class PZEMDC : public PollingComponent, public modbus::ModbusDevice {
void dump_config() override; void dump_config() override;
protected: protected:
sensor::Sensor *voltage_sensor_; sensor::Sensor *voltage_sensor_{nullptr};
sensor::Sensor *current_sensor_; sensor::Sensor *current_sensor_{nullptr};
sensor::Sensor *power_sensor_; sensor::Sensor *power_sensor_{nullptr};
sensor::Sensor *frequency_sensor_; sensor::Sensor *frequency_sensor_{nullptr};
sensor::Sensor *power_factor_sensor_; sensor::Sensor *power_factor_sensor_{nullptr};
}; };
} // namespace pzemdc } // namespace pzemdc

View file

@ -45,10 +45,10 @@ class QMC5883LComponent : public PollingComponent, public i2c::I2CDevice {
QMC5883LDatarate datarate_{QMC5883L_DATARATE_10_HZ}; QMC5883LDatarate datarate_{QMC5883L_DATARATE_10_HZ};
QMC5883LRange range_{QMC5883L_RANGE_200_UT}; QMC5883LRange range_{QMC5883L_RANGE_200_UT};
QMC5883LOversampling oversampling_{QMC5883L_SAMPLING_512}; QMC5883LOversampling oversampling_{QMC5883L_SAMPLING_512};
sensor::Sensor *x_sensor_; sensor::Sensor *x_sensor_{nullptr};
sensor::Sensor *y_sensor_; sensor::Sensor *y_sensor_{nullptr};
sensor::Sensor *z_sensor_; sensor::Sensor *z_sensor_{nullptr};
sensor::Sensor *heading_sensor_; sensor::Sensor *heading_sensor_{nullptr};
enum ErrorCode { enum ErrorCode {
NONE = 0, NONE = 0,
COMMUNICATION_FAILED, COMMUNICATION_FAILED,

View file

@ -91,8 +91,8 @@ class QMP6988Component : public PollingComponent, public i2c::I2CDevice {
protected: protected:
qmp6988_data_t qmp6988_data_; qmp6988_data_t qmp6988_data_;
sensor::Sensor *temperature_sensor_; sensor::Sensor *temperature_sensor_{nullptr};
sensor::Sensor *pressure_sensor_; sensor::Sensor *pressure_sensor_{nullptr};
QMP6988Oversampling temperature_oversampling_{QMP6988_OVERSAMPLING_16X}; QMP6988Oversampling temperature_oversampling_{QMP6988_OVERSAMPLING_16X};
QMP6988Oversampling pressure_oversampling_{QMP6988_OVERSAMPLING_16X}; QMP6988Oversampling pressure_oversampling_{QMP6988_OVERSAMPLING_16X};

View file

@ -19,8 +19,8 @@ class SHT3XDComponent : public PollingComponent, public sensirion_common::Sensir
void update() override; void update() override;
protected: protected:
sensor::Sensor *temperature_sensor_; sensor::Sensor *temperature_sensor_{nullptr};
sensor::Sensor *humidity_sensor_; sensor::Sensor *humidity_sensor_{nullptr};
}; };
} // namespace sht3xd } // namespace sht3xd

View file

@ -26,8 +26,8 @@ class SHTCXComponent : public PollingComponent, public sensirion_common::Sensiri
protected: protected:
SHTCXType type_; SHTCXType type_;
uint16_t sensor_id_; uint16_t sensor_id_;
sensor::Sensor *temperature_sensor_; sensor::Sensor *temperature_sensor_{nullptr};
sensor::Sensor *humidity_sensor_; sensor::Sensor *humidity_sensor_{nullptr};
}; };
} // namespace shtcx } // namespace shtcx

View file

@ -245,10 +245,10 @@ class TSL2591Component : public PollingComponent, public i2c::I2CDevice {
protected: protected:
const char *name_; const char *name_;
sensor::Sensor *full_spectrum_sensor_; sensor::Sensor *full_spectrum_sensor_{nullptr};
sensor::Sensor *infrared_sensor_; sensor::Sensor *infrared_sensor_{nullptr};
sensor::Sensor *visible_sensor_; sensor::Sensor *visible_sensor_{nullptr};
sensor::Sensor *calculated_lux_sensor_; sensor::Sensor *calculated_lux_sensor_{nullptr};
TSL2591IntegrationTime integration_time_; TSL2591IntegrationTime integration_time_;
TSL2591ComponentGain component_gain_; TSL2591ComponentGain component_gain_;
TSL2591Gain gain_; TSL2591Gain gain_;

View file

@ -43,8 +43,8 @@ class Tx20Component : public Component {
std::string wind_cardinal_direction_; std::string wind_cardinal_direction_;
InternalGPIOPin *pin_; InternalGPIOPin *pin_;
sensor::Sensor *wind_speed_sensor_; sensor::Sensor *wind_speed_sensor_{nullptr};
sensor::Sensor *wind_direction_degrees_sensor_; sensor::Sensor *wind_direction_degrees_sensor_{nullptr};
Tx20ComponentStore store_; Tx20ComponentStore store_;
}; };