WTH can't I attach a template sensor to a particular device

I often create derivative template sensors from other sensors created by particular integrations/devices. It would be nice to be able to declare the template to be part of the device, so that it could appear on the device’s page (e.g. under a separate template entities categories).

Or devices could automatically show all the template sensors which depend on the device’s entities.

It actually attaches itself to a device automatically, code reference:

Please note, devices are only a feature that can be used for things managed through the UI; there is no device context or possibility available when creating YAML helpers.

…/Frenck

1 Like

i can create device referneces in yaml, when i create mqtt entities, why the heck isn’t that possible when creating template entities in yaml?

For template helper entities created through the UI, you can associate them with a device through the template options.
I’ve been migrating some of my template sensors that were defined in YML to be configured through the UI (If they don’t use properties that are only definable through YML…)

Migration is not the problem. Problematic might be a situation if one wants to maintain his/her configuration organized in packages. Having some sensors in packages while others in UI isn’t a really good idea.

I’m not sure you still need a solution (for yaml created templates).
Since I’m on the same board, I was desperately looking for su a way, I found a custom integration that can do that. It’s still not the same as managing entities in yaml. But it’s better than nothing in some cases

It looks it provides lot of options to manipulate devices.
One of them is assigning any entity to a device. I can confirm I was able to assign the Yaml-created energy template sensor to an existing device.

PS. I hope it will not discourage possible developers to add native way to do so.

That looks interesting, but am I blind or is there no documentation whatsoever on how to use it? The only instructions there is only tells you how to install it. I’ve done that but there is no new Device Tools anywhere within HASS as far as I can find…

It’s true. I didn’t find it either.
But the usage is simple. install it, then in Settings/ Devices&Services use add integration button and select Device Tools.
After that, the GUI will guide you

I’m also using this custom_component.

so I can guide you a bit:

If you have a couple of sensors, for example, created via Modbus integration - or templates, you can create a new device.

If you want to modify an existing device, select the device name you want to modify…

Within the device, you can then assign the entities you want to.
Go to “Configure” - and there, you can add all the entities to your “new” or “modified” device, you want…

You could also merge two different devices together with this, if you want to… :slight_smile: