Error in describing condition: Cannot use 'in' operator to search for 'and' in

Hi everyone,

I’m a bit puzzled by an automation that used to work so far I recall and is now spitting out weird error messages. It’s a fairly straightforward one, creating a snapshot of cameras and notifying if cameras are catching something important at night or when we’re not home.

The point of those two condition tests is to 1/ debounce the execution of this automation (if executed less than 60s ago, don’t fire again) and 2/ check if we are home or if it’s during night.

The full error messages, as seen in automation traces, are:

“Error in describing condition: Cannot use ‘in’ operator to search for ‘and’ in {{ (as_timestamp(now()) - as_timestamp( state_attr(‘automation.frigate_camera_alert_v2_2’, ‘last_triggered’), 0)) | int > 60 }}”

And I get instantly below a second one:

“Error in describing condition: Cannot use ‘in’ operator to search for ‘and’ in {{ states(‘group.homies’) == ‘not_home’ or today_at(‘00:00’) <= now() <= today_at(‘08:00’) }}”

I’m not really sure why this error message is showing up since I’m not doing any kind of IN lookup, like is “bla” contained in “blablabla”. It’s a pure simple template evaluation.

Here is the complete automation for reference:
(I use packages)

group:
  homies:
    name: Cool People
    entities:
      - person.person1
      - person.person2

automation:
  - id: "410001"
    alias: Frigate - camera alert V2
    description: "Frigate - Camera detection alert V2"
    triggers:
      - trigger: mqtt
        topic: frigate/events
        payload: new
        value_template: "{{ value_json.type }}"
    conditions:
      - "{{ as_timestamp(now()) - as_timestamp(state_attr('automation.frigate_camera_alert_v2_2','last_triggered'), 0) | int > 60 }}"
      - "{{ states('group.homies') == 'not_home' or today_at('00:00') <= now() <= today_at('08:00') }}"
      - "{{ states('group.friends') == 'not_home' or today_at('00:00') <= now() <= today_at('08:00') }}"
      - "{{ states('input_boolean.security_2h_snooze') == 'off' }}"
      - "{{ trigger.payload_json['before']['stationary'] == false }}"
      - "{{ trigger.payload_json['after']['label'] == 'person' }}"
      - "{{ not(states('group.homies') == 'home' and trigger.payload_json['before']['camera'] == 'wyze') }}"
    actions:
      - repeat:
          for_each:
            - cam: rox
              where: "Pool"
            - cam: rookie
              where: "Garage"
            - cam: tic
              where: "Back garden"
            - cam: sagittaire
              where: "North terrace"
            - cam: radada
              where: "Driveway"
            - cam: wyze
              where: "Living room"
          sequence:
            - if: "{{ trigger.payload_json['before']['camera'] == repeat.item.cam }}"
              then:
                - action: system_log.write
                  data:
                    logger: "Frigate"
                    level: warning
                    message: "{{ trigger.payload_json['after']['label'] }} detected in {{ repeat.item.where }} by {{ repeat.item.cam }}"
                - action: camera.snapshot
                  target:
                    entity_id: "camera.{{ repeat.item.cam }}"
                  data:
                    filename: "/www/tmp/{{repeat.item.cam + now().strftime('-%H-%M_%d-%m-%Y')}}.jpg"
                - action: notify.mobile_app_REDACTED
                  data:
                    message: "{{trigger.payload_json['after']['label'] }} detected in {{ repeat.item.where }}"
                    data:
                      image: "http://192.168.0.49:8123/local/tmp/{{repeat.item.cam + now().strftime('-%H-%M_%d-%m-%Y')}}.jpg"
                - action: notify.info
                  data:
                    title: "{{trigger.payload_json['after']['label'] }} detected in {{ repeat.item.where }}"
                    message: "{{ repeat.item.cam }} saw something"
                    data:
                      attachment: "www/tmp/{{repeat.item.cam + now().strftime('-%H-%M_%d-%m-%Y')}}.jpg"
                      priority: 0
                      sound: intermission

The weirdest part is that the automation execution seems to survive the 1st error message and proceed to the second test anyway…!?

Does someone have any idea?

That is strange. I wonder if it’s something to do with the UI description of your YAML coding, but I pasted your automation into my UI automation editor and it didn’t have any problems with displaying it. I obviously cannot run it though.

Interesting that in the trace, the group.homies condition is showing up as the first condition.

My first test would be to start adding brackets to further reduce potential ambiguity, but it shouldn’t make a difference. Example:

      - "{{ (as_timestamp(now()) - as_timestamp(state_attr('automation.frigate_camera_alert_v2_2','last_triggered'),0)|int) > 60 }}"
      - "{{ (states('group.homies') == 'not_home') or (today_at('00:00') <= now() <= today_at('08:00')) }}"

To isolate the problem, I made a super-duper simple automation:

group:
  homies:
    name: Cool People
    entities:
      - person.person1
      - person.person2

  - id: "819913"
    alias: TEST - Homies state test
    triggers:
      - trigger: time_pattern
        minutes: "/1"
    conditions:
      - "{{ is_state('group.homies','home') }}"
    actions:
      - action: system_log.write
        data:
          logger: "TEST"
          level: warning
          message: "TESTING Group homies test {{ states('group.homies') }}"

And this one spits an error too!

