benct / lovelace-multiple-entity-row

Show multiple entity states and attributes on entity rows in Home Assistant's Lovelace UI
MIT License
809 stars 62 forks source link

Feature request: add condition element to hide entry based on templated condition #278

Open titiviking opened 1 year ago

titiviking commented 1 year ago

Allow for adding conditional element that displays or hides the complete multiple-entity-row from the dashboard based on the specified condition.

Currently the "Conditional Entity" type does not support attributes, but only entity states. A condition element in this multiple-entity-row would allow to also use templates to use attributes or more complex condition statements.

akomelj commented 1 year ago

A pull request with a narrower scope is in #280.

It does not implement templating (which would be better, of course) but allows for setting two additional options for hide_if configuration object:

The named entity's state or attribute will be evaluated against value/below/above condition when set.

UPDATED: Not to claim credit - hiding by attribute value has already been implemented; it was just not mentioned in the documentation.

Evililim commented 1 year ago

Can you make an exemple of hiding_by with an other entity state ? I can't find the correct YAML :

      - entity: switch.wake_on_lan
        name: Wake On Lan
        hide_if:
          - entity: sensor.my_pc_state
            state: on
akomelj commented 1 year ago

Please use the same keys (value, below, above) as with the original version. The new keys entity and attribute just set the pointer to the value that should be evaluated when hiding/showing the entity.

Example:

  - entity: sensor.fireplace_pump_speed
    name: Pump
    hide_if:
      entity: fan.fireplace_pump_fan
      value: "off"
Evililim commented 1 year ago

the hide_if don't work in my config... I will do some tests to understand...

      - entity: switch.wake_on_lan
        name: false
        show_icon: true
        icon: mdi:power
        hide_if:
          entity: sensor.my_pc_state
          value: 'on'
hmakmur commented 1 year ago

If this hide_if feature actually work, can someone add an example on the documentation? I have the same issue and can not get the correct yaml either. Thanks!

akomelj commented 1 year ago

Pull request is on a feature branch. You have to install the Javascript manually and provide a gzipped version too.

Something in the lines of (use correct path depending on your Home Assistant installation):

$ cd /config/www/community/lovelace-multiple-entity-row
$ curl -O https://raw.githubusercontent.com/akomelj/lovelace-multiple-entity-row/feature/hide-if-entity/multiple-entity-row.js
$ gzip -c multiple-entity-row.js > multiple-entity-row.js.gz

I have just run these commands, cleared the browser cache, reloaded the Lovelace and hide_if example from a few comments above works as intended.

$ ls -l multiple-entity-row.js multiple-entity-row.js.gz
-rw-r--r-- 1 andrej andrej 36073 jan 31 19:46 multiple-entity-row.js
-rw-r--r-- 1 andrej andrej 11906 jan 31 19:47 multiple-entity-row.js.gz

$ sha256sum multiple-entity-row.js multiple-entity-row.js.gz
1cba1ec64cdc4649d2b435e795676dea8b7996ed39b07f6c1b16d6a29a588ee8  multiple-entity-row.js
11440aade20aa6993e56f4842e39221fb27475d53bd8883de273a164ad29efd8  multiple-entity-row.js.gz
hmakmur commented 1 year ago

Thank you Andrej for your quick responds. I spend more time last night, followed your instructions but was unable to make it work. I may be doing this with incorrect syntax but I tried a few combinations and it still failed to hide. I was trying to hide the "distance" attribute from Espresense sensor but it did not work.

  - entity: sensor.ble_iphonedad
    secondary_info: last-updated
    type: custom:multiple-entity-row
    name: BLE_iPhoneDad
    entities:
      - attribute: distance
        unit: m
        hide_if:
          entity: sensor.ble_iphonedad
          value: "not_home"
TheNightmanX commented 5 months ago

Any progress here to get this feature request and the associated pull request done? I would need this feature, too, but am unable to contribute due to lack of programming skills.

miguelarios commented 3 months ago

Any progress on this? I really like this card, but want to hide the entire entity based on a state of the entity itself.