OR + AND conditions for Conditional Card

While OR future is not yet available to condition cards, there is a work around to get this functionality :partying_face: Basically all you need to do is to make a binary sensor by putting the below code in your configuration.yaml file

template:		 
  - binary_sensor:
      - name: trash_collection
        state: >
          {{ is_state('sensor.trash_collection', '2')
             or is_state('sensor.recycling_collection', '2') }}

After that you will be able to use binary sensor to in conditional card to make it appear/disappear. Below will be your conditional card.

type: conditional
conditions:
  - entity: binary_sensor.trash_collection
    state_not: '2'
card:
  color: var(--primary-color)
  color_type: label-card
  name: Trash/Recycling
  type: custom:button-card

Your solution is great, but it was already mentioned as a solution in the very beginning of this thread two years ago.

I want to highlight that this thread is about making it clear to HA devs that we would appreciate having native support for more complex conditionals without requiring setting up a binary template sensor.

8 Likes

Same use-case here.

Check out the response from @ASNNetworks above. You just have to set it to state_not. Everything is working perfectly for me now!

Still not enough I think. I want to display a card if any one of my alerts is not idle (can also be on or off):
( x != idle OR y != idle OR z != idle )
If I only can use AND instead of OR I would need to negate the whole expression:
!( x = idle AND y = idle AND z = idle )
But the condition card doesn’t support to negate the whole expression.

+1 here.
I just went to set up a conditional card with an OR condition, and found out it wasn’t available.
I have no problems doing a workaround, but this should be something native on the card.

2 Likes

Five years on and still no OR? Anyone know of a workaround?

Try with lovelace-state-switch from HACS

+1 - simple use case: Include a testing flag with every conditional, so that I can easily turn on all conditionals. I am using a whole lot of conditional to only show problems/infos/warnings and this would be helpful for testing

+1 for the or feature.

I’ve tried all variations so far mentioned above.

I have multiple entities I want to monitor and jus have one conditional card if any are not what they should be. Some entities would normally show connected, on, available or whatever else and the opposite when something is wrong.

3 years + on. Any chance this could be addressed :slight_smile:

calculating 2023 - 2019 = 5. okay. that is some creative expression. 4 full years until now.

but i need that feature too.

Weather warning and advance weather warning should be all in one card. but i cant

2 Likes

+1

This would come in handy right now.

oh yes, this function would be really necessary.

Yes please!

I solved this using Switch helper “input_boolean” and automation script with various conditions switching the helper. Helper can be used as condition in Conditional Card


I think template support for the condition in the card would be the ultimate solution. Any complex criteria can be defined then.

Thanks for pointing that card, going to give that a try :+1:

You can define any complex criteria using automation script - any variation of condition. Input_boolean is just middle man to show or hide the card. And you still can use entity filter card. In my use I am able to set to show card in case of any water sensor is not “off” and only “not_off” sensors are shown. So it includes also “unavailable”, “on”, “unknown” situations.

Yes I can confirm this card basically is what the condition card should be :blush:

Not sure why nobody mentioned it before. Easiest workaround is to define a helper with “group”.
Within the group settings you have the option to set “all entities” (yes/no). With this option you can model the OR condition. All you need to do then is to add the helper as a condition and you got the OR modelled.

However: still +1 obviously, as every work around is just not the same as the actual work :slight_smile: