Where can I put device serial numbers and locations?

Hesitant to open this thread since it’s hugely bikesheddy and I feel like there might be a 4000-reply thread that I can’t find… but how should I name/label devices and entities that do multiple things? I’m a bit tired of seeing this on my dashboards:

I just want shower, toilet, sink - everything else is redundant.

I could override the names just for the dashboard, which I’d have to do using a template filter since I’m using auto-entities, and thanks to this post I know I could do something like:

filter:
  template: >-
    {% for state in states.sensor -%}
      {%- if area_id(state.entity_id) == "bathroom_2" and state.attributes.device_class == "temperature" -%}
        {{
          {
            'entity': state.entity_id,
            'name': state.attributes.friendly_name | regex_replace(find='Bathroom 2\s*', replace='') | regex_replace(find=' motion sensor temperature', replace='')
          }
        }},
      {%- endif -%}
    {%- endfor %}

But this is pretty gnarly / incredibly fragile. We can improve on this using customize.yaml to add custom attributes to entities:

sensor.temp_83f8_bathroom_2_toilet:
  location: Toilet
sensor.temp_e627_bathroom_2_shower:
  location: Shower

Then use that in the auto-entities template:

          {
            'entity': state.entity_id,
            'name': state.attributes.location or state.attributes.friendly_name
          }

Now I can have what I want:

Shower 25 C
Toilet 25 C
Sink 25 C

But doing this custom attributes thing seems to be kind of deprecated (?) in HA? And this “location” specifier is really a property of the device, not the entity. The hardware serial number is another thing that belongs to the device, not the entity, and neither of these are concepts recognised as device properties by Home Assistant.

Finally, this solution also means I now have the location in the name of the device (Bathroom 2 shower motion), the entity ID of each entity (sensor.temp_e627_bathroom_2_shower), and also in a customize.yaml override for each entity, which seems like a lot of maintenance overhead and foot-gun potential if I move the device somewhere else.

Is there somewhere I can attach “Shower” to the device just ONCE, and then use that piece of data as a label for the device’s entities in some contexts?

The trouble is, devices don’t really exist in HA except as containers to put entities in. Entities are not attributes of devices - a lot of entities don’t belong to devices.

Efforts to make the system more user friendly over the past year or so have led to a lot of emphasis on devices in the GUI but it’s very misleading.

For serial numbers, you may be able to find something in HACS but integrations are mostly rather specialised - for example Battery Notes stores details of battery type and date last changed.

1 Like

Don’t areas fit your bill?
Just specify the area where your device resides in the GUI, then →

Areas don’t really work because I don’t think you can have areas that are children of other areas, and I’m using areas already for rooms, which is I think the right use of them.

You can just change the entity IDs, of course - although this can turn into a can of worms if you’ve used them in a lot of places.