Custom:button-card - using condtional states from multiple entities (AND OR) to determine value

I have a button-card that works as an indicator, lighting up if a group light.users_room_lights is on. Independent of this, I have an input_boolean that is on when the lights have been manually switched on, rather than by an automation or trigger, etc.

Sometimes I want to know if the lights are on because they were turned on manually or because they reacted to motion. Reason being, the latter might mean they’re on a timer to switch off or some other condition.

When using a button-card and checking if light.users_room_lights is on, I also want to check if input_boolean.users_rl_manual is on. If both are, I will color the icon an appropriate color to indicate this that’s different than if light is off, or if input_boolean is off.

This is my attempt and isn’t working as the values, outside of ‘off’ are never matched:

type: custom:button-card
entity: light.users_room_lights
color_type: icon
value_template: >-
    {% if is_state('light.users_room_lights', 'on') &&
    is_state('input_boolean.users_rl_manual', 'off') %}
        'auto'
    {% endif %}
icon: mdi:room
state:
  - value: 'off'
    styles:
      card:
        - filter: opacity(20%)
      icon:
        - filter: grayscale(100%)
 - value: 'auto'
    color_type: card
    styles:
      icon:
        - filter: opacity(100%)
        - color: rgb(150,255,0)
 - value: 'manual'
    color_type: card
    styles:
      icon:
        - filter: opacity(100%)
        - color: rgb(255,170,0)

Solved this in the end.

I don’t think there’s a built-in way of doing this so I turned to config-template-card, figuring it might work somehow. At first I was trying to dynamically switch entities and getting nowhere but realised the solution was simpler:

Just make a conditional value for the ‘color’ property that can check whatever entit(y/ies) states or attributes it needs and deliver whatever rgb string in return as a result, based on what it matches.

e.g:

color: ${MANUAL_TRIGGER === 'on' ? 'rgb(255, 0, 0)' : 'rgb(0,255,0)'}

I’m aware this is just checking the state/attribute of a single condition, not AND/OR like in the original question, but it can easily be adapted to check AND/OR. For my own purposes, I realised that checking were the lights manually triggered via the boolean was enough to know the lights were on too.

I don’t understand the solution. Can you post an example like the one you were trying to solve, using two entities?

You can’t use the typical Jinga2 templating engine with BUTTON-CARD. You have to use Java. Have a look at my situation from a similar post. I was also confused…Help with button-card with conditions using Java