Time trigger not triggering, Im doing something stupid :) - Solved

Ok, Here.s the scenario. I have a couple of HiGrow esp32 based Soil meters that I’ve “Modified” a little. But sometimes they stop for no apparent reason. My bright idea was to check for the last_updated attribute and if that was so many seconds earlier then now, send an alert.

I’ve written the Automation, and if I trigger the automation manually, Goto to States - Automation - Trigger , the automation fires and reports that the sensor hasn’t checked in in the time specified. If I try to use the Time platform to run this test every 15 minutes, it never runs. Here is the code I’m using.

- id: auto063
  alias: Garden Sensor 01 - Late Check in
  trigger:
    minutes: '/15'
    platform: time
    seconds: 00
  condition:
  - condition: and
    conditions:
    - condition: template
      value_template: '{{ as_timestamp(now()) - as_timestamp(states.sensor.garden_sensor_01_water.last_updated)
        | int }} > 1800'
    - condition: template
      value_template: '{{ not is_state(''persistent_notification.garden_sensor_01_error'',
        ''notifying'') }}'
  action:
  - data:
      message: Oh oh, {{states.sensor.garden_sensor_01_temperature.name}} update is
        due. Kick it! - {{now().strftime("%H:%M:%S %d/%m")}} {{ ((as_timestamp(now())-as_timestamp(states.sensor.garden_sensor_01_water.last_updated))|int)
        }} Seconds Since Check in!
    service: notify.family
  - data:
      message: Attention, {{states.sensor.garden_sensor_01_temperature.name}} update
        is due. {{ ((as_timestamp(now())-as_timestamp(states.sensor.garden_sensor_01_water.last_updated))|int)
        }} Seconds since check in
      notification_id: garden_sensor_01_error
      title: Garden Sensor 01 Error
    service: persistent_notification.create

possibly indentation, possibly the double 0:
try that

  trigger:
    - platform: time
      minutes: '/15'
      seconds: 0

I’ve tried with a single 0 and a double 00,

but I’m willing to give it another go…

i’m also going to change the minutes to ‘/5’ and wait with crossed fingers.

thnx

Did you check your templates? The double single quotes seem a bit odd.

This condition is wrong…

should be:

    - condition: template
      value_template: "{{ not is_state('persistent_notification.garden_sensor_01_error',
        'notifying') }}"

EDIT: to clarify, if you use quotes inside a value template, you need to use the ‘other type’ of quotes to encompass it. Example, I have a string that I want to output: “Hello”. If I place that string into a value template to output, it would be inside single quotes:

'{{ "Hello" }}'

or vice versa:

"{{ 'Hello' }}"
1 Like

Thanks,
I’ll make this change aswell.

the odd thing is that it works perfectly well if I manually trigger it.
thanks

Manual trigger only shows your action is working.

this condition is also wrong…

should be:

    - condition: template
      value_template: '{{ ( as_timestamp(now()) - as_timestamp(states.sensor.garden_sensor_01_water.last_updated) | int ) > 1800 }}'

EDIT: Basically, all your syntax needs to be inside {{ }} to evaluate properly.

In the end, I would expect your automation to be changed to this to properly work:

- id: auto063
  alias: Garden Sensor 01 - Late Check in
  trigger:
    minutes: '/15'
    platform: time
    seconds: 0
  condition:
    - condition: template
      value_template: '{{ ( as_timestamp(now()) - as_timestamp(states.sensor.garden_sensor_01_water.last_updated) | int ) > 1800}}'
    - condition: template
      value_template: '{{ not is_state("persistent_notification.garden_sensor_01_error", "notifying") }}'
  action:
  - data:
      message: Oh oh, {{states.sensor.garden_sensor_01_temperature.name}} update is
        due. Kick it! - {{now().strftime("%H:%M:%S %d/%m")}} {{ ((as_timestamp(now())-as_timestamp(states.sensor.garden_sensor_01_water.last_updated))|int)
        }} Seconds Since Check in!
    service: notify.family
  - data:
      message: Attention, {{states.sensor.garden_sensor_01_temperature.name}} update
        is due. {{ ((as_timestamp(now())-as_timestamp(states.sensor.garden_sensor_01_water.last_updated))|int)
        }} Seconds since check in
      notification_id: garden_sensor_01_error
      title: Garden Sensor 01 Error
    service: persistent_notification.create
1 Like

You should use “developer tools - templates” to check if your templates are working properly (or have @petro fix them for you :wink: )

1 Like

Man!!!

Talk about service :grin:

Can I make a feature request?? include an Auto-Petro Button…

Thans a Million. I’ll grab what you’ve written and give it a go.

Thanks Again

1 Like

and it now works perfectly!!

Thanks again all,

Much appreciated!

1 Like

I know this is an old post but hoping for a little help. I purchased 10 of the higrow soil sensors and did not do my home work first. I am having a hard time finding a confirmed working flash procedure and a best way to get into home assistant. Was hoping maybe you could share the procedure that you used to flash the units and add to home assistant? Please.
I am currently looking at the esphomelib as an option , but the board is not listed although the components are. Thanks in advance for your help!

In case you didn’t fix it so far, you can try this new custom firmware that exposes everything via MQTT.


There will be version 2.0 of firmware that should handle auto discovery (hopefully) and would need only 2 configuration options - mqtt server info and WiFi info.

Thanks! I threw them in a box figured someone smarter than me would figure it out sooner or later! I’ll give it a shot, thanks again!