Please check my sprinkler automation for a Sonoff Zigbee Hydro ONE

My b-hyve irrigation timers have been acting up with connection issues so I ordered the Sonoff Zigbee Hydro ONE. I looked for irrigation programs in HACS but ended up with a simple automation that I think mimics my current bHyve program and takes weather into account.

Would greatly appreciate someone looking this over for me and confirming it would turn on sprinklers on Tues, Thurs and Sunday at 50 minutes before sunrise for duration of 50 minutes but not turn on if either a >50% chance of rain tomorrow OR recent rainfall of >0.2 inches

Here is what I have:

description: ""
triggers:
  - trigger: sun
    event: sunrise
    offset: "-00:50:00"
conditions:
  - condition: time
    weekday:
      - sun
      - tue
      - thu
  - condition: numeric_state
    entity_id: sensor.home43_precipitation_probability_2d
    below: 50
  - condition: numeric_state
    entity_id: sensor.home_weather_event_rain
    below: 0.2
actions:
  - action: switch.turn_on
    metadata: {}
    target:
      entity_id: switch.front_sprinklers
    data: {}
  - delay:
      hours: 0
      minutes: 50
      seconds: 0
      milliseconds: 0
  - action: switch.turn_off
    metadata: {}
    target:
      entity_id: switch.front_sprinklers
    data: {}
mode: single

LGTM

Just a warning about using delay over a period of time, if HA reboots while it's waiting the automation will stop and your sprinklers will just keep watering.

Looks like it should work and very similar to what I do, except I vary the watering time based on yesterdays rain...

I water my garden every morning at a half hour before sunrise. The amount of time it is on (between 0 and 2 hours) is dependent on the amount of real rain we got the day before. Also if it's raining at the time of state it also skips the watering that day and if there's been over 1.5 inches of rain in the week it skips.

I use the compensation integration to determine the time based on the rainfall.

. Home-Assistant-Config/compensation.yaml at 0db966a399fcaeb85f0cdd27e9cb6b4e882fab8a · SirGoodenough/Home-Assistant-Config · GitHub
. . Home-Assistant-Config/templates/sensor/weather_s-tmpl.yaml at 0db966a399fcaeb85f0cdd27e9cb6b4e882fab8a · SirGoodenough/Home-Assistant-Config · GitHub
. . . Home-Assistant-Config/automation2/Outside_A2.yaml at 0db966a399fcaeb85f0cdd27e9cb6b4e882fab8a · SirGoodenough/Home-Assistant-Config · GitHub

The device has a max on time setting in the zigbee stack, so if the automation gets reset, the hardware watchdog will shut the faucet off. If yours doesn't have that, then you need to rethink the code. (As Rick Mentioned above)

Thanks. It appears that Z2M has the extra options but my current ZHA is far more bare bones. I don't have a ton of Zigbee devices so I may just move to Z2M at this point

In this case it is probably the Tuya water valve itself that exposes a setting for max on time. (Watchdog)

So for some reason, the switch is turning off after 10 minutes even though I have the delay for 50 minutes. Haven't moved to Z2M yet so trying to figure out why this is happening.

Long version: Sonoff SWV water valve - auto-turn-off
Short version: Check for firmware updates

Thank you.

For anyone else who gets the Sonoff Zigbee Hydro One, here is my recommendation for setting up:
First use the eWeLink app on your phone and connect to the Sonoff over BLE. Update firmware and change the default watering duration from 10 minutes to your preferred.

Then press the button for 5 seconds to enter pairing and add to ZHE.

I also added the ZHA quirk by downloading the file and uploading via HA file editor. That gave me more info than just switch and battery.