An automation doesn't want to stay enabled, why?

What would cause an automation to auto disable itself after a few seconds of being enabled?

I see nothing in the Core log (under Settings/System/Logs) and no warning in Settings or Notification. This is the automation:

alias: Présence - Martin le matin
description: ""
triggers:
  - hours: "6"
    minutes: "*"
    trigger: time_pattern
  - hours: "8"
    minutes: "*"
    trigger: time_pattern
conditions:
  - condition: state
    entity_id: input_boolean.thermostats_automatic
    state: "on"
  - condition: state
    entity_id: person.martin
    state: home
  - condition: state
    entity_id: climate.neviweb130_climate_martin
    state:
      - "off"
    attribute: eco_status
  - condition: or
    conditions:
      - condition: and
        conditions:
          - condition: state
            entity_id: binary_sensor.workday_today
            state: "on"
          - condition: time
            after: "6:00:00"
            before: "7:00:00"
            weekday:
              - mon
              - tue
              - wed
              - thu
              - fri
              - sat
              - sun
          - condition: template
            value_template: >-
              {% set at_time = 7 * 60 %} {% set cur_time = now() %} {% set
              cur_time = cur_time.hour * 60 + cur_time.minute %} {% set set_temp
              = states.climate.neviweb130_climate_martin.attributes.temperature
              | float %} {% set max_temp = 15.0 %} {% if
              states('sensor.acurite_outside_temperature') == 'unavailable' or
              states('sensor.acurite_outside_temperature') == 'unknown' %} {%
              set out_temp = states('sensor.temperature') | float %} {% else %}
              {% set out_temp = states('sensor.acurite_outside_temperature') |
              float %} {% endif %} {{ at_time - cur_time == 0 or (set_temp <
              20.0 and at_time - cur_time > 0 and out_temp < max_temp and
              at_time - cur_time + out_temp * 1.5 - 30.0 < 0) }}
      - condition: and
        conditions:
          - condition: state
            entity_id: binary_sensor.workday_today
            state: "off"
          - condition: time
            after: "08:00:00"
            before: "09:00:00"
            weekday:
              - mon
              - tue
              - wed
              - thu
              - fri
              - sat
              - sun
          - condition: template
            value_template: >-
              {% set at_time = 9 * 60 %} {% set cur_time = now() %} {% set
              cur_time = cur_time.hour * 60 + cur_time.minute %} {% set set_temp
              = states.climate.neviweb130_climate_martin.attributes.temperature
              | float %} {% set max_temp = 15.0 %} {% if
              states('sensor.acurite_outside_temperature') == 'unavailable' or
              states('sensor.acurite_outside_temperature') == 'unknown' %} {%
              set out_temp = states('sensor.temperature') | float %} {% else %}
              {% set out_temp = states('sensor.acurite_outside_temperature') |
              float %} {% endif %} {{ at_time - cur_time == 0 or (set_temp <
              20.0 and at_time - cur_time > 0 and out_temp < max_temp and
              at_time - cur_time + out_temp * 1.5 - 30.0 < 0) }}
actions:
  - data_template:
      temperature: >-
        {% if is_state('binary_sensor.workday_today','on') %}22{% else %}21{%
        endif %}
      entity_id: climate.neviweb130_climate_martin
    action: climate.set_temperature
  - data_template:
      temperature: >-
        {% if is_state('binary_sensor.workday_today','on') %}22{% else %}21{%
        endif %}
      entity_id: climate.neviweb130_climate_martin_toilette
    action: climate.set_temperature
mode: single

I have a very similar one (for another person and another bedroom) and it stays enabled. This is the difference between both:

1c1
< alias: Présence - Martin le matin
---
> alias: Présence - Michèle le matin
4c4
<   - hours: "6"
---
>   - hours: "5"
7c7
<   - hours: "8"
---
>   - hours: "7"
15c15
<     entity_id: person.martin
---
>     entity_id: person.michele
18c18
<     entity_id: climate.neviweb130_climate_martin
---
>     entity_id: climate.neviweb130_climate_michele
30,31c30,31
<             after: "6:00:00"
<             before: "7:00:00"
---
>             after: "5:00:00"
>             before: "6:00:00"
42c42
<               {% set at_time = 7 * 60 %} {% set cur_time = now() %} {% set
---
>               {% set at_time = 6 * 60 %} {% set cur_time = now() %} {% set
44c44
<               = states.climate.neviweb130_climate_martin.attributes.temperature
---
>               = states.climate.neviweb130_climate_michele.attributes.temperature
59,60c59,60
<             after: "08:00:00"
<             before: "09:00:00"
---
>             after: "7:00:00"
>             before: "8:00:00"
71c71
<               {% set at_time = 9 * 60 %} {% set cur_time = now() %} {% set
---
>               {% set at_time = 8 * 60 %} {% set cur_time = now() %} {% set
73c73
<               = states.climate.neviweb130_climate_martin.attributes.temperature
---
>               = states.climate.neviweb130_climate_michele.attributes.temperature
87c87
<       entity_id: climate.neviweb130_climate_martin
---
>       entity_id: climate.neviweb130_climate_michele
93c93
<       entity_id: climate.neviweb130_climate_martin_toilette
---
>       entity_id: climate.neviweb130_climate_bureau

No logic difference, just trigger times, persons and devices.

Check the logbook for clues. The most likely scenario is that you have accidentally named the entity id of the automation for a turn_off action or something like that. Do you by any chance turn things off by label or by area and got it included in that by accident?

That’s the thing, there is nothing in the logbook (you mean the log seen in Settings/System/Logs)?

No, that is the error log. The activity log that shows what happens in the system. It often shows what caused something to happen. Usually it is in the left menu.

Look at the traces too.

The problem is that it might be in the trace of some unexpected other automation.

True.
It was not a suggestion to ONLY look in the traces. :wink:

Thanks. Found it. Here’s a twist. Before posting, I did find a syntax error within the template and fixed it. However, it still didn’t want to stay enabled. So I came here and posted this. After your reply, I checked the activity log and saw that it said Présence - Martin le matin turned on triggered by action Automation: Turn on and it stayed on. What? I went and checked that automation and indeed it’s now on. I wonder why after I fixed the error, saved the automation and try to enable it, it didn’t want to… Anyway, It’s enabled now so all is fine. Thanks for your help.

As it didn’t want to enable, there was nothing in the trace. Thanks for the suggestion though.

I still get the feeling those commands are in some other automation my mistake. It is a shame though it sisn’t say what executed the action.

If it keeps misbehaving, come back here. Maybe an automation to trigger on the state of the automation can tell the context of why it happened.

1 Like