A different take on designing a Lovelace UI

@Mattias_Persson or to someone that this has happened to him? I don’t know what the error is. Thank you.
When I add the template -recently_downloaded I get this error.

                    card:
                      type: custom:button-card
                      entity: sensor.plex_recently_added
                      tap_action:
                        action: none
                      template:
                        - conditional_media
                        #- recently_downloaded
                        - icon_plex

Error

The sensor has an online status

Your data is empty… Here’s what it should look like

@Mattias_Persson what do i need to do to have the switch for tablet screensaver setup to my ha?
Cannot find any templates for it in your GitHub repository, or i miss something :see_no_evil:

switch.galaxy_tab_a_screensaver

Never mind @Mattias_Persson, have forgotten to install FullyKiosk integration. My bad, sorry :wink:

Hi @Mattias_Persson.

What does this. Does a bash file run?
ssh -o StrictHostKeyChecking=no -i /config/.ssh/id_rsa [REDACTED USER@IP] 'osascript -e "set volume with output muted

Sorry for so many questions. But I want to understand how you programmed everything.ni.

Anyone that have an SVG for a door lock (Idlock 150)

There are some free on flaticon: Search results for Door lock - Flaticon

Hi all… someone have this error with TV icon???

Hi Mattias,

First of all, awesome UI. I love it.

I am trying to implement your code but having some trouble. I tried asking in discord, but no one seemed to be able/present to help.

Sepcifically Line 59 of your ui-lovelace.yaml:

