Conditional inside entities card

I’ve never used the conditional so much appreciative if someone could lend a hand.

I have the below. What I’m trying to do is only show entity: input_text.lockcode_status if it’s value is not blank. I’m not sure if what I have for row is correct. Error I receive is Conditions should be in an array.

- type: entities
          entities:
            - entity: input_text.lockcode_code
            - entity: input_select.lockcode_selectuser
            - entity: input_select.lockcode_slot
            - type: conditional
              conditions:
                entity: input_text.lockcode_status
                state_not: ""
              row: input_text.lockcode_status
            - type: "custom:button-card"
              entity: input_boolean.lockcode_submitcode
              show_state: false
              show_icon: false
              show_label: true 
              label: >
                [[[
                  if (states['input_text.lockcode_status'].state != "")
                  return "Reset";
                  else
                  return "Submit";
                ]]]
              show_name: false

I just had a quick look at one of my conditional cards and the difference I see is that mine is more like this:

- type: entities
          entities:
            - entity: input_text.lockcode_code
            - entity: input_select.lockcode_selectuser
            - entity: input_select.lockcode_slot
            - type: conditional
              conditions:
                - entity: input_text.lockcode_status
                  state_not: ""
              row: input_text.lockcode_status
            - type: "custom:button-card"
              entity: input_boolean.lockcode_submitcode
              show_state: false
              show_icon: false
              show_label: true 
              label: >
                [[[
                  if (states['input_text.lockcode_status'].state != "")
                  return "Reset";
                  else
                  return "Submit";
                ]]]
              show_name: false

which should fix the ‘array’ issue I think

1 Like

Now I get the below. Must be a way to check for nulls.

Conditions are invalid.
type: conditional
conditions:
  - entity: input_text.lockcode_status
    state_not: ''
row: input_text.lockcode_status

Ok, found a thread where someone mentioned using none which seems to get pass that error but now it’s saying. Wondering if this is because of what I pass in for row?

Config is not an object
input_text.lockcode_status

I haven’t used the ‘row’ parameter before. Where are you getting that from? It’s not a valid entry for a conditional card

Look at the entities card and scroll down to the conditional section. @sparkydave This is not the same as the conditional card. This is the conditional row that you can do inside the entities card.

Ah, my bad. I’ll have a play with it and see what I can come up with. Have you tried using a different entity for the ‘row’ element?

EDIT: it really sucks that there aren’t any examples in the docs for this as I can’t get it to work either. I get the some error ‘Config is not an object’…so what can we use as the ‘row’?

EDIT 2: figured it out with some searching on this forum, this this:

type: conditional
conditions:
  - entity: input_text.lockcode_status
    state_not: ''
row: 
  entity: input_text.lockcode_status
1 Like

@sparkydave Thanks for the assist brother. I was actually trying different configs since it states row accepts map and not list but I was adding map entity without the word entity.

I will look into updating the doc with an example for others so we can at least give back from what we learn.

Yeah, the docs certainly aren’t intuitive in many places. Unfortunately unless you know the answer you can’t send in a PR for the doc change. Catch 22. That will be good if you put one in for this, otherwise I can. Either way, cheers.

I’m still going to have to work on the null value as it looks like others have ran into issues getting conditional to check for nulls.

My example with command remote broadlink if TV is on:

