Automation with value template

Hello all,

I am trying to set a Helper toggle to on or off state based on a value template but can’t seem to get it right. Here is my automation.

alias: Test Person Detected Status
description: ''
mode: single
  - platform: state
      - image_processing.deepstack_object_desk_cam
    attribute: Summary
condition: []
  - if:
      - condition: template
        value_template: >-
          {{ state_attr('image_processing.deepstack_object_desk_cam', 'Summary')
          != '{}' }}
      - service: homeassistant.turn_on
        data: {}
          entity_id: input_boolean.at_desk
      - service: homeassistant.turn_off
        data: {}
          entity_id: input_boolean.at_desk

Here is when no person object is found.

When I test this condition I get the following error.
Error occurred while testing condition
template value should be a string for dictionary value @ data[‘value_template’]. Got None

I would get grateful for any help getting this to work.

That’s a problem with the editor not your template. There’s an open issue for it.

Thank you tom_l,

I triggered this automation and it always executes the then branch and never the else branch. When no person object is and I look at the attribute is shows Summary {} so I am testing for that. When a person object is detected it shows Summary person: 1 or more depending on if it detects 1 or more people. But the automation always execute the then branch and sets the toggle to On never setting it to Off.

Check the trace to see what is happening:

Thank you tom_l,

I changed from looking at attribute state to entity state and it works now.