Test device attribute: is_device_attr

The is_device_attr template function checks whether a specific attribute of a deviceA device is a model representing a physical or logical unit that contains entities. matches a given value. It returns true or false. This is the device-level equivalent of is_state_attr, working with the device registry instead of entity states.

This is useful when you want to make decisions in automationsAutomations in Home Assistant allow you to automatically respond to things that happen in and around your home. [Learn more] or templatesA template is an automation definition that can include variables for the action or data from the trigger values. This allows automations to generate dynamic actions. [Learn more] based on device properties. For example, you could check if a device is made by a specific manufacturer, runs a particular firmware version, or matches a certain model. You might use it to apply different logic depending on the hardware vendor, or to trigger an alert when a device’s software version doesn’t match the expected value after an update.

Usage

Here’s how to use this template function. Copy any example and adjust it to your setup.

TemplateA template is an automation definition that can include variables for the action or data from the trigger values. This allows automations to generate dynamic actions. [Learn more]
{{ is_device_attr("a1b2c3d4e5f6a1b2c3d4e5f6", "manufacturer", "Philips") }}
Result (booleanA value that is either true or false. Used for on/off states, yes/no conditions, and similar binary choices.)
true

Function signature

The signature is a technical summary of this template function. It shows the name of the function, the values (called parameters) it accepts, and what type of data each parameter expects (for example, a piece of text or a number).

Function parameters that have a = with a value after them are optional. If you leave them out, the default value shown is used automatically. Function parameters without a default are required.

is_device_attr(
    device_or_entity_id: str,
    attr_name: str,
    attr_value: Any,
) -> bool

Function parameters

The following parameters can be provided to this function.

device_or_entity_id string Required

The device ID or entity ID to check. When using an entity ID, the function first resolves the device the entity belongs to.

attr_name string Required

The name of the device attribute to test. Common attributes include manufacturer, model, sw_version, hw_version, and serial_number.

attr_value any Required

The value to compare the attribute against.

Good to know

  • Returns false (not an error) when the device or attribute does not exist.
  • String comparison is case-sensitive. is_device_attr(id, "manufacturer", "philips") does not match "Philips".
  • Accepts either a device ID or an entity ID. With an entity ID, the device is resolved first.

Try it yourself

Ready to test this? Open Developer tools > Template, paste the example into the Template editor, and watch the result update on the right. Edit the values to see how the function adapts to your own entitiesAn entity represents a sensor, actor, or function in Home Assistant. Entities are used to monitor physical properties or to control other entities. An entity is usually part of a device or a service. [Learn more].

More examples

Real scenarios where this function comes up in automations and templates. Copy any example and adapt it to your setup.

Check if a device is a specific model

Verify that a device matches an expected model, for example to apply model-specific logic in an automation.

TemplateA template is an automation definition that can include variables for the action or data from the trigger values. This allows automations to generate dynamic actions. [Learn more]
{{ is_device_attr("light.living_room", "model", "LCA001") }}
Result (booleanA value that is either true or false. Used for on/off states, yes/no conditions, and similar binary choices.)
true

Use in an automation condition

Only run the rest of the automationAutomations in Home Assistant allow you to automatically respond to things that happen in and around your home. [Learn more] if the device is from a specific manufacturer.

AutomationAutomations in Home Assistant allow you to automatically respond to things that happen in and around your home. [Learn more]
condition:
  - condition: template
    value_template: >
      {{ is_device_attr("sensor.front_door", "manufacturer", "Aqara") }}

Check firmware version across devices in an area

Combine with area_devices to find devices in an area that are running a specific firmware version.

TemplateA template is an automation definition that can include variables for the action or data from the trigger values. This allows automations to generate dynamic actions. [Learn more]
{% for dev_id in area_devices("Living Room") %}
  {% if is_device_attr(dev_id, "sw_version", "1.104.2") %}
    {{ device_name(dev_id) }}
  {% endif %}
{% endfor %}

Still stuck?

The Home Assistant community is quick to help: join Discord for real-time chat, post on the community forum with your template and expected result, or share on our subreddit /r/homeassistant.

Tip

AI assistants like ChatGPT or Claude can also explain or fix templates when you describe what you want in plain language.

Related template functions

These functions work well alongside this one: