ESPHome 2026.11.0-dev
Loading...
Searching...
No Matches
sprinkler.h
Go to the documentation of this file.
1#pragma once
2
5#include "esphome/core/hal.h"
9
10#include <array>
11#include <vector>
12
13namespace esphome::sprinkler {
14
15inline constexpr const char *MIN_STR = "min";
16
17enum SprinklerState : uint8_t {
18 // NOTE: these states are used by both SprinklerValveOperator and Sprinkler (the controller)!
19 IDLE, // system/valve is off
20 STARTING, // system/valve is starting/"half open" -- either pump or valve is on, but the remaining pump/valve is not
21 ACTIVE, // system/valve is running its cycle
22 STOPPING, // system/valve is stopping/"half open" -- either pump or valve is on, but the remaining pump/valve is not
23 BYPASS // used by SprinklerValveOperator to ignore the instance checking pump status
24};
25
30
36
37class Sprinkler; // this component
38class SprinklerControllerNumber; // number components that appear in the front end; based on number core
39class SprinklerControllerSwitch; // switches that appear in the front end; based on switch core
40class SprinklerValveOperator; // manages all switching on/off of valves and associated pumps
41class SprinklerValveRunRequest; // tells the sprinkler controller what valve to run and for how long as well as what
42 // SprinklerValveOperator is handling it
43template<typename... Ts> class StartSingleValveAction;
44template<typename... Ts> class ShutdownAction;
45template<typename... Ts> class ResumeOrStartAction;
46
51
53 bool active;
56 std::function<void()> func;
57};
58
72
74 public:
75 void setup() override;
76 void dump_config() override;
77 float get_setup_priority() const override { return setup_priority::PROCESSOR; }
78
80 void set_initial_value(float initial_value) { initial_value_ = initial_value; }
81 void set_restore_value(bool restore_value) { this->restore_value_ = restore_value; }
82
83 protected:
84 void control(float value) override;
85 float initial_value_{NAN};
86 bool restore_value_{true};
88
90};
91
93 public:
95
96 void setup() override;
97 void dump_config() override;
98
99 void set_state_lambda(std::function<optional<bool>()> &&f);
102 void loop() override;
103
104 float get_setup_priority() const override;
105
106 protected:
107 void write_state(bool state) override;
108
109 optional<std::function<optional<bool>()>> f_;
113};
114
116 public:
119 void loop();
120 void set_controller(Sprinkler *controller);
121 void set_valve(SprinklerValve *valve);
122 void set_run_duration(uint32_t run_duration); // set the desired run duration in seconds
123 void set_start_delay(uint32_t start_delay, bool start_delay_is_valve_delay);
124 void set_stop_delay(uint32_t stop_delay, bool stop_delay_is_valve_delay);
125 void start();
126 void stop();
127 uint32_t run_duration(); // returns the desired run duration in seconds
128 uint32_t time_remaining(); // returns seconds remaining (does not include stop_delay_)
129 SprinklerState state() { return this->state_; }
130 switch_::Switch *pump_switch(); // returns this SprinklerValveOperator's pump switch
131
132 protected:
133 void pump_off_();
134 void pump_on_();
135 void valve_off_();
136 void valve_on_();
137 void kill_();
138 void run_();
144 optional<uint32_t> start_millis_{};
145 optional<uint32_t> stop_millis_{};
149};
150
152 public:
155 bool has_request() { return this->has_valve_; }
156 bool has_valve_operator();
159 void set_valve(size_t valve_number);
161 void reset();
163 size_t valve() { return this->valve_number_; }
164 optional<size_t> valve_as_opt();
167
168 protected:
169 bool has_valve_{false};
170 size_t valve_number_{0};
174};
175
176class Sprinkler final : public Component {
177 public:
178 Sprinkler();
179 Sprinkler(const char *name);
180 void setup() override;
181 void loop() override;
182 void dump_config() override;
183
185 void add_valve(SprinklerControllerSwitch *valve_sw, SprinklerControllerSwitch *enable_sw = nullptr);
186
188 void add_controller(Sprinkler *other_controller);
189
193 this->auto_adv_sw_ = auto_adv_switch;
194 }
196 this->queue_enable_sw_ = queue_enable_switch;
197 }
198 void set_controller_reverse_switch(SprinklerControllerSwitch *reverse_switch) { this->reverse_sw_ = reverse_switch; }
200
203 this->multiplier_number_ = multiplier_number;
204 }
205 void set_controller_repeat_number(SprinklerControllerNumber *repeat_number) { this->repeat_number_ = repeat_number; }
206
208 void configure_valve_switch(size_t valve_number, switch_::Switch *valve_switch, uint32_t run_duration);
209
211 void configure_valve_pump_switch(size_t valve_number, switch_::Switch *pump_switch);
212
214 void configure_valve_run_duration_number(size_t valve_number, SprinklerControllerNumber *run_duration_number);
215
217 void set_divider(optional<uint32_t> divider);
218
220 void set_multiplier(optional<float> multiplier);
221
223 void set_next_prev_ignore_disabled_valves(bool ignore_disabled) {
224 this->next_prev_ignore_disabled_ = ignore_disabled;
225 }
226
228 void set_pump_start_delay(uint32_t start_delay);
229
231 void set_pump_stop_delay(uint32_t stop_delay);
232
234 void set_valve_start_delay(uint32_t start_delay);
235
237 void set_valve_stop_delay(uint32_t stop_delay);
238
241 void set_pump_switch_off_during_valve_open_delay(bool pump_switch_off_during_valve_open_delay) {
242 this->pump_switch_off_during_valve_open_delay_ = pump_switch_off_during_valve_open_delay;
243 }
244
246 void set_valve_open_delay(uint32_t valve_open_delay);
247
249 void set_valve_overlap(uint32_t valve_overlap);
250
252 void set_manual_selection_delay(uint32_t manual_selection_delay);
253
255 void set_valve_run_duration(optional<size_t> valve_number, optional<uint32_t> run_duration);
256
259
261 void set_repeat(optional<uint32_t> repeat);
262
264 void set_queue_enable(bool queue_enable);
265
267 void set_reverse(bool reverse);
268
270 void set_standby(bool standby);
271
273 uint32_t valve_run_duration(size_t valve_number);
274
276 uint32_t valve_run_duration_adjusted(size_t valve_number);
277
279 bool auto_advance();
280
282 float multiplier();
283
285 optional<uint32_t> repeat();
286
288 optional<uint32_t> repeat_count();
289
291 bool queue_enabled();
292
294 bool reverse();
295
297 bool standby();
298
301 void start_from_queue();
302
305 void start_full_cycle();
306
308 void start_single_valve(optional<size_t> valve_number, optional<uint32_t> run_duration = nullopt);
309
312 void queue_valve(optional<size_t> valve_number, optional<uint32_t> run_duration);
313
315 void clear_queued_valves();
316
318 void next_valve();
319
321 void previous_valve();
322
324 void shutdown(bool clear_queue = false);
325
327 void pause();
328
330 void resume();
331
334
336 void reset_resume();
337
339 ESPDEPRECATED("Use valve_log_name() or control_switch()->get_name_to() instead. Will be removed in ESPHome 2027.5.0",
340 "2026.11.0")
341 const char *valve_name(size_t valve_number);
343 const LogString *valve_log_name(size_t valve_number);
344
347
349 optional<size_t> active_valve();
350
352 optional<size_t> paused_valve() { return this->paused_valve_; }
353
355 optional<size_t> queued_valve();
356
359 optional<size_t> manual_valve() { return this->manual_valve_; }
360
362 size_t number_of_valves() { return this->valve_.size(); }
363
365 bool is_a_valid_valve(size_t valve_number);
366
368 bool pump_in_use(switch_::Switch *pump_switch);
369
371 void set_pump_state(switch_::Switch *pump_switch, bool state);
372
375
378
381
384
386 optional<uint32_t> time_remaining_active_valve();
387
389 optional<uint32_t> time_remaining_current_operation();
390
393
396
398 SprinklerControllerSwitch *control_switch(size_t valve_number);
399
401 SprinklerControllerSwitch *enable_switch(size_t valve_number);
402
404 switch_::Switch *valve_switch(size_t valve_number);
405
407 switch_::Switch *valve_pump_switch(size_t valve_number);
408
411
412 protected:
414 bool valve_is_enabled_(size_t valve_number);
415
417 void mark_valve_cycle_complete_(size_t valve_number);
418
420 bool valve_cycle_complete_(size_t valve_number);
421
423 optional<size_t> next_valve_number_(optional<size_t> first_valve = nullopt, bool include_disabled = true,
424 bool include_complete = true);
425
427 optional<size_t> previous_valve_number_(optional<size_t> first_valve = nullopt, bool include_disabled = true,
428 bool include_complete = true);
429
432 optional<size_t> next_valve_number_in_cycle_(optional<size_t> first_valve = nullopt);
433
438 void load_next_valve_run_request_(optional<size_t> first_valve = nullopt);
439
442
446
448 void all_valves_off_(bool include_pump = false);
449
451 void prep_full_cycle_();
452
454 void reset_cycle_states_();
455
457 void fsm_request_(size_t requested_valve, uint32_t requested_run_duration = 0);
458
460 void fsm_kick_();
461
463 void fsm_transition_();
464
467
470
473
475 void log_standby_warning_(const LogString *method_name);
476
478 void log_multiplier_zero_warning_(const LogString *method_name);
479
481 const LogString *req_as_str_(SprinklerValveRunRequestOrigin origin);
482
484 const LogString *state_as_str_(SprinklerState state);
485
487 void start_timer_(SprinklerTimerIndex timer_index);
488 bool cancel_timer_(SprinklerTimerIndex timer_index);
490 bool timer_active_(SprinklerTimerIndex timer_index);
492 void set_timer_duration_(SprinklerTimerIndex timer_index, uint32_t time);
495 std::function<void()> timer_cbf_(SprinklerTimerIndex timer_index);
496
499 void sm_timer_callback_();
500
502 const uint8_t max_queue_size_{100};
503
506
509
511 bool valve_overlap_{false};
512
516
520
521 const char *name_{""};
522
525
528
531
534
536 optional<size_t> manual_valve_;
537
539 optional<size_t> paused_valve_;
540
542 optional<uint32_t> target_repeats_;
543
545 optional<uint32_t> resume_duration_;
546
548 optional<uint32_t> manual_selection_delay_;
549
551 optional<uint32_t> switching_delay_;
552
555
557 float multiplier_{1.0};
558
560 std::vector<SprinklerQueueItem> queued_valves_;
561
563 std::vector<switch_::Switch *> pump_;
564
566 std::vector<SprinklerValve> valve_;
567
569 std::vector<SprinklerValveOperator> valve_op_{2};
570
572 std::array<SprinklerTimer, 2> timer_;
573
575 std::vector<Sprinkler *> other_controllers_;
576
583
587
588 std::unique_ptr<ShutdownAction<>> sprinkler_shutdown_action_;
589 std::unique_ptr<ShutdownAction<>> sprinkler_standby_shutdown_action_;
590 std::unique_ptr<ResumeOrStartAction<>> sprinkler_resumeorstart_action_;
591
592 std::unique_ptr<Automation<>> sprinkler_turn_off_automation_;
593 std::unique_ptr<Automation<>> sprinkler_turn_on_automation_;
594 std::unique_ptr<Automation<>> sprinkler_standby_turn_on_automation_;
595};
596
597} // namespace esphome::sprinkler
Base-class for all numbers.
Definition number.h:29
void set_initial_value(float initial_value)
Definition sprinkler.h:80
void set_restore_value(bool restore_value)
Definition sprinkler.h:81
void set_state_lambda(std::function< optional< bool >()> &&f)
Definition sprinkler.cpp:69
optional< std::function< optional< bool >()> > f_
Definition sprinkler.h:109
void set_controller_standby_switch(SprinklerControllerSwitch *standby_switch)
void add_controller(Sprinkler *other_controller)
add another controller to the controller so it can check if pumps/main valves are in use
void resume()
resumes a cycle that was suspended using pause()
void fsm_transition_to_shutdown_()
starts up the system from IDLE state
optional< size_t > previous_valve_number_(optional< size_t > first_valve=nullopt, bool include_disabled=true, bool include_complete=true)
returns the number of the previous valve in the vector or nullopt if no valves match criteria
bool is_a_valid_valve(size_t valve_number)
returns true if valve number is valid
bool reverse()
returns true if reverse is enabled
bool next_prev_ignore_disabled_
When set to true, the next and previous actions will skip disabled valves.
Definition sprinkler.h:505
void reset_resume()
resets resume state
SprinklerControllerNumber * repeat_number_
Definition sprinkler.h:586
bool valve_is_enabled_(size_t valve_number)
returns true if valve number is enabled
SprinklerState state_
Sprinkler controller state.
Definition sprinkler.h:524
void next_valve()
advances to the next valve (numerically)
void log_standby_warning_(const LogString *method_name)
log error message when a method is called but standby is enabled
uint32_t repeat_count_
Number of times the full cycle has been repeated.
Definition sprinkler.h:554
void configure_valve_switch(size_t valve_number, switch_::Switch *valve_switch, uint32_t run_duration)
configure a valve's switch object and run duration. run_duration is time in seconds.
std::vector< SprinklerValve > valve_
Sprinkler valve objects.
Definition sprinkler.h:566
void queue_valve(optional< size_t > valve_number, optional< uint32_t > run_duration)
adds a valve into the queue.
void set_valve_run_duration(optional< size_t > valve_number, optional< uint32_t > run_duration)
set how long the valve should remain on/open. run_duration is time in seconds
optional< uint32_t > resume_duration_
Set from time_remaining() when paused.
Definition sprinkler.h:545
void set_repeat(optional< uint32_t > repeat)
set the number of times to repeat a full cycle
float multiplier()
returns the current value of the multiplier
bool auto_advance()
returns true if auto_advance is enabled
uint32_t total_queue_time()
returns the amount of time in seconds required for all valves in the queue
void fsm_transition_from_shutdown_()
starts up the system from IDLE state
optional< uint32_t > repeat_count()
if a cycle is active, returns the number of times the controller has repeated the cycle....
void all_valves_off_(bool include_pump=false)
turns off/closes all valves, including pump if include_pump is true
SprinklerValveRunRequest prev_req_
The previous run request the controller processed.
Definition sprinkler.h:533
std::array< SprinklerTimer, 2 > timer_
Valve control timers, indexed by SprinklerTimerIndex (also used as the scheduler id)
Definition sprinkler.h:572
void start_valve_(SprinklerValveRunRequest *req)
loads an available SprinklerValveOperator (valve_op_) based on req and starts it (switches it on).
optional< uint32_t > repeat()
returns the number of times the controller is set to repeat cycles, if at all. check with 'has_value(...
void mark_valve_cycle_complete_(size_t valve_number)
marks a valve's cycle as complete
void set_pump_stop_delay(uint32_t stop_delay)
set how long the pump should stop after the valve (when the pump is starting)
void log_multiplier_zero_warning_(const LogString *method_name)
log error message when a method is called but multiplier is zero
optional< size_t > paused_valve()
returns the number of the valve that is paused, if any. check with 'has_value()'
Definition sprinkler.h:352
void set_controller_reverse_switch(SprinklerControllerSwitch *reverse_switch)
Definition sprinkler.h:198
uint32_t start_delay_
Pump start/stop delay intervals.
Definition sprinkler.h:518
const LogString * req_as_str_(SprinklerValveRunRequestOrigin origin)
return the specified SprinklerValveRunRequestOrigin as a string
void set_valve_overlap(uint32_t valve_overlap)
set how long the controller should wait after opening a valve before closing the previous valve
optional< SprinklerValveRunRequestOrigin > active_valve_request_is_from()
returns what invoked the valve that is currently active, if any. check with 'has_value()'
void set_reverse(bool reverse)
if reverse is true, controller will iterate through all enabled valves in reverse (descending) order
SprinklerControllerNumber * multiplier_number_
Number components we'll present to the front end.
Definition sprinkler.h:585
std::vector< SprinklerValveOperator > valve_op_
Sprinkler valve operator objects.
Definition sprinkler.h:569
SprinklerControllerSwitch * enable_switch(size_t valve_number)
returns a pointer to a valve's enable switch object
void start_full_cycle()
starts a full cycle of all enabled valves and enables auto_advance.
SprinklerControllerSwitch * controller_sw_
Definition sprinkler.h:579
void set_valve_stop_delay(uint32_t stop_delay)
set how long the valve should stop after the pump (when the pump is stopping)
void set_controller_queue_enable_switch(SprinklerControllerSwitch *queue_enable_switch)
Definition sprinkler.h:195
void set_pump_state(switch_::Switch *pump_switch, bool state)
switches on/off a pump "safely" by checking that the new state will not conflict with another control...
optional< uint32_t > target_repeats_
Set the number of times to repeat a full cycle.
Definition sprinkler.h:542
void set_controller_main_switch(SprinklerControllerSwitch *controller_switch)
configure important controller switches
switch_::Switch * valve_switch(size_t valve_number)
returns a pointer to a valve's switch object
optional< uint32_t > time_remaining_current_operation()
returns the amount of time remaining in seconds for all valves remaining, including the active valve,...
const LogString * state_as_str_(SprinklerState state)
return the specified SprinklerState state as a string
SprinklerControllerSwitch * reverse_sw_
Definition sprinkler.h:581
optional< uint32_t > switching_delay_
Valve switching delay.
Definition sprinkler.h:551
void fsm_kick_()
kicks the state machine to advance, starting it if it is not already active
SprinklerValveRunRequest active_req_
The valve run request that is currently active.
Definition sprinkler.h:527
ESPDEPRECATED("Use valve_log_name() or control_switch()->get_name_to() instead. Will be removed in ESPHome 2027.5.0", "2026.11.0") const char *valve_name(size_t valve_number)
returns a pointer to a valve's name string object; returns nullptr if valve_number is invalid
bool any_controller_is_active()
returns true if this or any sprinkler controller this controller knows about is active
void set_valve_open_delay(uint32_t valve_open_delay)
set how long the controller should wait to open/switch on the valve after it becomes active
std::vector< switch_::Switch * > pump_
Sprinkler valve pump switches.
Definition sprinkler.h:563
bool start_delay_is_valve_delay_
Pump start/stop delay interval types.
Definition sprinkler.h:514
optional< size_t > manual_valve_
The number of the manually selected valve currently selected.
Definition sprinkler.h:536
bool pump_switch_off_during_valve_open_delay_
Pump should be off during valve_open_delay interval.
Definition sprinkler.h:508
bool cancel_timer_(SprinklerTimerIndex timer_index)
SprinklerControllerSwitch * queue_enable_sw_
Definition sprinkler.h:580
void start_timer_(SprinklerTimerIndex timer_index)
Start/cancel/get status of valve timers.
void previous_valve()
advances to the previous valve (numerically)
switch_::Switch * valve_pump_switch_by_pump_index(size_t pump_index)
returns a pointer to a valve's pump switch object
void set_auto_advance(bool auto_advance)
if auto_advance is true, controller will iterate through all enabled valves
void prep_full_cycle_()
prepares for a full cycle by verifying auto-advance is on as well as one or more valve enable switche...
uint32_t valve_run_duration_adjusted(size_t valve_number)
returns valve_number's run duration (in seconds) adjusted by multiplier_
std::unique_ptr< ShutdownAction<> > sprinkler_shutdown_action_
Definition sprinkler.h:588
std::unique_ptr< ResumeOrStartAction<> > sprinkler_resumeorstart_action_
Definition sprinkler.h:590
void clear_queued_valves()
clears/removes all valves from the queue
bool any_valve_is_enabled_()
returns true if any valve is enabled
size_t number_of_valves()
returns the number of valves the controller is configured with
Definition sprinkler.h:362
void set_pump_start_delay(uint32_t start_delay)
set how long the pump should start after the valve (when the pump is starting)
void set_standby(bool standby)
if standby is true, controller will refuse to activate any valves
std::vector< SprinklerQueueItem > queued_valves_
Queue of valves to activate next, regardless of auto-advance.
Definition sprinkler.h:560
bool queue_enabled()
returns true if the queue is enabled to run
void resume_or_start_full_cycle()
if a cycle was suspended using pause(), resumes it. otherwise calls start_full_cycle()
std::unique_ptr< Automation<> > sprinkler_turn_on_automation_
Definition sprinkler.h:593
void valve_selection_callback_()
callback functions for timers
optional< size_t > next_valve_number_(optional< size_t > first_valve=nullopt, bool include_disabled=true, bool include_complete=true)
returns the number of the next valve in the vector or nullopt if no valves match criteria
uint32_t total_cycle_time_all_valves()
returns the amount of time in seconds required for all valves
std::unique_ptr< Automation<> > sprinkler_turn_off_automation_
Definition sprinkler.h:592
const uint8_t max_queue_size_
Maximum allowed queue size.
Definition sprinkler.h:502
optional< uint32_t > time_remaining_active_valve()
returns the amount of time remaining in seconds for the active valve, if any
optional< size_t > next_valve_number_in_cycle_(optional< size_t > first_valve=nullopt)
returns the number of the next valve that should be activated in a full cycle.
std::function< void()> timer_cbf_(SprinklerTimerIndex timer_index)
void set_pump_switch_off_during_valve_open_delay(bool pump_switch_off_during_valve_open_delay)
if pump_switch_off_during_valve_open_delay is true, the controller will switch off the pump during th...
Definition sprinkler.h:241
std::unique_ptr< ShutdownAction<> > sprinkler_standby_shutdown_action_
Definition sprinkler.h:589
optional< uint32_t > manual_selection_delay_
Manual switching delay.
Definition sprinkler.h:548
void set_controller_repeat_number(SprinklerControllerNumber *repeat_number)
Definition sprinkler.h:205
void start_single_valve(optional< size_t > valve_number, optional< uint32_t > run_duration=nullopt)
activates a single valve and disables auto_advance.
uint32_t valve_run_duration(size_t valve_number)
returns valve_number's run duration in seconds
void load_next_valve_run_request_(optional< size_t > first_valve=nullopt)
loads next_req_ with the next valve that should be activated, including its run duration.
void fsm_transition_()
advance controller state, advancing to target_valve if provided
void fsm_request_(size_t requested_valve, uint32_t requested_run_duration=0)
make a request of the state machine
optional< size_t > paused_valve_
The number of the valve to resume from (if paused)
Definition sprinkler.h:539
SprinklerValveRunRequest next_req_
The next run request for the controller to consume after active_req_ is complete.
Definition sprinkler.h:530
void configure_valve_run_duration_number(size_t valve_number, SprinklerControllerNumber *run_duration_number)
configure a valve's run duration number component
const LogString * valve_log_name(size_t valve_number)
returns a valve's name for a "%s" log argument; returns nullptr if valve_number is invalid
SprinklerControllerSwitch * auto_adv_sw_
Switches we'll present to the front end.
Definition sprinkler.h:578
void set_controller_multiplier_number(SprinklerControllerNumber *multiplier_number)
configure important controller number components
Definition sprinkler.h:202
void set_manual_selection_delay(uint32_t manual_selection_delay)
set how long the controller should wait to activate a valve after next_valve() or previous_valve() is...
uint32_t total_cycle_time_enabled_incomplete_valves()
returns the amount of time in seconds required for all enabled & incomplete valves,...
bool valve_overlap_
Sprinkler valve cycle should overlap.
Definition sprinkler.h:511
switch_::Switch * valve_pump_switch(size_t valve_number)
returns a pointer to a valve's pump switch object
void set_divider(optional< uint32_t > divider)
sets the multiplier value to '1 / divider' and sets repeat value to divider
std::unique_ptr< Automation<> > sprinkler_standby_turn_on_automation_
Definition sprinkler.h:594
void set_valve_start_delay(uint32_t start_delay)
set how long the valve should start after the pump (when the pump is stopping)
void pause()
same as shutdown(), but also stores active_valve() and time_remaining() allowing resume() to continue...
void set_next_prev_ignore_disabled_valves(bool ignore_disabled)
enable/disable skipping of disabled valves by the next and previous actions
Definition sprinkler.h:223
optional< size_t > active_valve()
returns the number of the valve that is currently active, if any. check with 'has_value()'
void set_queue_enable(bool queue_enable)
if queue_enable is true, controller will iterate through valves in the queue
bool pump_in_use(switch_::Switch *pump_switch)
returns true if the pump the pointer points to is in use
bool timer_active_(SprinklerTimerIndex timer_index)
returns true if the specified timer is active/running
optional< size_t > queued_valve()
returns the number of the next valve in the queue, if any. check with 'has_value()'
std::vector< Sprinkler * > other_controllers_
Other Sprinkler instances we should be aware of (used to check if pumps are in use)
Definition sprinkler.h:575
void start_from_queue()
starts the controller from the first valve in the queue and disables auto_advance.
void configure_valve_pump_switch(size_t valve_number, switch_::Switch *pump_switch)
configure a valve's associated pump switch object
void reset_cycle_states_()
resets the cycle state for all valves
float multiplier_
Sprinkler valve run time multiplier value.
Definition sprinkler.h:557
SprinklerControllerSwitch * control_switch(size_t valve_number)
returns a pointer to a valve's control switch object
void set_multiplier(optional< float > multiplier)
value multiplied by configured run times – used to extend or shorten the cycle
void set_timer_duration_(SprinklerTimerIndex timer_index, uint32_t time)
time is converted to milliseconds (ms) for set_timeout()
SprinklerState controller_state()
returns the current state of the sprinkler controller
Definition sprinkler.h:395
void set_controller_auto_adv_switch(SprinklerControllerSwitch *auto_adv_switch)
Definition sprinkler.h:192
void fsm_transition_from_valve_run_()
transitions from ACTIVE state to ACTIVE (as in, next valve) or to a SHUTDOWN or IDLE state
bool standby()
returns true if standby is enabled
uint32_t total_cycle_time_enabled_valves()
returns the amount of time in seconds required for all enabled valves
bool valve_cycle_complete_(size_t valve_number)
returns true if valve's cycle is flagged as complete
optional< size_t > manual_valve()
returns the number of the valve that is manually selected, if any.
Definition sprinkler.h:359
void add_valve(SprinklerControllerSwitch *valve_sw, SprinklerControllerSwitch *enable_sw=nullptr)
add a valve to the controller
SprinklerControllerSwitch * standby_sw_
Definition sprinkler.h:582
uint32_t timer_duration_(SprinklerTimerIndex timer_index)
returns time in milliseconds (ms)
void set_valve(SprinklerValve *valve)
void set_run_duration(uint32_t run_duration)
void set_start_delay(uint32_t start_delay, bool start_delay_is_valve_delay)
void set_controller(Sprinkler *controller)
void set_stop_delay(uint32_t stop_delay, bool stop_delay_is_valve_delay)
SprinklerValveRunRequestOrigin origin_
Definition sprinkler.h:173
SprinklerValveRunRequestOrigin request_is_from()
Definition sprinkler.h:166
void set_request_from(SprinklerValveRunRequestOrigin origin)
Definition sprinkler.h:157
SprinklerValveOperator * valve_operator()
void set_run_duration(uint32_t run_duration)
void set_valve_operator(SprinklerValveOperator *valve_op)
Base class for all switches.
Definition switch.h:43
bool state
The current reported state of the binary sensor.
Definition switch.h:60
bool state
Definition fan.h:2
constexpr float PROCESSOR
For components that use data from sensors like displays.
Definition component.h:47
constexpr const char * MIN_STR
Definition sprinkler.h:15
static void uint32_t
std::function< void()> func
Definition sprinkler.h:56
std::unique_ptr< StartSingleValveAction<> > valve_resumeorstart_action
Definition sprinkler.h:68
SprinklerControllerNumber * run_duration_number
Definition sprinkler.h:60
std::unique_ptr< Automation<> > valve_turn_off_automation
Definition sprinkler.h:69
SprinklerControllerSwitch * enable_switch
Definition sprinkler.h:62
std::unique_ptr< ShutdownAction<> > valve_shutdown_action
Definition sprinkler.h:67
SprinklerControllerSwitch * controller_switch
Definition sprinkler.h:61
std::unique_ptr< Automation<> > valve_turn_on_automation
Definition sprinkler.h:70
optional< size_t > pump_switch_index
Definition sprinkler.h:65