Sub attribute

Read through the threads. Trying to set up a sub attribute condition.

- condition: or
      - condition: template
        value_template: {{ state_attr('sensor.double_take_kalitka','matches')["name"] == "andrey" }}

And this is what i get in return

I have already tried various combinations


 - condition: template
   value_template: “{{ state_attr('sensor.double_take_kalitka','name’) = ‘andrey’ }}”

Btw, by ‘name’, do you mean friendly_name?

No. It’s a sub attribute “name” for the “matches” attribute in the cam config. And i believe it’s missing in your suggestion. In this case you are calling attribute “name”

Something like over here

Show the entity info from the States tool… we need to know if matches is a list or dictionary. Also, your template is missing quotes…

1 Like

Can you share both templates for the better understanding?

What is returned when you paste the following in the template editor?

{{ state_attr('sensor.double_take_kalitka', 'matches') }}

Rule 1:

Templating - Home Assistant (

        value_template: "{{ state_attr('sensor.double_take_kalitka','matches')['name'] == 'andrey' }}"
1 Like

Guess i was too early.

This are the attributes for the sensor

id: b4e75ff9-8fc5-4cb9-b769-d8a901axxxx
duration: 1.3
timestamp: 2023-07-26T07:23:07.302Z
attempts: 1
camera: kalitka
- name: andrey
  confidence: 99.82
  match: true
    top: 282
    left: 1002
    width: 489
    height: 594
  type: mqtt
  duration: 0.46
  detector: compreface
  filename: 8ad68add-d664-427d-bdca-376f73e12690.jpg
  base64: null

personCount: 0
person: 0
match: 0
miss: 0
unknown: 0

icon: mdi:camera
friendly_name: double_take_kalitka
    "name": "andrey",
    "confidence": 99.82,
    "match": true,
    "box": {
      "top": 282,
      "left": 1002,
      "width": 489,
      "height": 594
    "type": "mqtt",
    "duration": 0.46,
    "detector": "compreface",
    "filename": "8ad68add-d664-427d-bdca-376f73e12690.jpg",
    "base64": null

So it’s a list. This is why supplying all the relevant information up front is so important :slight_smile: .

        value_template: "{{ state_attr('sensor.double_take_kalitka','matches')[0]['name'] == 'andrey' }}"
1 Like

That nailed it. Thanks!

I don’t use DoubleTake, so this may not be a big enough issue to bother with, but that condition may fail if multiple matches occur at the same time and “andrey” isn’t in the first position.

If this is an issue you experience, you can try the following:

{{ state_attr('sensor.double_take_kalitka', 'matches')
| map(attribute='name') | list is search('andrey')}}

If you need to check multiple names use a pipe (|) between names (no spaces) in the last function.

{{ .... is search('andrey|person2') }}
1 Like