Giter VIP home page Giter VIP logo

Comments (6)

thomasloven avatar thomasloven commented on August 10, 2024

You could wrap auto-entities in another auto-entities

type: custom:auto-entities
filter:
  include:
    - dynamic things
  exclude:
    - filter out dynamic things
card:
  type: custom:auto-entities
  filter:
    include:
      - things to always include
  card:
    type: entities

Haven't tested it, but I think this should work...

from lovelace-auto-entities.

jonohunt avatar jonohunt commented on August 10, 2024

Sorry for the delay getting back to you on this! I'm on holiday at the moment and have limited internet access.

I've tried this, but it wouldn't work for me:

- type: custom:auto-entities
  show_empty: true
  card:
    type: entities
    title: "Testing"
    show_header_toggle: false
  filter:
    include:
      - entity_id: light.office_light
      - entity_id: light.landing_light
      - entity_id: light.hall_lamp
      - entity_id: light.outside_light
    exclude:
      - state: "off"
      - state: "unavailable"
    card:
      type: custom:auto-entities
      card:
        type: entities
      filter:
        include:
          - entity_id: light.desk_light

Also, I tried 'show_empty: true' in a normal auto-entities card (without wrapping multiple auto-entities) and it doesn't show the card until I turn on a light that's a listed entity.

Does that work OK for you?

from lovelace-auto-entities.

thomasloven avatar thomasloven commented on August 10, 2024

Take another look at that indentation, and the order of things.
You can also try the new not: filter.

filter:
  include:
    - entity_id: light.always_show_me
    - entity_id: light.show_me_sometimes
      not:
        - state: "off"
          state 2: "unavailable"

from lovelace-auto-entities.

Fredderic avatar Fredderic commented on August 10, 2024

I have a variant of this, where I want to sort a group, but then have certain entities pulled to the front. I do this by specifying those entities first, and then including the group, and finally setting the unique option.

But something else ocured to me along the way;

I wonder if it would make sense to add a filterset filter, which nests all the options relevant to building the final entities list. The rationale:

  • For the case of ensuring some items; the base filter set would include the entities you want to always show, and any overall sort order, and then a filterset with the regular stuff, with it's includes and excludes lists. You'd then merge the nested entities list back into the main list, omitting duplicates against the two already added, and finally sorting if desired.
  • For my case using this option, I'd include the two entities I want just the same, but then include a filterset with the group included, and a sort option. The result being the group nicely sorted, but after being folded back into the enclosing list, those specific items would now be "pulled to the front".

From a brief look at the code, it doesn't look like it'd take much to do that. The function that builds the entities list would take a config as parameter (the main card config itself in the base case), then when it hits a filterset filter, call itself recursively with that filters config, and finally merge the result back in as per regular group filters. The computed entities list would be returned, which the base case would then take as the cards final entities list.

from lovelace-auto-entities.

jonohunt avatar jonohunt commented on August 10, 2024

Take another look at that indentation, and the order of things.
You can also try the new not: filter.

filter:
  include:
    - entity_id: light.always_show_me
    - entity_id: light.show_me_sometimes
      not:
        - state: "off"
          state 2: "unavailable"

I've looked at the indentation, tried more variations etc. but still can't get it to work.

Not to worry, thanks anyway for trying.

from lovelace-auto-entities.

thomasloven avatar thomasloven commented on August 10, 2024

I've looked at the indentation, tried more variations etc. but still can't get it to work.

While the example I gave you was not correct (edited now), I think you could find the problem if we look at this together.

- type: custom:auto-entities # auto-entities starts here
| show_empty: true
| card: # card settings start here
| | type: entities
| | title: "Testing"
| | show_header_toggle: false
| # card settings end here
| filter: # filters start here
| | include: # filters -> include starts here
| | | - entity_id: light.office_light
| | | - entity_id: light.landing_light
| | | - entity_id: light.hall_lamp
| | |  - entity_id: light.outside_light
| | # filter -> include ends here
| | exclude: # filter -> exclude starts here
| | | - state: "off"
| | | - state: "unavailable"
| | # filter -> exclude ends here
| | card: # filter -> card (what?) starts here
| | | type: custom:auto-entities
| | | card: # etc...
| | | | type: entities
| | | filter:
| | | | include:
| | | | | - entity_id: light.desk_light
| | # filter -> card (???) ends here
| # filter settings end here
# auto-entities ends here

from lovelace-auto-entities.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.