home-assistant / architecture

Repo to discuss Home Assistant architecture
315 stars 99 forks source link

Get device details in templates #416

Closed dwradcliffe closed 1 year ago

dwradcliffe commented 4 years ago

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

balloob commented 4 years ago

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

dwradcliffe commented 4 years ago

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

frenck commented 1 year ago

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