# Irrigation
Irrigation system
Irrigation
T
R
P
S1
S2
S3
S4
S5
S6
S7
S8
# Inputs
| ID | Abbrev | Name | Type | Default | Description |
|---|---|---|---|---|---|
trigger | T | Trigger | BOOLEAN | false | |
reset | R | Reset | BOOLEAN | false |
# Outputs
| ID | Abbrev | Name | Type | Default | Description |
|---|---|---|---|---|---|
pump | P | Pump | BOOLEAN | false | Output for pump control |
section_1 | S1 | Section #1 | BOOLEAN | false | Output for section #1 valve control |
section_2 | S2 | Section #2 | BOOLEAN | false | Output for section #2 valve control |
section_3 | S3 | Section #3 | BOOLEAN | false | Output for section #3 valve control |
section_4 | S4 | Section #4 | BOOLEAN | false | Output for section #4 valve control |
section_5 | S5 | Section #5 | BOOLEAN | false | Output for section #5 valve control |
section_6 | S6 | Section #6 | BOOLEAN | false | Output for section #6 valve control |
section_7 | S7 | Section #7 | BOOLEAN | false | Output for section #7 valve control |
section_8 | S8 | Section #8 | BOOLEAN | false | Output for section #8 valve control |
# Configuration
| ID | Name | Type | Default | Unit | Description |
|---|---|---|---|---|---|
s1_enabled | S1 enabled | BOOLEAN | true | Controls if the section #1 is enabled | |
s1_duration | S1 duration | NUMBER | 600 | s | Total irrigation time in seconds for section #1 Details: Visible when s1_enabled = true≥ 0 |
s2_enabled | S2 enabled | BOOLEAN | false | Controls if the section #2 is enabled | |
s2_duration | S2 duration | NUMBER | 600 | s | Total irrigation time in seconds for section #2 Details: Visible when s2_enabled = true≥ 0 |
s3_enabled | S3 enabled | BOOLEAN | false | Controls if the section #3 is enabled | |
s3_duration | S3 duration | NUMBER | 600 | s | Total irrigation time in seconds for section #3 Details: Visible when s3_enabled = true≥ 0 |
s4_enabled | S4 enabled | BOOLEAN | false | Controls if the section #4 is enabled | |
s4_duration | S4 duration | NUMBER | 600 | s | Total irrigation time in seconds for section #4 Details: Visible when s4_enabled = true≥ 0 |
s5_enabled | S5 enabled | BOOLEAN | false | Controls if the section #5 is enabled | |
s5_duration | S5 duration | NUMBER | 600 | s | Total irrigation time in seconds for section #5 Details: Visible when s5_enabled = true≥ 0 |
s6_enabled | S6 enabled | BOOLEAN | false | Controls if the section #6 is enabled | |
s6_duration | S6 duration | NUMBER | 600 | s | Total irrigation time in seconds for section #6 Details: Visible when s6_enabled = true≥ 0 |
s7_enabled | S7 enabled | BOOLEAN | false | Controls if the section #7 is enabled | |
s7_duration | S7 duration | NUMBER | 600 | s | Total irrigation time in seconds for section #7 Details: Visible when s7_enabled = true≥ 0 |
s8_enabled | S8 enabled | BOOLEAN | false | Controls if the section #8 is enabled | |
s8_duration | S8 duration | NUMBER | 600 | s | Total irrigation time in seconds for section #8 Details: Visible when s8_enabled = true≥ 0 |
# State
| ID | Name | Type | Default | Unit | Description |
|---|---|---|---|---|---|
active | active | BOOLEAN | false | Is irrigation currently active |
# Source Code
View Volang source
channel = input::channel()
section_count = 8
fn disable_all(section_count) {
section = 0
while (section < section_count) {
section += 1
output::set(str::fmt("section_{}", section), false)
}
}
extern fn onCallback(section_count, callback_id) {
disable_all(section_count)
current_section = 0
if (callback_id == 0) {
output::set("pump", true)
callback::set(0, "onCallback", section_count, 1)
return
} else if (callback_id > 0 and callback_id < (section_count + 1)) {
current_section = callback_id
} else if (callback_id == (section_count + 1)) {
output::set("pump", false)
state::set("active", false)
return
}
section_output = str::fmt("section_{}", current_section)
section_enabled_cfg = str::fmt("s{}_enabled", current_section)
section_duration_cfg = str::fmt("s{}_duration", current_section)
section_enabled = config::get(section_enabled_cfg)
section_duration = config::get(section_duration_cfg)
if (!section_enabled) {
callback::set(0, "onCallback", section_count, current_section + 1)
return
}
output::set(section_output, true)
callback::set(section_duration * 1000, "onCallback", section_count, current_section + 1)
}
input_value = input::value()
if (channel == "trigger" and input_value) {
if (state::get("active")) {
return
}
state::set("active", true)
callback::set(0, "onCallback", section_count, 0)
return
}
if (channel == "reset") {
callback::clear()
callback::set(0, "onCallback", section_count, section_count + 1)
return
}
