Add Template Sensors to Device page

Also looking for the same thing. I have a Z-Wave device with an entity that occasionally sends incorrect/erroneous values. I can make a template sensor to filter the outliers, but it would be nice to associate this sensor with the device.

I would love to see this functionality implemented. I have a lot of sensors that require some sort of manipulation (e.g. filtering for temperature, power, humidity), or other manipulation (integration of power to get energy for the energy dashboard).

This means I have all these nice devices with their overview pages, and then a whole bunch of entities which a derived from those devices but not linked to them.

I think it would make a lot of sense if we could link entities to devices.

5 Likes

Hi

I need this fonctionality too, for linking template sensors, and helper to existing device.

For example :
I made an automation to shutdown a switch if power is less that a numerical values since a delay.
It would be nice in in device pannel, i see the automation, the power values, and the delay value

+1. I am often needing to clean up values (especially cumulative energy from zwave devices). So a way to associate template sensors and also filter sensors with a device would be extremely useful.

+1, being able to specify device_id in template sensors would be great

1 Like

I believe this may be possible if the derived sensor entity is created using MQTT, but seemingly not when it is a template sensor

I have so many template sensors that simply exist to address dealing with ‘unknown’ values or more often, simply rounding decimals off temperatures to prevent database bloat and IO frequency

Being able to associate them with a device would be great, however for me, the best solution (in most cases) would be to not require so many template sensors, but to define a templated attribute for the underlying source entity that controlled the precision I actually care about having stored in the database as well as how significant the change should be for me to even consider recording it

1 Like

Giving this a bump because it seems HA now has the capability to do this internally, so I feel like it isn’t a stretch to ask for this to be exposed to the user base.

For example, when you create a reimann sum integration sensor via the helper page, it adds an attribute called “source” to the entity which points to an entity_id. The device page for that entity now shows both the original entities, as well as the newly linked reimann sum entity.

It also adds “Reimann Sum Integration” to the devices integrations list.

I was hoping this meant that I could now manually specify a “source” attribute in order to manually link it to the device, in the same way it seems to handle it internally, however, after testing it out, it does not work.

In my case, this would be very useful because I take a lot of time to calibrate all of my temperature entities. I create a template sensor to mimic the original temperature entity, but then it adjusts it using a +/- value. Unfortunately, this occasionally makes using the HA UI a bit annoying because these template sensors don’t have the option to jump to the device page.

1 Like

+1 => Being able to specify device_id in template sensors would be great !

+1. It’s starting to be ALOT of template entities in my config after a couple of years. It would be great to be able to organize them with self-defined devices but also the possibility to link them to existing devices.

Template devices would be nice, to mix and match entities with

1 Like

+1 searched for: “homeassistant template device” - found this threat

2 Likes

Why don’t you add the Template-sensor to the Helpers-Page? My utility meter are all added to the respective devices. (I am using HomeAssistant in a docker container. Being able to add template sensors as a ‘helper’ would allow me to get rid of VSCode…)

There’s a Template helper in 2023.9.0 that allows you to create a Template Sensor via the UI.

Oh, my docker container is still in version 2023.8.2. Looking forward to the upgrade!

I think we are (mostly) hoping to have this facilitated in YAML and the UI.

If I create a template sensor in the UI (or in YAML)

       e.g.  'sensor.t_motion_shower_02_battery_is_available'  

       based on a single 'sensor.motion_shower_02_battery' 

my new template sensor does not appear on the device page for the device to which ‘sensor.motion_shower_02_battery’ belongs…

It gets its own page in the UI, but it is associated (linked to) the template integration

I would like to have some way of getting it to appear as an additional sensor on this device page (the device page to which the source sensor belongs)

1 Like

+1 same, i’m relatively new to HA and found this thread while searching how to associate a template sensor to a parent device. Same situation as someone else where zwave blinds state is unknown and i created a template sensor to be based off a 0-100 value that represents the tilt.

All of this really should be possible. Manually defined MQTT entities have been able to do this for a while now.

Exactly. Much like manually defined MQTT entities, one should be able to define the device to which a template entity belongs.

Here is an example of something that I just created:

mqtt:
  climate:
    - device:
        identifiers: ["house.air_conditioner"]
        name: Air Conditioner
        manufacturer: Daikin Industries, Ltd.
        model: FTXA35BS
      name: Thermostat
      ... # Other configurations here
 
template:
  - sensor:
      - name: "Air Conditioner Current Temperature"
        state: "{{ state_attr('climate.air_conditioner', 'current_temperature') }}"
        unit_of_measurement: "°C"
        device_class: "temperature"

        # This is the feature request: the ability to set the entity's device.
        # As of now, this will not work (do not try at home).
        device:
          identifiers: ["house.air_conditioner"]

This would allow for adding template entities to devices, grouping them all together.

The same syntax proposed for the MQTT integration could be used:

2 Likes

+1

Being able to associate entities with devices in yaml would be very useful. I have an immediate need to do this with history_stats sensors and trigger-based template sensors & binary_sensors.

Also in need of this, I bought some cheap temperature and humidity sensors that work mostly OK but they clearly have an offset compared to other better quality sensors. I’d like to hide the sensor’s “raw” value and expose the templated sensor as the visible entity.