Is there a chance to overwrite attribute value names?

I have a sensor entity reporting, whether something is true or false. Everything works just fine, but in the UI, true/false looks way to artificial.
Is there a way, without creating even more entities/sensors (my DB is already too big) to simply overwrite what I get to see within the UI cards?

E.g. I would simple like to see yes/no, above/below, present/absent, … instead of true/false.

Use device classes:

Do you have an example, how I can achieve what I need?

Currently customizing the entity means for me, I can rename e.g. attributes, meaning, if the sensor reports present=true, then I could go there and change it from ‘present’ to ‘The cat is in the house’.
But it looks not that good, if this statement is then followed by a ‘true’. I would like to change this ‘true’ to ‘Yes, it is.’.

To take an example:

This switch should not be on/off. If should be active/inactive. Can this be achieved?

device_class: presence doesn’t work for you?

Nope, not yet. I didn’t find an example helping me just yet.

I can customize friendly_names, but not the values I get returned.

You’ll have to make a template sensor for that. Here’s an example using immediate if (iif) and guessing the entity_id of your cat sensor:

template:
  - sensor:
      - name: "The cat is in the house"
        icon: mdi:cat
        state: >
          {{ iif(is_state('binary_sensor.cat_presence', 'on'),
                 'Yes, it is.',
                 'No, it is not.') }}

A very legitimate concern.

If you have to create a template, I’d recommend excluding the original sensor entity from Recorder. It takes a lot of discipline to consider the impact on the Recorder database every time you add or change an entity. But it’s totally worth it to keep your DB size, and the load on your system, manageable.

Is there a nice way to get a list of all entities making it easy to create a list of sensors to be excluded? I guess for me it would make sense to (semi)automatically exclude all helpers and so many other sensors from being made persistent for ever. So Im not talking about the dev tools - just thinking about a list to copy and paste a group of entities to add them to the config xml.

In the template editor:

{{ states|map(attribute='entity_id')|list|join('\n') }}

image

2 Likes

Brilliant!

I’m about to exclude more than 750 entities from ending up in a database forever. What sense does it make to store whether there is an update available for the zigbee addon or not? And I do not even get a hint that HA is going to blow up my database with such useless information.

Again thanks @Troon for this line. It should be a mandatory thing for everyone starting with HA.

1 Like

I totally agree it should be mandatory training (e.g.; in the Getting Started docs) that every entity needs to be considered for exclusion at the time it’s added. I think this should be part of adding any new device, just as we’re now prompted to add new devices to an area. As you say, the new user gets no hint that a problem is developing in the Recorder database until it’s too late.

I also think the keep_days parameter should be set for each entity, not be a one-size-fits-all value. Some things are handy to look back on for a couple of days. Others need to be kept a bit longer. Still more should be kept forever, or at least a very long time.

1 Like

It somehow works for me. Just if I create a new sensor entity and prevent it from being recorded, I as well loose the information for the current day or week when clicking on the item in the UI.

Summary: I’m doing this, because the answer to Troon’s question, whether the cat is at home or not, should not be ‘false’ in my dashboard, but ‘No, it is not’.
When I now click on this object in the dashboard, I can normally see the history for the last couple hours, so I could see, when the cat was home during the day. This is not possible, if I turn recording for the artificially created entity off. Yes, I could search for the original entity, but if you create artificial objects I bet you forget about the name of the original one, so you have to go into your config files or come up with your own naming conventions or … it’s just inconvenient.

From my point of view, it would be good if we would have two changes. First in the UI we should be able to overwrite the values we see, just to avoid the hassle creating new objects. Maybe even only in the card we are using in the dashboard, maybe globally. Secondly it would be good to explicitly activate recording for each entity instead of having everything stored for ever automatically.

Would that make sense?

Definitely! I have just added two Synology drives and directly see 90 new entities. Currently I am only interested in a couple of HDD temperature values, so again a lot to be excluded manually to the config file.