Trigger script for irrigation at sunset and sunrise

I’ve got the following automation, which checks for a rainy day in 48h (found somewhere on this forum a while ago). No i want to trigger my script at sunrise and sunset and water my garden for 10min if no rain is forecasted and the min forecasted temperature is 4 degrees celcius.

Somehow my script is only triggered once, but not every sunset/sunrise. What am i doing wrong?

id: '1651254951626'
alias: Sunset
description: ''
trigger:
  - platform: sun
    event: sunset
    offset: '0'
  - platform: sun
    event: sunset
    offset: '0'
condition:
  - condition: state
    entity_id: sensor.rainy_day
    state: 'false'
  - condition: numeric_state
    entity_id: sensor.openweathermap_forecast_temperature
    above: '4'
action:
  - service: notify.mobile_app_mi_10_pro
    data:
      message: Watering the garden.
      title: Irrigation
  - type: turn_on
    device_id: 654fa17ab828213bc94c87a7f4d4c6f1
    entity_id: switch.irrigation_pump
    domain: switch
  - delay:
      hours: 0
      minutes: 10
      seconds: 0
      milliseconds: 0
  - type: turn_off
    device_id: 654fa17ab828213bc94c87a7f4d4c6f1
    entity_id: switch.irrigation_pump
    domain: switch
mode: restart

Best regads

It only triggers on sunset because you are using it twice.

I already fixed that, but the problem remains: It only triggers once. Not every day. It seems that trigger sunset or sunrise is not working properly?

I want it to trigger on every sunrise and sunset.

What are the debug traces telling?

Triggered by the sunset at May 4, 2022, 9:02:38 PM
Test state condition
Stopped because a condition failed at May 4, 2022, 9:02:38 PM (runtime: 0.00 seconds)

Executed: May 4, 2022, 9:02:38 PM
Result:

result: false

## entity_id/0

Executed: May 4, 2022, 9:02:38 PM
Result:

result: false state: 'No' wanted_state: 'false'

So i changed the wanted_state: ‘no’, that should fix it?

Could you post a picture of that entity’s state and attributes under Developer Tools → States?


Man i feel stupid right now, i check for the variable false while sensors output is yes/no.


condition:
  - condition: state
    entity_id: sensor.rainy_day
    state: 'No'
  - condition: numeric_state
    entity_id: sensor.openweathermap_forecast_temperature
    above: '4'

:grin:
Sh… happens.

No. That was to test your logic.