Skip to content

Commit 89709f8

Browse files
authored
Update pzemac.cpp
m_
1 parent c8261c7 commit 89709f8

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

esphome/components/pzemac/pzemac.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ void PZEMAC::on_modbus_data(const std::vector<uint8_t> &data) {
1515
ESP_LOGW(TAG, "Invalid size for PZEM AC!");
1616
return;
1717
}
18-
this->last_update_time_ = millis();
18+
this->m_last_update_time_ = millis();
1919

2020
// See https://github.com/esphome/feature-requests/issues/49#issuecomment-538636809
2121
// 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
@@ -50,8 +50,8 @@ void PZEMAC::on_modbus_data(const std::vector<uint8_t> &data) {
5050
ESP_LOGD(TAG,
5151
"PZEM AC: Addr 0x%02X, V=%.1f V, I=%.3f A, P=%.1f W, E=%.1f Wh, E(pre)=%.1f Wh, E-E(pre)=%.1f Wh, F=%.1f "
5252
"Hz, PF=%.2f",
53-
int(this->address_), voltage, current, active_power, active_energy, this->last_energy_sensor,
54-
active_energy - this->last_energy_sensor, frequency, power_factor);
53+
int(this->address_), voltage, current, active_power, active_energy, this->m_last_energy_sensor,
54+
active_energy - this->m_last_energy_sensor, frequency, power_factor);
5555
if (this->voltage_sensor_ != nullptr) {
5656
if (voltage < 450) {
5757
this->voltage_sensor_->publish_state(voltage);
@@ -74,15 +74,15 @@ void PZEMAC::on_modbus_data(const std::vector<uint8_t> &data) {
7474
}
7575
}
7676
if (this->energy_sensor_ != nullptr) {
77-
if (this->last_energy_sensor == 0) {
77+
if (this->m_last_energy_sensor == 0) {
7878
this->energy_sensor_->publish_state(active_energy);
79-
this->last_energy_sensor = active_energy;
79+
this->m_last_energy_sensor = active_energy;
8080
} else {
81-
if (abs(active_energy - this->last_energy_sensor) < 1000) {
81+
if (abs(active_energy - this->m_last_energy_sensor) < 1000) {
8282
this->energy_sensor_->publish_state(active_energy);
83-
this->last_energy_sensor = active_energy;
83+
this->m_last_energy_sensor = active_energy;
8484
} else {
85-
this->energy_sensor_->publish_state(this->last_energy_sensor);
85+
this->energy_sensor_->publish_state(this->m_last_energy_sensor);
8686
}
8787
}
8888
}
@@ -98,7 +98,7 @@ void PZEMAC::update() {
9898
this->send(PZEM_CMD_READ_IN_REGISTERS, 0, PZEM_REGISTER_COUNT);
9999

100100
if (this->get_update_interval() != SCHEDULER_DONT_RUN &&
101-
(millis() - this->last_update_time_) > this->get_update_interval() * 2) {
101+
(millis() - this->m_last_update_time_) > this->get_update_interval() * 2) {
102102
ESP_LOGE(TAG, "PZEM AC Addr 0x%02X: Timeout!!!", int(this->address_));
103103
if (this->voltage_sensor_ != nullptr) {
104104
this->voltage_sensor_->publish_state(0.0f);
@@ -110,7 +110,7 @@ void PZEMAC::update() {
110110
this->power_sensor_->publish_state(0.0f);
111111
}
112112
if (this->energy_sensor_ != nullptr) {
113-
this->energy_sensor_->publish_state(this->last_energy_sensor);
113+
this->energy_sensor_->publish_state(this->m_last_energy_sensor);
114114
}
115115
if (this->frequency_sensor_ != nullptr) {
116116
this->frequency_sensor_->publish_state(0.0f);

0 commit comments

Comments
 (0)