1
0
mirror of https://github.com/esphome/esphome.git synced 2025-01-31 02:00:55 +00: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
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

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
}
}