Lovelace: Swiper card

Does anyone know how I would remove the background dark parts between the cards?

Here is my code:

          - prefix: Main Bedroom
            <<: *title
            style:
              top: 53%
              left: 25%
              <<: *title-style
          - type: custom:swipe-card
            start_card: 1
            parameters:
              effect: coverflow
              speed: 650
              spaceBetween: 20
              threshold: 7
              coverflowEffect:
                rotate: 80
                depth: 300
            style:
              top: 56.55%
              left: 35.8%
              width: 20.97%
              height: 1px
              color: transparent
              --ha-card-border-radius: .88vw
            cards:            
              - type: picture-elements
                image: /local/Render/transparent.png
                elements:
                  - type: custom:button-card
                    entity:  light.main_bedroom_light_2
                    Name: Light
                    custom_fields:
                      icon_chan: *icon_chan
                    styles: *icon_chan_styles
                    style:
                      top: 23.9%
                      left: 23.8%
                      width: 47.7%
                    template: light

...

I canā€™t get pictures to work getting t.setConfig error, how did you manage to get images?

Having an issue where the slider for a light in a room is moving with the swipe. So if I start a slider on a light or cover, the card starts swiping with it.

Is there a way to fix it so the slider of the entity moves but the card doesnt swipe unless I swipe on the card itself?

I have this working for two seperate tabs. When i try to use it on a third, iā€™m met with this t.setConfig is not a function error. It renders on a browser but not my iphone.

Anyone else experience this?

Hello , i am using a swipercard inside a picture element card in panelmode. Inside the swipercard i have one more picture element card. I cant figure out how to set the height of the swipercard. I can set the Width with the style parameter of the picture element card but the height do not change. I have also tried to set height inside the swipercard but nothing works. The swipercard is to long right now so the pagination bullets ends up way to far Down on my Screen. Does anyone know a solution ?

Is it possible to change the card programmatically? i.e. instead of the mouse doing the swipe/drag event, I would like to swipe based on a home assistant event.

Does anybody know how to do that?

Just discovered this card and think itā€™s great! What a fantastic little space saver for those of us with iPad Mini-sized dashboards.

I managed to get it to auto scroll cards, but was wondering if itā€™s possible to assign a time (or delay) between translations?

Edit: I figured it out. just add delay: "milliseconds" after autoplay: with the number of milliseconds you need.

Experiencing the same issue with Android aswell. But for the lift of me canā€™t work out why

Hi Hellis, did you figure this out? iā€™m also looking for a solution.

1 Like

Whatā€™s the syntax and formatting for setting card specific autoplay delays? Over here in the docs it says it can be done, but I would need a YAML example for how to implement this.

If you need to specify different delay for specific slides you can do it by usingdata-swiper-autoplay (in ms) attribute on slide.

<div class="swiper-slide" data-swiper-autoplay="2000">

Hi!
Really loving this! A super sweet addition to my dashboard!
Although I have a problem which Iā€™m woundering if anyone know how to fix.
I have a dashboard setup on a raspberry pi 3 using raspbian and its chromium browser but the issue also remains in the home assistant app on my android phone when trying there.

Whenever I swipe across the screen, once I release it acts as a click on the card I ā€œheld ontoā€ while sliding, either performing a button press or alternativly bringing up the info window for that entety.

For example, Iā€™ve added the ability to swipe between two different weather info cards for both my homes but whenever I release my finger off the screen it brings up the window showing all information from that weather card.
Alternativly I have some buttons activating some light scenes and another set of buttons I can swipe to that controls individual light instead. But swiping back and forth between these causes the button I ā€œheld ontoā€ to activate once I let go of the screen, accidentally activatings scenes or turning on/off lights by simply just swiping.

Is there a way to stop this?

1 Like

Hi all, Iā€™m attempting to figure out how to implement hash control to this swipe-card. Using the below parameters and manually inserting data-hash="p1 , data-hash="p2" into the swiper-slide-active cards html, I can change the hash on swipe and using the navigation arrows. These changes are reflected in the three button cards above.

(Screen grab GIF attached)

