Quantcast
Channel: Configuration - Home Assistant Community
Viewing all articles
Browse latest Browse all 95919

Template Condition does not work

$
0
0

@sermayoral wrote:

Hi everybody.

I have an automation that makes me mad. It’s very simple. I don’t want the automation executes more than once in a period of 15 seconds. But it does not work. To undestand what is happening, i have written a ‘system_log.write’ with a copy paste of the condition, like this :

  - id: '1562516212611'
    alias: Llaman al portero
    description: Notifica por telegram las llamadas al portero
    trigger:
    - entity_id: binary_sensor.portero
      platform: state
      from: 'off'
      to: 'on'
    condition:
    - condition: template
      value_template: '{{ (as_timestamp(now()) - as_timestamp(state_attr("automation.llaman_al_portero", "last_triggered")) |int(20) ) > 15 }}'
    action:
    - data:
        message: "\U0001F4DE Han llamado al portero"
      service: notify.telegram_casa
    - data_template:
        user: !secret user_telegram_sergio
        message: Hola_Sergio,_han_llamado_al_portero
      service: shell_command.telegram_call
    - service: system_log.write
      data_template:
        level: warning
        logger: homeassistant.components.mylogger
        message: 'Condition of automation.llaman_al_portero is {{ (as_timestamp(now()) - as_timestamp(state_attr("automation.llaman_al_portero", "last_triggered")) |int(20) ) > 15 }}'

This morning has happened again, the automation executed twice in less than 15 seconds. When i have seen the log, i have found this:

2020-01-31 17:04:58 WARNING (MainThread) [homeassistant.components.mylogger] Condition of automation.llaman_al_portero is True
2020-01-31 17:05:03 WARNING (MainThread) [homeassistant.components.mylogger] Condition of automation.llaman_al_portero is False

The firt log is OK, but the second log tells me that the condition is False. So, why the automation is being executed??

Posts: 17

Participants: 4

Read full topic


Viewing all articles
Browse latest Browse all 95919

Trending Articles