https://github.com/matt8707/hass-config/blob/c518a860beef7dfee01718e93d5834a914453757/ui-lovelace.yaml
  1. what is the {.: in line 1?
  2. this is more complicated. this code is using the GitHub - thomasloven/lovelace-card-mod: 🔹 Add CSS styles to (almost) any lovelace card. In the document, it says ha-card is the lowest element it can reach. But for some reason, this github seemed to have find some way to circumvent that and inserted css into the p and span elements of the ha-markdown.

I can see you that you are grouping the elements by the number of levels its been wrapped around. But apart from that, I am struggling to understand that string.

Any help would be much appreciated!

  1. oh, and also what is the $ sign at line 34?

Thanks again for all your work!!

hey Vasco, are you willing to share the images you use for the garbage status? It looks quite clean

1 Like

Sure @drimps

3 Likes

Hi,

I have been studying your code for a while. progres is slow, but slowly getting there.

For the vacuum, information and update button. They appear at the top at the moment. I can’t seem to find the part of the code which makes them appear at the bottom.

Can anybody direct me to it?

My Screenshot:

https://imgur.com/a/BvcHAzh

My Code:

https://paste.ubuntu.com/p/mfTjfn8Nzs/

Hi, i believe it’s in the theme :

See line 251-252 :
display: flex;
align-items: flex-end;

the flex-end set icons at the end of the “sidebar” container.

Opposed to align-items: flex-start; in the phone config just after.

Someone knows to install this ? I´d tried to copy all git files and put into HA folders but it doesnt change nothing in the layout.

Only copying the files is not enough. Have you also added all resources from HACS? Or manually? Fonts?
Have you rebooted HA?
Did you change the theme to: “tablet”?

And so forth. Earlier i’ve written a bit how the file structure works.

minified duplicate of themes markdown
https://onlineyamltools.com/minify-yaml

ha-markdown is a card, the p and span are css selectors

$ = shadowroot
https://github.com/thomasloven/lovelace-card-mod#dom-navigation

How can I make a button which spans two columns, but only one row.
Tried different ways. aspect_ratio, stack-cards, etc.
Can somebody help me?

Another problem. One button isn’t showing his icon.

ui-lovelace.yaml

          - type: custom:button-card
            entity: calendar.abfallkalender
            template:
              - abfall

button_card_templates.yaml

base:
  variables:
    state: >
      [[[ return entity === undefined || entity.state; ]]]
    timeout: >
      [[[ return entity === undefined || Date.now() - Date.parse(entity.last_changed); ]]]
    light_color: >
      [[[ return entity === undefined ? 'var(--state-icon-color)' : 'var(--button-card-light-color-no-temperature)'; ]]]
  aspect_ratio: 1/1
  show_state: true
  show_icon: false
  state_display: >
    [[[ if (variables.state === true) return 'Unbekannt'; ]]]
  tap_action:
    ui_sound_tablet: |
      [[[
        const tablet = states['switch.dashboard_screensaver'];
        const screensaver = states[tablet] === undefined || states[tablet].state;

        if (variables.state === 'off' && screensaver === 'off') {
          hass.callService('media_player', 'play_media', {
            entity_id: 'media_player.dashboard_fullykiosk',
            media_content_id: '/local/sound/on.m4a',
            media_content_type: 'music'
          });
        }
        if (variables.state === 'on' && screensaver === 'off') {
          hass.callService('media_player', 'play_media', {
            entity_id: 'media_player.dashboard_fullykiosk',
            media_content_id: '/local/sound/off.m4a',
            media_content_type: 'music'
          });
        }
      ]]]
    animation_card: |
      [[[
        const animation_speed_ms = 900;
        const animation = `card_bounce ${animation_speed_ms}ms cubic-bezier(0.22, 1, 0.36, 1)`;
        this.shadowRoot.getElementById("card").style.animation = animation;
        window.setTimeout(() => {
          this.shadowRoot.getElementById("card").style.animation = "none";
        }, animation_speed_ms)
      ]]]
    action: toggle
    haptic: medium
  styles:
    grid:
      - grid-template-areas: |
          "icon  circle"
          "n     n"
          "s     s"
      - grid-template-columns: repeat(2, 1fr)
      - grid-template-rows: auto repeat(2, min-content)
      - gap: 2%
      - align-items: start
    name:
      - justify-self: start
      - line-height: 115%
    state:
      - justify-self: start
      - line-height: 115%
    card:
      - font-family: Sf Display
      - border-radius: var(--custom-button-card-border-radius)
      - -webkit-tap-highlight-color: rgba(0,0,0,0)
      - transition: none
      - padding: 10%
      - --mdc-ripple-color: >
          [[[
            return (variables.state === 'on' || variables.state === 'home' || variables.state === 'open') ?
              'rgb(0, 0, 0)' :
              'rgba(255, 255, 255, 0.3)';
          ]]]
      - color: >
          [[[
            return (variables.state === 'on' || variables.state === 'home' || variables.state === 'open') ?
              'rgba(0, 0, 0, 0.6)' :
              'rgba(255, 255, 255, 0.3)';
          ]]]
      - background-color: >
          [[[
            return (variables.state === 'on' || variables.state === 'home' || variables.state === 'open') ?
              'rgba(255, 255, 255, 0.8)' :
              'rgba(115, 115, 115, 0.2)';
          ]]]
  extra_styles: |
    #name, #state {
      font-size: 1.34vw;
      letter-spacing: 0.05vw;
    }
    /* portrait */
    @media screen and (max-width: 1200px) {
      #name, #state {
        font-size: 2vw;
        letter-spacing: 0.05vw;
      }
    }
    /* phone */
    @media screen and (max-width: 800px) {
      #name, #state {
        font-size: 3.1vw;
        letter-spacing: 0.12vw;
      }
    }
    @keyframes card_bounce {
      0% {
        transform: scale(1);
      }
      15% {
        transform: scale(0.9);
      }
      25% {
        transform: scale(1);
      }
      30% {
        transform: scale(0.98);
      }
      100% {
        transform: scale(1);
      }
    }

