1
0
mirror of https://github.com/esphome/esphome.git synced 2025-09-01 10:52:19 +01:00

Update sprinkler.cpp (#7996)

This commit is contained in:
Juan Jose Restrepo
2025-01-10 18:22:30 -05:00
committed by GitHub
parent de603c7565
commit 4d7c6b28e1

View File

@@ -184,11 +184,13 @@ void SprinklerValveOperator::set_controller(Sprinkler *controller) {
void SprinklerValveOperator::set_valve(SprinklerValve *valve) {
if (valve != nullptr) {
if (this->state_ != IDLE) { // Only kill if not already idle
this->kill_(); // ensure everything is off before we let go!
}
this->state_ = IDLE; // reset state
this->run_duration_ = 0; // reset to ensure the valve isn't started without updating it
this->start_millis_ = 0; // reset because (new) valve has not been started yet
this->stop_millis_ = 0; // reset because (new) valve has not been started yet
this->kill_(); // ensure everything is off before we let go!
this->valve_ = valve; // finally, set the pointer to the new valve
}
}