mirror of
https://github.com/esphome/esphome.git
synced 2026-11-09 14:45:57 +00:00
[components] Define simple setters in the header (sensor drivers) (#22468)
This commit is contained in:
1 parent
46f532e2bd
commit
86442c8816
22 files changed
+33
-72
No files matched your search
@@ -194,10 +194,6 @@ void BangBangClimate::change_away_(bool away) {
|
||||
this->preset = away ? climate::CLIMATE_PRESET_AWAY : climate::CLIMATE_PRESET_HOME;
|
||||
}
|
||||
|
||||
void BangBangClimate::set_normal_config(const BangBangClimateTargetTempConfig &normal_config) {
|
||||
this->normal_config_ = normal_config;
|
||||
}
|
||||
|
||||
void BangBangClimate::set_away_config(const BangBangClimateTargetTempConfig &away_config) {
|
||||
this->supports_away_ = true;
|
||||
this->away_config_ = away_config;
|
||||
|
||||
@@ -27,7 +27,7 @@ class BangBangClimate final : public climate::Climate, public Component {
|
||||
|
||||
void set_supports_cool(bool supports_cool) { this->supports_cool_ = supports_cool; }
|
||||
void set_supports_heat(bool supports_heat) { this->supports_heat_ = supports_heat; }
|
||||
void set_normal_config(const BangBangClimateTargetTempConfig &normal_config);
|
||||
void set_normal_config(const BangBangClimateTargetTempConfig &normal_config) { this->normal_config_ = normal_config; }
|
||||
void set_away_config(const BangBangClimateTargetTempConfig &away_config);
|
||||
|
||||
Trigger<> *get_idle_trigger();
|
||||
|
||||
@@ -280,15 +280,6 @@ float BME280Component::read_humidity_(const uint8_t *data, int32_t t_fine) {
|
||||
|
||||
return h / 1024.0f;
|
||||
}
|
||||
void BME280Component::set_temperature_oversampling(BME280Oversampling temperature_over_sampling) {
|
||||
this->temperature_oversampling_ = temperature_over_sampling;
|
||||
}
|
||||
void BME280Component::set_pressure_oversampling(BME280Oversampling pressure_over_sampling) {
|
||||
this->pressure_oversampling_ = pressure_over_sampling;
|
||||
}
|
||||
void BME280Component::set_humidity_oversampling(BME280Oversampling humidity_over_sampling) {
|
||||
this->humidity_oversampling_ = humidity_over_sampling;
|
||||
}
|
||||
uint8_t BME280Component::read_u8_(uint8_t a_register) {
|
||||
uint8_t data = 0;
|
||||
this->read_byte(a_register, &data);
|
||||
|
||||
@@ -63,11 +63,17 @@ class BME280Component : public PollingComponent {
|
||||
|
||||
public:
|
||||
/// Set the oversampling value for the temperature sensor. Default is 16x.
|
||||
void set_temperature_oversampling(BME280Oversampling temperature_over_sampling);
|
||||
void set_temperature_oversampling(BME280Oversampling temperature_over_sampling) {
|
||||
this->temperature_oversampling_ = temperature_over_sampling;
|
||||
}
|
||||
/// Set the oversampling value for the pressure sensor. Default is 16x.
|
||||
void set_pressure_oversampling(BME280Oversampling pressure_over_sampling);
|
||||
void set_pressure_oversampling(BME280Oversampling pressure_over_sampling) {
|
||||
this->pressure_oversampling_ = pressure_over_sampling;
|
||||
}
|
||||
/// Set the oversampling value for the humidity sensor. Default is 16x.
|
||||
void set_humidity_oversampling(BME280Oversampling humidity_over_sampling);
|
||||
void set_humidity_oversampling(BME280Oversampling humidity_over_sampling) {
|
||||
this->humidity_oversampling_ = humidity_over_sampling;
|
||||
}
|
||||
/// Set the IIR Filter used to increase accuracy, defaults to no IIR Filter.
|
||||
void set_iir_filter(BME280IIRFilter iir_filter) { this->iir_filter_ = iir_filter; }
|
||||
|
||||
|
||||
@@ -423,15 +423,6 @@ uint32_t BME680Component::calc_meas_duration_() {
|
||||
|
||||
return tph_dur;
|
||||
}
|
||||
void BME680Component::set_temperature_oversampling(BME680Oversampling temperature_oversampling) {
|
||||
this->temperature_oversampling_ = temperature_oversampling;
|
||||
}
|
||||
void BME680Component::set_pressure_oversampling(BME680Oversampling pressure_oversampling) {
|
||||
this->pressure_oversampling_ = pressure_oversampling;
|
||||
}
|
||||
void BME680Component::set_humidity_oversampling(BME680Oversampling humidity_oversampling) {
|
||||
this->humidity_oversampling_ = humidity_oversampling;
|
||||
}
|
||||
void BME680Component::set_heater(uint16_t heater_temperature, uint16_t heater_duration) {
|
||||
this->heater_temperature_ = heater_temperature;
|
||||
this->heater_duration_ = heater_duration;
|
||||
|
||||
@@ -73,11 +73,17 @@ class BME680Component final : public PollingComponent, public i2c::I2CDevice {
|
||||
|
||||
public:
|
||||
/// Set the temperature oversampling value. Defaults to 16X.
|
||||
void set_temperature_oversampling(BME680Oversampling temperature_oversampling);
|
||||
void set_temperature_oversampling(BME680Oversampling temperature_oversampling) {
|
||||
this->temperature_oversampling_ = temperature_oversampling;
|
||||
}
|
||||
/// Set the pressure oversampling value. Defaults to 16X.
|
||||
void set_pressure_oversampling(BME680Oversampling pressure_oversampling);
|
||||
void set_pressure_oversampling(BME680Oversampling pressure_oversampling) {
|
||||
this->pressure_oversampling_ = pressure_oversampling;
|
||||
}
|
||||
/// Set the humidity oversampling value. Defaults to 16X.
|
||||
void set_humidity_oversampling(BME680Oversampling humidity_oversampling);
|
||||
void set_humidity_oversampling(BME680Oversampling humidity_oversampling) {
|
||||
this->humidity_oversampling_ = humidity_oversampling;
|
||||
}
|
||||
/// Set the IIR Filter value. Defaults to no IIR Filter.
|
||||
void set_iir_filter(BME680IIRFilter iir_filter) { this->iir_filter_ = iir_filter; }
|
||||
|
||||
|
||||
@@ -195,12 +195,6 @@ float BMP280Component::read_pressure_(int32_t t_fine) {
|
||||
p = ((p + var1 + var2) >> 8) + (p7 << 4);
|
||||
return (p / 256.0f) / 100.0f;
|
||||
}
|
||||
void BMP280Component::set_temperature_oversampling(BMP280Oversampling temperature_over_sampling) {
|
||||
this->temperature_oversampling_ = temperature_over_sampling;
|
||||
}
|
||||
void BMP280Component::set_pressure_oversampling(BMP280Oversampling pressure_over_sampling) {
|
||||
this->pressure_oversampling_ = pressure_over_sampling;
|
||||
}
|
||||
uint8_t BMP280Component::read_u8_(uint8_t a_register) {
|
||||
uint8_t data = 0;
|
||||
this->bmp_read_byte(a_register, &data);
|
||||
|
||||
@@ -55,9 +55,13 @@ class BMP280Component : public PollingComponent {
|
||||
|
||||
public:
|
||||
/// Set the oversampling value for the temperature sensor. Default is 16x.
|
||||
void set_temperature_oversampling(BMP280Oversampling temperature_over_sampling);
|
||||
void set_temperature_oversampling(BMP280Oversampling temperature_over_sampling) {
|
||||
this->temperature_oversampling_ = temperature_over_sampling;
|
||||
}
|
||||
/// Set the oversampling value for the pressure sensor. Default is 16x.
|
||||
void set_pressure_oversampling(BMP280Oversampling pressure_over_sampling);
|
||||
void set_pressure_oversampling(BMP280Oversampling pressure_over_sampling) {
|
||||
this->pressure_oversampling_ = pressure_over_sampling;
|
||||
}
|
||||
/// Set the IIR Filter used to increase accuracy, defaults to no IIR Filter.
|
||||
void set_iir_filter(BMP280IIRFilter iir_filter) { this->iir_filter_ = iir_filter; }
|
||||
|
||||
|
||||
@@ -550,8 +550,4 @@ haier_protocol::HandlerError Smartair2Climate::process_status_message_(const uin
|
||||
return haier_protocol::HandlerError::HANDLER_OK;
|
||||
}
|
||||
|
||||
void Smartair2Climate::set_alternative_swing_control(bool swing_control) {
|
||||
this->use_alternative_swing_control_ = swing_control;
|
||||
}
|
||||
|
||||
} // namespace esphome::haier
|
||||
@@ -12,7 +12,7 @@ class Smartair2Climate final : public HaierClimateBase {
|
||||
Smartair2Climate &operator=(const Smartair2Climate &) = delete;
|
||||
~Smartair2Climate();
|
||||
void dump_config() override;
|
||||
void set_alternative_swing_control(bool swing_control);
|
||||
void set_alternative_swing_control(bool swing_control) { this->use_alternative_swing_control_ = swing_control; }
|
||||
|
||||
protected:
|
||||
void set_handlers() override;
|
||||
|
||||
@@ -87,12 +87,4 @@ void HONEYWELLABPSensor::dump_config() {
|
||||
LOG_UPDATE_INTERVAL(this);
|
||||
}
|
||||
|
||||
void HONEYWELLABPSensor::set_honeywellabp_min_pressure(float min_pressure) {
|
||||
this->honeywellabp_min_pressure_ = min_pressure;
|
||||
}
|
||||
|
||||
void HONEYWELLABPSensor::set_honeywellabp_max_pressure(float max_pressure) {
|
||||
this->honeywellabp_max_pressure_ = max_pressure;
|
||||
}
|
||||
|
||||
} // namespace esphome::honeywellabp
|
||||
@@ -19,8 +19,8 @@ class HONEYWELLABPSensor final : public PollingComponent,
|
||||
void update() override;
|
||||
float get_setup_priority() const override;
|
||||
void dump_config() override;
|
||||
void set_honeywellabp_min_pressure(float min_pressure);
|
||||
void set_honeywellabp_max_pressure(float max_pressure);
|
||||
void set_honeywellabp_min_pressure(float min_pressure) { this->honeywellabp_min_pressure_ = min_pressure; }
|
||||
void set_honeywellabp_max_pressure(float max_pressure) { this->honeywellabp_max_pressure_ = max_pressure; }
|
||||
|
||||
protected:
|
||||
float honeywellabp_min_pressure_ = 0.0;
|
||||
|
||||
@@ -95,8 +95,6 @@ void MAX6956::set_brightness_global(uint8_t current) {
|
||||
|
||||
void MAX6956::write_brightness_global() { this->write_reg_(MAX6956_GLOBAL_CURRENT, global_brightness_); }
|
||||
|
||||
void MAX6956::set_brightness_mode(max6956::MAX6956CURRENTMODE brightness_mode) { brightness_mode_ = brightness_mode; };
|
||||
|
||||
void MAX6956::write_brightness_mode() {
|
||||
uint8_t reg_addr = MAX6956_CONFIGURATION;
|
||||
uint8_t config = 0;
|
||||
|
||||
@@ -50,7 +50,7 @@ class MAX6956 final : public Component, public i2c::I2CDevice {
|
||||
float get_setup_priority() const override { return setup_priority::HARDWARE; }
|
||||
|
||||
void set_brightness_global(uint8_t current);
|
||||
void set_brightness_mode(max6956::MAX6956CURRENTMODE brightness_mode);
|
||||
void set_brightness_mode(max6956::MAX6956CURRENTMODE brightness_mode) { this->brightness_mode_ = brightness_mode; }
|
||||
void set_pin_brightness(uint8_t pin, float brightness);
|
||||
|
||||
void dump_config() override;
|
||||
|
||||
@@ -171,8 +171,4 @@ void SDS011Component::parse_data_() {
|
||||
PUBLISH_STATE(this->pm_10_0_sensor_, pm_10_0_concentration);
|
||||
}
|
||||
|
||||
void SDS011Component::set_update_interval_min(uint8_t update_interval_min) {
|
||||
this->update_interval_min_ = update_interval_min;
|
||||
}
|
||||
|
||||
} // namespace esphome::sds011
|
||||
@@ -21,7 +21,7 @@ class SDS011Component final : public Component, public uart::UARTDevice {
|
||||
void dump_config() override;
|
||||
void loop() override;
|
||||
|
||||
void set_update_interval_min(uint8_t update_interval_min);
|
||||
void set_update_interval_min(uint8_t update_interval_min) { this->update_interval_min_ = update_interval_min; }
|
||||
void set_working_state(bool working_state);
|
||||
|
||||
protected:
|
||||
|
||||
@@ -284,8 +284,6 @@ SprinklerValveRunRequest::SprinklerValveRunRequest(size_t valve_number, uint32_t
|
||||
|
||||
bool SprinklerValveRunRequest::has_valve_operator() { return !(this->valve_op_ == nullptr); }
|
||||
|
||||
void SprinklerValveRunRequest::set_run_duration(uint32_t run_duration) { this->run_duration_ = run_duration; }
|
||||
|
||||
void SprinklerValveRunRequest::set_valve(size_t valve_number) {
|
||||
this->valve_number_ = valve_number;
|
||||
this->run_duration_ = 0;
|
||||
|
||||
@@ -155,7 +155,7 @@ class SprinklerValveRunRequest {
|
||||
bool has_request() { return this->has_valve_; }
|
||||
bool has_valve_operator();
|
||||
void set_request_from(SprinklerValveRunRequestOrigin origin) { this->origin_ = origin; }
|
||||
void set_run_duration(uint32_t run_duration);
|
||||
void set_run_duration(uint32_t run_duration) { this->run_duration_ = run_duration; }
|
||||
void set_valve(size_t valve_number);
|
||||
void set_valve_operator(SprinklerValveOperator *valve_op);
|
||||
void reset();
|
||||
|
||||
@@ -133,9 +133,6 @@ float TSL2561Sensor::get_integration_time_ms_() {
|
||||
}
|
||||
return 0.0f;
|
||||
}
|
||||
void TSL2561Sensor::set_integration_time(TSL2561IntegrationTime integration_time) {
|
||||
this->integration_time_ = integration_time;
|
||||
}
|
||||
|
||||
bool TSL2561Sensor::tsl2561_write_byte(uint8_t a_register, uint8_t value) {
|
||||
return this->write_byte(a_register | TSL2561_COMMAND_BIT, value);
|
||||
|
||||
@@ -40,7 +40,7 @@ class TSL2561Sensor final : public sensor::Sensor, public PollingComponent, publ
|
||||
*
|
||||
* @param integration_time The new integration time.
|
||||
*/
|
||||
void set_integration_time(TSL2561IntegrationTime integration_time);
|
||||
void set_integration_time(TSL2561IntegrationTime integration_time) { this->integration_time_ = integration_time; }
|
||||
|
||||
/** Set the internal gain of the sensor. Can be useful for low-light conditions
|
||||
*
|
||||
|
||||
@@ -175,10 +175,6 @@ void TSL2591Component::update() {
|
||||
}
|
||||
}
|
||||
|
||||
void TSL2591Component::set_integration_time(TSL2591IntegrationTime integration_time) {
|
||||
this->integration_time_ = integration_time;
|
||||
}
|
||||
|
||||
void TSL2591Component::set_device_and_glass_attenuation_factors(float device_factor, float glass_attenuation_factor) {
|
||||
this->device_factor_ = device_factor;
|
||||
this->glass_attenuation_factor_ = glass_attenuation_factor;
|
||||
|
||||
@@ -239,7 +239,7 @@ class TSL2591Component final : public PollingComponent, public i2c::I2CDevice {
|
||||
/** Used by ESPHome framework. */
|
||||
SUB_SENSOR(calculated_lux)
|
||||
/** Used by ESPHome framework. Does NOT actually set the value on the device. */
|
||||
void set_integration_time(TSL2591IntegrationTime integration_time);
|
||||
void set_integration_time(TSL2591IntegrationTime integration_time) { this->integration_time_ = integration_time; }
|
||||
/** Used by ESPHome framework. Does NOT actually set the value on the device. */
|
||||
void set_gain(TSL2591ComponentGain gain) { this->component_gain_ = gain; }
|
||||
/** Used by ESPHome framework. */
|
||||
|
||||
Reference in new issue
Block a user