Invalid config for [automation]: [True] is an invalid option for [automation]

Hi! I use this automation to alert me when a heat recovery fan’s filter needs cleaning:

- alias: bathroom_fan_clean_filter
  mode: single
  trigger:
    - platform: template
      value_template: '{{ is_state_attr("fan.bathroom", "filter_alarm", true) }}'
      id: id_filter_alarm
  action:
    - choose:
      - conditions: '{{ trigger.id == "id_filter_alarm" }}'
        sequence:
          - service: input_boolean.turn_on
            target:
              entity_id: input_boolean.clean_bathroom_fan_filter
          - service: notify.mobile_app_person
            data:
              title: Clean filter
              message: The bathroom fan filter needs cleaning.
          - service: persistent_notification.create
            data:
              title: Clean filter
              message: The bathroom fan filter needs cleaning.
              notification_id: bathroom_fan_clean_filter

This works no problem - however I’d like to extend this automation as follows:

  1. Remind me daily to clean the filter once the filter alarm triggers.
  2. Check that the filter alarm is turned off once the filter has been cleaned and replaced. If it hasn’t alert me to the problem.
  alias: bathroom_fan_clean_filter
  mode: single
  trigger:
    - platform: template
      value_template: '{{ is_state_attr("fan.bathroom", "filter_alarm", true) }}'
      id: id_filter_alarm
    - platform: time
      at: '19:00:00'
      id: id_time
    - platform: state
      entity_id: input_boolean.clean_bathroom_fan_filter
      from: 'on'
      on: 'off'
      id: id_filter_cleaned
  action:
    - choose:
      - conditions: '{{ trigger.id == "id_filter_alarm" }}'
        sequence:
          - service: input_boolean.turn_on
            target:
              entity_id: input_boolean.clean_bathroom_fan_filter
          - service: notify.mobile_app_person
            data:
              title: Clean filter
              message: The bathroom fan filter needs cleaning.
          - service: persistent_notification.create
            data:
              title: Clean filter
              message: The bathroom fan filter needs cleaning.
              notification_id: bathroom_fan_clean_filter
      - conditions:
          - '{{ trigger.id == "id_time" }}'
          - '{{ is_state_attr("fan.bathroom", "filter_alarm", true) }}'
          -  >-
              {% set last = states.input_boolean.clean_bathroom_fan_filter.last_changed %}
              {{ is_state("input_boolean.clean_bathroom_fan_filter", "on") and last is none or as_timestamp(last)|timestamp_custom("%j")|int != now().strftime("%j")|int }}
        sequence:
          - service: notify.mobile_app_person
            data:
              title: Clean filter
              message: The bathroom fan filter needs cleaning.
          - service: persistent_notification.create
            data:
              title: Clean filter
              message: The bathroom fan filter needs cleaning.
              notification_id: bathroom_fan_clean_filter
      - conditions: '{{ trigger.id == "id_filter_cleaned" }}'
        sequence:
          - service: dukaone.reset_filter_timer
            data:
              entity_id: fan.bathroom
          - wait_template: '{{ is_state("input_boolean.clean_bathroom_fan_filter", "off") and is_state_attr("fan.bathroom", "filter_alarm", false) }}'
            timeout: '00:00:20'
          - choose:
            - conditions: '{{ not wait.completed }}'           
              sequence:
                - service: notify.mobile_app_person
                  data:
                    title: Filter cleaned
                    message: The bathroom fan filter has been cleaned.
                - service: persistent_notification.create
                  data:
                    title: Filter cleaned
                    message: The bathroom fan filter has been cleaned.
                    notification_id: bathroom_fan_filter_cleaned
            default:
              - service: notify.mobile_app_person
                data:
                  title: Fan filter error
                  message: There was an error reseting the bathroom fan filter.
              - service: persistent_notification.create
                data:
                  title: Fan filter error
                  message: There was an error reseting the bathroom fan filter.
                  notification_id: bathroom_fan_filter_cleaned

But I’m getting this error in my logs:

Logger: homeassistant.config
Source: config.py:454 
First occurred: 19:16:18 (1 occurrences) 
Last logged: 19:16:18

Invalid config for [automation]: [True] is an invalid option for [automation]. Check: automation->True. (See /config/configuration.yaml, line 259).

I’ve tried removing the two instances of true from the automation but that doesn’t seem to help and I don’t understand why the first iteration works but the second doesn’t. What am I missing?

Try this:

  trigger:
    - platform: template
      value_template: '{{ is_state_attr("fan.bathroom", "filter_alarm", "true") }}'

I’ve tried that, throws the same error. Super annoying that it doesn’t give more detail.

Are you sure it is this automation that is causing the error?

Have you tried commenting it out and re-running the config check?

Hi yes it’s definitely the second version of the automation that’s causing the problem. If I comment it out or use the first version and run the config check there’s no error.

I’ve tried adding sections piece by piece from the 2nd version to the first - to try and figure out which lines are causing the problem. No luck so far, just introducing the additional 2 triggers from the 2nd version to the first, causes the same error - I don’t get it :woman_shrugging:

- alias: bathroom_fan_clean_filter
  mode: single
  trigger:
    - platform: template
      value_template: '{{ is_state_attr("fan.bathroom", "filter_alarm", true) }}'
      id: id_filter_alarm
    - platform: time
      at: '19:00:00'
      id: id_time
    - platform: state
      entity_id: input_boolean.clean_bathroom_fan_filter
      from: 'on'
      on: 'off'
      id: id_filter_cleaned
  action:
    - choose:
      - conditions: '{{ trigger.id == "id_filter_alarm" }}'
        sequence:
          - service: input_boolean.turn_on
            target:
              entity_id: input_boolean.clean_bathroom_fan_filter
          - service: notify.mobile_app_person
            data:
              title: Clean filter
              message: The bathroom fan filter needs cleaning.
          - service: persistent_notification.create
            data:
              title: Clean filter
              message: The bathroom fan filter needs cleaning.
              notification_id: bathroom_fan_clean_filter

Well you don’t need a template trigger for your first trigger, just a plain old state trigger with an attribute.

Second, I would assume this is coming from your 3 shorthand template conditions as they resolve to true/false. Id just make that a single multi line condition with ands in between.

Thanks have done as you advised and merged the 3 conditions into 1. Have isolated the issue to the third trigger, I am so dumb, was caused by a typo:


Should be to: 'on' gah! Well at least it’s fixed sorry to waste your time!