Add ability to lock to set mode (#5924)

This commit is contained in:
Yorick Smilda
2023-12-20 11:52:46 +01:00
committed by GitHub
parent 84174aeb80
commit 23ceddafed
3 changed files with 10 additions and 5 deletions
+1 -1
View File
@@ -96,7 +96,7 @@ void HLW8012Component::update() {
this->energy_sensor_->publish_state(energy);
}
if (this->change_mode_at_++ == this->change_mode_every_) {
if (this->change_mode_every_ != 0 && 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");
this->change_mode_at_ = 0;