abfall:
  template:
    - base
  show_icon: true
  icon: mdi:delete
  name: >
    [[[
      if (states[entity.entity_id].attributes.message === 'Biotonne in Memmingen' )
        return 'Biotonne';
      if (states[entity.entity_id].attributes.message === 'Restmülltonne in Memmingen')
        return 'Restmüll';
      else
        return 'Altpapier';
    ]]]
  state_display: >
    [[[ 
      { return states['sensor.abfall_morgen'].state; }
    ]]]
  state:
    - operator: template
      value: >
        [[[ return (states[entity.entity_id].attributes.message == 'Biotonne in Memmingen') && ((states['sensor.abfall_morgen'].state == 'Morgen') || (states['sensor.abfall_morgen'].state == 'Heute')) ]]]
      styles:
        card: [background-color: "rgba(186, 146, 0, 0.8)"]
        name: [color: "rgba(0, 0, 0, 0.6)"]
        state: [color: "rgba(0, 0, 0, 0.6)"]
    - operator: template
      value: >
        [[[ return (states[entity.entity_id].attributes.message == 'Restmülltonne in Memmingen') && ((states['sensor.abfall_morgen'].state == 'Morgen') || (states['sensor.abfall_morgen'].state == 'Heute')) ]]]
      styles:
        card: [background-color: "rgba(160, 160, 160, 0.8)"]
        name: [color: "rgba(0, 0, 0, 0.6)"]
        state: [color: "rgba(0, 0, 0, 0.6)"]
    - operator: template
      value: >
        [[[ return (states[entity.entity_id].attributes.message == 'Altpapier') && ((states['sensor.abfall_morgen'].state == 'Morgen') || (states['sensor.abfall_morgen'].state == 'Heute')) ]]]
      styles:
        card: [background-color: "rgba(0, 100, 200, 0.8)"]
        name: [color: "rgba(0, 0, 0, 0.6)"]
        state: [color: "rgba(0, 0, 0, 0.6)"]

Hi
I am not getting my icons, have the button_card template setup, what do I do wrong ?
image

Hi @Mattias_Persson
One question is why the font gets so small in cellular mode
Thanks

@font-face {
	font-family: sf mono;
	font-weight: 600;
	font-style: italic;
	src: url(/local/fonts/SFMono-SemiboldItalic.otf)
}

@font-face {    
	font-family: archivo black;
	font-weight: 400;
	src: url(/local/fonts/archivo-black.regular.otf)
}
    styles:
      grid:
        - grid-template-areas: |
            "icon1 icon2 icon3"
            "s     s     s"
        - grid-template-columns: auto auto auto
        - grid-template-rows: 1fr 5fr
        - gap: 2%
        - align-items: start
      state:
        - font-size: 4vw
        - opacity: 0.65
        - padding: 0.55vw 1.2vw 0.5vw 1.2vw
      card:
        - font-family: archivo black
        - border-radius: var(--custom-button-card-border-radius)
        - -webkit-tap-highlight-color: rgba(0,0,0,0)
        - transition: none
        - padding: 10%
        - --mdc-ripple-color: >
            [[[
              return (variables.state === 'on' || variables.state === 'home') ?
                'rgb(0, 0, 0)' :
                'rgba(255, 255, 255, 0.3)';
            ]]]
        - color: >
            [[[
              return (variables.state === 'on' || variables.state === 'home') ?
                'rgba(0, 0, 0, 0.6)' :
                'rgba(255, 255, 255, 0.3)';
            ]]]
        - background-color: >
            [[[
              return (variables.state === 'on' || variables.state === 'home') ?
                'rgba(255, 255, 255, 0.8)' :
                'rgba(115, 115, 115, 0.2)';
            ]]]
    extra_styles: |
      #name, #state {
        font-size: 1.34vw;
        letter-spacing: 0.05vw;
      }
      /* portrait */
      @media screen and (max-width: 1200px) {
        #name, #state {
          font-size: 2vw;
          letter-spacing: 0.05vw;
        }
      }
      /* phone */
      @media screen and (max-width: 800px) {
        #name, #state {
          font-size: 4vw;
          letter-spacing: 0.12vw;
        }
      }
      @keyframes card_bounce {
        0% {
          transform: scale(1);
        }
        15% {
          transform: scale(0.9);
        }
        25% {
          transform: scale(1);
        }
        30% {
          transform: scale(0.98);
        }
        100% {
          transform: scale(1);
        }
      }     

2

it’s working, my bad :slight_smile: