Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Always include/show some entities? #22

Closed
jonohunt opened this issue Jul 31, 2019 · 6 comments
Closed

Always include/show some entities? #22

jonohunt opened this issue Jul 31, 2019 · 6 comments

Comments

@jonohunt
Copy link

jonohunt commented Jul 31, 2019

Is it possible to create a card with this that always shows some entities, along with filtering other entities?

I tried with this (and a few variations) but didn't work

  - type: custom:auto-entities
    show_empty: false
    card:
      type: entities
      title: "Office"
    - filter:
        include:
          - entity_id: scene.office_off
          - entity_id: switch.imac_power
          - entity_id: switch.synology_power
          - entity_id: script.reboot_ubuntu_server
    - filter:
        include:
          - entity: light.office_ceiling_light
          - entity: light.office_wall_lights
          - entity: light.office_lamp
          - type: divider  
          - entity: switch.office_fan
      exclude:
      - state: "off"
      - state: "unavailable"

Ideally I'd like to show cards for each room, and always show certain scenes, scripts etc. but hide other lights and switches. I could then activate scenes from that card, or activate a popup card from displayed scenes or scripts to turn on lights individually.

If not possible please consider adding it as a feature request in the future :)

@thomasloven
Copy link
Owner

thomasloven commented Aug 5, 2019

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...

@jonohunt
Copy link
Author

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?

@thomasloven
Copy link
Owner

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"

@Fredderic
Copy link

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.

@jonohunt
Copy link
Author

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.

@thomasloven
Copy link
Owner

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants