lovelace-multiple-entity-row icon indicating copy to clipboard operation
lovelace-multiple-entity-row copied to clipboard

FR: Substitution text for a state

Open ildar170975 opened this issue 2 years ago • 3 comments

It could be great to have a possibility to substitute a sensor's state value by some user-defined text. Particularly it could be useful to write smth like "No data" instead of "Unavailable" - if the sensor is unavailable:

  - type: entities
    entities:
      - type: custom:multiple-entity-row
        entity: sun.sun
        entities:
          - entity: sensor.service_unavailable_value
        show_state: false

image

Another example is to write "cool", "hot", "warm" instead of writing an actual temperature.

To implement this functionality, I propose to add a new option - substitute_if. This option should be available:

  • for the main entity;
  • for each additional entities.

The option should be an object like a "hide_if" option. Below there is a draft of the paragraph from ReadMe:

### Substitution

The `substitute_if` option can be used to substitute an entity's state if its state or attribute value matches the specified criteria.
It can be used directly with a string, number or boolean value (i.e. `substitute_if: 'off'`), as a list with several values,
or as an object with one or more of the options listed below.

| Name    | Type     | Description                                                         |
| ------- | -------- | ------------------------------------------------------------------- |
| text    | string   | Substitution text                                                   |
| above   | number   | Substitute if entity _number_ value is above the specified value    |
| below   | number   | Substitute if entity _number_ value is below the specified value    |
| value   | list/any | Substitute if value matches specified value or any value in a list  |

ildar170975 avatar Apr 12 '22 00:04 ildar170975

+1

I was looking for a way to substitute user-friendly words to state values, with lists of corresponding values. Basic example: I have a sensor for "internet connected" which is a boolean and appears as an additional entity with the value 0 or 1. I would like to substitute something like "connected" / "disconnected" instead, and I think your proposal would do just that.

Gyosa3 avatar May 18 '22 10:05 Gyosa3

+1

I want to display my covers state as "open" or "close" rather than 100 or 0.

jaegerschnitzel avatar Jul 10 '22 06:07 jaegerschnitzel

+1 I want to see the petrol station is opened/closed instead of on/off.

The entity has the state on/off, but the show_as option is set to door. That's why the entity state in default lovelace cards is already shown correctly. But multiple-entity-row unfortunately does not make use of show_as option.

Fjury avatar Feb 25 '24 00:02 Fjury