Why is my automation not triggering?

Hello,

For starters, I love HA.

My project is about automating my garden. I have B-Hyve valves and Ecowitt soil moistture sensors. I have 3 watring lines with that setup. I learned for instance that the cucumbers consume water is really different from the way tomatoes consume water. So, I have 1 line for cucumbers (frequent shorter watering cycles (31%-48% soil moisture), 1 for tomatoes (long infrequent cycles) and 1 for smaller plants like herbs.

My problem is that I often have to restart HA so that my automations will execute. For example, yesterday, cucumber moisture was 30% and the automation is supposed to be triggered by a moistture below 31% but it wasn’t triggered. I simply did a restart of HA via the dev tools menu and the automation got triggered right away.

I am now thinking of doing periodic restarts (obviously automated ones) of HA but it’s not normal and I was wondering if anyboby else ran into this problem.

Also,what do people use to backup HA?

Thanks!

So why didn’t the automation trigger?
What did the traces say?

I’m also very confused why it suddenly triggered when you restarted HA.
Because a normal numeric trigger shouldn’t have triggered at that point.
I think it’s a lot better if you post the automation

1 Like

A common mistakes is that the trigger is set to only trigger when the threshold gets passed.

2 Likes

Without posting the yaml, you will only get guess’s at best.

Here’s the YAML for the tomatoes line. Please take note that these automations normally tigger fine, until they don’t, which gets fixed with a restart.

alias: "Tomates doivent etre arrosées "
description: ""
trigger:
  - platform: numeric_state
    entity_id:
      - sensor.humidite_piments_soil_moisture_2
    for:
      hours: 0
      minutes: 0
      seconds: 0
    below: 33
condition:
  - condition: sun
    after: sunrise
  - condition: time
    before: "17:00:00"
    weekday:
      - mon
      - tue
      - wed
      - thu
      - fri
      - sat
      - sun
action:
  - type: turn_on
    device_id: 89cdf52460bdc9e8789dccfdffae0f81
    entity_id: a010b5e2585437b8265b93f55241021b
    domain: switch
  - wait_for_trigger:
      - type: humidity
        platform: device
        device_id: 5818cb1bd9745c22905f3bfa75d85492
        entity_id: 4a054398612a374d99c0167d932dcca1
        domain: sensor
        above: 50
    timeout:
      hours: 0
      minutes: 30
      seconds: 0
      milliseconds: 0
  - type: turn_off
    device_id: 89cdf52460bdc9e8789dccfdffae0f81
    entity_id: a010b5e2585437b8265b93f55241021b
    domain: switch
mode: single

You should really try to use entity ids instead of device ids.
It easier to read and it will be easier to replace failing devices later.

Other than that I can only see one issue with your automation and that is the timeout on the watering.
If you do not succeed in getting the value above 30 in those 30 minutes, then it will be able to trigger again, because it will not pass from above 30 to below 30.

1 Like

As suggested above the trigger needs to time or sensor.humidite_piments_soil_moisture_2 value changing not going below 33

At present you will only trigger if the value drops below 33 after sunrise but before 5pm. if its already below 33 at sunrise it will not trigger.

1 Like

I believe Are is on the right track.
Add a trigger on sunrise also.

Ah! Good observation, that’s probably it.

How would you formulate a trigger when the value is already below a certain point, as opposed to dropping below that point?

Thanks!

As I posted just above

A common mistakes is that the trigger is set to only trigger when the threshold gets passed.

Just to be certain, are you saying that it’s a common mistake that the automation is only triggered at the exact time that a certain value is reached (For example, exactly when a clock ticks to12:00), rather than that the automation is triggered any time that the value is at or below that threshold, for example 12:00 and all values beyond it)?

Yes it triggers when. It goes from before 12:00 and to after 12:00.
It does not trigger when going from 12:30 to
12:31
It does trigger if it goes from 11:30 to12:31.
It had to pass the trigger value.

So should I check soil humidity all the time, and put time restrictions on the action?

Let’s say my threshold is 30. Dropping to 29 will trigger the automation, but will dropping from 29 to 28 also trigger it?

It depends how you want it to run. If you want to check the moisture at a certain time say 5 pm. Then trigger on time. If you want to check when the moisture level drops between certain times, the trigger by the sensor value changing and condition between times. There are probably more efficient ways of doing it but if you are questioning this way of doing it templates may be a step too far.

My intent would be to always be aware of the soil moisture, but only water between sunrise and 17:00.

no. once it crosses the threshold it no longer cares about any changes either up or down unless it goes above then back below the threshold.

Here’s an example of how I rewrote my automations, and it’s working great so far. The trigger is any change of state of my soil moisture sensor. Then the humidity threshold is in the condition for watering.

Thanks for the help everyone!

alias: Arroser tomates
description: ""
trigger:
  - platform: state
    entity_id:
      - sensor.humidite_piments_soil_moisture_2
condition:
  - condition: sun
    after: sunrise
  - condition: time
    before: "17:00:00"
    weekday:
      - sun
      - sat
      - fri
      - thu
      - wed
      - tue
      - mon
  - condition: numeric_state
    entity_id: sensor.humidite_piments_soil_moisture_2
    below: 33
action:
  - type: turn_on
    device_id: 89cdf52460bdc9e8789dccfdffae0f81
    entity_id: a010b5e2585437b8265b93f55241021b
    domain: switch
  - wait_for_trigger:
      - platform: numeric_state
        entity_id:
          - sensor.humidite_piments_soil_moisture_2
        above: 60
timeout:
      hours: 0
      minutes: 30
      seconds: 0
      milliseconds: 0
  - type: turn_off
    device_id: 89cdf52460bdc9e8789dccfdffae0f81
    entity_id: a010b5e2585437b8265b93f55241021b
    domain: switch
mode: single

Just a guess, but you have a condition below 33, and then asking it to trigger above 60, as 60 is always bigger than 33, it will have stopped the automation before it gets to that trigger.

This automation is worse then the one you started with.
Are you willing to listen to our advices or do you first want to flood your garden?

[EDIT] I just realized this was a different thread than what I was expecting.
The automation is bad but my second sentence above is not something I should have written if I had understood it was this thread. Sorry about that.

It opens a water tap I assume and then waits for the moisture to go up and then switch off.
But it won’t work very good in real life.