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:
parent
de603c7565
commit
4d7c6b28e1
@ -184,11 +184,13 @@ void SprinklerValveOperator::set_controller(Sprinkler *controller) {
|
|||||||
|
|
||||||
void SprinklerValveOperator::set_valve(SprinklerValve *valve) {
|
void SprinklerValveOperator::set_valve(SprinklerValve *valve) {
|
||||||
if (valve != nullptr) {
|
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->state_ = IDLE; // reset state
|
||||||
this->run_duration_ = 0; // reset to ensure the valve isn't started without updating it
|
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->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->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
|
this->valve_ = valve; // finally, set the pointer to the new valve
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user