Automation not firing automatically

I have a plant water sensor that should fire when it hits a certain moisture level. It looks like:
alias: Plant Moisture Notification
description: Plant sensor
trigger:

  • platform: numeric_state
    entity_id:
    • sensor.plant_sensor_0868_moisture
      below: 8
      condition:
  • condition: state
    entity_id: input_boolean.plant_needs_water
    state: “off”
    action:
  • service: script.fetch_and_notify_plant
    data: {}
    mode: single

It works fine when I run it manually to test it.

When I checked its moisture level this morning it shows me:
sensor.plant_sensor_0868_moisture Moisture 6

Why isn’t it running when the moisture level is below 8??

Hello Steve,

The way triggers like that one work is the trigger happens at the exact second the value goes from 8 to under 8. If the value is already under 8, it will not trigger.

For a notification like that and I guessing the way you are thinking, you may want to trigger on any change to the

by removing the

And add a condition that the moisture sensor value be below 8.
Then any change in the sensor below 8 will send you another action execution.

It doesn’t seem to like just removing the below: 8 portion. Says its malformed

pls post your latest code formatted properly using the </> button… since formatting is significant in yaml, it’s hard to debug without that

Here is the way the current automation stands:

alias: Plant Moisture Notification
description: ""
trigger:
  - platform: numeric_state
    entity_id:
      - sensor.plant_sensor_0868_moisture
    below: 8
condition:
  - condition: state
    entity_id: input_boolean.plant_needs_water
    state: "off"
action:
  - service: script.fetch_and_notify_plant
    data: {}
mode: single

The plant sensor needs to cross 8 going from above 8 to below 8 for the trigger to occur. If the value of the sensor is already below 8, it will not trigger until the sensor rises above 8 then crosses below again.

removing below: 8 is indeed invalid. if you want to trigger every time the sensor changes, change it from numeric_state to state and remove the below: 8

the design of home assistant (and most home automation systems) is to trigger on an event… like becoming below 8. it won’t trigger if it is already below 8.

Even after that happens, if we water the plant and it goes back up above 8, and then down again, its still not firing

Do you have a history to prove this? You’re claiming a staple trigger, used by pretty much every home assistant installation isn’t working. This would be a major problem if what you’re saying is True.

Have you checked your traces to verify it’s not triggering?

When I check the trace timeline I’m seeing:

  • Triggered by the numeric state of sensor.plant_sensor_0868_moisture at August 4, 2024 at 6:20:51 PM
  • Test Error in describing condition: e is undefined
  • Stopped because a condition failed at August 4, 2024 at 6:20:51 PM

I’m not sure what the Test Error describing condition: e is undefined means. I don’t see just a ‘e’ anywhere

can you download the trace and post the results here please?

{
  "trace": {
    "last_step": "condition/0/entity_id/0",
    "run_id": "6c0523eb722f59840cf0f3ff1eca134e",
    "state": "stopped",
    "script_execution": "failed_conditions",
    "timestamp": {
      "start": "2024-08-05T00:20:51.492489+00:00",
      "finish": "2024-08-05T00:20:51.493166+00:00"
    },
    "domain": "automation",
    "item_id": "1718578909244",
    "trigger": "numeric state of sensor.plant_sensor_0868_moisture",
    "trace": {
      "trigger/0": [
        {
          "path": "trigger/0",
          "timestamp": "2024-08-05T00:20:51.492560+00:00",
          "changed_variables": {
            "this": {
              "entity_id": "automation.plant_moisture_level",
              "state": "on",
              "attributes": {
                "id": "1718578909244",
                "last_triggered": "2024-06-25T22:58:12.722244+00:00",
                "mode": "single",
                "current": 0,
                "friendly_name": "plant Moisture Notification"
              },
              "last_changed": "2024-07-23T06:36:52.169823+00:00",
              "last_reported": "2024-07-23T06:36:52.169823+00:00",
              "last_updated": "2024-07-23T06:36:52.169823+00:00",
              "context": {
                "id": "01J3F4X729PEH6JW9XZCCBZ8TV",
                "parent_id": null,
                "user_id": null
              }
            },
            "trigger": {
              "id": "0",
              "idx": "0",
              "alias": null,
              "platform": "numeric_state",
              "entity_id": "sensor.plant_sensor_0868_moisture",
              "below": 8,
              "above": null,
              "from_state": {
                "entity_id": "sensor.plant_sensor_0868_moisture",
                "state": "8",
                "attributes": {
                  "state_class": "measurement",
                  "unit_of_measurement": "%",
                  "device_class": "moisture",
                  "friendly_name": "plant Moisture"
                },
                "last_changed": "2024-08-05T00:20:09.475811+00:00",
                "last_reported": "2024-08-05T00:20:09.475811+00:00",
                "last_updated": "2024-08-05T00:20:09.475811+00:00",
                "context": {
                  "id": "01J4FYGS43QR352J4JH9QSFN46",
                  "parent_id": null,
                  "user_id": null
                }
              },
              "to_state": {
                "entity_id": "sensor.plant_sensor_0868_moisture",
                "state": "7",
                "attributes": {
                  "state_class": "measurement",
                  "unit_of_measurement": "%",
                  "device_class": "moisture",
                  "friendly_name": "plant Moisture"
                },
                "last_changed": "2024-08-05T00:20:51.492201+00:00",
                "last_reported": "2024-08-05T00:20:51.492201+00:00",
                "last_updated": "2024-08-05T00:20:51.492201+00:00",
                "context": {
                  "id": "01J4FYJ254GSCNCTDE3TXP7GY5",
                  "parent_id": null,
                  "user_id": null
                }
              },
              "for": null,
              "description": "numeric state of sensor.plant_sensor_0868_moisture"
            }
          }
        }
      ],
      "condition/0": [
        {
          "path": "condition/0",
          "timestamp": "2024-08-05T00:20:51.492623+00:00",
          "error": "In 'state':\n  In 'state' condition: unknown entity input_boolean.plant_needs_water"
        }
      ],
      "condition/0/entity_id/0": [
        {
          "path": "condition/0/entity_id/0",
          "timestamp": "2024-08-05T00:20:51.492682+00:00",
          "error": "In 'state' condition: unknown entity input_boolean.plant_needs_water"
        }
      ]
    },
    "config": {
      "id": "1718578909244",
      "alias": "plant Moisture Notification",
      "description": "",
      "trigger": [
        {
          "platform": "numeric_state",
          "entity_id": [
            "sensor.plant_sensor_0868_moisture"
          ],
          "below": 8
        }
      ],
      "condition": [
        {
          "condition": "state",
          "entity_id": "input_boolean.plant_needs_water",
          "state": "off"
        }
      ],
      "action": [
        {
          "service": "script.fetch_and_notify_plant_plant",
          "data": {}
        }
      ],
      "mode": "single"
    },
    "blueprint_inputs": null,
    "context": {
      "id": "01J4FYJ254WRCTZKY058QDFV81",
      "parent_id": "01J4FYJ254GSCNCTDE3TXP7GY5",
      "user_id": null
    }
  },
  "logbookEntries": []
}

does this entity exist? input_boolean.plant_needs_water

It is now…guess I missed that

So, how often does HA check the sensor levels and then run automation? I’m trying to determine when I should check to see the next time this runs on its own.

That depends on your integration. If it’s polling, it checks the value at the polling frequency. If it’s a push integration, it only checks when the sensor tells HA that it’s value changed.

Does it say somewhere which it is?

Yes, on the home assistant documentation page for the integration. It will say “Local Push”, “Cloud Push”, “Local Polling”, or “Cloud Polling”.