Automation wasn't triggered

Can anyone see why my automation might not have been triggered?

From looking at the moisture level I can see it’s below the set 45 and the system time is correct

- id: '161651'
  alias: Plant Watering - Baby Jade Plant
  description: ''
  trigger:
  - platform: numeric_state
    entity_id: plant.baby_jade_plant
    attribute: moisture
    below: '45'
  condition:
  - condition: time
    after: '19:04'
  action:
  - service: notify.mypushover
    data:
      message: 'The baby jade plant in the kitchen needs watering!  '
      title: Plant SOS
  - service: notify.alexa_media
    data:
      data:
        type: announce
      target:
      - media_player.living_room
      - media_player.kitchen_echo
      message: The baby jade plant in the kitchen needs watering!
  mode: single

Sensor data:

unit_of_measurement_dict:
  temperature: °C
  moisture: '%'
  brightness: lx
  conductivity: µS/cm
moisture: 39
temperature: 19.7
conductivity: 225
brightness: 90
max_brightness: 112630
friendly_name: Baby Jade Plant

I can see 2 problem that could stop it

1

  - platform: numeric_state
    entity_id: plant.baby_jade_plant
    attribute: moisture
    below: '45'

to

  - platform: numeric_state
    entity_id: plant.baby_jade_plant
    attribute: moisture
    below: 45

as it a number_state and below want a number give it one

  condition:
  - condition: time
    after: '19:04'

change the time to full time

  condition:
  - condition: time
    after: '19:04:00'

Don’t forget too that the moisture must cross the 45 barrier, ie from, say, 46 to 44.

good spotting @nickrout didn’t think of that one

Home assistant is clever enough to convert that to a number.

Thanks for the suggestions. I have been using the GUI editor and that’s how the below: ‘45’ was created.

So it now looks like -

- id: '161651'
  alias: Plant Watering - Baby Jade Plant
  description: ''
  trigger:
  - platform: numeric_state
    entity_id: plant.baby_jade_plant
    attribute: moisture
    below: 99
  condition:
  - condition: time
    after: '21:10:00'
  action:
  - service: notify.mypushover
    data:
      message: 'The baby jade plant in the kitchen needs watering!  '
      title: Plant SOS
  - service: notify.alexa_media
    data:
      data:
        type: announce
      target:
      - media_player.living_room
      - media_player.kitchen_echo
      message: The baby jade plant in the kitchen needs watering!
  mode: single

Plant Status -

System time -

time

Sadly it still won’t trigger. If I trigger the automation manually the push over and Alexa notification work fine

So you now have below: 99

When testing, was it above 99 and then transitioned to below 99? The automation will not trigger just because the reading is now 84.

Your automation’s Numeric State Trigger will trigger the moment moisture attribute’s value crosses the threshold of 45 (from a value above 45 to a value below 45).

If moisture is currently less than 45, the Numeric State Trigger will do nothing until the value first rises above 45 and will trigger the moment it decreases below 45. That’s how a Numeric State Trigger works.

You also have a condition that checks if the current time is later than 21:10, ostensibly to avoid being notified before that time. However, here’s what can happen:

  • Assume the value of moisture decreases from 48 to 44 at, say, 17:30. This decrease crosses the threshold of 45 so the Numeric State Trigger is triggered. However, it happens at a time before the condition’s requirement of 21:10 so the action is not executed (and a notification is not sent).

  • The value of moisture continues to decrease and is well below 45 by the time it’s 21:10. However, the Numeric State Trigger does not keep triggering as the value decreases. It has only one opportunity to trigger and that’s when the value crosses the threshold. That already happened at 17:30 and won’t happen again until the value first goes back up over the threshold and then decreases below it again.

What I suggest you do is create two triggers and two conditions like this (a very common technique):

- id: '161651'
  alias: Plant Watering - Baby Jade Plant
  description: ''
  trigger:
  - platform: numeric_state
    entity_id: plant.baby_jade_plant
    attribute: moisture
    below: 45
  - condition: time
    at: '21:10:00'
  condition:
  - condition: numeric_state
    entity_id: plant.baby_jade_plant
    attribute: moisture
    below: 45
  - condition: time
    after: '21:09:00'
  action:
  - service: notify.mypushover
    data:
      message: 'The baby jade plant in the kitchen needs watering!  '
      title: Plant SOS
  - service: notify.alexa_media
    data:
      data:
        type: announce
      target:
      - media_player.living_room
      - media_player.kitchen_echo
      message: The baby jade plant in the kitchen needs watering!
  mode: single

This compensates for the failure scenario I described. In addition to the Numeric State Trigger it has a Time Trigger. It triggers at 21:10 and if moisture is below 45 it executes the action.

Manually executing the automation skips the automation’s trigger and condition (if any) and simply executes the action. By manually executing your automation, you have confirmed its action works.

2 Likes

Ah it all makes sense now and is so obvious lol.

Thank you for the help :slight_smile:

1 Like