It seems the behavior of a group of trackers (home/not_home) is somewhat different from what it used to be in previous versions. And when I test in the automation editor, the state of a person and the state of a group, the test of a person offers home/not_home. Still, the test of a group of person trackers visually shows this instead (unknown/unavailable):

But if I test it in the developer tab in a template with:
{{ is_state('group.homies', 'not_home') }}

It renders correctly ‘true’ or ‘false’.

@123 @petro any clue? I know this type of group is the “Old style group” as per the documentation, but it’s still supposed to work in manual Yaml automation. Anyway “new” groups don’t seem to handle device trackers do they?

1 Like

I don’t see that behaviour. My automation (your YAML pasted and reformatted; and I assume your group definition is separate in reality):

alias: group test
description: ""
triggers:
  - trigger: time_pattern
    minutes: /1
conditions:
  - condition: template
    value_template: "{{ is_state('group.usual_residents','home') }}"
actions:
  - action: system_log.write
    data:
      logger: TEST
      level: warning
      message: TESTING Group homies test {{ states('group.usual_residents') }}

The group:

group:
  usual_residents:
    name: "Usual residents"
    entities:
      - person.troon
      - person.spouse
      - person.child

Trace screen:

Logs:

2025-07-02 11:00:00.395 INFO (MainThread) [homeassistant.components.automation.group_test] group test: Running automation actions
2025-07-02 11:00:00.395 INFO (MainThread) [homeassistant.components.automation.group_test] group test: Executing step call service
2025-07-02 11:00:00.395 WARNING (MainThread) [TEST] TESTING Group homies test home

I think that’s normal. To work how you want it to, the UI editor would need to be able to determine what sort of group it is to give you the possible states. You can always manually type in the state to be checked against.

The group is declared within a package with the classical structure:

group:
xyz

automation:
xyz

But I think it’s related to the “old style” group. How did you declare your group? Is it through YAML config? If so in a package or through flat files? If through the UI what type are the members of the group? (because tracker isn’t offered in my UI)

YAML group of persons, as shown. Only thing I changed was the real names.

Old school groups haven’t changed in years. They have been made legacy, which means no code changes.

Old school groups have never offered state options in the dropdown list either. So you’re miss remembering that. You have to manually type out home or not_home.

What I remember is that automations used to work when testing the state of a group for “home” or “not_home” and now it clearly doesn’t anymore.

New groups don’t seem to cover trackers, so I’m missing a point here ?
(or maybe it’s because I’m using packages ?)

What do you mean “testing the state”?

If you’re referring to clicking the test button on the condition, that will still work as long as it’s not a template.

{{ (is_state('group.homies','not_home') }}

right,

it used to work “templated” or I’m hallucinating ?

IIRC it’s never worked for templates. Especially fully templated ones.

ok is it just a visual bug in the automation tracer or is the automation really failing?

Well, I just created your test and both are working for me. So I must be remembering that templates with trigger variables don’t work when testing.

1 Like

Ah, showing the trace, I see why it’s not working for you. You have exterior quotes on your template. Those should only exist in yaml, when you use the fromend, it should look like what I had above.

Sorry I don’t use the frontend, only the old school Yaml, in a package:


  - id: "819913"
    alias: TEST - Homies state test
    triggers:
      - trigger: time_pattern
        minutes: "/1"
    conditions:
      - "{{ is_state('person.philippe','home') }}"
      - "{{ is_state('group.homies','not_home') }}"
      - "{{ now() > state_attr('automation.frigate_camera_alert_v3', 'last_triggered') | as_datetime | as_local + timedelta(minutes=2) }}"
    actions:
      - action: system_log.write
        data:
          logger: "TEST"
          level: warning
          message: "TESTING Group homies test {{ states('group.homies') }}"

So I should remove the double quotes from my templated test conditions?

It seems the problem is with shorthand conditions. When you switch back to visual editor, it should add all the additional plumbing.

1 Like

Ok… As usual, you’re 100% right @petro.

I did more tests. It’s just a visual glitch with shorthand conditions, indeed, but the automation still proceeds, which is tricky because, in some cases, this message relates to a real error.

This form gives a visual error in the automation tracer, to all conditions even if only one seems to be triggering this (the tracker group test), but the automation still proceeds:

    conditions:
      - "{{ is_state('group.homies','home') }}"

The form generated by the automation UI, which doesn’t use the short form but instead the full form triggers no visual error.:

  - condition: template
    value_template: '{{ is_state(''group.homies'',''home'') }}'

Yes, looks like a bug with shorthand conditions in the UI trace view. I recreated the test automation in YAML (as I usually do):

- alias: group test yaml
  id: 776a1c49-aea0-47e0-9b08-533e3a19a38f
  description: ""
  triggers:
    - trigger: time_pattern
      minutes: /1
  conditions:
    - "{{ is_state('group.usual_residents','home') }}"
  actions:
    - action: system_log.write
      data:
        logger: TEST
        level: warning
        message: TESTING Group homies test {{ states('group.usual_residents') }}

and now see the error on the trace:

No error is generated in the logs and the automation works fine. This is not in a package, just standard config.

I see the same error message in all my existing automations that use shorthand template conditions.

Issue raised: Error message in automation traces with YAML template shorthand conditions · Issue #26031 · home-assistant/frontend · GitHub

2 Likes