architecture icon indicating copy to clipboard operation
architecture copied to clipboard

Get device details in templates

Open dwradcliffe opened this issue 5 years ago • 2 comments

Context

As more components use the device registry, more device data is moved away from entities and on to devices, as was designed. This means that the current methods of getting attributes on entities is no longer sufficient within templates.

Example: With the new ozw component, there is a real device for each zwave node, and we no longer have the zwave.* entities. Information about the node, such as device model and manufacturer is on the device and not on any entity. There is no way to get the model of, for example, a switch from a template.

Here is an example script that no longer works: https://github.com/kschlichter/Home-Assistant-Inovelli-Red-Dimmer-Switch/blob/master/inovelli_red_dimmer_switch

Proposal

I propose we add one or more template extensions/helpers to fetch information from the device registry for a given entity.

Something like this:

{% if 'LZW31' in device_name(entity_id) %}

Consequences

This will give people more ways to use the proper device/entity architecture. I'm not sure if there's any negative consequences.

cc @frenck @cgarwood

dwradcliffe avatar Aug 03 '20 13:08 dwradcliffe

I wouldn't want to return just the device name. Probably something like device(entity_id) returning a device registry entry

balloob avatar Aug 11 '20 21:08 balloob

That sounds good. 👍 I can try to get a PR started when I have a chance this week unless someone beats me to it.

dwradcliffe avatar Aug 11 '20 21:08 dwradcliffe

This architecture issue is old, stale, and possibly obsolete. Things changed a lot over the years. Additionally, we have been moving to discussions for these architectural discussions.

For that reason, I'm going to close this issue.

../Frenck

frenck avatar May 11 '23 13:05 frenck