ESPHome
2024.11.0
|
#include <sprinkler.h>
Public Member Functions | |
Sprinkler () | |
Sprinkler (const std::string &name) | |
void | setup () override |
void | loop () override |
void | dump_config () override |
void | add_valve (SprinklerControllerSwitch *valve_sw, SprinklerControllerSwitch *enable_sw=nullptr) |
add a valve to the controller More... | |
void | add_controller (Sprinkler *other_controller) |
add another controller to the controller so it can check if pumps/main valves are in use More... | |
void | set_controller_main_switch (SprinklerControllerSwitch *controller_switch) |
configure important controller switches More... | |
void | set_controller_auto_adv_switch (SprinklerControllerSwitch *auto_adv_switch) |
void | set_controller_queue_enable_switch (SprinklerControllerSwitch *queue_enable_switch) |
void | set_controller_reverse_switch (SprinklerControllerSwitch *reverse_switch) |
void | set_controller_standby_switch (SprinklerControllerSwitch *standby_switch) |
void | set_controller_multiplier_number (SprinklerControllerNumber *multiplier_number) |
configure important controller number components More... | |
void | set_controller_repeat_number (SprinklerControllerNumber *repeat_number) |
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. More... | |
void | configure_valve_switch_pulsed (size_t valve_number, switch_::Switch *valve_switch_off, switch_::Switch *valve_switch_on, uint32_t pulse_duration, uint32_t run_duration) |
void | configure_valve_pump_switch (size_t valve_number, switch_::Switch *pump_switch) |
configure a valve's associated pump switch object More... | |
void | configure_valve_pump_switch_pulsed (size_t valve_number, switch_::Switch *pump_switch_off, switch_::Switch *pump_switch_on, uint32_t pulse_duration) |
void | configure_valve_run_duration_number (size_t valve_number, SprinklerControllerNumber *run_duration_number) |
configure a valve's run duration number component More... | |
void | set_divider (optional< uint32_t > divider) |
sets the multiplier value to '1 / divider' and sets repeat value to divider More... | |
void | set_multiplier (optional< float > multiplier) |
value multiplied by configured run times – used to extend or shorten the cycle More... | |
void | set_next_prev_ignore_disabled_valves (bool ignore_disabled) |
enable/disable skipping of disabled valves by the next and previous actions More... | |
void | set_pump_start_delay (uint32_t start_delay) |
set how long the pump should start after the valve (when the pump is starting) More... | |
void | set_pump_stop_delay (uint32_t stop_delay) |
set how long the pump should stop after the valve (when the pump is starting) More... | |
void | set_valve_start_delay (uint32_t start_delay) |
set how long the valve should start after the pump (when the pump is stopping) More... | |
void | set_valve_stop_delay (uint32_t stop_delay) |
set how long the valve should stop after the pump (when the pump is stopping) More... | |
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 the valve_open_delay interval More... | |
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 More... | |
void | set_valve_overlap (uint32_t valve_overlap) |
set how long the controller should wait after opening a valve before closing the previous valve More... | |
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 called More... | |
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 More... | |
void | set_auto_advance (bool auto_advance) |
if auto_advance is true, controller will iterate through all enabled valves More... | |
void | set_repeat (optional< uint32_t > repeat) |
set the number of times to repeat a full cycle More... | |
void | set_queue_enable (bool queue_enable) |
if queue_enable is true, controller will iterate through valves in the queue More... | |
void | set_reverse (bool reverse) |
if reverse is true, controller will iterate through all enabled valves in reverse (descending) order More... | |
void | set_standby (bool standby) |
if standby is true, controller will refuse to activate any valves More... | |
uint32_t | valve_run_duration (size_t valve_number) |
returns valve_number's run duration in seconds More... | |
uint32_t | valve_run_duration_adjusted (size_t valve_number) |
returns valve_number's run duration (in seconds) adjusted by multiplier_ More... | |
bool | auto_advance () |
returns true if auto_advance is enabled More... | |
float | multiplier () |
returns the current value of the multiplier More... | |
optional< uint32_t > | repeat () |
returns the number of times the controller is set to repeat cycles, if at all. check with 'has_value()' More... | |
optional< uint32_t > | repeat_count () |
if a cycle is active, returns the number of times the controller has repeated the cycle. check with 'has_value()' More... | |
bool | queue_enabled () |
returns true if the queue is enabled to run More... | |
bool | reverse () |
returns true if reverse is enabled More... | |
bool | standby () |
returns true if standby is enabled More... | |
void | start_from_queue () |
starts the controller from the first valve in the queue and disables auto_advance. More... | |
void | start_full_cycle () |
starts a full cycle of all enabled valves and enables auto_advance. More... | |
void | start_single_valve (optional< size_t > valve_number, optional< uint32_t > run_duration=nullopt) |
activates a single valve and disables auto_advance. More... | |
void | queue_valve (optional< size_t > valve_number, optional< uint32_t > run_duration) |
adds a valve into the queue. More... | |
void | clear_queued_valves () |
clears/removes all valves from the queue More... | |
void | next_valve () |
advances to the next valve (numerically) More... | |
void | previous_valve () |
advances to the previous valve (numerically) More... | |
void | shutdown (bool clear_queue=false) |
turns off all valves, effectively shutting down the system. More... | |
void | pause () |
same as shutdown(), but also stores active_valve() and time_remaining() allowing resume() to continue the cycle More... | |
void | resume () |
resumes a cycle that was suspended using pause() More... | |
void | resume_or_start_full_cycle () |
if a cycle was suspended using pause(), resumes it. otherwise calls start_full_cycle() More... | |
void | reset_resume () |
resets resume state More... | |
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 More... | |
optional< SprinklerValveRunRequestOrigin > | active_valve_request_is_from () |
returns what invoked the valve that is currently active, if any. check with 'has_value()' More... | |
optional< size_t > | active_valve () |
returns the number of the valve that is currently active, if any. check with 'has_value()' More... | |
optional< size_t > | paused_valve () |
returns the number of the valve that is paused, if any. check with 'has_value()' More... | |
optional< size_t > | queued_valve () |
returns the number of the next valve in the queue, if any. check with 'has_value()' More... | |
optional< size_t > | manual_valve () |
returns the number of the valve that is manually selected, if any. More... | |
size_t | number_of_valves () |
returns the number of valves the controller is configured with More... | |
bool | is_a_valid_valve (size_t valve_number) |
returns true if valve number is valid More... | |
bool | pump_in_use (SprinklerSwitch *pump_switch) |
returns true if the pump the pointer points to is in use More... | |
void | set_pump_state (SprinklerSwitch *pump_switch, bool state) |
switches on/off a pump "safely" by checking that the new state will not conflict with another controller More... | |
uint32_t | total_cycle_time_all_valves () |
returns the amount of time in seconds required for all valves More... | |
uint32_t | total_cycle_time_enabled_valves () |
returns the amount of time in seconds required for all enabled valves More... | |
uint32_t | total_cycle_time_enabled_incomplete_valves () |
returns the amount of time in seconds required for all enabled & incomplete valves, not including the active valve More... | |
uint32_t | total_queue_time () |
returns the amount of time in seconds required for all valves in the queue More... | |
optional< uint32_t > | time_remaining_active_valve () |
returns the amount of time remaining in seconds for the active valve, if any More... | |
optional< uint32_t > | time_remaining_current_operation () |
returns the amount of time remaining in seconds for all valves remaining, including the active valve, if any More... | |
bool | any_controller_is_active () |
returns true if this or any sprinkler controller this controller knows about is active More... | |
SprinklerState | controller_state () |
returns the current state of the sprinkler controller More... | |
SprinklerControllerSwitch * | control_switch (size_t valve_number) |
returns a pointer to a valve's control switch object More... | |
SprinklerControllerSwitch * | enable_switch (size_t valve_number) |
returns a pointer to a valve's enable switch object More... | |
SprinklerSwitch * | valve_switch (size_t valve_number) |
returns a pointer to a valve's switch object More... | |
SprinklerSwitch * | valve_pump_switch (size_t valve_number) |
returns a pointer to a valve's pump switch object More... | |
SprinklerSwitch * | valve_pump_switch_by_pump_index (size_t pump_index) |
returns a pointer to a valve's pump switch object More... | |
Public Member Functions inherited from esphome::Component | |
virtual float | get_setup_priority () const |
priority of setup(). More... | |
float | get_actual_setup_priority () const |
void | set_setup_priority (float priority) |
virtual float | get_loop_priority () const |
priority of loop(). More... | |
void | call () |
virtual void | on_shutdown () |
virtual void | on_safe_shutdown () |
uint32_t | get_component_state () const |
virtual void | mark_failed () |
Mark this component as failed. More... | |
bool | is_failed () const |
bool | is_ready () const |
virtual bool | can_proceed () |
bool | status_has_warning () const |
bool | status_has_error () const |
void | status_set_warning (const char *message="unspecified") |
void | status_set_error (const char *message="unspecified") |
void | status_clear_warning () |
void | status_clear_error () |
void | status_momentary_warning (const std::string &name, uint32_t length=5000) |
void | status_momentary_error (const std::string &name, uint32_t length=5000) |
bool | has_overridden_loop () const |
void | set_component_source (const char *source) |
Set where this component was loaded from for some debug messages. More... | |
const char * | get_component_source () const |
Get the integration where this component was declared as a string. More... | |
Protected Member Functions | |
bool | valve_is_enabled_ (size_t valve_number) |
returns true if valve number is enabled More... | |
void | mark_valve_cycle_complete_ (size_t valve_number) |
marks a valve's cycle as complete More... | |
bool | valve_cycle_complete_ (size_t valve_number) |
returns true if valve's cycle is flagged as complete More... | |
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 More... | |
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 More... | |
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. More... | |
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. More... | |
bool | any_valve_is_enabled_ () |
returns true if any valve is enabled More... | |
void | start_valve_ (SprinklerValveRunRequest *req) |
loads an available SprinklerValveOperator (valve_op_) based on req and starts it (switches it on). More... | |
void | all_valves_off_ (bool include_pump=false) |
turns off/closes all valves, including pump if include_pump is true More... | |
void | prep_full_cycle_ () |
prepares for a full cycle by verifying auto-advance is on as well as one or more valve enable switches. More... | |
void | reset_cycle_states_ () |
resets the cycle state for all valves More... | |
void | fsm_request_ (size_t requested_valve, uint32_t requested_run_duration=0) |
make a request of the state machine More... | |
void | fsm_kick_ () |
kicks the state machine to advance, starting it if it is not already active More... | |
void | fsm_transition_ () |
advance controller state, advancing to target_valve if provided More... | |
void | fsm_transition_from_shutdown_ () |
starts up the system from IDLE state More... | |
void | fsm_transition_from_valve_run_ () |
transitions from ACTIVE state to ACTIVE (as in, next valve) or to a SHUTDOWN or IDLE state More... | |
void | fsm_transition_to_shutdown_ () |
starts up the system from IDLE state More... | |
std::string | req_as_str_ (SprinklerValveRunRequestOrigin origin) |
return the specified SprinklerValveRunRequestOrigin as a string More... | |
std::string | state_as_str_ (SprinklerState state) |
return the specified SprinklerState state as a string More... | |
void | start_timer_ (SprinklerTimerIndex timer_index) |
Start/cancel/get status of valve timers. More... | |
bool | cancel_timer_ (SprinklerTimerIndex timer_index) |
bool | timer_active_ (SprinklerTimerIndex timer_index) |
returns true if the specified timer is active/running More... | |
void | set_timer_duration_ (SprinklerTimerIndex timer_index, uint32_t time) |
time is converted to milliseconds (ms) for set_timeout() More... | |
uint32_t | timer_duration_ (SprinklerTimerIndex timer_index) |
returns time in milliseconds (ms) More... | |
std::function< void()> | timer_cbf_ (SprinklerTimerIndex timer_index) |
void | valve_selection_callback_ () |
callback functions for timers More... | |
void | sm_timer_callback_ () |
Protected Member Functions inherited from esphome::Component | |
virtual void | call_loop () |
virtual void | call_setup () |
virtual void | call_dump_config () |
void | set_interval (const std::string &name, uint32_t interval, std::function< void()> &&f) |
Set an interval function with a unique name. More... | |
void | set_interval (uint32_t interval, std::function< void()> &&f) |
bool | cancel_interval (const std::string &name) |
Cancel an interval function. More... | |
void | set_retry (const std::string &name, uint32_t initial_wait_time, uint8_t max_attempts, std::function< RetryResult(uint8_t)> &&f, float backoff_increase_factor=1.0f) |
Set an retry function with a unique name. More... | |
void | set_retry (uint32_t initial_wait_time, uint8_t max_attempts, std::function< RetryResult(uint8_t)> &&f, float backoff_increase_factor=1.0f) |
bool | cancel_retry (const std::string &name) |
Cancel a retry function. More... | |
void | set_timeout (const std::string &name, uint32_t timeout, std::function< void()> &&f) |
Set a timeout function with a unique name. More... | |
void | set_timeout (uint32_t timeout, std::function< void()> &&f) |
bool | cancel_timeout (const std::string &name) |
Cancel a timeout function. More... | |
void | defer (const std::string &name, std::function< void()> &&f) |
Defer a callback to the next loop() call. More... | |
void | defer (std::function< void()> &&f) |
Defer a callback to the next loop() call. More... | |
bool | cancel_defer (const std::string &name) |
Cancel a defer callback using the specified name, name must not be empty. More... | |
Protected Attributes | |
const uint8_t | max_queue_size_ {100} |
Maximum allowed queue size. More... | |
bool | next_prev_ignore_disabled_ {false} |
When set to true, the next and previous actions will skip disabled valves. More... | |
bool | pump_switch_off_during_valve_open_delay_ {false} |
Pump should be off during valve_open_delay interval. More... | |
bool | valve_overlap_ {false} |
Sprinkler valve cycle should overlap. More... | |
bool | start_delay_is_valve_delay_ {false} |
Pump start/stop delay interval types. More... | |
bool | stop_delay_is_valve_delay_ {false} |
uint32_t | start_delay_ {0} |
Pump start/stop delay intervals. More... | |
uint32_t | stop_delay_ {0} |
std::string | name_ |
SprinklerState | state_ {IDLE} |
Sprinkler controller state. More... | |
SprinklerValveRunRequest | active_req_ |
The valve run request that is currently active. More... | |
SprinklerValveRunRequest | next_req_ |
The next run request for the controller to consume after active_req_ is complete. More... | |
SprinklerValveRunRequest | prev_req_ |
The previous run request the controller processed. More... | |
optional< size_t > | manual_valve_ |
The number of the manually selected valve currently selected. More... | |
optional< size_t > | paused_valve_ |
The number of the valve to resume from (if paused) More... | |
optional< uint32_t > | target_repeats_ |
Set the number of times to repeat a full cycle. More... | |
optional< uint32_t > | resume_duration_ |
Set from time_remaining() when paused. More... | |
optional< uint32_t > | manual_selection_delay_ |
Manual switching delay. More... | |
optional< uint32_t > | switching_delay_ |
Valve switching delay. More... | |
uint32_t | repeat_count_ {0} |
Number of times the full cycle has been repeated. More... | |
float | multiplier_ {1.0} |
Sprinkler valve run time multiplier value. More... | |
std::vector< SprinklerQueueItem > | queued_valves_ |
Queue of valves to activate next, regardless of auto-advance. More... | |
std::vector< SprinklerSwitch > | pump_ |
Sprinkler valve pump objects. More... | |
std::vector< SprinklerValve > | valve_ |
Sprinkler valve objects. More... | |
std::vector< SprinklerValveOperator > | valve_op_ {2} |
Sprinkler valve operator objects. More... | |
std::vector< SprinklerTimer > | timer_ {} |
Valve control timers. More... | |
std::vector< Sprinkler * > | other_controllers_ |
Other Sprinkler instances we should be aware of (used to check if pumps are in use) More... | |
SprinklerControllerSwitch * | auto_adv_sw_ {nullptr} |
Switches we'll present to the front end. More... | |
SprinklerControllerSwitch * | controller_sw_ {nullptr} |
SprinklerControllerSwitch * | queue_enable_sw_ {nullptr} |
SprinklerControllerSwitch * | reverse_sw_ {nullptr} |
SprinklerControllerSwitch * | standby_sw_ {nullptr} |
SprinklerControllerNumber * | multiplier_number_ {nullptr} |
Number components we'll present to the front end. More... | |
SprinklerControllerNumber * | repeat_number_ {nullptr} |
std::unique_ptr< ShutdownAction<> > | sprinkler_shutdown_action_ |
std::unique_ptr< ShutdownAction<> > | sprinkler_standby_shutdown_action_ |
std::unique_ptr< ResumeOrStartAction<> > | sprinkler_resumeorstart_action_ |
std::unique_ptr< Automation<> > | sprinkler_turn_off_automation_ |
std::unique_ptr< Automation<> > | sprinkler_turn_on_automation_ |
std::unique_ptr< Automation<> > | sprinkler_standby_turn_on_automation_ |
Protected Attributes inherited from esphome::Component | |
uint32_t | component_state_ {0x0000} |
State of this component. More... | |
float | setup_priority_override_ {NAN} |
const char * | component_source_ {nullptr} |
Definition at line 205 of file sprinkler.h.
esphome::sprinkler::Sprinkler::Sprinkler | ( | ) |
Definition at line 390 of file sprinkler.cpp.
esphome::sprinkler::Sprinkler::Sprinkler | ( | const std::string & | name | ) |
Definition at line 391 of file sprinkler.cpp.
optional< size_t > esphome::sprinkler::Sprinkler::active_valve | ( | ) |
returns the number of the valve that is currently active, if any. check with 'has_value()'
Definition at line 1008 of file sprinkler.cpp.
optional< SprinklerValveRunRequestOrigin > esphome::sprinkler::Sprinkler::active_valve_request_is_from | ( | ) |
returns what invoked the valve that is currently active, if any. check with 'has_value()'
Definition at line 1001 of file sprinkler.cpp.
void esphome::sprinkler::Sprinkler::add_controller | ( | Sprinkler * | other_controller | ) |
add another controller to the controller so it can check if pumps/main valves are in use
Definition at line 444 of file sprinkler.cpp.
void esphome::sprinkler::Sprinkler::add_valve | ( | SprinklerControllerSwitch * | valve_sw, |
SprinklerControllerSwitch * | enable_sw = nullptr |
||
) |
add a valve to the controller
Definition at line 416 of file sprinkler.cpp.
|
protected |
turns off/closes all valves, including pump if include_pump is true
Definition at line 1440 of file sprinkler.cpp.
bool esphome::sprinkler::Sprinkler::any_controller_is_active | ( | ) |
returns true if this or any sprinkler controller this controller knows about is active
Definition at line 1233 of file sprinkler.cpp.
|
protected |
returns true if any valve is enabled
Definition at line 1407 of file sprinkler.cpp.
bool esphome::sprinkler::Sprinkler::auto_advance | ( | ) |
returns true if auto_advance is enabled
Definition at line 756 of file sprinkler.cpp.
|
protected |
Definition at line 1654 of file sprinkler.cpp.
void esphome::sprinkler::Sprinkler::clear_queued_valves | ( | ) |
clears/removes all valves from the queue
Definition at line 885 of file sprinkler.cpp.
void esphome::sprinkler::Sprinkler::configure_valve_pump_switch | ( | size_t | valve_number, |
switch_::Switch * | pump_switch | ||
) |
configure a valve's associated pump switch object
Definition at line 512 of file sprinkler.cpp.
void esphome::sprinkler::Sprinkler::configure_valve_pump_switch_pulsed | ( | size_t | valve_number, |
switch_::Switch * | pump_switch_off, | ||
switch_::Switch * | pump_switch_on, | ||
uint32_t | pulse_duration | ||
) |
Definition at line 526 of file sprinkler.cpp.
void esphome::sprinkler::Sprinkler::configure_valve_run_duration_number | ( | size_t | valve_number, |
SprinklerControllerNumber * | run_duration_number | ||
) |
configure a valve's run duration number component
Definition at line 544 of file sprinkler.cpp.
void esphome::sprinkler::Sprinkler::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.
Definition at line 494 of file sprinkler.cpp.
void esphome::sprinkler::Sprinkler::configure_valve_switch_pulsed | ( | size_t | valve_number, |
switch_::Switch * | valve_switch_off, | ||
switch_::Switch * | valve_switch_on, | ||
uint32_t | pulse_duration, | ||
uint32_t | run_duration | ||
) |
Definition at line 501 of file sprinkler.cpp.
SprinklerControllerSwitch * esphome::sprinkler::Sprinkler::control_switch | ( | size_t | valve_number | ) |
returns a pointer to a valve's control switch object
Definition at line 1248 of file sprinkler.cpp.
|
inline |
returns the current state of the sprinkler controller
Definition at line 414 of file sprinkler.h.
|
overridevirtual |
Reimplemented from esphome::Component.
Definition at line 1686 of file sprinkler.cpp.
SprinklerControllerSwitch * esphome::sprinkler::Sprinkler::enable_switch | ( | size_t | valve_number | ) |
returns a pointer to a valve's enable switch object
Definition at line 1255 of file sprinkler.cpp.
|
protected |
kicks the state machine to advance, starting it if it is not already active
Definition at line 1481 of file sprinkler.cpp.
|
protected |
make a request of the state machine
Definition at line 1473 of file sprinkler.cpp.
|
protected |
advance controller state, advancing to target_valve if provided
Definition at line 1487 of file sprinkler.cpp.
|
protected |
starts up the system from IDLE state
Definition at line 1534 of file sprinkler.cpp.
|
protected |
transitions from ACTIVE state to ACTIVE (as in, next valve) or to a SHUTDOWN or IDLE state
Definition at line 1551 of file sprinkler.cpp.
|
protected |
starts up the system from IDLE state
Definition at line 1598 of file sprinkler.cpp.
bool esphome::sprinkler::Sprinkler::is_a_valid_valve | ( | size_t | valve_number | ) |
returns true if valve number is valid
Definition at line 1029 of file sprinkler.cpp.
|
protected |
loads next_req_ with the next valve that should be activated, including its run duration.
if next_req_ already contains a request, nothing is done. after next_req_, queued valves have priority, followed by enabled valves if auto-advance is enabled. if no valve is next (for example, a full cycle is complete), next_req_ is reset via reset().
Definition at line 1361 of file sprinkler.cpp.
|
overridevirtual |
Reimplemented from esphome::Component.
Definition at line 401 of file sprinkler.cpp.
optional< size_t > esphome::sprinkler::Sprinkler::manual_valve | ( | ) |
returns the number of the valve that is manually selected, if any.
check with 'has_value()' this is set by next_valve() and previous_valve() when manual_selection_delay_ > 0
Definition at line 1025 of file sprinkler.cpp.
|
protected |
marks a valve's cycle as complete
Definition at line 1294 of file sprinkler.cpp.
float esphome::sprinkler::Sprinkler::multiplier | ( | ) |
returns the current value of the multiplier
Definition at line 763 of file sprinkler.cpp.
void esphome::sprinkler::Sprinkler::next_valve | ( | ) |
advances to the next valve (numerically)
Definition at line 890 of file sprinkler.cpp.
|
protected |
returns the number of the next valve in the vector or nullopt if no valves match criteria
Definition at line 1308 of file sprinkler.cpp.
|
protected |
returns the number of the next valve that should be activated in a full cycle.
if no valve is next (cycle is complete), returns no value (check with 'has_value()')
Definition at line 1354 of file sprinkler.cpp.
size_t esphome::sprinkler::Sprinkler::number_of_valves | ( | ) |
returns the number of valves the controller is configured with
Definition at line 1027 of file sprinkler.cpp.
void esphome::sprinkler::Sprinkler::pause | ( | ) |
same as shutdown(), but also stores active_valve() and time_remaining() allowing resume() to continue the cycle
Definition at line 951 of file sprinkler.cpp.
optional< size_t > esphome::sprinkler::Sprinkler::paused_valve | ( | ) |
returns the number of the valve that is paused, if any. check with 'has_value()'
Definition at line 1016 of file sprinkler.cpp.
|
protected |
prepares for a full cycle by verifying auto-advance is on as well as one or more valve enable switches.
Definition at line 1452 of file sprinkler.cpp.
void esphome::sprinkler::Sprinkler::previous_valve | ( | ) |
advances to the previous valve (numerically)
Definition at line 913 of file sprinkler.cpp.
|
protected |
returns the number of the previous valve in the vector or nullopt if no valves match criteria
Definition at line 1331 of file sprinkler.cpp.
bool esphome::sprinkler::Sprinkler::pump_in_use | ( | SprinklerSwitch * | pump_switch | ) |
returns true if the pump the pointer points to is in use
Definition at line 1033 of file sprinkler.cpp.
bool esphome::sprinkler::Sprinkler::queue_enabled | ( | ) |
returns true if the queue is enabled to run
Definition at line 785 of file sprinkler.cpp.
void esphome::sprinkler::Sprinkler::queue_valve | ( | optional< size_t > | valve_number, |
optional< uint32_t > | run_duration | ||
) |
adds a valve into the queue.
queued valves have priority over valves to be run as a part of a full cycle. NOTE: queued valves will always run, regardless of auto-advance and/or valve enable switches.
Definition at line 874 of file sprinkler.cpp.
optional< size_t > esphome::sprinkler::Sprinkler::queued_valve | ( | ) |
returns the number of the next valve in the queue, if any. check with 'has_value()'
Definition at line 1018 of file sprinkler.cpp.
optional< uint32_t > esphome::sprinkler::Sprinkler::repeat | ( | ) |
returns the number of times the controller is set to repeat cycles, if at all. check with 'has_value()'
Definition at line 770 of file sprinkler.cpp.
optional< uint32_t > esphome::sprinkler::Sprinkler::repeat_count | ( | ) |
if a cycle is active, returns the number of times the controller has repeated the cycle. check with 'has_value()'
Definition at line 777 of file sprinkler.cpp.
|
protected |
return the specified SprinklerValveRunRequestOrigin as a string
Definition at line 1605 of file sprinkler.cpp.
|
protected |
resets the cycle state for all valves
Definition at line 1467 of file sprinkler.cpp.
void esphome::sprinkler::Sprinkler::reset_resume | ( | ) |
resets resume state
Definition at line 989 of file sprinkler.cpp.
void esphome::sprinkler::Sprinkler::resume | ( | ) |
resumes a cycle that was suspended using pause()
Definition at line 962 of file sprinkler.cpp.
void esphome::sprinkler::Sprinkler::resume_or_start_full_cycle | ( | ) |
if a cycle was suspended using pause(), resumes it. otherwise calls start_full_cycle()
Definition at line 981 of file sprinkler.cpp.
bool esphome::sprinkler::Sprinkler::reverse | ( | ) |
returns true if reverse is enabled
Definition at line 792 of file sprinkler.cpp.
void esphome::sprinkler::Sprinkler::set_auto_advance | ( | bool | auto_advance | ) |
if auto_advance is true, controller will iterate through all enabled valves
Definition at line 658 of file sprinkler.cpp.
void esphome::sprinkler::Sprinkler::set_controller_auto_adv_switch | ( | SprinklerControllerSwitch * | auto_adv_switch | ) |
Definition at line 466 of file sprinkler.cpp.
void esphome::sprinkler::Sprinkler::set_controller_main_switch | ( | SprinklerControllerSwitch * | controller_switch | ) |
configure important controller switches
Definition at line 446 of file sprinkler.cpp.
void esphome::sprinkler::Sprinkler::set_controller_multiplier_number | ( | SprinklerControllerNumber * | multiplier_number | ) |
configure important controller number components
Definition at line 486 of file sprinkler.cpp.
void esphome::sprinkler::Sprinkler::set_controller_queue_enable_switch | ( | SprinklerControllerSwitch * | queue_enable_switch | ) |
Definition at line 470 of file sprinkler.cpp.
void esphome::sprinkler::Sprinkler::set_controller_repeat_number | ( | SprinklerControllerNumber * | repeat_number | ) |
Definition at line 490 of file sprinkler.cpp.
void esphome::sprinkler::Sprinkler::set_controller_reverse_switch | ( | SprinklerControllerSwitch * | reverse_switch | ) |
Definition at line 474 of file sprinkler.cpp.
void esphome::sprinkler::Sprinkler::set_controller_standby_switch | ( | SprinklerControllerSwitch * | standby_switch | ) |
Definition at line 478 of file sprinkler.cpp.
void esphome::sprinkler::Sprinkler::set_divider | ( | optional< uint32_t > | divider | ) |
sets the multiplier value to '1 / divider' and sets repeat value to divider
Definition at line 551 of file sprinkler.cpp.
void esphome::sprinkler::Sprinkler::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 called
Definition at line 627 of file sprinkler.cpp.
void esphome::sprinkler::Sprinkler::set_multiplier | ( | optional< float > | multiplier | ) |
value multiplied by configured run times – used to extend or shorten the cycle
Definition at line 564 of file sprinkler.cpp.
void esphome::sprinkler::Sprinkler::set_next_prev_ignore_disabled_valves | ( | bool | ignore_disabled | ) |
enable/disable skipping of disabled valves by the next and previous actions
Definition at line 580 of file sprinkler.cpp.
void esphome::sprinkler::Sprinkler::set_pump_start_delay | ( | uint32_t | start_delay | ) |
set how long the pump should start after the valve (when the pump is starting)
Definition at line 584 of file sprinkler.cpp.
void esphome::sprinkler::Sprinkler::set_pump_state | ( | SprinklerSwitch * | pump_switch, |
bool | state | ||
) |
switches on/off a pump "safely" by checking that the new state will not conflict with another controller
Definition at line 1068 of file sprinkler.cpp.
void esphome::sprinkler::Sprinkler::set_pump_stop_delay | ( | uint32_t | stop_delay | ) |
set how long the pump should stop after the valve (when the pump is starting)
Definition at line 589 of file sprinkler.cpp.
void esphome::sprinkler::Sprinkler::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 the valve_open_delay interval
Definition at line 604 of file sprinkler.cpp.
void esphome::sprinkler::Sprinkler::set_queue_enable | ( | bool | queue_enable | ) |
if queue_enable is true, controller will iterate through valves in the queue
Definition at line 685 of file sprinkler.cpp.
void esphome::sprinkler::Sprinkler::set_repeat | ( | optional< uint32_t > | repeat | ) |
set the number of times to repeat a full cycle
Definition at line 672 of file sprinkler.cpp.
void esphome::sprinkler::Sprinkler::set_reverse | ( | bool | reverse | ) |
if reverse is true, controller will iterate through all enabled valves in reverse (descending) order
Definition at line 699 of file sprinkler.cpp.
void esphome::sprinkler::Sprinkler::set_standby | ( | bool | standby | ) |
if standby is true, controller will refuse to activate any valves
Definition at line 713 of file sprinkler.cpp.
|
protected |
time is converted to milliseconds (ms) for set_timeout()
Definition at line 1661 of file sprinkler.cpp.
void esphome::sprinkler::Sprinkler::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
Definition at line 608 of file sprinkler.cpp.
void esphome::sprinkler::Sprinkler::set_valve_overlap | ( | uint32_t | valve_overlap | ) |
set how long the controller should wait after opening a valve before closing the previous valve
Definition at line 617 of file sprinkler.cpp.
void esphome::sprinkler::Sprinkler::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
Definition at line 635 of file sprinkler.cpp.
void esphome::sprinkler::Sprinkler::set_valve_start_delay | ( | uint32_t | start_delay | ) |
set how long the valve should start after the pump (when the pump is stopping)
Definition at line 594 of file sprinkler.cpp.
void esphome::sprinkler::Sprinkler::set_valve_stop_delay | ( | uint32_t | stop_delay | ) |
set how long the valve should stop after the pump (when the pump is stopping)
Definition at line 599 of file sprinkler.cpp.
|
overridevirtual |
Reimplemented from esphome::Component.
Definition at line 399 of file sprinkler.cpp.
void esphome::sprinkler::Sprinkler::shutdown | ( | bool | clear_queue = false | ) |
turns off all valves, effectively shutting down the system.
Definition at line 936 of file sprinkler.cpp.
|
protected |
Definition at line 1680 of file sprinkler.cpp.
bool esphome::sprinkler::Sprinkler::standby | ( | ) |
returns true if standby is enabled
Definition at line 799 of file sprinkler.cpp.
void esphome::sprinkler::Sprinkler::start_from_queue | ( | ) |
starts the controller from the first valve in the queue and disables auto_advance.
if the queue is empty, does nothing.
Definition at line 806 of file sprinkler.cpp.
void esphome::sprinkler::Sprinkler::start_full_cycle | ( | ) |
starts a full cycle of all enabled valves and enables auto_advance.
if no valves are enabled, all valves will be enabled.
Definition at line 830 of file sprinkler.cpp.
void esphome::sprinkler::Sprinkler::start_single_valve | ( | optional< size_t > | valve_number, |
optional< uint32_t > | run_duration = nullopt |
||
) |
activates a single valve and disables auto_advance.
Definition at line 853 of file sprinkler.cpp.
|
protected |
Start/cancel/get status of valve timers.
Definition at line 1643 of file sprinkler.cpp.
|
protected |
loads an available SprinklerValveOperator (valve_op_) based on req and starts it (switches it on).
NOTE: if run_duration is zero, the valve's run_duration will be set based on the valve's configuration.
Definition at line 1415 of file sprinkler.cpp.
|
protected |
return the specified SprinklerState state as a string
Definition at line 1621 of file sprinkler.cpp.
optional< uint32_t > esphome::sprinkler::Sprinkler::time_remaining_active_valve | ( | ) |
returns the amount of time remaining in seconds for the active valve, if any
Definition at line 1199 of file sprinkler.cpp.
optional< uint32_t > esphome::sprinkler::Sprinkler::time_remaining_current_operation | ( | ) |
returns the amount of time remaining in seconds for all valves remaining, including the active valve, if any
Definition at line 1213 of file sprinkler.cpp.
|
protected |
returns true if the specified timer is active/running
Definition at line 1659 of file sprinkler.cpp.
|
protected |
Definition at line 1667 of file sprinkler.cpp.
|
protected |
returns time in milliseconds (ms)
Definition at line 1665 of file sprinkler.cpp.
uint32_t esphome::sprinkler::Sprinkler::total_cycle_time_all_valves | ( | ) |
returns the amount of time in seconds required for all valves
Definition at line 1100 of file sprinkler.cpp.
uint32_t esphome::sprinkler::Sprinkler::total_cycle_time_enabled_incomplete_valves | ( | ) |
returns the amount of time in seconds required for all enabled & incomplete valves, not including the active valve
Definition at line 1138 of file sprinkler.cpp.
uint32_t esphome::sprinkler::Sprinkler::total_cycle_time_enabled_valves | ( | ) |
returns the amount of time in seconds required for all enabled valves
Definition at line 1116 of file sprinkler.cpp.
uint32_t esphome::sprinkler::Sprinkler::total_queue_time | ( | ) |
returns the amount of time in seconds required for all valves in the queue
Definition at line 1175 of file sprinkler.cpp.
|
protected |
returns true if valve's cycle is flagged as complete
Definition at line 1301 of file sprinkler.cpp.
|
protected |
returns true if valve number is enabled
Definition at line 1283 of file sprinkler.cpp.
const char * esphome::sprinkler::Sprinkler::valve_name | ( | size_t | valve_number | ) |
returns a pointer to a valve's name string object; returns nullptr if valve_number is invalid
Definition at line 994 of file sprinkler.cpp.
SprinklerSwitch * esphome::sprinkler::Sprinkler::valve_pump_switch | ( | size_t | valve_number | ) |
returns a pointer to a valve's pump switch object
Definition at line 1269 of file sprinkler.cpp.
SprinklerSwitch * esphome::sprinkler::Sprinkler::valve_pump_switch_by_pump_index | ( | size_t | pump_index | ) |
returns a pointer to a valve's pump switch object
Definition at line 1276 of file sprinkler.cpp.
uint32_t esphome::sprinkler::Sprinkler::valve_run_duration | ( | size_t | valve_number | ) |
returns valve_number's run duration in seconds
Definition at line 727 of file sprinkler.cpp.
uint32_t esphome::sprinkler::Sprinkler::valve_run_duration_adjusted | ( | size_t | valve_number | ) |
returns valve_number's run duration (in seconds) adjusted by multiplier_
Definition at line 741 of file sprinkler.cpp.
|
protected |
callback functions for timers
Definition at line 1671 of file sprinkler.cpp.
SprinklerSwitch * esphome::sprinkler::Sprinkler::valve_switch | ( | size_t | valve_number | ) |
returns a pointer to a valve's switch object
Definition at line 1262 of file sprinkler.cpp.
|
protected |
The valve run request that is currently active.
Definition at line 540 of file sprinkler.h.
|
protected |
Switches we'll present to the front end.
Definition at line 591 of file sprinkler.h.
|
protected |
Definition at line 592 of file sprinkler.h.
|
protected |
Manual switching delay.
Definition at line 561 of file sprinkler.h.
|
protected |
The number of the manually selected valve currently selected.
Definition at line 549 of file sprinkler.h.
|
protected |
Maximum allowed queue size.
Definition at line 515 of file sprinkler.h.
|
protected |
Sprinkler valve run time multiplier value.
Definition at line 570 of file sprinkler.h.
|
protected |
Number components we'll present to the front end.
Definition at line 598 of file sprinkler.h.
|
protected |
Definition at line 534 of file sprinkler.h.
|
protected |
When set to true, the next and previous actions will skip disabled valves.
Definition at line 518 of file sprinkler.h.
|
protected |
The next run request for the controller to consume after active_req_ is complete.
Definition at line 543 of file sprinkler.h.
|
protected |
Other Sprinkler instances we should be aware of (used to check if pumps are in use)
Definition at line 588 of file sprinkler.h.
|
protected |
The number of the valve to resume from (if paused)
Definition at line 552 of file sprinkler.h.
|
protected |
The previous run request the controller processed.
Definition at line 546 of file sprinkler.h.
|
protected |
Sprinkler valve pump objects.
Definition at line 576 of file sprinkler.h.
|
protected |
Pump should be off during valve_open_delay interval.
Definition at line 521 of file sprinkler.h.
|
protected |
Definition at line 593 of file sprinkler.h.
|
protected |
Queue of valves to activate next, regardless of auto-advance.
Definition at line 573 of file sprinkler.h.
|
protected |
Number of times the full cycle has been repeated.
Definition at line 567 of file sprinkler.h.
|
protected |
Definition at line 599 of file sprinkler.h.
|
protected |
Set from time_remaining() when paused.
Definition at line 558 of file sprinkler.h.
|
protected |
Definition at line 594 of file sprinkler.h.
|
protected |
Definition at line 603 of file sprinkler.h.
|
protected |
Definition at line 601 of file sprinkler.h.
|
protected |
Definition at line 602 of file sprinkler.h.
|
protected |
Definition at line 607 of file sprinkler.h.
|
protected |
Definition at line 605 of file sprinkler.h.
|
protected |
Definition at line 606 of file sprinkler.h.
|
protected |
Definition at line 595 of file sprinkler.h.
|
protected |
Pump start/stop delay intervals.
Definition at line 531 of file sprinkler.h.
|
protected |
Pump start/stop delay interval types.
Definition at line 527 of file sprinkler.h.
|
protected |
Sprinkler controller state.
Definition at line 537 of file sprinkler.h.
|
protected |
Definition at line 532 of file sprinkler.h.
|
protected |
Definition at line 528 of file sprinkler.h.
|
protected |
Valve switching delay.
Definition at line 564 of file sprinkler.h.
|
protected |
Set the number of times to repeat a full cycle.
Definition at line 555 of file sprinkler.h.
|
protected |
Valve control timers.
Definition at line 585 of file sprinkler.h.
|
protected |
Sprinkler valve objects.
Definition at line 579 of file sprinkler.h.
|
protected |
Sprinkler valve operator objects.
Definition at line 582 of file sprinkler.h.
|
protected |
Sprinkler valve cycle should overlap.
Definition at line 524 of file sprinkler.h.