What doesnā€™t work is if I change the browser hash from one of buttons, the swiper-card will not update or listen to this change.

  1. is there any way to make swiper-card listen for hash changes from buttons etc? (Similar to custom:button-card or custom:state-switch)

  2. is there any way to define data-hash=" " within the YAML config for each card? Without manually inputing this in the developer console it just adds #null to the url for ALL cards.

This would be super exciting if this could work and opens up a lot of UI/Navigation possibilities.

Any help is hugely appreciated!

      - type: 'custom:swipe-card'
        view_layout:
          grid-row: 3
        start_card: 1
        parameters:
          hashNavigation:
            enabled: true
            watchState: true
            onHashChange: true
            replaceState: true
          effect: coverflow
          grabCursor: true
          centeredSlides: true
          slidesPerView: 1
          coverflowEffect:
            rotate: 50
            stretch: 50
            depth: 50
            modifier: 1
            slideShadows: true
          pagination:                        
            type: 'bullets'
          navigation:

1 Like

anyone using either light-popup-card or thermostat-popup-card wrapped in a swipe-card, with success?

when I put my popup cards (code below) inside the swipe card, I lose the ability to control the individual lights.

image

                  - type: vertical-stack
                    cards:
                      # Markdown for Lights Stack
                      - type: markdown
                        content: |
                          # Lights
                        style:
                          .: |
                            ha-card {
                              --ha-card-background: none !important;
                              box-shadow: none !important;
                            }
                          ha-markdown:
                            $: |
                              h1 {
                                font-size: 16px;
                                font-weight: bold;
                                font-family: Helvetica;
                                letter-spacing: '-0.01em';
                              }
                      # Picture Elements to hold light popup cards
                      - type: picture-elements
                        card_mod:
                          style: |
                            ha-card {
                            --ha-card-background: transparent;
                            padding: 16px;
                            font-size: 14px !important;
                            box-shadow: none !important;
                            height: 260px !important;
                            }
                        elements:
                          # Living Room
                          - type: 'custom:light-popup-card'
                            card_mod:
                              style: |
                                ha-card {
                                }
                                h4 {
                                font-size: 14px !important;
                                color: var(--primary-text-color); }
                            entity: light.living_room
                            icon: 'mdi:lightbulb'
                            hideState: null
                            sliderColor: var(--accent-color)
                            brightnessHeight: 140px
                            brightnessWidth: 50px
                            fullscreen: true
                            sliderThumbColor: var(--accent-color)
                            sliderTrackColor: '#3a3c55'
                            switchHeight: 150px
                            switchWidth: 50px
                            displayType: slider
                            style:
                              top: 80px
                              left: 60px
                              height: 200px
                          - type: 'custom:button-card'
                            card_mod:
                              style: |
                               ha-card {
                               font-size: 14px !important;
                               }
                            name: Living
                            style:
                              top: 205px
                              left: 60px
                              width: 80px
1 Like

Hi all, working on wrapping some custom button cards in a swipe view like so


However everytime i swipe i also click the button card which toggles the lights. Does anyone have any tips/ideas on how to fix that?
the preventClicks and preventClicksPropagation does not seem to work. Using the ios and android app.

1 Like

This has always been the case with hold actions inside swiper card. Also affects sliders, since you have to hold and touch. Iā€™m guessing youā€™re using on desktop/laptop. See my workaround I figured out here: A different take on designing a Lovelace UI - #700 by ASNNetworks

I use popup slider cards inside swiper card successfully with this workaround.

Iā€™m trying to find a way to dynamically add cards to the Swiper card, so new messages and alerts can be displayed and autoplayed through. Does anyone have any suggestions?

thatā€™s what I do, albeit with a set of predefined button-cards, which can be max 4 in a horizontal stack:


main config for that setup is:

type: conditional
conditions:
  - entity: sensor.count_alerts_notifying
    state_not: '0'
card:
  type: vertical-stack
  cards:
    - !include /config/lovelace/includes/include_button_marquee_alerts.yaml

# https://swiperjs.com/swiper-api#modules
    - type: custom:swipe-card
  #    card_width: '185px'
  #    start_card: 6
      parameters:
        spaceBetween: 8