type: entities
entities:
  - type: button
    icon: 'mdi:power'
    name: TV
    action_name: Ligar/Desligar
    tap_action:
      action: call-service
      service: remote.send_command
      service_data:
        entity_id: remote.broadlink_sala_remote
        command: >-
          b64:JgBGAJKVDzsQOhA6EBUQFRAVERQRFBE5EDoSOBEUERQRFBAVEBURFBE5ERQRFBAVERQRFBEUETkRFBE5ETkRORE5EToQOg8ADQUAAA==
  - type: button
    icon: 'mdi:video-input-hdmi'
    name: Box
    action_name: Ligar BOX
    tap_action:
      action: call-service
      service: remote.send_command
      service_data:
        entity_id: remote.broadlink_sala_remote
        command: >-
          b64:JgBIAAABK5IUERM3EjcSNxITEjcTNhM2EzYTNhQ2EhMWDxITEhIUNRM3EjcSFBISEhMSExISExIUNRM3ETgSNxM2EzYTEhM3EgANBQ==
  - type: conditional
    conditions:
      - entity: media_player.samsung_ue55mu6205
        state: 'on'
    row:
      entity: media_player.samsung_ue55mu6205
      type: button
      icon: 'mdi:menu'
      name: BOX
      action_name: Menu BOX
      tap_action:
        action: call-service
        service: remote.send_command
        service_data:
          entity_id: remote.broadlink_sala_remote
          command: >-
            b64:JgBQAAABK5IUERI3FDUTNhMSEzYTNhM3FDUSNxU0ExITExETEhMSNxM2EzYTEhMTERMUERYPEhMSNxM2FDUTNhM2EzYSFBI3FAAEngABKUoVAA0F
  - type: conditional
    conditions:
      - entity: media_player.samsung_ue55mu6205
        state: 'on'
    row:
      entity: media_player.samsung_ue55mu6205
      type: button
      icon: 'mdi:bullseye'
      name: BOX
      action_name: OK
      tap_action:
        action: call-service
        service: remote.send_command
        service_data:
          entity_id: remote.broadlink_sala_remote
          command: >-
            b64:JgCQAAABK5EUEhM4ETcSNxITEjcTNhM2FDUUNRM4ERMSFBETEhIUNhITEhITNRQ3FDUSExI3EhQSNhQ1EzYTNhQ2EjcSExI3EwAEWwABKpISFBE3FDUTNxISEzcTNRQ2EjcSOBE3FBIRExIUERMSOBE3ExISNxQREhUQExITEhQRNxI3EjgUNBQ1EzYTEhQ2EwANBQ==
  - type: conditional
    conditions:
      - entity: media_player.samsung_ue55mu6205
        state: 'on'
    row:
      entity: media_player.samsung_ue55mu6205
      type: button
      icon: 'mdi:arrow-up-bold-box'
      name: BOX
      action_name: Para cima
      tap_action:
        action: call-service
        service: remote.send_command
        service_data:
          entity_id: remote.broadlink_sala_remote
          command: >-
            b64:JgBQAAABKpISFBE3EzYUNhISFDYSNxI3EzYSOBE3ExMSEhQSERMSOBITEzUTEhQ1FBISExISFBIRNxM2EjgSNhM3EzYSExM2FAAEngABKkgUAA0F
  - type: conditional
    conditions:
      - entity: media_player.samsung_ue55mu6205
        state: 'on'
    row:
      entity: media_player.samsung_ue55mu6205
      type: button
      icon: 'mdi:arrow-down-bold-box'
      name: BOX
      action_name: Para baixo
      tap_action:
        action: call-service
        service: remote.send_command
        service_data:
          entity_id: remote.broadlink_sala_remote
          command: >-
            b64:JgBQAAABKpMTExI2FDYSNxITEjcSNxM2EzYTNhM3EhMSExITEhITNhMSExMRNxQ2EhQREhMSExITNhQ2EjcSNxI3FDUTEhQ2EgAEnwABKUoSAA0F
  - type: conditional
    conditions:
      - entity: media_player.samsung_ue55mu6205
        state: 'on'
    row:
      entity: media_player.samsung_ue55mu6205
      type: button
      icon: 'mdi:arrow-right-bold-box'
      name: BOX
      action_name: Direita
      tap_action:
        action: call-service
        service: remote.send_command
        service_data:
          entity_id: remote.broadlink_sala_remote
          command: >-
            b64:JgBQAAABK5ISExM2EjgTNhITEjcTNhQ1EjcTNhQ2ERQSEhMSExITNhQREzYTNxITEhMRFBISEhMUNRI3EzcSNxE4FDUTExE4EgAEnwABKUoSAA0F
  - type: conditional
    conditions:
      - entity: media_player.samsung_ue55mu6205
        state: 'on'
    row:
      entity: media_player.samsung_ue55mu6205
      type: button
      icon: 'mdi:arrow-left-bold-box'
      name: BOX
      action_name: Esquerda
      tap_action:
        action: call-service
        service: remote.send_command
        service_data:
          entity_id: remote.broadlink_sala_remote
          command: >-
            b64:JgBQAAABKpMUEBI4EjgSNhMTETgSNhQ2EjcSNhQ2EhMTEhITExISNhU1EhQSEhI3FBEUEhISEhISOBI3EjcTNhI4ETgSExI4EQAEngABLUkTAA0F
  - type: conditional
    conditions:
      - entity: media_player.samsung_ue55mu6205
        state: 'on'
    row:
      entity: media_player.samsung_ue55mu6205
      type: button
      icon: 'mdi:television-ambient-light'
      name: TV
      action_name: Assistir TV
      tap_action:
        action: call-service
        service: remote.send_command
        service_data:
          entity_id: remote.broadlink_sala_remote
          command: >-
            b64:JgBGAJKVETkRORE5ERQQFRAVERQQFRE5ETkROREUERQRFBEUERQRORAVERUPOxAVDzsQOhA6EBUQOhA6EBUQOhAVEBUPFhAADQUAAA==
  - type: conditional
    conditions:
      - entity: media_player.samsung_ue55mu6205
        state: 'on'
    row:
      entity: media_player.samsung_ue55mu6205
      type: button
      icon: 'mdi:volume-plus'
      name: TV
      action_name: Aumentar volume
      tap_action:
        action: call-service
        service: remote.send_command
        service_data:
          entity_id: remote.broadlink_sala_remote
          command: >-
            b64:JgBGAJKVETkRORA6ERQRFBAVEBUQFRA7EDkROhAUERUQFRAUEBYQOhA6EDoPFhAVEBUQFQ8WEBUPFhAVEDoQOhA6EDoQOg8ADQUAAA
  - type: conditional
    conditions:
      - entity: media_player.samsung_ue55mu6205
        state: 'on'
    row:
      entity: media_player.samsung_ue55mu6205
      type: button
      icon: 'mdi:volume-minus'
      name: TV
      action_name: Diminuir volume
      tap_action:
        action: call-service
        service: remote.send_command
        service_data:
          entity_id: remote.broadlink_sala_remote
          command: >-
            b64:JgBGAJKVEDoSOBE5EBUQFREUERQRFBA6EDoROREUEBURFBEUEBUQOhE5ERQROREUEBURFBAVEBUQFRE5ERQQOhE5EDoQOhAADQUAAA==
  - entity: switch.sonoff_10009e5a98_1
  - entity: switch.sonoff_10009e5a98_2
  - entity: cover.bfcc297f9be785443ex3to
  - entity: scene.q8xowymf6rcxmusn
  - entity: scene.bpkwqokv9rp5liad
title: Sala
state_color: true

TV is ON:

Isn’t it possible to list several entities under the row parameter ? Is it necessary to add the conditional line for each entity ?

If the condition is the same and you want that conditional row to be button entities then no, you can list multiple buttons on that single conditional row:

type: entities
entities:
  - sensor.garage_door_lock_log
  - sensor.life360_may_battery
  - sensor.time
  - type: conditional
    conditions:
      - entity: binary_sensor.ha_uptodate
        state: on
    row:
      type: buttons
      entities:
        - lock.garage_door_lock
        - lock.front_door_lock
      

image

You can only list multiple buttons per row since a single button, attribute, web link, divider and section each occupy an entire row. If you want those types to be conditional, then the condition has to be listed for each of them.

2 Likes

Thanks for your reply. But in my case, I’d like to have several rows (similar to an entity card). I understand it accepts only a single row.

Yes, for each conditional row you’d have to replicate the condition for that entity. If the conditions are the same it’s not a horrendous job with copy/paste in yaml. The card would need to either accept a new element like rows: which accepted an array of entities or modify row: to accept either a map or an array of entities for what you’re asking.

type: entities
entities:
  - sensor.garage_door_lock_log
  - sensor.life360_may_battery
  - sensor.time
  - type: conditional
    conditions:
      - entity: lock.fron_door_lock
        state: unlocked
    row:
      entity: lock.front_door_lock
  - type: conditional
    conditions:
      - entity: lock.garage_door_lock
        state: unlocked
    row:
      entity: lock.garage_door_lock

image

You could use state switch which has more options.

1 Like