Automation does not trigger, value_template

Can you tell me what’s wrong with this automation?

alias: Set mobile not home
triggers:
  - value_template: >-
      {{ (states('sensor.mobile_wifi_connection') != 'NetStarX') and
      (states('device_tracker.mobile') != 'Casa PE') }}
    for:
      seconds: 120
    trigger: template
actions:
  - data:
      message: A casa
    action: telegram_bot.send_message
  - data:
      payload: not_home
      topic: devices/mobile_vale
      retain: true
    action: mqtt.publish

I can see that this
states('sensor.mobile_wifi_connection')
is true
and this
states('device_tracker.mobile') != 'Casa PE')
is true
for ore than 10 minutes.

Why the automation does not trigger?
Do you see any error in that automation?

I can see this error:

but how to fix it?

the weird thing is that the error is random… it seems that the error is generated by the telegram notifier.
it works most of the time, but sometimes it gives this error.

but how to debug it?

The trigger happens at the 120 second mark and only then. not again until after one of the AND’s is false, then both true again and then happens again at 120 seconds.

A Template Trigger fires when its template’s result changes from false to true.

If your template is currently reporting true then it means the Template Trigger will not fire until the template first reports false and then changes to true and remains true for at least 120 seconds.

From the documentation:

Template triggers work by evaluating a template when any of the recognized entities change state. The trigger will fire if the state change caused the template to render ‘true’ (a non-zero number or any of the strings true, yes, on, enable) when it was previously ‘false’ (anything else).


NOTE

According to the second screenshot you posted, the automation’s Template Trigger did trigger but then it encountered a problem afterwards (while attempting to send a Telegram message). That’s not a problem with the Template Trigger but with the Telegram action.

thanks for the reply, I found the issue, there was a mismatch in the docker networks, I fixed it, problem solved :slight_smile:

thanks!

Can you explain how that prevented the Telegram bot’s ability to send a message?