custom-cards / flex-table-card

Highly Flexible Lovelace Card - arbitrary contents/columns/rows, regex matched, perfect to show appdaemon created content and anything breaking out of the entity_id + attributes concept
GNU General Public License v3.0
198 stars 23 forks source link

Unused entities does not work together with this card #5

Closed sjabby closed 4 years ago

sjabby commented 5 years ago

With this config added:

- type: 'custom:flex-table-card'
    sort_by: battery_level+
    strict: true
    title: Battery Levels
    entities:
      exclude:
        - unknown_device
      include: zwave.*
    columns:
      - attr: node_id
        name: NodeID
      - name: Name
        prop: name
      - attr: battery_level
        name: Battery Level (%)

The Unused Entities view in lovelace does not work. (page is just blank) Gives this error in console:

c51eb71de175ca5b2bc6.chunk.js:1 Uncaught (in promise) TypeError: obj.entities.forEach is not a function
    at addEntities (c51eb71de175ca5b2bc6.chunk.js:1)
    at obj.cards.forEach.card (c51eb71de175ca5b2bc6.chunk.js:1)
    at Array.forEach (<anonymous>)
    at addEntities (c51eb71de175ca5b2bc6.chunk.js:1)
    at config.views.forEach.view (c51eb71de175ca5b2bc6.chunk.js:1)
    at Array.forEach (<anonymous>)
    at computeUsedEntities (c51eb71de175ca5b2bc6.chunk.js:1)
    at computeUnusedEntities (c51eb71de175ca5b2bc6.chunk.js:1)
    at HTMLElement._createElement (c51eb71de175ca5b2bc6.chunk.js:12)
    at HTMLElement.set hass [as hass] (c51eb71de175ca5b2bc6.chunk.js:1)
ggi3201 commented 5 years ago

Same error here, do you need more info ?

daringer commented 5 years ago

well that's really a tricky one, would need to find out how to avoid "marking" entities as used. because it looks like the "unused entity" thingy within HA is applying some magic to find out if a certain entity was "used". flex-table "uses" all for filtering....

despite that the fact that the unused entity is not working without any non-used entities seems like a HA bug to me

JamieP83 commented 5 years ago

Got the same issue I think

Using this to display train times and towards the end of the day, when there are no more trains and so no data for the table, everything goes blank as the data set is empty! I wonder if a way to end something to my list potentially that forces a “no more today” value so at least something for this table to use?

daringer commented 5 years ago

Your issue is likely not related to this discussion, you are looking for an empty data behavior, right? Not yet available, added an issue #12 to remind me the next time I am looking into it.

JamieP83 commented 5 years ago

sorry, i just confirmed, my issue is the same as this one. when i use the following on a page, i lose the "unsued entitles" option.

  - type: 'custom:flex-table-card'
    title: xxx to xxx Trains
    max_rows: 10
    entities:
      exclude: null
      include: sensor.next_train_to_xxx
    columns:
      - align: center
        attr_as_list: next_trains
        modify: x.status
        name: status
      - align: center
        attr_as_list: next_trains
        modify: x.scheduled
        name: scheduled
      - align: center
        attr_as_list: next_trains
        modify: x.estimated
        name: estimated
      - align: center
        attr_as_list: next_trains
        modify: x.platform
        name: platform
      - align: center
        attr_as_list: next_trains
        modify: x.destination_name
        name: destination
daringer commented 4 years ago

was digging into that due to #25 + #27 and found out that lovelace does the unused entities computation (amongs other options) by simply iterating over .entities of each card, thus assuming it is an Array. The very same reason this issue was opened. So this PR solves the issue. Means I would expect this issue here to be fixed with the next home-assistant/lovelace release.

On the other side the entities used by flex-table-card will then not be accounted as "used", this is by-design also not possible as far as I understand: lovelace is parsing the configuration as of my understanding. Will have to do more tests, but at least overall the unused entities view will work again soon!

daringer commented 4 years ago

further discussions confirmed the statements above and I've found a similar issue here . So looks like this is not possible by-design, which is understandable as this would lead to the evaluation of all lovelace cards in order to determine the unused entities, which is quite inefficient if not waste of compute time. means: wont'fix ...