remove references to peak_current

the register is now used for thd

Signed-off-by: Matthew Thode <mthode@mthode.org>
This commit is contained in:
2026-07-10 22:59:13 -05:00
parent 26a7335659
commit 14a7c2ef82
3 changed files with 0 additions and 38 deletions
-18
View File
@@ -43,9 +43,6 @@ void ATM90E36Component::loop() {
if (this->phase_[phase].harmonic_active_power_sensor_ != nullptr)
this->phase_[phase].harmonic_active_power_ = this->get_phase_harmonic_active_power_(phase);
// if (this->phase_[phase].peak_current_sensor_ != nullptr)
// this->phase_[phase].peak_current_ = this->get_phase_peak_current_(phase);
// After the local store is collected we can publish them trusting they are within +-1 hardware sampling
if (this->phase_[phase].voltage_sensor_ != nullptr)
this->phase_[phase].voltage_sensor_->publish_state(this->get_local_phase_voltage_(phase));
@@ -83,8 +80,6 @@ void ATM90E36Component::loop() {
this->get_local_phase_harmonic_active_power_(phase));
}
// if (this->phase_[phase].peak_current_sensor_ != nullptr)
// this->phase_[phase].peak_current_sensor_->publish_state(this->get_local_phase_peak_current_(phase));
}
// THD values
if (this->thd_voltage_a_sensor_ != nullptr) {
@@ -240,7 +235,6 @@ void ATM90E36Component::dump_config() {
LOG_SENSOR(" ", "Active Reverse Energy A", this->phase_[PHASEA].reverse_active_energy_sensor_);
LOG_SENSOR(" ", "Harmonic Power A", this->phase_[PHASEA].harmonic_active_power_sensor_);
LOG_SENSOR(" ", "Phase Angle A", this->phase_[PHASEA].phase_angle_sensor_);
// LOG_SENSOR(" ", "Peak Current A", this->phase_[PHASEA].peak_current_sensor_);
LOG_SENSOR(" ", "Voltage B", this->phase_[PHASEB].voltage_sensor_);
LOG_SENSOR(" ", "Current B", this->phase_[PHASEB].current_sensor_);
LOG_SENSOR(" ", "Power B", this->phase_[PHASEB].power_sensor_);
@@ -253,7 +247,6 @@ void ATM90E36Component::dump_config() {
LOG_SENSOR(" ", "Active Reverse Energy B", this->phase_[PHASEB].reverse_active_energy_sensor_);
LOG_SENSOR(" ", "Harmonic Power B", this->phase_[PHASEB].harmonic_active_power_sensor_);
LOG_SENSOR(" ", "Phase Angle B", this->phase_[PHASEB].phase_angle_sensor_);
// LOG_SENSOR(" ", "Peak Current B", this->phase_[PHASEB].peak_current_sensor_);
LOG_SENSOR(" ", "Voltage C", this->phase_[PHASEC].voltage_sensor_);
LOG_SENSOR(" ", "Current C", this->phase_[PHASEC].current_sensor_);
LOG_SENSOR(" ", "Power C", this->phase_[PHASEC].power_sensor_);
@@ -266,7 +259,6 @@ void ATM90E36Component::dump_config() {
LOG_SENSOR(" ", "Active Reverse Energy C", this->phase_[PHASEC].reverse_active_energy_sensor_);
LOG_SENSOR(" ", "Harmonic Power C", this->phase_[PHASEC].harmonic_active_power_sensor_);
LOG_SENSOR(" ", "Phase Angle C", this->phase_[PHASEC].phase_angle_sensor_);
// LOG_SENSOR(" ", "Peak Current C", this->phase_[PHASEC].peak_current_sensor_);
LOG_SENSOR(" ", "Frequency", this->freq_sensor_);
LOG_SENSOR(" ", "Chip Temp", this->chip_temperature_sensor_);
}
@@ -362,8 +354,6 @@ float ATM90E36Component::get_local_phase_harmonic_active_power_(uint8_t phase) {
return this->phase_[phase].harmonic_active_power_;
}
//float ATM90E36Component::get_local_phase_peak_current_(uint8_t phase) { return this->phase_[phase].peak_current_; }
float ATM90E36Component::get_phase_voltage_(uint8_t phase) {
uint16_t voltage = this->read16_(ATM90E36_REGISTER_URMS + phase);
this->validate_spi_read_(voltage, "get_phase_voltage()");
@@ -467,14 +457,6 @@ float ATM90E36Component::get_phase_angle_(uint8_t phase) {
return (val > 180) ? (float) (val - 360.0f) : (float) val;
}
//float ATM90E36Component::get_phase_peak_current_(uint8_t phase) {
// int16_t val = (float) this->read16_(ATM90E36_REGISTER_IPEAK + phase);
// if (!this->peak_current_signed_)
// val = std::abs(val);
// // phase register * phase current gain value / 1000 * 2^13
// return (val * this->phase_[phase].ct_gain_ / 8192000.0);
//}
float ATM90E36Component::get_frequency_() {
const uint16_t freq = this->read16_(ATM90E36_REGISTER_FREQ);
return (float) freq / 100;
-7
View File
@@ -59,7 +59,6 @@ class ATM90E36Component : public PollingComponent,
void set_harmonic_active_power_sensor(int phase, sensor::Sensor *obj) {
this->phase_[phase].harmonic_active_power_sensor_ = obj;
}
void set_peak_current_sensor(int phase, sensor::Sensor *obj) { this->phase_[phase].peak_current_sensor_ = obj; }
void set_volt_gain(int phase, uint16_t gain) {
this->phase_[phase].voltage_gain_ = gain;
}
@@ -67,7 +66,6 @@ class ATM90E36Component : public PollingComponent,
this->phase_[phase].ct_gain_ = gain;
}
void set_freq_sensor(sensor::Sensor *freq_sensor) { freq_sensor_ = freq_sensor; }
void set_peak_current_signed(bool flag) { peak_current_signed_ = flag; }
void set_chip_temperature_sensor(sensor::Sensor *chip_temperature_sensor) {
chip_temperature_sensor_ = chip_temperature_sensor;
}
@@ -124,7 +122,6 @@ class ATM90E36Component : public PollingComponent,
float get_local_phase_reverse_active_energy_(uint8_t phase);
float get_local_phase_angle_(uint8_t phase);
float get_local_phase_harmonic_active_power_(uint8_t phase);
float get_local_phase_peak_current_(uint8_t phase);
float get_phase_voltage_(uint8_t phase);
float get_phase_voltage_avg_(uint8_t phase);
float get_phase_current_(uint8_t phase);
@@ -137,7 +134,6 @@ class ATM90E36Component : public PollingComponent,
float get_phase_reverse_active_energy_(uint8_t phase);
float get_phase_angle_(uint8_t phase);
float get_phase_harmonic_active_power_(uint8_t phase);
float get_phase_peak_current_(uint8_t phase);
float get_thd_voltage_a();
float get_thd_current_a();
float get_thd_voltage_b();
@@ -178,7 +174,6 @@ class ATM90E36Component : public PollingComponent,
float reverse_active_energy_{0};
float phase_angle_{0};
float harmonic_active_power_{0};
float peak_current_{0};
sensor::Sensor *voltage_sensor_{nullptr};
sensor::Sensor *current_sensor_{nullptr};
sensor::Sensor *power_sensor_{nullptr};
@@ -189,7 +184,6 @@ class ATM90E36Component : public PollingComponent,
sensor::Sensor *reverse_active_energy_sensor_{nullptr};
sensor::Sensor *phase_angle_sensor_{nullptr};
sensor::Sensor *harmonic_active_power_sensor_{nullptr};
sensor::Sensor *peak_current_sensor_{nullptr};
uint32_t cumulative_forward_active_energy_{0};
uint32_t cumulative_reverse_active_energy_{0};
} phase_[3];
@@ -261,7 +255,6 @@ class ATM90E36Component : public PollingComponent,
int line_freq_{60};
int current_phases_{3};
bool publish_interval_flag_{false};
bool peak_current_signed_{false};
uint16_t pga_cal{0x0};
};
-13
View File
@@ -57,8 +57,6 @@ CONF_OFFSET_CURRENT = "offset_current"
CONF_OFFSET_ACTIVE_POWER = "offset_active_power"
CONF_OFFSET_REACTIVE_POWER = "offset_reactive_power"
CONF_HARMONIC_POWER = "harmonic_power"
#CONF_PEAK_CURRENT = "peak_current"
#CONF_PEAK_CURRENT_SIGNED = "peak_current_signed"
CONF_ENABLE_OFFSET_CALIBRATION = "enable_offset_calibration"
CONF_ENABLE_GAIN_CALIBRATION = "enable_gain_calibration"
CONF_PHASE_STATUS = "phase_status"
@@ -163,12 +161,6 @@ ATM90E36_PHASE_SCHEMA = cv.Schema(
device_class=DEVICE_CLASS_POWER,
state_class=STATE_CLASS_MEASUREMENT,
),
# cv.Optional(CONF_PEAK_CURRENT): sensor.sensor_schema(
# unit_of_measurement=UNIT_AMPERE,
# accuracy_decimals=2,
# device_class=DEVICE_CLASS_CURRENT,
# state_class=STATE_CLASS_MEASUREMENT,
# ),
cv.Optional(CONF_GAIN_VOLTAGE, default=7305): cv.uint16_t,
cv.Optional(CONF_GAIN_CT, default=27961): cv.uint16_t,
cv.Optional(CONF_OFFSET_VOLTAGE, default=0): cv.int_,
@@ -205,7 +197,6 @@ CONFIG_SCHEMA = (
cv.Optional(CONF_GAIN_CURRENT, default="1X"): cv.enum(CURRENT_GAINS, upper=True),
cv.Optional(CONF_GAIN_VOLTAGE, default="1X"): cv.enum(VOLTAGE_GAINS, upper=True),
cv.Optional(CONF_GAIN_DPGA, default="1X"): cv.enum(DPGA_GAINS, upper=True),
# cv.Optional(CONF_PEAK_CURRENT_SIGNED, default=False): cv.boolean,
cv.Optional(CONF_ENABLE_OFFSET_CALIBRATION, default=False): cv.boolean,
cv.Optional(CONF_ENABLE_GAIN_CALIBRATION, default=False): cv.boolean,
cv.Optional(CONF_THD_VOLTAGE_A): sensor.sensor_schema(
@@ -286,9 +277,6 @@ async def to_code(config):
if harmonic_active_power_config := conf.get(CONF_HARMONIC_POWER):
sens = await sensor.new_sensor(harmonic_active_power_config)
cg.add(var.set_harmonic_active_power_sensor(i, sens))
# if peak_current_config := conf.get(CONF_PEAK_CURRENT):
# sens = await sensor.new_sensor(peak_current_config)
# cg.add(var.set_peak_current_sensor(i, sens))
if frequency_config := config.get(CONF_FREQUENCY):
sens = await sensor.new_sensor(frequency_config)
cg.add(var.set_freq_sensor(sens))
@@ -300,7 +288,6 @@ async def to_code(config):
cg.add(var.set_pga_current(config[CONF_GAIN_CURRENT]))
cg.add(var.set_pga_voltage(config[CONF_GAIN_VOLTAGE]))
cg.add(var.set_dpga_gain(config[CONF_GAIN_DPGA]))
# cg.add(var.set_peak_current_signed(config[CONF_PEAK_CURRENT_SIGNED]))
if CONF_THD_VOLTAGE_A in config:
sens = await sensor.new_sensor(config[CONF_THD_VOLTAGE_A])
cg.add(var.set_thd_voltage_a_sensor(sens))