Problem with Conditional card and input_select

Tags: #<Tag:0x00007f326802b088>

I’m having some trouble with a Conditional card and the input_select.

I have a couple of input_selects defined as follows:

announcement_suggested_text:
    options:
      - Dinner is ready!
      - Lunch is ready!
      - We're leaving now!
      - Steve's on his way home!
      - I'm on my way home!
      - Custom Message
  announcement_target:
    options:
      - Everywhere
      - Upstairs
      - Steves Bedroom
      - Computer Room
      - Kitchen

an input_text named announcement_text and a conditional card as follows:

My aim was to have a card which could show input_select.announcement_suggested_text and only show input_select.announcement text if “Custom Message” was selected from the dropdown. To this end I created the following with a couple of Conditional cards, inside a vertical-stack:

- type: vertical-stack
  cards:
    - type: conditional
      conditions:
        - entity: input_select.announcement_suggested_text
          state_not: Custom Message
      card:
        type: entities
        show_header_toggle: false
        entities:
          - entity: input_select.announcement_target
          - entity: input_select.announcement_suggested_text
          - type: call-service
            icon: 'mdi:voice'
            action_name: Announce It...
            name: ' '
            service: script.send_annoucement
    - type: conditional
      conditions:
        - entity: input_select.announcement_suggested_text
          state: Custom Message
      card:
        type: entities
        show_header_toggle: false
        entities:
          - entity: input_select.announcement_target
          - entity: input_select.announcement_suggested_text
          - entity: input_text.announcement_text
          - type: call-service
            icon: 'mdi:voice'
            action_name: Announce It...
            name: ' '
            service: script.send_annoucement

This appeared to work but, if I switch to “Custom Message” to one of the other options (with the text input hidden as expected) and then back to “Custom Message”, although the text box re-appears as expected the input_select changes to show the option I had previously selected, like this:

59

This then seems to get stuck. I can’t select any other option until I refresh the page. It looks like this is because the displayed value in the dropdown doesn’t actually match the state of the input_select. Refreshing the page fixes it, and the dropdown resets to show the actual state of the input_select.

Does anybody have any ideas of a way to fix this, or a better way of having one of the entities in an entities card shown or hidden based on the state of another entity?

Not sure if that matters, but the indentation of the second conditional needs two more spaces.
If not, maybe give state-switch a try.

That was just a typo when I copied and pasted it, it’s indented correctly in my config, but I’ll take a look at that card, thanks.

Sorry, I can’t help with your issue.

But, how did you get your text input field to look like that, when I do it, it’s shoved right up to the right hand side.

I’ve created a custom text input row for that. I haven’t had change to publish it yet, I’ll let you know when I have.

that would be great, I have no idea where to start creating one

Here you go:

If you use custom_updater you can add this by just having this in your resources:

resources:
  - url: /customcards/github/gadgetchnnel/lovelace-text-input-row.js?track=true
    type: js

Otherwise, you can add it manually by downloading the lovelace-text-input-row.js file from there and adding it like this:

resources:
  - url: local/path/to/file/lovelace-text-input-row.js?v=0.0.7
    type: js

You then use it like:

- type: entities
  entities:
    - entity: input_text.my_text
      type: 'custom:text-input-row'
3 Likes

probably should make this in share your projects. Other people have asked for this. I’ll be implementing it later tonight in this spot

image

1 Like

thanks, just what I wanted and it works a treat :slight_smile:

Dear Petro,
I know it’s a lot late… but do you still have this code ? if yes can you post it please ?
I like a lot :slight_smile:

Thanks in advance
Denis

I’m sorry, I don’t have that code anymore

1 Like