thomasloven / lovelace-auto-entities

🔹Automatically populate the entities-list of lovelace cards
MIT License
1.18k stars 111 forks source link

Filter uses or instead of and #421

Open AnderssonPeter opened 5 months ago

AnderssonPeter commented 5 months ago

According to the documentation if I specify multiple filters the card should use and between them so

filter:
  include:
    - domain: plant
    - area: Stuga

And

filter:
  include:
    - and:
      - domain: plant
      - area: Stuga

Should be the same thing? But the first code uses or instead of and?

Is the documentation wrong or am I doing something wrong?

outdooracorn commented 5 months ago

The options inside a filter use AND, multiple different filters use OR. There is a good example of this in the repeating options section of the docs.

This includes entities where the domain is plant OR area is Stuga:

filter:
  include:
    - domain: plant
    - area: Stuga

This includes entities where the domain is plant AND area is Stuga:

filter:
  include:
    - domain: plant
      area: Stuga
erkr commented 3 months ago

@outdooracorn or others :-) I tried to include powercalc entities in two areas like this:

filter:
  include:
    - integration: powercalc
      area: 
        - cellar
        - attic

Based on the example above, I expect to have the areas evaluated as an OR, but is seems to be an AND relation?! The next example works, selecting powercalc entities in area cellar or attic, but is a little silly:

filter:
  include:
    - integration: powercalc
      area: cellar
    - integration: powercalc
      area: attic
outdooracorn commented 3 months ago

I don't think you can provide a list to area, but you might be able use the or: special option (untested):

filter:
  include:
    - integration: powercalc
      or:
        - area: cellar
        - area: attic 
erkr commented 3 months ago

I don't think you can provide a list to area, but you might be able use the or: special option (untested):


filter:

  include:

    - integration: powercalc

      or:

        - area: cellar

        - area: attic 

Nice! That works😊 I tried to use OR but missed this structure. Thanks for helping out. Eric

erkr commented 3 months ago

@thomasloven Maybe a nice idea to include the two examples how to use OR in the readme. Thanks for the great card!!! Eric