AutomationDataset/JakeTheRabbit/JakeTheRabbit_automations.yaml

1187 lines
42 KiB
YAML

- id: dryback_completed
alias: Dryback Completed
description: Records a completed dryback cycle in the history
trigger:
- platform: state
entity_id: sensor.dryback_last_valley_time
condition:
- condition: template
value_template: '{{ trigger.to_state.state != ''unknown'' and trigger.to_state.state
!= trigger.from_state.state }}'
- condition: template
value_template: '{{ states(''sensor.dryback_last_percentage'') | float >= states(''input_number.cs_dryback_min_percentage'')
| float }}'
- condition: template
value_template: '{{ states(''sensor.dryback_last_duration'') | float >= states(''input_number.cs_dryback_min_duration'')
| float }}'
action:
- variables:
timestamp: '{{ as_timestamp(now()) }}'
peak_time: '{{ states(''sensor.dryback_last_peak_time'') }}'
valley_time: '{{ states(''sensor.dryback_last_valley_time'') }}'
peak_vwc: '{{ states(''sensor.dryback_last_peak_vwc'') }}'
valley_vwc: '{{ states(''sensor.dryback_last_valley_vwc'') }}'
percentage: '{{ states(''sensor.dryback_last_percentage'') }}'
duration: '{{ states(''sensor.dryback_last_duration'') }}'
phase: '{{ states(''input_select.crop_steering_phase'') }}'
current_history: '{{ states(''input_text.dryback_history_json'') }}'
- service: input_text.set_value
target:
entity_id: input_text.dryback_history_json
data:
value: "{% if current_history is string and current_history|first == '[' %}\n\
\ {% set history = current_history | from_json(default=[]) %}\n {% set new_entry\
\ = {\n 'timestamp': timestamp | float(0),\n 'peak_time': peak_time,\n\
\ 'valley_time': valley_time,\n 'peak_vwc': peak_vwc | float(0),\n \
\ 'valley_vwc': valley_vwc | float(0),\n 'percentage': percentage | float(0),\n\
\ 'duration': duration | float(0),\n 'phase': phase\n } %}\n {% set\
\ updated = [new_entry] + history %}\n {% if updated | length > 100 %}\n\
\ {% set updated = updated[:100] %}\n {% endif %}\n {{ updated | to_json\
\ }}\n{% else %}\n {% set new_entry = {\n 'timestamp': as_timestamp(now()),\n\
\ 'peak_time': peak_time,\n 'valley_time': valley_time,\n 'peak_vwc':\
\ peak_vwc | float(0),\n 'valley_vwc': valley_vwc | float(0),\n 'percentage':\
\ percentage | float(0),\n 'duration': duration | float(0),\n 'phase':\
\ phase\n } %}\n {{ [new_entry] | to_json }}\n{% endif %}\n"
- service: persistent_notification.create
data:
title: Dryback Cycle Completed
message: 'A dryback cycle has been completed:
Start: {{ peak_time }} End: {{ valley_time }} Duration: {{ duration }} minutes
Dryback: {{ percentage }}% Phase: {{ phase }}
Peak VWC: {{ peak_vwc }}% Valley VWC: {{ valley_vwc }}%
'
notification_id: dryback_completed
- id: dryback_reset_potential_peak
alias: Reset Potential Peak
description: Resets the potential peak detection after irrigation
trigger:
- platform: state
entity_id: switch.cs_configured_pump_switch
from: 'on'
to: 'off'
action:
- service: homeassistant.update_entity
target:
entity_id: sensor.dryback_potential_peak
- delay:
seconds: 300
- service: homeassistant.update_entity
target:
entity_id: sensor.dryback_potential_peak
- id: improved_crop_steering_change_to_p0
alias: Crop Steering - Change to P0 at lights-on
description: Changes the crop steering phase to P0 when lights turn on
trigger:
- platform: time
at: input_datetime.cs_lights_on_time
action:
- service: input_select.select_option
data:
option: P0
target:
entity_id: input_select.cs_crop_steering_phase
- service: input_number.set_value
target:
entity_id: input_number.cs_p1_shot_count
data:
value: 0
- service: input_number.set_value
target:
entity_id: input_number.cs_p2_shot_count
data:
value: 0
- service: input_number.set_value
target:
entity_id: input_number.cs_p3_shot_count
data:
value: 0
mode: single
- id: improved_crop_steering_p0_to_p1
alias: Crop Steering - P0 to P1 Transition
description: Transitions from P0 to P1 based on dryback target or maximum wait time
trigger:
- platform: state
entity_id:
- sensor.cs_configured_avg_vwc
- platform: template
value_template: '{{ states(''sensor.cs_minutes_since_lights_on'') | int % 5 ==
0 }}'
condition:
- condition: state
entity_id: input_select.cs_crop_steering_phase
state: P0
- condition: template
value_template: '{{ states(''sensor.cs_minutes_since_lights_on'') | int >= states(''input_number.cs_p0_min_wait_time'')
| int }}'
action:
- choose:
- conditions:
- condition: template
value_template: '{{ states(''sensor.cs_configured_avg_vwc'') | float <= states(''sensor.cs_dynamic_p0_dryback'')
| float }}'
sequence:
- service: input_select.select_option
data:
option: P1
target:
entity_id: input_select.cs_crop_steering_phase
- service: notify.mobile_app_notify
data:
title: Crop Steering Phase Change
message: 'Transitioned to P1 (Ramp-Up Phase) after reaching dryback target
of {{ states(''sensor.cs_dynamic_p0_dryback'') }}%. Current VWC: {{ states(''sensor.cs_configured_avg_vwc'')
}}% # Use configured entity
'
data:
tag: crop_steering_phase_change
- conditions:
- condition: template
value_template: '{{ states(''sensor.cs_minutes_since_lights_on'') | int >=
states(''input_number.cs_p0_max_wait_time'') | int }}'
sequence:
- service: input_select.select_option
data:
option: P1
target:
entity_id: input_select.cs_crop_steering_phase
- service: notify.mobile_app_notify
data:
title: Crop Steering Phase Change
message: 'Transitioned to P1 (Ramp-Up Phase) after reaching maximum wait
time of {{ states(''input_number.cs_p0_max_wait_time'') }} minutes. Current
VWC: {{ states(''sensor.cs_configured_avg_vwc'') }}% # Use configured
entity
'
data:
tag: crop_steering_phase_change
mode: single
- id: improved_crop_steering_p1_to_p2
alias: Crop Steering - P1 to P2 Transition
description: Transitions from P1 to P2 based on shot count, VWC, or EC
trigger:
- platform: state
entity_id: input_number.cs_p1_shot_count
- platform: numeric_state
entity_id:
- sensor.cs_configured_avg_vwc
above: input_number.cs_substrate_field_capacity
- platform: numeric_state
entity_id:
- sensor.cs_configured_avg_ec
below: input_number.cs_ec_target_flush
condition:
- condition: state
entity_id: input_select.cs_crop_steering_phase
state: P1
action:
- choose:
- conditions:
- condition: template
value_template: '{{ states(''input_number.cs_p1_shot_count'') | float >= states(''input_number.cs_p1_max_shots'')
| float }}'
sequence:
- service: input_select.select_option
target:
entity_id: input_select.cs_crop_steering_phase
data:
option: P2
- service: notify.mobile_app_notify
data:
title: Crop Steering Phase Change
message: 'Transitioned to P2 (Maintenance Phase) after reaching maximum
shot count of {{ states(''input_number.cs_p1_max_shots'') }}. Current
VWC: {{ states(''sensor.cs_configured_avg_vwc'') }}% # Use configured
entity
'
data:
tag: crop_steering_phase_change
- conditions:
- condition: numeric_state
entity_id: sensor.cs_configured_avg_vwc
above: '{{ states(''input_number.cs_p1_target_vwc'') }}'
sequence:
- service: input_select.select_option
target:
entity_id: input_select.cs_crop_steering_phase
data:
option: P2
- service: notify.mobile_app_notify
data:
title: Crop Steering Phase Change
message: 'Transitioned to P2 (Maintenance Phase) after reaching target VWC
of {{ states(''input_number.cs_p1_target_vwc'') }}%. Current VWC: {{ states(''sensor.cs_configured_avg_vwc'')
}}% # Use configured entity
'
data:
tag: crop_steering_phase_change
- conditions:
- condition: numeric_state
entity_id: sensor.cs_configured_avg_ec
below: input_number.cs_ec_target_flush
- condition: numeric_state
entity_id: sensor.cs_configured_avg_vwc
above: input_number.cs_p1_target_vwc
- condition: numeric_state
entity_id: input_number.cs_p1_shot_count
above: '{{ states(''input_number.cs_p1_min_shots'') | int -1 }}'
sequence:
- service: input_select.select_option
target:
entity_id: input_select.cs_crop_steering_phase
data:
option: P2
- service: notify.mobile_app_notify
data:
title: Crop Steering Phase Change
message: 'Transitioned to P2 (Maintenance Phase) after reaching EC target.
Current EC: {{ states(''sensor.cs_configured_avg_ec'') }} mS/cm # Use
configured entity Current VWC: {{ states(''sensor.cs_configured_avg_vwc'')
}}% # Use configured entity
'
data:
tag: crop_steering_phase_change
mode: single
- id: improved_crop_steering_to_p3
alias: Crop Steering - P2 to P3 Transition
description: Transitions from P2 to P3 based on calculated time before lights-off
trigger:
- platform: template
value_template: '{% set current_timestamp = as_timestamp(now()) %} {% set p3_start
= as_timestamp(today_at(states(''sensor.cs_p3_start_time_calculated''))) %}
# Renamed sensor dependency {% set diff_seconds = current_timestamp - p3_start
%} {{ diff_seconds >= 0 and diff_seconds < 60 }}
'
condition:
- condition: state
entity_id: input_select.cs_crop_steering_phase
state: P2
action:
- service: input_select.select_option
data:
option: P3
target:
entity_id: input_select.cs_crop_steering_phase
- service: notify.mobile_app_notify
data:
title: Crop Steering Phase Change
message: 'Transitioned to P3 (Overnight Dry Back Phase). {% if is_state(''input_select.cs_steering_mode'',
''Vegetative'') %} # Renamed Using vegetative dry back strategy ({{ states(''input_number.cs_p3_veg_last_irrigation'')
}} min before lights-off). # Renamed {% else %} Using generative dry back
strategy ({{ states(''input_number.cs_p3_gen_last_irrigation'') }} min before
lights-off). # Renamed {% endif %}
'
data:
tag: crop_steering_phase_change
mode: single
- id: improved_crop_steering_p1_irrigation
alias: Crop Steering - P1 Ramp-Up Irrigation
description: Controls irrigation during P1 with gradually increasing shot sizes
trigger:
- platform: time_pattern
minutes: /1
condition:
- condition: state
entity_id: input_select.cs_crop_steering_phase
state: P1
- condition: template
value_template: '{% set current_minute = now().minute | int %} {% set interval
= states(''input_number.cs_p1_time_between_shots'') | int %} # Renamed {{ current_minute
% interval == 0 }}
'
- condition: template
value_template: '{{ states(''input_number.cs_p1_shot_count'') | int < states(''input_number.cs_p1_max_shots'')
| int }}'
- condition: state
entity_id: switch.cs_configured_pump_switch
state: 'off'
action:
- variables:
shot_duration: '{{ states(''sensor.cs_p1_shot_duration_seconds'') | float }}'
shot_count: '{{ states(''input_number.cs_p1_shot_count'') | int }}'
shot_size_percent: '{{ states(''sensor.cs_p1_current_shot_size_percent'') |
float }}'
- service: switch.turn_on
target:
entity_id: switch.cs_configured_pump_switch
- delay:
seconds: '{{ shot_duration }}'
- service: switch.turn_off
target:
entity_id: switch.cs_configured_pump_switch
- service: input_number.set_value
target:
entity_id: input_number.cs_p1_shot_count
data:
value: '{{ shot_count + 1 }}'
- service: logbook.log
data:
name: P1 Irrigation
message: 'Ramp-Up Shot {{ shot_count + 1 }}: {{ shot_duration }}s ({{ shot_size_percent
}}% of substrate volume) VWC Before: {{ states(''sensor.cs_configured_avg_vwc'')
}}% # Use configured entity EC: {{ states(''sensor.cs_configured_avg_ec'')
}} mS/cm # Use configured entity
'
mode: single
- id: improved_crop_steering_p2_irrigation_on
alias: Crop Steering - P2 EC-Adjusted Irrigation On
description: Turns on irrigation during P2 based on EC-adjusted VWC threshold
trigger:
- platform: state
entity_id:
- sensor.cs_configured_avg_vwc
- platform: state
entity_id:
- sensor.cs_p2_vwc_threshold_ec_adjusted
condition:
- condition: numeric_state
entity_id: sensor.cs_configured_avg_vwc
below: sensor.cs_p2_vwc_threshold_ec_adjusted
- condition: state
entity_id: input_select.cs_crop_steering_phase
state: P2
- condition: state
entity_id: switch.cs_configured_pump_switch
state: 'off'
action:
- variables:
threshold: '{{ states(''sensor.cs_p2_vwc_threshold_ec_adjusted'') | float }}'
current_vwc: '{{ states(''sensor.cs_configured_avg_vwc'') | float }}'
ec_ratio: '{{ states(''sensor.cs_ec_ratio'') | float }}'
shot_duration: '{{ states(''sensor.cs_p2_shot_duration_seconds'') | float }}'
- service: switch.turn_on
target:
entity_id: switch.cs_configured_pump_switch
- service: logbook.log
data:
name: P2 Irrigation Started
message: 'Maintenance Irrigation: {{ shot_duration }}s VWC Before: {{ current_vwc
}}% EC Ratio: {{ ec_ratio }} Adjusted Threshold: {{ threshold }}%
'
mode: single
- id: improved_crop_steering_p2_irrigation_off_timed
alias: Crop Steering - P2 Timed Irrigation Off
description: Turns off irrigation during P2 after calculated duration
trigger:
- platform: state
entity_id: switch.cs_configured_pump_switch
from: 'off'
to: 'on'
condition:
- condition: state
entity_id: input_select.cs_crop_steering_phase
state: P2
action:
- variables:
shot_duration: '{{ states(''sensor.cs_p2_shot_duration_seconds'') | float }}'
- delay:
seconds: '{{ shot_duration if shot_duration > 0 else 1 }}'
- service: switch.turn_off
target:
entity_id: switch.cs_configured_pump_switch
- service: input_number.set_value
target:
entity_id: input_number.cs_p2_shot_count
data:
value: '{{ (states(''input_number.cs_p2_shot_count'') | int) + 1 }}'
- service: logbook.log
data:
name: P2 Irrigation Completed
message: 'Maintenance Irrigation Completed Duration: {{ shot_duration }}s VWC
After: {{ states(''sensor.cs_configured_avg_vwc'') }}% # Use configured entity
EC: {{ states(''sensor.cs_configured_avg_ec'') }} mS/cm # Use configured entity
'
mode: single
- id: improved_crop_steering_p2_irrigation_off_capacity
alias: Crop Steering - P2 Irrigation Off at Field Capacity
description: Turns off irrigation during P2 when field capacity is reached
trigger:
- platform: numeric_state
entity_id:
- sensor.cs_configured_avg_vwc
above: input_number.cs_substrate_field_capacity
condition:
- condition: state
entity_id: input_select.cs_crop_steering_phase
state: P2
- condition: state
entity_id: switch.cs_configured_pump_switch
state: 'on'
action:
- service: switch.turn_off
target:
entity_id: switch.cs_configured_pump_switch
- service: logbook.log
data:
name: P2 Irrigation Stopped
message: 'Maintenance Irrigation Stopped - Field Capacity Reached VWC: {{ states(''sensor.cs_configured_avg_vwc'')
}}% # Use configured entity Field Capacity: {{ states(''input_number.cs_substrate_field_capacity'')
}}% # Renamed
'
mode: single
- id: improved_crop_steering_p3_emergency_irrigation
alias: Crop Steering - P3 Emergency Irrigation
description: Provides emergency irrigation during P3 if VWC drops too low
trigger:
- platform: numeric_state
entity_id:
- sensor.cs_configured_min_vwc
below: sensor.cs_dynamic_p3_dryback
condition:
- condition: state
entity_id: input_select.cs_crop_steering_phase
state: P3
- condition: state
entity_id: switch.cs_configured_pump_switch
state: 'off'
action:
- variables:
shot_duration: '{{ states(''sensor.cs_p3_emergency_shot_duration_seconds'')
| float }}'
current_vwc: '{{ states(''sensor.cs_configured_min_vwc'') | float }}'
threshold: '{{ states(''sensor.cs_dynamic_p3_dryback'') | float }}'
- service: switch.turn_on
target:
entity_id: switch.cs_configured_pump_switch
- delay:
seconds: '{{ shot_duration }}'
- service: switch.turn_off
target:
entity_id: switch.cs_configured_pump_switch
- service: input_number.set_value
target:
entity_id: input_number.cs_p3_shot_count
data:
value: '{{ (states(''input_number.cs_p3_shot_count'') | int) + 1 }}'
- service: logbook.log
data:
name: P3 Emergency Irrigation
message: 'Emergency Irrigation During P3 Duration: {{ shot_duration }}s VWC
Before: {{ current_vwc }}% Emergency Threshold: {{ threshold }}%
'
- service: notify.mobile_app_notify
data:
title: Emergency Irrigation
message: 'Emergency irrigation triggered during P3 phase. VWC dropped to {{
current_vwc }}% (below threshold of {{ threshold }}%).
'
data:
tag: emergency_irrigation
mode: single
- id: improved_steering_mode_changed
alias: Improved Steering Mode Changed
description: Updates parameters when steering mode changes
trigger:
- platform: state
entity_id: input_select.cs_steering_mode
action:
- service: homeassistant.update_entity
target:
entity_id:
- sensor.cs_dynamic_p0_dryback
- sensor.cs_p3_start_time_calculated
- sensor.cs_current_ec_target
- service: notify.mobile_app_notify
data:
title: Growth Steering Mode Changed
message: '{% if is_state(''input_select.cs_steering_mode'', ''Vegetative'')
%} # Renamed Switched to Vegetative steering mode. P0 Dryback: {{ states(''input_number.cs_p0_veg_dryback_target'')
}}% # Renamed P3 Start: {{ states(''input_number.cs_p3_veg_last_irrigation'')
}} min before lights-off # Renamed {% else %} Switched to Generative steering
mode. P0 Dryback: {{ states(''input_number.cs_p0_gen_dryback_target'') }}%
# Renamed P3 Start: {{ states(''input_number.cs_p3_gen_last_irrigation'')
}} min before lights-off # Renamed {% endif %}
'
data:
tag: steering_mode_update
mode: single
- id: update_zone_status_from_selector
alias: Update Zone Status from Selector
description: Updates the individual zone enabled states based on the zone selector
trigger:
- platform: state
entity_id: input_select.active_irrigation_zones
action:
- choose:
- conditions:
- condition: state
entity_id: input_select.active_irrigation_zones
state: All Zones
sequence:
- service: input_boolean.turn_on
target:
entity_id:
- input_boolean.zone_1_enabled
- input_boolean.zone_2_enabled
- input_boolean.zone_3_enabled
- conditions:
- condition: state
entity_id: input_select.active_irrigation_zones
state: Zone 1 Only
sequence:
- service: input_boolean.turn_on
target:
entity_id: input_boolean.zone_1_enabled
- service: input_boolean.turn_off
target:
entity_id:
- input_boolean.zone_2_enabled
- input_boolean.zone_3_enabled
- conditions:
- condition: state
entity_id: input_select.active_irrigation_zones
state: Zone 2 Only
sequence:
- service: input_boolean.turn_on
target:
entity_id: input_boolean.zone_2_enabled
- service: input_boolean.turn_off
target:
entity_id:
- input_boolean.zone_1_enabled
- input_boolean.zone_3_enabled
- conditions:
- condition: state
entity_id: input_select.active_irrigation_zones
state: Zone 3 Only
sequence:
- service: input_boolean.turn_on
target:
entity_id: input_boolean.zone_3_enabled
- service: input_boolean.turn_off
target:
entity_id:
- input_boolean.zone_1_enabled
- input_boolean.zone_2_enabled
- conditions:
- condition: state
entity_id: input_select.active_irrigation_zones
state: Zones 1 & 2
sequence:
- service: input_boolean.turn_on
target:
entity_id:
- input_boolean.zone_1_enabled
- input_boolean.zone_2_enabled
- service: input_boolean.turn_off
target:
entity_id: input_boolean.zone_3_enabled
- conditions:
- condition: state
entity_id: input_select.active_irrigation_zones
state: Zones 1 & 3
sequence:
- service: input_boolean.turn_on
target:
entity_id:
- input_boolean.zone_1_enabled
- input_boolean.zone_3_enabled
- service: input_boolean.turn_off
target:
entity_id: input_boolean.zone_2_enabled
- conditions:
- condition: state
entity_id: input_select.active_irrigation_zones
state: Zones 2 & 3
sequence:
- service: input_boolean.turn_on
target:
entity_id:
- input_boolean.zone_2_enabled
- input_boolean.zone_3_enabled
- service: input_boolean.turn_off
target:
entity_id: input_boolean.zone_1_enabled
- conditions:
- condition: state
entity_id: input_select.active_irrigation_zones
state: No Zones (Disabled)
sequence:
- service: input_boolean.turn_off
target:
entity_id:
- input_boolean.zone_1_enabled
- input_boolean.zone_2_enabled
- input_boolean.zone_3_enabled
default: []
- id: turn_on_irrigation_pump_zones
alias: Turn On Irrigation Pump and Zones
description: Turns on the mainline valve and selected zone valves based on configured
entities
trigger:
- platform: state
entity_id: switch.cs_configured_pump_switch
to: 'on'
action:
- variables:
pump_entity: '{{ states(''input_text.cs_config_pump_switch_entity'') }}'
zone_switches: '{{ states(''input_text.cs_config_zone_switch_entities'').split('','')
| map(''trim'') | reject(''=='', '''') | list }}'
waste_switch: '{{ states(''input_text.cs_config_waste_switch_entity'') }}'
zone1_switch: '{{ zone_switches[0] if zone_switches | length > 0 else none }}'
zone2_switch: '{{ zone_switches[1] if zone_switches | length > 1 else none }}'
zone3_switch: '{{ zone_switches[2] if zone_switches | length > 2 else none }}'
- if:
- '{{ waste_switch | length > 0 }}'
then:
- service: switch.turn_off
target:
entity_id: '{{ waste_switch }}'
- service: switch.turn_on
target:
entity_id: '{{ pump_entity }}'
- if:
- '{{ zone1_switch is not none and is_state(''input_boolean.zone_1_enabled'',
''on'') }}'
then:
- service: switch.turn_on
target:
entity_id: '{{ zone1_switch }}'
- if:
- '{{ zone2_switch is not none and is_state(''input_boolean.zone_2_enabled'',
''on'') }}'
then:
- service: switch.turn_on
target:
entity_id: '{{ zone2_switch }}'
- if:
- '{{ zone3_switch is not none and is_state(''input_boolean.zone_3_enabled'',
''on'') }}'
then:
- service: switch.turn_on
target:
entity_id: '{{ zone3_switch }}'
- id: turn_off_irrigation_pump_zones
alias: Turn Off Irrigation Pump and Zones
description: Turns off all configured valves when the configured pump switch is
turned off
trigger:
- platform: state
entity_id: switch.cs_configured_pump_switch
to: 'off'
action:
- variables:
pump_entity: '{{ states(''input_text.cs_config_pump_switch_entity'') }}'
zone_switches: '{{ states(''input_text.cs_config_zone_switch_entities'').split('','')
| map(''trim'') | reject(''=='', '''') | list }}'
zone1_switch: '{{ zone_switches[0] if zone_switches | length > 0 else none }}'
zone2_switch: '{{ zone_switches[1] if zone_switches | length > 1 else none }}'
zone3_switch: '{{ zone_switches[2] if zone_switches | length > 2 else none }}'
- service: switch.turn_off
target:
entity_id: '{% set entities = [] %} {% if zone1_switch is not none %}{% set
entities = entities + [zone1_switch] %}{% endif %} {% if zone2_switch is not
none %}{% set entities = entities + [zone2_switch] %}{% endif %} {% if zone3_switch
is not none %}{% set entities = entities + [zone3_switch] %}{% endif %} {{
entities }}
'
- service: switch.turn_off
target:
entity_id: '{{ pump_entity }}'
- id: zone_specific_p2_irrigation_trigger
alias: Zone-Specific P2 Irrigation Trigger
description: Sets active zones and triggers main pump if any enabled zone needs
P2 irrigation
trigger:
- platform: template
value_template: "{% set phase = states('input_select.cs_crop_steering_phase')\
\ %} {% if phase == 'P2' %}\n {% set zone1_enabled = is_state('input_boolean.zone_1_enabled',\
\ 'on') %}\n {% set zone2_enabled = is_state('input_boolean.zone_2_enabled',\
\ 'on') %}\n {% set zone3_enabled = is_state('input_boolean.zone_3_enabled',\
\ 'on') %}\n \n {% set zone1_vwc = states('sensor.zone_1_vwc') | float(999)\
\ %} {# Use local zone sensor #}\n {% set zone2_vwc = states('sensor.zone_2_vwc')\
\ | float(999) %} {# Use local zone sensor #}\n {% set zone3_vwc = states('sensor.zone_3_vwc')\
\ | float(999) %} {# Use local zone sensor #}\n \n {% set dryback_target =\
\ states('sensor.cs_dynamic_p2_dryback') | float(0) %} {# Use dynamic target\
\ #}\n \n {% if (zone1_enabled and zone1_vwc <= dryback_target) or\n \
\ (zone2_enabled and zone2_vwc <= dryback_target) or\n (zone3_enabled\
\ and zone3_vwc <= dryback_target) %}\n true\n {% else %}\n false\n \
\ {% endif %}\n{% else %}\n false\n{% endif %}\n"
condition:
- condition: state
entity_id: switch.cs_configured_pump_switch
state: 'off'
- condition: state
entity_id: input_select.cs_crop_steering_phase
state: P2
action:
- variables:
dryback_target: '{{ states(''sensor.cs_dynamic_p2_dryback'') | float(0) }}'
zone1_needs_irrigation: '{% set zone1_enabled = is_state(''input_boolean.zone_1_enabled'',
''on'') %} {% set zone1_vwc = states(''sensor.zone_1_vwc'') | float(999) %}
{{ zone1_enabled and zone1_vwc <= dryback_target }}
'
zone2_needs_irrigation: '{% set zone2_enabled = is_state(''input_boolean.zone_2_enabled'',
''on'') %} {% set zone2_vwc = states(''sensor.zone_2_vwc'') | float(999) %}
{{ zone2_enabled and zone2_vwc <= dryback_target }}
'
zone3_needs_irrigation: '{% set zone3_enabled = is_state(''input_boolean.zone_3_enabled'',
''on'') %} {% set zone3_vwc = states(''sensor.zone_3_vwc'') | float(999) %}
{{ zone3_enabled and zone3_vwc <= dryback_target }}
'
- choose:
- conditions: '{{ zone1_needs_irrigation and zone2_needs_irrigation and zone3_needs_irrigation
}}'
sequence:
- service: input_select.select_option
target:
entity_id: input_select.active_irrigation_zones
data:
option: All Zones
- conditions: '{{ zone1_needs_irrigation and zone2_needs_irrigation }}'
sequence:
- service: input_select.select_option
target:
entity_id: input_select.active_irrigation_zones
data:
option: Zones 1 & 2
- conditions: '{{ zone1_needs_irrigation and zone3_needs_irrigation }}'
sequence:
- service: input_select.select_option
target:
entity_id: input_select.active_irrigation_zones
data:
option: Zones 1 & 3
- conditions: '{{ zone2_needs_irrigation and zone3_needs_irrigation }}'
sequence:
- service: input_select.select_option
target:
entity_id: input_select.active_irrigation_zones
data:
option: Zones 2 & 3
- conditions: '{{ zone1_needs_irrigation }}'
sequence:
- service: input_select.select_option
target:
entity_id: input_select.active_irrigation_zones
data:
option: Zone 1 Only
- conditions: '{{ zone2_needs_irrigation }}'
sequence:
- service: input_select.select_option
target:
entity_id: input_select.active_irrigation_zones
data:
option: Zone 2 Only
- conditions: '{{ zone3_needs_irrigation }}'
sequence:
- service: input_select.select_option
target:
entity_id: input_select.active_irrigation_zones
data:
option: Zone 3 Only
default: []
- service: switch.turn_on
target:
entity_id: switch.cs_configured_pump_switch
- id: zone_specific_p3_irrigation_trigger
alias: Zone-Specific P3 Emergency Irrigation Trigger
description: Sets active zones and triggers main pump if any enabled zone needs
P3 emergency irrigation
trigger:
- platform: template
value_template: "{% set phase = states('input_select.cs_crop_steering_phase')\
\ %} {% if phase == 'P3' %}\n {% set zone1_enabled = is_state('input_boolean.zone_1_enabled',\
\ 'on') %}\n {% set zone2_enabled = is_state('input_boolean.zone_2_enabled',\
\ 'on') %}\n {% set zone3_enabled = is_state('input_boolean.zone_3_enabled',\
\ 'on') %}\n \n {% set zone1_vwc = states('sensor.zone_1_vwc') | float(999)\
\ %} {# Use local zone sensor #}\n {% set zone2_vwc = states('sensor.zone_2_vwc')\
\ | float(999) %} {# Use local zone sensor #}\n {% set zone3_vwc = states('sensor.zone_3_vwc')\
\ | float(999) %} {# Use local zone sensor #}\n \n {% set dryback_target =\
\ states('sensor.cs_dynamic_p3_dryback') | float(0) %} {# Use dynamic target\
\ #}\n \n {% if (zone1_enabled and zone1_vwc <= dryback_target) or\n \
\ (zone2_enabled and zone2_vwc <= dryback_target) or\n (zone3_enabled\
\ and zone3_vwc <= dryback_target) %}\n true\n {% else %}\n false\n \
\ {% endif %}\n{% else %}\n false\n{% endif %}\n"
condition:
- condition: state
entity_id: switch.cs_configured_pump_switch
state: 'off'
- condition: state
entity_id: input_select.cs_crop_steering_phase
state: P3
action:
- variables:
dryback_target: '{{ states(''sensor.cs_dynamic_p3_dryback'') | float(0) }}'
zone1_needs_irrigation: '{% set zone1_enabled = is_state(''input_boolean.zone_1_enabled'',
''on'') %} {% set zone1_vwc = states(''sensor.zone_1_vwc'') | float(999) %}
{{ zone1_enabled and zone1_vwc <= dryback_target }}
'
zone2_needs_irrigation: '{% set zone2_enabled = is_state(''input_boolean.zone_2_enabled'',
''on'') %} {% set zone2_vwc = states(''sensor.zone_2_vwc'') | float(999) %}
{{ zone2_enabled and zone2_vwc <= dryback_target }}
'
zone3_needs_irrigation: '{% set zone3_enabled = is_state(''input_boolean.zone_3_enabled'',
''on'') %} {% set zone3_vwc = states(''sensor.zone_3_vwc'') | float(999) %}
{{ zone3_enabled and zone3_vwc <= dryback_target }}
'
- choose:
- conditions: '{{ zone1_needs_irrigation and zone2_needs_irrigation and zone3_needs_irrigation
}}'
sequence:
- service: input_select.select_option
target:
entity_id: input_select.active_irrigation_zones
data:
option: All Zones
- conditions: '{{ zone1_needs_irrigation and zone2_needs_irrigation }}'
sequence:
- service: input_select.select_option
target:
entity_id: input_select.active_irrigation_zones
data:
option: Zones 1 & 2
- conditions: '{{ zone1_needs_irrigation and zone3_needs_irrigation }}'
sequence:
- service: input_select.select_option
target:
entity_id: input_select.active_irrigation_zones
data:
option: Zones 1 & 3
- conditions: '{{ zone2_needs_irrigation and zone3_needs_irrigation }}'
sequence:
- service: input_select.select_option
target:
entity_id: input_select.active_irrigation_zones
data:
option: Zones 2 & 3
- conditions: '{{ zone1_needs_irrigation }}'
sequence:
- service: input_select.select_option
target:
entity_id: input_select.active_irrigation_zones
data:
option: Zone 1 Only
- conditions: '{{ zone2_needs_irrigation }}'
sequence:
- service: input_select.select_option
target:
entity_id: input_select.active_irrigation_zones
data:
option: Zone 2 Only
- conditions: '{{ zone3_needs_irrigation }}'
sequence:
- service: input_select.select_option
target:
entity_id: input_select.active_irrigation_zones
data:
option: Zone 3 Only
default: []
- service: switch.turn_on
target:
entity_id: switch.cs_configured_pump_switch
- alias: F1 Light Acclimation
description: Linear increase from 50% to 90% over 21 days, then disable itself
mode: single
trigger:
- platform: time
at: input_datetime.f1_lights_on_time
action:
- service: light.turn_on
target:
entity_id: light.f1_light_group
data:
brightness: '{{ states(''input_number.f1_target_brightness'') | float | round
}}'
- service: input_number.set_value
target:
entity_id: input_number.f1_target_brightness
data:
value: '{{ [states(''input_number.f1_target_brightness'') | float + 5.1, 229.5]
| min }}'
- choose:
- conditions:
- condition: numeric_state
entity_id: input_number.f1_target_brightness
above: 229.4
sequence:
- service: notify.mobile_app_s23ultra
data:
message: '✅ F1 Light Acclimation complete: reached 90% brightness.'
- service: automation.turn_off
target:
entity_id: automation.f1_light_acclimation
- alias: Tank Low Level Refill and Dose
description: Manages tank refill and dosing process when water level drops below
0.6 or manual button press. Checks pH and EC values after dosing and alerts if
out of range.
mode: single
trigger:
- platform: numeric_state
entity_id: sensor.aqua_pro_water_level
below: 5
for:
minutes: 1
id: water_level
enabled: false
- platform: state
entity_id: input_button.manual_tank_fill
id: manual_button
enabled: true
- platform: state
entity_id: binary_sensor.tank_sensor_tank_level
from: 'on'
to: 'off'
- platform: numeric_state
entity_id: sensor.aqua_pro_water_level
below: 0.06
condition:
- condition: state
entity_id: input_boolean.tank_fill_safety_switch
state: 'on'
- condition: numeric_state
entity_id: sensor.aqua_pro_water_level
below: 0.06
action:
- service: notify.mobile_app_s23ultra
data:
message: Starting tank fill sequence - Turning off irrigation
data:
tag: tank_fill_process
- service: input_boolean.turn_on
target:
entity_id: input_boolean.nutrient_dosing_active
- service: switch.turn_off
target:
entity_id:
- switch.f1_irrigation_relays_relay_1
- switch.f1_irrigation_relays_relay_2
- switch.f1_irrigation_relays_relay_3
- switch.f1_irrigation_relays_relay_4
- switch.waste_valve
- delay: 00:00:05
- service: switch.turn_off
target:
entity_id:
- switch.espoe_irrigation_relay_1_2
- switch.espoe_irrigation_relay_2_4
- delay: 00:00:05
- service: notify.mobile_app_s23ultra
data:
message: Turning on tank fill valve
data:
tag: tank_fill_process
- service: switch.turn_on
target:
entity_id: switch.espoe_irrigation_relay_1_4
- service: notify.mobile_app_s23ultra
data:
message: Starting tank fill - Running for 10 minutes
data:
tag: tank_fill_process
- delay: 00:10:00
- service: notify.mobile_app_s23ultra
data:
title: Tank Fill Progress
message: Tank fill complete - Starting circulation
data:
tag: tank_fill_process
- service: switch.turn_off
target:
entity_id:
- switch.pump_power_switch
- switch.f1_irrigation_pump_master_switch
- service: switch.turn_on
target:
entity_id:
- switch.espoe_irrigation_relay_2_4
- switch.espoe_irrigation_relay_1_1
- delay: 00:00:03
- service: switch.turn_on
target:
entity_id: switch.pump_power_switch
- delay: 00:00:02
- service: switch.turn_on
target:
entity_id: switch.f1_irrigation_pump_master_switch
- delay: 00:00:15
- condition: numeric_state
entity_id: sensor.pump_power_switch_power
above: 100
- service: notify.mobile_app_s23ultra
data:
title: Tank Fill Progress
message: Starting nutrient dosing
data:
tag: tank_fill_process
- choose:
- conditions:
- condition: numeric_state
entity_id: sensor.pump_power_switch_power
below: 100
sequence:
- service: switch.turn_off
target:
entity_id: switch.f1_irrigation_pump_master_switch
- delay: 00:00:05
- service: switch.turn_on
target:
entity_id: switch.f1_irrigation_pump_master_switch
- delay: 00:00:10
- service: notify.mobile_app_s23ultra
data:
message: 'URGENT: Pump power below 100W after reset. Stopping automation.'
priority: high
data:
tag: tank_fill_error
- stop
- delay: 00:00:30
- service: mqtt.publish
data:
topic: AQU1AD04A42/ctr
payload: '{"cmd": "setNutrient", "msgid": "start_dose", "sn": "AQU1AD04A42",
"monitor": 0}'
- delay: 00:03:00
- service: notify.mobile_app_s23ultra
data:
message: Dosing complete - Starting mixing period
data:
tag: tank_fill_process
- service: mqtt.publish
data:
topic: AQU1AD04A42/ctr
payload: '{"cmd": "setNutrient", "msgid": "force_stop", "sn": "AQU1AD04A42",
"monitor": 1}'
- service: notify.mobile_app_s23ultra
data:
message: Mixing complete - Shutting down pumps
data:
tag: tank_fill_process
- service: switch.turn_off
target:
entity_id:
- switch.espoe_irrigation_relay_1_4
- delay: 00:01:00
- service: switch.turn_off
target:
entity_id:
- switch.espoe_irrigation_relay_1_1
- delay: 00:00:01
- service: switch.turn_off
target:
entity_id:
- switch.espoe_irrigation_relay_2_4
- delay: 00:05:00
- service: notify.mobile_app_s23ultra
data:
message: Checking pH and EC levels...
data:
tag: tank_fill_process
- choose:
- conditions:
- condition: or
conditions:
- condition: numeric_state
entity_id: sensor.atlas_legacy_1_ph_res1
below: 5.8
- condition: numeric_state
entity_id: sensor.atlas_legacy_1_ph_res1
above: 6.2
sequence:
- service: notify.mobile_app_s23ultra
data:
title: pH Value Out of Range
message: 'CRITICAL ALERT: pH out of range! Current pH: {{ states(''sensor.atlas_legacy_1_ph_res1'')
}}. Should be between 5.80-6.20.'
data:
ttl: 0
priority: high
channel: critical_alerts
importance: high
vibrationPattern:
- 100
- 1000
- 100
- 1000
- 100
tag: ph_ec_alert
- conditions:
- condition: or
conditions:
- condition: numeric_state
entity_id: sensor.atlas_legacy_1_ec_res1
below: 2.8
- condition: numeric_state
entity_id: sensor.atlas_legacy_1_ec_res1
above: 3.2
sequence:
- service: notify.mobile_app_s23ultra
data:
title: EC Value Out of Range
message: 'CRITICAL ALERT: EC out of range! Current EC: {{ states(''sensor.atlas_legacy_1_ec_res1'')
}}. Should be between 2.80-3.20.'
data:
ttl: 0
priority: high
channel: critical_alerts
importance: high
vibrationPattern:
- 100
- 1000
- 100
- 1000
- 100
tag: ph_ec_alert
- service: notify.mobile_app_s23ultra
data:
message: 'Process complete - pH: {{ states(''sensor.atlas_legacy_1_ph_res1'')
}}, EC: {{ states(''sensor.atlas_legacy_1_ec_res1'') }}'
data:
tag: tank_fill_process
- choose:
- conditions:
- condition: time
after: 06:00:00
before: 02:00:00
sequence:
- service: automation.turn_on
target:
entity_id: automation.f1_irrigation_irrigate_5_minutes_every_45_minutes
- service: notify.mobile_app_s23ultra
data:
message: Irrigation schedule resumed after tank fill (daytime)
data:
tag: tank_fill_process
default:
- service: notify.mobile_app_s23ultra
data:
message: Tank fill complete, but irrigation remains disabled (nighttime)
data:
tag: tank_fill_process
- service: notify.mobile_app_s23ultra
data:
message: Tank fill and dose sequence complete - Starting cooldown period
data:
tag: tank_fill_process
- service: input_boolean.turn_off
target:
entity_id: input_boolean.nutrient_dosing_active
- delay: 01:30:00
- service: input_boolean.turn_on
target:
entity_id: input_boolean.nutrient_dosing_active