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

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.

using stated-switch on a bigger view level like:

  - type: custom:state-switch
    entity: mediaquery
    states:
      "(pointer: coarse)":
        !include /config/dashboard/includes/include_plattegrond_swipe_3.yaml
      all:
        !include /config/dashboard/includes/include_plattegrond_grid_4.yaml

which includes a grid config for desktop or a swiper config for mobile (pointer: coarse), I can help but notice a huge delay upon each loading of the card.

If I use either of these configs individually, there is still some lag (it is a rather large view, including a lot of picture-glance cards for all of my rooms) but it is way more responsive.

Would there be a better way of deciding which card config to use based on either mobile or non mobile?

Hi all, Iā€™m looking for a way to install version 1.9.3, is there a way to do that?

I need that version for minimalist adaptieve ui.

I have a button that I only want to see when an entity is 1ā€¦

YAML:

- type: conditional
        conditions:
          - entity: binary_sensor.bureau_bewegingsmelder_occupancy
            state: 'on'
        card:
          - type: custom:mushroom-chips-card
            chips:
              - type: template

The button is not seen, but when the entity is 1 I get ā€œno card type configuredā€. what is wrong with the code ?

You put the single card there as a list item. Remove the - in front of ā€˜typeā€™

Thanks for helping me but I donā€™t understand :frowning:

instead of the above, use

        card:
          type: custom:mushroom-chips-card
          chips:
            - type: template

no - in front of the type:

as Thomas says, using the - makes that a list, and the card expects a single card, not a list of cards

1 Like

I still got the same error

here is the full code on the actionā€¦

YAML:

- type: conditional

        conditions:

          - entity: binary_sensor.bureau_bewegingsmelder_occupancy

            state: 'on'

        card:

          type: custom:mushroom-chips-card

          chips:

            - type: template

              entity: binary_sensor.bureau_bewegingsmelder_occupancy

              content_info: none

              use_light_color: false

              card_mod: null

              tap_action:

                !include alarm.yaml    

              icon: |2-

                    {% set state=states('binary_sensor.bureau_bewegingsmelder_occupancy') %}

                    {% if state=='on' %}

                    mdi:bell-outline

                    {% elif state=='off' %}

                    show_icon: false

                    {% endif %}

              icon_color: |2-

                    {% set state=states('binary_sensor.bureau_bewegingsmelder_occupancy') %}

                    {% if state=='on' %}

                    red

                    {% elif state=='off' %}

                    grey

                    {% endif %}

              style: |

                ha-card {

                  {% if states('binary_sensor.bureau_bewegingsmelder_occupancy') == 'on' %}

                  animation: blink 0.4s linear infinite;

                  }

                  @keyframes blink {

                    50% {opacity: 0;}

                    }

                  {%- else -%}

                  box-shadow: 0px 0px;

                  {%- endif %}

                ha-card {

                  box-shadow: 0px 0px;

          alignment: center

if this is your actual yaml, then you should at least fix the spacing. Maybe its a c&p fluke, but

- type: conditional

        conditions:

          - entity: binary_sensor.bureau_bewegingsmelder_occupancy

            state: 'on'

        card:

should be:

- type: conditional
  conditions:
    - entity: binary_sensor.bureau_bewegingsmelder_occupancy
      state: 'on'
  card:
    type:

   # and next your correct card config

check the example in the docs:

type: conditional
conditions:
  - entity: light.bed_light
    state: "on"
  - entity: switch.decorative_lights
    state_not: "off"
card:
  type: entities
  entities:
    - device_tracker.demo_paulus
    - cover.kitchen_window
    - group.kitchen
    - lock.kitchen_door
    - light.bed_light

you should try the conditional card with a simple entity first. so you know the conditional works ok.
also, try the card itself without conditional, soy know that works.

If both are fine, you can joinā€¦

- type: conditional
  conditions:
      - entity: binary_sensor.bureau_bewegingsmelder_occupancy
        state: 'on'
  card:
    - type: 'custom:button-card'
      entities:
         - sensor.p1_meter_5c2faf04a1f2_active_power

this is now my conditional code. It still says there is no card configured

yes but button card does not support entities:ā€¦ only entity:

that is why I said to take a card you know to work , and then add it t the conditional

also, you still have that dash in front of the type:

2 crucial mistakesā€¦ Please read carefully what people advise you to do

3 Likes

ok, found it. thanks

Apologies to ask something that may have been asked before. Is it possible to define a state in which no card is shown if that is the right state? I can use a conditional card to achieve the same thing but much prefer the transition effect that state switch provides.

I tried with a blank card but it still pads out more than I want.

@jaswalters I am trying to do something like you did here for my screens using shutter-card.
Would it be possible to share your code for this card?
Kind regards, Bert

I try to use the custom:state-switch card but run into an problemā€¦
I try to replicate this example. paragraph entity_id.

This is the code I mad of the example (using the UI):

type: entities
title: Test input_select.home_mode
entities:
  - entity: input_select.home_mode
type: custom:state-switch
entity: input_select.home_mode
states:
  Home:
    type: vertical-stack
    cards:
      - type: entities
        title: Lights
        entities:
          - light.sonoff_8s20
          - light.sonoff_3s20
          - light.sonoff_4s20
      - type: picture-glance
        camera_image: camera.oprit_profile000_mainstream
        entities: []
  Away:
    type: alarm-panel
    entity: alarm_control_panel.alarmo
  Guests:
    type: glance
    title: Lights
    entities:
      - light.sonoff_8s20
      - light.sonoff_3s20
      - light.sonoff_4s20

But I get an error message about the duplicate mapping of a cardā€¦:
image
The difference is the the example starts with

cards:

But when I put the original code (including cards:) in the editor i get:

No type provided.

How can I configure this in the UI?

I dont know if i can ask a update here but i will try.
I love this card but is missed something like going to default after x sec.
So iā€™s it possible to returm to default page after x sec when you push a button
Example i push button 3 and get page 3 but then after 10 sec itā€™s return to the default page.

Thx

Just a hasty guess: this could be (probably) achieved by some automation:
ā€“ pushing a button starts an automation;
ā€“ this automation sets some value to some helper;
ā€“ the state-switch-card then switches to some card - dependently on this helperā€™s value;
ā€“ then after some time interval the value is reset - an the state-switch-card is reset too.