#       effect: coverflow
        grabCursor: true
        centeredSlides: false
        slidesPerView: 4
 #       coverflowEffect:
  #        rotate: 50
  #        stretch: 0
  #        depth: 100
  #        modifier: 1
  #        slideShadows : true
        pagination:
          type: bullets
          hideOnClick: true
      cards:
        !include /config/lovelace/buttons/buttons_alerts_swipe.yaml
#    - type: custom:state-switch
#      entity: sensor.count_alerts_notifying
#      states:
#        1:
#          !include /config/lovelace/buttons/buttons_alerts_1.yaml
#        2:
#          !include /config/lovelace/buttons/buttons_alerts_2.yaml
#        3:
#          !include /config/lovelace/buttons/buttons_alerts_3.yaml
#        4:
#          !include /config/lovelace/buttons/buttons_alerts_4.yaml

    - type: custom:button-card
      template: vertical-filler

and the buttons_alerts_swipe.yaml looks like:

- type: conditional
  conditions:
    - entity: binary_sensor.alarm_triggered
      state: 'on'
  card:
    !include /config/lovelace/includes/include_button_alarm_disarm.yaml

- type: conditional
  conditions:
    - entity: input_boolean.flood_alert
      state: 'on'
  card: !include /config/lovelace/includes/include_button_flood_alert.yaml

- type: conditional
  conditions:
    - entity: binary_sensor.doors
      state: 'on'
  card: !include /config/lovelace/includes/include_button_sensor_doors.yaml

- type: conditional
  conditions:
    - entity: binary_sensor.garage_door
      state: 'on'
  card: !include /config/lovelace/includes/include_button_garage_door.yaml

- type: conditional
  conditions:
    - entity: binary_sensor.github_repo_has_update
      state: 'on'
  card: !include /config/lovelace/includes/include_button_github_repo_alert.yaml

- type: conditional
  conditions:
    - entity: binary_sensor.earthquakes_near_active
      state: 'on'
  card: !include /config/lovelace/includes/include_button_quake_alert.yaml

- type: conditional
  conditions:
    - entity: binary_sensor.trash_notification
      state: 'on'
  card: !include /config/lovelace/includes/include_button_trash_alert.yaml

- type: conditional
  conditions:
    - entity: binary_sensor.climate_living_alert
      state: 'on'
  card: !include /config/lovelace/includes/include_button_ventilate.yaml

- type: conditional
  conditions:
    - entity: binary_sensor.updater_notification
      state: 'on'
  card: !include /config/lovelace/includes/include_button_updater.yaml

- type: conditional
  conditions:
    - entity: binary_sensor.addon_updates_available
      state: 'on'
  card: !include /config/lovelace/includes/include_button_addons_updates_available.yaml

etcetcetc

swipe card has proven to be the only card with which I can dynamically show these cards, and donā€™t have to pre-format any other settings (see the commented state-switch config which I had before). like the number of alerts ā€˜onā€™. If there is 1-4, they simply show in the horizontal stack. If there are more, then I swipe.

You can use multiple markdown cards inside a swiper card. Make sure each markdown card is inside a conditional card. That way only the markdown cards show when a certain criteria has been met. For instance:

Conditional card where the wrapped markdown card only shows when status of binary_sensor.frontdoor is set to on. Then use markdown card with tekst like The frontdoor is open. This means that if the frontdoor sensor is set to on, than the markdown card wil show up.

Create multiple conditional cards, each containing a markdown card. And use autoplay: true as a parameter for Swiper card. Having said this: if nothing is displaying, you will see a white area. So you need to be creative by using multiple nested conditional cards, or default Markdown tekst when all sensors are off.

In any case: this is not simple if you have never used markdown, conditional or swiper card. So start by experimenting with those cards and read the docs!

The conditional card seems to make the swiper card throw and error: t.setConfig is not a function which is not happening with other card types (Iā€™ve tried entity and custom:button-card).

type: custom:swipe-card
parameters:
  effect: fade
  pagination:
    type: bullets
  autoplay:
    pauseOnMouseEnter: true
    disableOnInteraction: false
    delay: 5000
  speed: 1000
cards:
  - type: conditional
    conditions:
      - entity: input_boolean.swiper_message_1
        state: 'on'
    card:
      type: light
      entity: light.living_room_lamp