mirror of
https://github.com/Threnklyn/esphome-dev.git
synced 2026-06-01 18:48:28 +02:00
Added energy sensor to hlw8012 (#1198)
This commit is contained in:
@@ -79,6 +79,12 @@ void HLW8012Component::update() {
|
||||
this->power_sensor_->publish_state(power);
|
||||
}
|
||||
|
||||
if (this->energy_sensor_ != nullptr) {
|
||||
cf_total_pulses_ += raw_cf;
|
||||
float energy = cf_total_pulses_ * power_multiplier_micros / 3600 / 1000000.0f;
|
||||
this->energy_sensor_->publish_state(energy);
|
||||
}
|
||||
|
||||
if (this->change_mode_at_++ == this->change_mode_every_) {
|
||||
this->current_mode_ = !this->current_mode_;
|
||||
ESP_LOGV(TAG, "Changing mode to %s mode", this->current_mode_ ? "CURRENT" : "VOLTAGE");
|
||||
|
||||
Reference in New Issue
Block a user