Closed chemelli74 closed 2 years ago
You may use several filters for one list:
- type: custom:auto-entities
card:
type: entities
filter:
include:
- domain: sensor
attributes:
device_class: temperature
sort:
count: 3
- domain: sensor
attributes:
device_class: humidity
sort:
count: 3
You particular case may be rewritten as:
- type: custom:auto-entities
card:
type: entities
filter:
include:
- domain: binary_sensor
state: 'on'
exclude:
- attributes:
device_class: connectivity
- attributes:
device_class: plug
You particular case may be rewritten as:
- type: custom:auto-entities card: type: entities filter: include: - domain: binary_sensor state: 'on' exclude: - attributes: device_class: connectivity - attributes: device_class: plug
I would like to exclude only when "on" and not when "off" ;-) This is why I need to filter inside the include and not in the exclude block.
Simone
would like to exclude only when "on" and not when "off" ;-)
I think that my solution does what you need.
would like to exclude only when "on" and not when "off" ;-)
I think that my solution does what you need.
Same card, 2 lists:
I cannot see how your solution can achive this goal. Thx,
Simone
cannot see how your solution can achive this goal
Have you tested my solution?
cannot see how your solution can achive this goal
Have you tested my solution?
I did, but just reading the code I can see that there is no binary_sensor
on off
mode, which is one of the request.
Simone
I did
Did you get correct results in the output?
It is strange that I am trying to convince you to accept the solution.
I did
Did you get correct results in the output?
No, otherwise I would have a solution ;-)
It is strange that I am trying to convince you to accept the solution.
It is, but I think you didn't get the point.
Let's try to make a full code sample:
type: custom:auto-entities
card:
type: entities
title: Active problems
show_header_toggle: false
state_color: true
filter:
include:
- domain: binary_sensor
state: 'on'
not:
attributes:
device_class: connectivity
- domain: binary_sensor
state: 'off'
attributes:
device_class: connectivity
options:
style: |
:host {
--paper-item-icon-color: var(--paper-item-icon-active-color)
- domain: binary_sensor
state: 'off'
attributes:
device_class: plug
options:
style: |
:host {
--paper-item-icon-color: var(--paper-item-icon-active-color)
sort:
method: state
reverse: true
numeric: true
The above is nearly working; still need to exclude binary_sensor
with state off
and device_class plug
Simone
Your initial intention was this:
Means - all binary_sensors which are: state = ON device_class = not connectivity and not plug
Let's check this example.
You need only yellow entities, right?
If so, this code gives the same:
type: custom:auto-entities
card:
type: entities
title: not
filter:
include:
- domain: binary_sensor
state: 'on'
exclude:
- attributes:
device_class: connectivity
- attributes:
device_class: problem
- attributes:
device_class: battery_charging
sort:
method: attribute
attribute: device_class
Note that here I excluded connectivity
, problem
& battery_charging
just for example (to make a list shorter); I do not have a "plug" sensor. As a result only "none" & "moving" sensors are displayed. All displayed sensors are ON.
Regarding your code - there are some small errors (not related to the topic):
1) show_header_toggle: false
- not needed, the binary_sensor
do not have a toggle.
2) numeric: true
- not needed for binary_sensor
.
3) Closing brackets for card-mod are missing:
style: |
:host {
--paper-item-icon-color: var(--paper-item-icon-active-color)
I need also the blue one, otherwise is was so easy that I would not open a issue ;-)
Simone
I need also the blue one,
But this is not what was described first:
Initially you asked for a different case, I gave you a code.
OK, here is a code for the new case: 1) Only ON except connectivity & plug. 2) Only OFF which are connectivity or plug.
type: custom:auto-entities
card:
type: entities
filter:
include:
- domain: binary_sensor
state: 'on'
- domain: binary_sensor
state: 'off'
attributes:
device_class: connectivity
- domain: binary_sensor
state: 'off'
attributes:
device_class: plug
exclude:
- domain: binary_sensor
state: 'on'
attributes:
device_class: connectivity
- domain: binary_sensor
state: 'on'
attributes:
device_class: plug
I need also the blue one,
But this is not what was described first: [...] Initially you asked for a different case, I gave you a code.
I better explained in a second comment ;-)
OK, here is a code for the new case:
- Only ON except connectivity & plug.
- Only OFF which are connectivity or plug.
Thx, will test it asap.
Does include /exclude order makes a difference ? I wrote it with first esclude and then include and was not working.
Simone
I think that order SHOULD not matter
Thx for your help
Simone
Is the code working?
Is the code working?
Yes it is, this is why i closed the issue.
Simone
Is there a way exclude/include more than 1 attribute ? Like:
If not, can you consider adding it as a feature ?
Thx in advance,
Simone