85 std::function<void()>
func;
104 void setup()
override;
105 void dump_config()
override;
113 void control(
float value)
override;
114 float initial_value_{NAN};
115 bool restore_value_{
true};
125 void setup()
override;
126 void dump_config()
override;
131 void loop()
override;
133 float get_setup_priority()
const override;
136 void write_state(
bool state)
override;
149 void set_controller(
Sprinkler *controller);
151 void set_run_duration(uint32_t run_duration);
152 void set_start_delay(uint32_t start_delay,
bool start_delay_is_valve_delay);
153 void set_stop_delay(uint32_t stop_delay,
bool stop_delay_is_valve_delay);
156 uint32_t run_duration();
157 uint32_t time_remaining();
168 bool start_delay_is_valve_delay_{
false};
169 bool stop_delay_is_valve_delay_{
false};
170 uint32_t start_delay_{0};
171 uint32_t stop_delay_{0};
172 uint32_t run_duration_{0};
173 uint64_t start_millis_{0};
174 uint64_t stop_millis_{0};
185 bool has_valve_operator();
187 void set_run_duration(uint32_t run_duration);
188 void set_valve(
size_t valve_number);
191 uint32_t run_duration();
198 bool has_valve_{
false};
199 size_t valve_number_{0};
200 uint32_t run_duration_{0};
209 void setup()
override;
210 void loop()
override;
211 void dump_config()
override;
217 void add_controller(
Sprinkler *other_controller);
231 void configure_valve_switch(
size_t valve_number,
switch_::Switch *valve_switch, uint32_t run_duration);
232 void configure_valve_switch_pulsed(
size_t valve_number,
switch_::Switch *valve_switch_off,
236 void configure_valve_pump_switch(
size_t valve_number,
switch_::Switch *pump_switch);
237 void configure_valve_pump_switch_pulsed(
size_t valve_number,
switch_::Switch *pump_switch_off,
250 void set_next_prev_ignore_disabled_valves(
bool ignore_disabled);
253 void set_pump_start_delay(uint32_t start_delay);
256 void set_pump_stop_delay(uint32_t stop_delay);
259 void set_valve_start_delay(uint32_t start_delay);
262 void set_valve_stop_delay(uint32_t stop_delay);
266 void set_pump_switch_off_during_valve_open_delay(
bool pump_switch_off_during_valve_open_delay);
269 void set_valve_open_delay(uint32_t valve_open_delay);
272 void set_valve_overlap(uint32_t valve_overlap);
275 void set_manual_selection_delay(uint32_t manual_selection_delay);
281 void set_auto_advance(
bool auto_advance);
287 void set_queue_enable(
bool queue_enable);
290 void set_reverse(
bool reverse);
293 void set_standby(
bool standby);
296 uint32_t valve_run_duration(
size_t valve_number);
299 uint32_t valve_run_duration_adjusted(
size_t valve_number);
314 bool queue_enabled();
324 void start_from_queue();
328 void start_full_cycle();
338 void clear_queued_valves();
344 void previous_valve();
347 void shutdown(
bool clear_queue =
false);
356 void resume_or_start_full_cycle();
362 const char *valve_name(
size_t valve_number);
381 size_t number_of_valves();
384 bool is_a_valid_valve(
size_t valve_number);
393 uint32_t total_cycle_time_all_valves();
396 uint32_t total_cycle_time_enabled_valves();
399 uint32_t total_cycle_time_enabled_incomplete_valves();
402 uint32_t total_queue_time();
411 bool any_controller_is_active();
433 bool valve_is_enabled_(
size_t valve_number);
436 void mark_valve_cycle_complete_(
size_t valve_number);
439 bool valve_cycle_complete_(
size_t valve_number);
443 bool include_complete =
true);
447 bool include_complete =
true);
460 bool any_valve_is_enabled_();
467 void all_valves_off_(
bool include_pump =
false);
470 void prep_full_cycle_();
473 void reset_cycle_states_();
476 void fsm_request_(
size_t requested_valve, uint32_t requested_run_duration = 0);
482 void fsm_transition_();
485 void fsm_transition_from_shutdown_();
488 void fsm_transition_from_valve_run_();
491 void fsm_transition_to_shutdown_();
511 void valve_selection_callback_();
512 void sm_timer_callback_();
515 const uint8_t max_queue_size_{100};
518 bool next_prev_ignore_disabled_{
false};
521 bool pump_switch_off_during_valve_open_delay_{
false};
524 bool valve_overlap_{
false};
527 bool start_delay_is_valve_delay_{
false};
528 bool stop_delay_is_valve_delay_{
false};
531 uint32_t start_delay_{0};
532 uint32_t stop_delay_{0};
567 uint32_t repeat_count_{0};
570 float multiplier_{1.0};
582 std::vector<SprinklerValveOperator> valve_op_{2};
585 std::vector<SprinklerTimer> timer_{};
Base class for all switches.
float get_setup_priority() const override
void set_off_switch(switch_::Switch *off_switch)
SprinklerControllerSwitch * controller_switch
SprinklerValveRunRequest next_req_
The next run request for the controller to consume after active_req_ is complete. ...
bool valve_cycle_complete
std::unique_ptr< Automation<> > sprinkler_standby_turn_on_automation_
optional< uint32_t > resume_duration_
Set from time_remaining() when paused.
std::vector< SprinklerValve > valve_
Sprinkler valve objects.
optional< uint32_t > switching_delay_
Valve switching delay.
void set_pulse_duration(uint32_t pulse_duration)
Trigger< float > * get_set_trigger() const
switch_::Switch * on_switch_
std::unique_ptr< ResumeOrStartAction<> > sprinkler_resumeorstart_action_
optional< size_t > pump_switch_index
std::unique_ptr< Automation<> > valve_turn_off_automation
std::vector< Sprinkler * > other_controllers_
Other Sprinkler instances we should be aware of (used to check if pumps are in use) ...
SprinklerValveRunRequestOrigin
uint32_t pulse_duration()
void set_on_switch(switch_::Switch *on_switch)
switch_::Switch * on_switch()
std::unique_ptr< Automation<> > sprinkler_turn_on_automation_
const nullopt_t nullopt((nullopt_t::init()))
std::function< void()> func
SprinklerControllerNumber * run_duration_number
void set_initial_value(float initial_value)
Base-class for all numbers.
SprinklerState controller_state()
returns the current state of the sprinkler controller
const float PROCESSOR
For components that use data from sensors like displays.
ESPPreferenceObject pref_
optional< size_t > manual_valve_
The number of the manually selected valve currently selected.
optional< uint32_t > target_repeats_
Set the number of times to repeat a full cycle.
switch_::Switch * off_switch_
const std::string MIN_STR
void set_restore_value(bool restore_value)
std::vector< SprinklerSwitch > pump_
Sprinkler valve pump objects.
SprinklerSwitch valve_switch
SprinklerValveRunRequest prev_req_
The previous run request the controller processed.
optional< size_t > paused_valve_
The number of the valve to resume from (if paused)
std::unique_ptr< StartSingleValveAction<> > valve_resumeorstart_action
void sync_valve_state(bool latch_state)
std::unique_ptr< ShutdownAction<> > sprinkler_shutdown_action_
std::unique_ptr< Automation<> > sprinkler_turn_off_automation_
Trigger * turn_on_trigger_
Implementation of SPI Controller mode.
optional< uint32_t > manual_selection_delay_
Manual switching delay.
std::unique_ptr< Automation<> > valve_turn_on_automation
std::vector< SprinklerQueueItem > queued_valves_
Queue of valves to activate next, regardless of auto-advance.
SprinklerControllerSwitch * enable_switch
std::unique_ptr< ShutdownAction<> > sprinkler_standby_shutdown_action_
Trigger * turn_off_trigger_
switch_::Switch * off_switch()
SprinklerValveRunRequest active_req_
The valve run request that is currently active.
std::unique_ptr< ShutdownAction<> > valve_shutdown_action