šŸ”¹ state-switch - conditional card on steroids

Itā€™s the approach I use for a similar scenario, and it works for me.

Try using template option

1 Like

Of course! Sorry I missed that. However, this note intrigues me:

Note: Jinja2 templating is not cheap. Avoid it for simple things that can be solved with just an entity.

Does that mean that setting up a separate entity (here a binary sensor) is ā€˜cheaperā€™ than using a Jinja2 template directly in the frontend?

IMHO jinjia2 operates on a server side only.

The meaning if that note was:
instead of:

entity: "{{is_state('sun.sun','below_horizon')}}"
states:
  true:
    type: markdown
    content: ...
  false:
    type: markdown
    content: ...

use this:

entity: sun.sun
states:
  'below_horizon':
    type: markdown
    content: ...
  'above_horizon':
    type: markdown
    content: ...

Yep, totally missed that as well. I knew there was a better way. Thanks dude. Will give it a go!

This seems like a question for the browser-mod thread.

I want to have multiple !include statements, but they get concatinated rather than processed in series. Thoughts about fixes or workarounds?

This works:

  - type: custom:state-switch
    entity: input_select.remote
    states:
      'DISH':
        !include remote_dish.yaml
      'FireTV':
        !include remote_firetv.yaml
      'RADIO':
        !include remote_radio.yaml
      'VCR2':
        !include remote_off.yaml

But this raises an error:
No such file or directory: '/config/lovelace/media/remote_sources.yaml !include remote_dish.yaml'
Adding a newline between the !includes raises the same error.

  - type: custom:state-switch
    entity: input_select.remote
    states:
      'DISH':
        !include remote_sources.yaml
        !include remote_dish.yaml
      'FireTV':
        !include remote_firetv.yaml
      'RADIO':
        !include remote_radio.yaml
      'VCR2':
        !include remote_off.yaml

Btw, I believed that it should be this:

    states:
      'DISH': !include remote_dish.yaml

Thanks, but this works:

    states:
      'DISH':
        !include remote_dish.yaml

This does not:

    states:
      'DISH':
        !include remote_sources.yaml
        !include remote_dish.yaml

The parser concatenates both lines (two file names) into one line (one file name), as in a ā€œ>ā€ markup.

I have been trying to get this card working but no matter what I have done, I donā€™t get the options to show up. Iā€™ve uninstalled and reinstalled the repository and cleared the cache and cookies but nothing has changed. Iā€™ve tried very basic setups and nothing is showing up so maybe the code is bad? Does it need to be in another card to work?

type: custom:state-switch
entity: input_select.test_mode_select
default: Test1
states:
  Test1:
    type: vertical-stack
    cards:
      - type: entities
        title: one
        entities:
          - entity: light.3d_light
  Test2:
    type: vertical-stack
    cards:
      - type: entities
        title: two
        entities:
          - entity: light.3d_light

Make sure that your input_select is set to either Test1, or Test2. (Look at Developer > States for the input_selectā€™s current State).

It seems to be. The Test1 card option displays but I donā€™t have a place to choose it or Test2.

What?
Just place your input_select entity on the same view and see possible options.

@thomasloven I really love this card. Can you share the code for the example you give with the button presses change the view. Do you use an input boolean to accomplish this or what?

Be careful of tagging people out of the blue. It comes across as demanding.

I am not begging for help I just want to get the code to see if I can get it to work properly. I know its not a forum I understand that I was just curious if the maker of the card is willing to elaborate more on the code structure. I am just wanting to try to use a card in an advanced way and wanting to see if it is possible.

did you check lovelace-state-switch/test at master Ā· thomasloven/lovelace-state-switch Ā· GitHub?

I didnt, but Thomas did put-up some examples there

Is it possible to have the card preform two transitions?
I have a custom button card with tap_action to navigation _path: ā€˜#p1ā€™
based on my state switch the my card slides down to show my cards or entities. I was looking to have the card slip back up then down again showing another set of cards or entities when a different button is pressed.

1 Like

HI Marius

Did you end up finding a solution for this without the button-card?? I have been trying for a few days now to convert window.location.pathname into either a variable or usable template. Tried also using custom:config-template-card but just cant find a way of making the pathname usable in later code. I could use DeviceID in BrowserMod but I want the code a little more dynamic without manually needing to assign Device names etc.

My use case is that I have navigation buttons that I only want available when using a tablet and not on a PC.

no I havent, it simply cant be done in jinja, because path is frontend available only.