mirror of
https://github.com/esphome/esphome.git
synced 2025-10-23 20:23:50 +01:00
Merge remote-tracking branch 'upstream/dev' into integration
This commit is contained in:
@@ -35,6 +35,7 @@ CONF_CHARGE = "charge"
|
||||
CONF_CHARGE_COULOMBS = "charge_coulombs"
|
||||
CONF_ENERGY_JOULES = "energy_joules"
|
||||
CONF_TEMPERATURE_COEFFICIENT = "temperature_coefficient"
|
||||
CONF_RESET_ON_BOOT = "reset_on_boot"
|
||||
UNIT_AMPERE_HOURS = "Ah"
|
||||
UNIT_COULOMB = "C"
|
||||
UNIT_JOULE = "J"
|
||||
@@ -113,6 +114,7 @@ INA2XX_SCHEMA = cv.Schema(
|
||||
cv.Optional(CONF_TEMPERATURE_COEFFICIENT, default=0): cv.int_range(
|
||||
min=0, max=16383
|
||||
),
|
||||
cv.Optional(CONF_RESET_ON_BOOT, default=True): cv.boolean,
|
||||
cv.Optional(CONF_SHUNT_VOLTAGE): cv.maybe_simple_value(
|
||||
sensor.sensor_schema(
|
||||
unit_of_measurement=UNIT_MILLIVOLT,
|
||||
@@ -206,6 +208,7 @@ async def setup_ina2xx(var, config):
|
||||
cg.add(var.set_adc_range(config[CONF_ADC_RANGE]))
|
||||
cg.add(var.set_adc_avg_samples(config[CONF_ADC_AVERAGING]))
|
||||
cg.add(var.set_shunt_tempco(config[CONF_TEMPERATURE_COEFFICIENT]))
|
||||
cg.add(var.set_reset_on_boot(config[CONF_RESET_ON_BOOT]))
|
||||
|
||||
adc_time_config = config[CONF_ADC_TIME]
|
||||
if isinstance(adc_time_config, dict):
|
||||
|
@@ -257,7 +257,12 @@ bool INA2XX::reset_energy_counters() {
|
||||
bool INA2XX::reset_config_() {
|
||||
ESP_LOGV(TAG, "Reset");
|
||||
ConfigurationRegister cfg{0};
|
||||
cfg.RST = true;
|
||||
if (!this->reset_on_boot_) {
|
||||
ESP_LOGI(TAG, "Skipping on-boot device reset");
|
||||
cfg.RST = false;
|
||||
} else {
|
||||
cfg.RST = true;
|
||||
}
|
||||
return this->write_unsigned_16_(RegisterMap::REG_CONFIG, cfg.raw_u16);
|
||||
}
|
||||
|
||||
|
@@ -127,6 +127,7 @@ class INA2XX : public PollingComponent {
|
||||
void set_adc_time_die_temperature(AdcTime time) { this->adc_time_die_temperature_ = time; }
|
||||
void set_adc_avg_samples(AdcAvgSamples samples) { this->adc_avg_samples_ = samples; }
|
||||
void set_shunt_tempco(uint16_t coeff) { this->shunt_tempco_ppm_c_ = coeff; }
|
||||
void set_reset_on_boot(bool reset) { this->reset_on_boot_ = reset; }
|
||||
|
||||
void set_shunt_voltage_sensor(sensor::Sensor *sensor) { this->shunt_voltage_sensor_ = sensor; }
|
||||
void set_bus_voltage_sensor(sensor::Sensor *sensor) { this->bus_voltage_sensor_ = sensor; }
|
||||
@@ -172,6 +173,7 @@ class INA2XX : public PollingComponent {
|
||||
AdcTime adc_time_die_temperature_{AdcTime::ADC_TIME_4120US};
|
||||
AdcAvgSamples adc_avg_samples_{AdcAvgSamples::ADC_AVG_SAMPLES_128};
|
||||
uint16_t shunt_tempco_ppm_c_{0};
|
||||
bool reset_on_boot_{true};
|
||||
|
||||
//
|
||||
// Calculated coefficients
|
||||
|
@@ -7,6 +7,7 @@ sensor:
|
||||
max_current: 40 A
|
||||
adc_range: 1
|
||||
temperature_coefficient: 50
|
||||
reset_on_boot: true
|
||||
shunt_voltage:
|
||||
id: ina2xx_i2c_shunt_voltage
|
||||
name: "INA2xx Shunt Voltage"
|
||||
|
Reference in New Issue
Block a user