I have 2 integrations up and running (a Tuya automated watering/irrigation system with multiple zones, and a Ecowitt system to measure soli moisture for each of those zones). I’m hoping to get these systems running together to control the automated irrigation of 6 separate zones on my property. So, if the soil moisture is below a target level, the irrigation system will be triggered.
I have a series of automations created to check the moisture level against a helper value, and if the moisture is lower, to run the irrigation for 15 minutes and turn it off. Those automations are working well.
Next challenge is to get those automations to run in sequence. So we check each zone and if it needs water we give it water, and then move on to the next zone.
Lastly, we want to get this cycle to happen once a day, just a bit before sunrise.
So - current idea was to set up an automation > to trigger a script > to trigger the zone automations in sequence.
But when I manually run the script I get the following error - “Watering cycle turned off triggered by state of Watering cycle turned on” which to me says that the script turned itself off. Which is weird because there aren’t any conditions in the script itself.
Example zone automation and the script are below.
Automation for Zone 1
alias: Water Zone 1
description: ""
trigger: []
condition:
- condition: state
entity_id: sensor.sensor_zone_one_below_threshold
state: "true"
action:
- service: notify.notify
data:
title: Water Zone 1 Turned On
- type: turn_on
device_id: 2b389bd614de6507c00b8b1190b4c27e
entity_id: switch.wx8_102_Zone1
domain: switch
- delay:
hours: 0
minutes: 15
seconds: 0
milliseconds: 0
- type: turn_off
device_id: 2b389bd614de6507c00b8b1190b4c27e
entity_id: switch.wx8_102_Zone1
domain: switch
mode: single
Script to loop through a series of zone automations
An automation without a trigger is no longer an automation, it’s a bastardized script.
I suggest you convert them to proper scripts.
That triggers an automation without executing the automation’s trigger. In this case it’s a moot point because your ‘automations’ have no trigger. However, the automation.trigger service call you created also won’t execute the automation’s condition (there’s a separate option for indicating if the condition should be executed as well).
tl;dr
Change everything to scripts and it will not only work properly but adhere to Home Assistant’s common practices (triggerless automations are not).
FWIW, it’s possible to consolidate it into a single script that employs a repeat to iterate through all irrigation zones (choosing to water them or not based on their respective sensor value).
I ended up combining all the conditions into one script that just goes through the zones in sequence. Triggered via an automation an hour before sun rise. Worked perfectly. FWIW here is the script and automation.
I used the switch names exactly as shown in your example. I don’t know if the last underscore character in switch.wx8_102_zone_1_ is correct or a typo. Let me know either way.