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?