A different take on designing a Lovelace UI

I noticed you have succeeded to send two actions from Lovelace directly form tap_action, I didn’t think that was possible. I tried to change so it instead of restarting hass it turns on a light or does something else but I can’t get it to work, is there anything I am missing?

Found it here,
https://github.com/matt8707/hass-config/blob/790e39657c6809684c598e23294431d3920af8bb/popup/sidebar_information.yaml#L85

This is my try to just turn on a light, the toast msg works but not the the light.turn_on

type: 'custom:button-card'
name: 'Tänd lampan'
tap_action:
  services: |
    [[[ hass.callService('browser_mod', 'toast', {message: 'Tänder lampan...'});
    hass.callService('light.turn_on', 'light.kontor_fatolj'); ]]]
hass.callService('light', 'turn_on', {entity_id: 'light.kontor_fatolj'});

Of course…thanks @Mattias_Persson, I have been searching for this for a while

Tack som fan! :slight_smile:

You’ve got a point. It’s the main picture-elements style blocking your attempt at changing the colors. Change hui-icon-element {color: rgba(255, 255, 255, 0.1) !important; to opacity instead, like this:

- type: picture-elements
  image: /local/background.png
  style:
    .: |
      /* Global */

      #root > hui-icon-element {opacity: 0.1 !important; transition: 0.4s;}
      #root > hui-icon-element:hover {opacity: 0.25 !important; transition: none;}
      #root > hui-icon-element:active {opacity: 0.35 !important; transition: none;}

and then remove alpha and insert initial opacity for all three icons

- type: icon
  icon: mdi:arrow-up-bold-circle-outline
  title: Uppdateringar
  style:
    top: 87.41%
    left: 16.55%
    color: rgb(255, 255, 255)   # <-
    opacity: 0.1                # <-
    padding: 0.8vw
    --mdc-icon-size: 4vw
  tap_action: !include popup/sidebar_update.yaml

If you’re using the special color if there’s an update that needs opacity too

  #root > hui-icon-element:nth-child(10) {
    {% if states('sensor.hass_version_installed') != states('sensor.hass_version_latest') and 
    not is_state('sensor.hass_version_latest', 'unknown') or 
    not is_state('sensor.hacs', '0') and not is_state('sensor.hacs', 'unknown') %}
      color: rgb(35,78,106) !important; opacity: 1 !important;
    {% endif %}
    }

Thanks @Mattias_Persson

Hello Jose, would you share you Lovelace setup?

I try to show all lights that are “on” in a vertical stack card. I want that the lights anrage from the left to right when thy are turned on. So i try it with this :

  ```
     - type: custom:button-card
        entity: light.obergeschoss
        name: Obergeschoss
        style:
          top: 38.35%
          left: 78%
          width: 38%
          z-index: 2
          tap_action:
          action: navigate
          navigation_path: /lovelace/licht
        template: stockwerk

      - type: custom:layout-card
        column_num: 5
        column_width: 200
        layout: vertical
        style: 
          top: 34.5%
          left: 70%
        cards:
          - type: entities
            entities:
             - type: custom:hui-element
               card_type: vertical-stack
               column_num: 5
               cards:
                 - type: custom:hui-markdown-card
                   style:
                   content: >
    
                     {% if is_state('light.schlafzimmer', 'on') %}
                     <img src="/local/zimmer/schlafzimmer.png" width="35%">{% endif %}

                     {% if is_state('light.bad', 'on') %}
                     <img src="/local/zimmer/bad.png" width="35%">{% endif %}
                     
                     {% if is_state('light.tom', 'on') %}
                     <img src="/local/zimmer/tom.png" width="35%">{% endif %}
    
                     {% if is_state('light.elly', 'on') %}
                     <img src="/local/zimmer/elly.png" width="35%">{% endif %}

                     {% if is_state('light.flur_og', 'on') %}
                     <img src="/local/btn/info.png" width="35%">{% endif %}```

, but it only show 2 in one line and the next in a second line.


I have set column_num to 5, but it ignores it. Any ideas why, or ist there a better way to make this? If it was possible, i like to have the Button Cards to show when the light is on, but i dont find out how.

Hi Guys,

i have a problem with a import:

any idea?

You have delet or rename a Yaml in the Popup Folder.

I have change it and make a Sensor for the Markdown :

      eg_active:
        value_template: >-
              {% set lights = [states.light.wohnzimmer, states.light.kuche, states.light.tradfri_esszimmer, states.light.wc, states.light.flur_eg] %}
              {% set lights_on = lights | selectattr('state','eq','on') | list %}
              {% set lights_name = lights | selectattr('state','eq','on') | map(attribute='name') | join(', ') %}

              {% if (lights_on ) %} 
              {{ lights_name | regex_replace(',([^,]*)$',' und\\1') }} sind an</b>

              {% else %} 
              <font color='#6a7377'><b>Alle Lampen sind aus</font> 
              {% endif %}

now, it woks with the Name. But i need to have a Image for each light instead of the Name. hmmmmm…

The card now is easy and looks like:

          - type: custom:hui-markdown-card
            style: 
              top: 18.5%
              left: 65%
            content: >
              <b>{{ states('sensor.eg_active') }}</b>

You pretty much need all of it. What he has put on Github is pretty much the barebones essentials to get started. then you need to explore the code in all the YAML files, understand how everything works together, change sensors, switches, devices, integrations for yours, and then modify his UI code to get it to work with your stuff. It is honestly not something that you can do in a single day. Implementing this in your own Home Assistant instance, to work with your devices, integrations, entities, automations, etc is a pretty big job. There is no quick “click Next/Next/Next/Install” way to implement this. Everything in there is custom coded for his own stuff.

@xADDRx

You can’t use some features like includes in the “Raw config editor”. Use an external editor like VS Code.

why not one card works:

can anyone help me please?

Hi Mattias,
You’ve done an awesome job here, i’m trying to copy almost everything you’ve set up :wink:

I don’t use plex, but use Kodi so i have installed and configured correctly the kodi recently added addon (displaying perfectly in my standard dashboard).

But i’m really lost to replace plex by kodi in your media conditionnal card, nothing is displayed when the conditions are meet.
There is my sensor in the template page :

<template state sensor.kodi_recently_added_movies=off; data=[{"title_default": "$title", "line1_default": "$genres", "line2_default": "$release", "line3_default": "$rating - $runtime", "line4_default": "$studio", "icon": "mdi:arrow-down-bold"}], friendly_name=kodi_recently_added_movies @ 2020-09-01T18:50:35.392924+02:00>

and the conditionnal media card

                 - type: conditional
                   conditions:
                     - entity: light.salon
                       state: 'on'
                   elements:
                     - type: custom:button-card
                       entity: sensor.kodi_recently_added_movies
                       triggers_update:
                         ['sensor.kodi_recently_added_movies']
                       name: Derniers Films
                       state_display: >
                         [[[ const data = states[entity.entity_id].attributes.data;
                         const number = data[1].number == undefined ? '(' + data[1].aired.split('-')[0] + ')' : data[1].number;
                         return `${data[1].title} ${number}`; ]]]
                       custom_fields:
                         icon: >
                           <svg viewBox="0 0 50 50"><path d="M7.7.3h34.6c4.1 0 7.4 3.3 7.4 7.4v34.6c0 4.1-3.3 7.4-7.4 7.4H7.7c-4.1 0-7.4-3.3-7.4-7.4V7.7C.3 3.6 3.6.3 7.7.3z" fill="#282a2d"/><path d="M25,7.1H14.6L25,25L14.6,42.9H25L35.4,25L25,7.1z" fill="#e5a00d"/></svg>
                         blur: >
                           <svg viewBox="0 0 50 50" />
                       styles:
                         custom_fields:
                           media_image: &plex_poster
                             [background-position: center center, background-image: 
                             "[[[ return 'url(' + states[entity.entity_id].attributes.data[1].poster + ')'; ]]]"]
                           blur: *plex_poster
                           overlay: [background: 'rgba(0, 0, 0, 0.4)']
                         card:
                           [color: '#efefef', text-shadow: '1px 1px 5px rgba(18, 22, 23, 0.9)']
                       tap_action:
                         action: none
                       style:
                         top: 50%
                         left: 50%
                         width: 100%
                       template: conditional_media

Forget about the light.salon ‘on’ condition, it’s just for testing.

If you could point me in the right direction, it would be greatly apprecied :slight_smile:
Thx !

Just checked mine. Your sensor is off.

< template state sensor.kodi_recently_added_movies = off;
data = [{
  "title_default": "$title",
  "line1_default": "$genres",
  "line2_default": "$release",
  "line3_default": "$rating - $runtime",
  "line4_default": "$studio",
  "icon": "mdi:arrow-down-bold"
}], friendly_name = kodi_recently_added_movies @ 2020 - 09 - 01 T18: 50: 35.392924 + 02: 00 >

My sensor is online with data.

< template state sensor.plex_recently_added = Online;
data = [{
  'title_default': '$title',
  'line1_default': '$episode',
  'line2_default': '$release',
  'line3_default': '$number - $rating - $runtime',
  'line4_default': '$genres',
  'icon': 'mdi:eye-off'
}, {
  'airdate': '2020-08-25T19:20:32Z',
  'aired': '',
  'release': '$day, $date $time',
  'flag': True,
  'title': 'Firefly',
  'episode': 'Episode 15',
  'number': 'S01E15',
  'runtime': 44,
  'rating': '',
  'poster': '/local/Plex_Recently_Added/p3968.jpg',
  'fanart': '/local/Plex_Recently_Added/f3968.jpg'
}], friendly_name = Plex Recently Added @ 2020 - 08 - 29 T00: 50: 43.488463 + 02: 00 >
1 Like

Thx a lot, you’re right i had a problem with kodi.

Now my sensor is active and populated, but i have a white background and no image.

This is my sensor :

<template state sensor.kodi_recently_added_movies=on; data=[{"title_default": "$title", "line1_default": "$genres", "line2_default": "$release", "line3_default": "$rating - $runtime", "line4_default": "$studio", "icon": "mdi:arrow-down-bold"}, {"aired": "2020-03-05", "airdate": "2020-08-16T01:19:07Z", "flag": true, "genres": "Drame", "rating": "\u2605 6.7", "release": "$date", "runtime": 108, "title": "The Way Back", "studio": "Warner Bros. Pictures", "fanart": "http://image.tmdb.org/t/p/original/5mubFanEHVFJff4jLQH0uIOThMz.jpg", "poster": "http://image.tmdb.org/t/p/original/ylPnfaphW3FrLBUVwAREVtiL9My.jpg"}, {"aired": "2020-03-11", "airdate": "2020-08-16T01:19:07Z", "flag": true, "genres": "Drame,Romance,Histoire", "rating": "\u2605 6.3", "release": "$date", "runtime": 109, "title": "Radioactive", "studio": "Working Title Films", "fanart": "http://image.tmdb.org/t/p/original/e7tjpKP36Xd6BzyTMZo4AUe86VM.jpg", "poster": "http://image.tmdb.org/t/p/original/eTUBqUBLGx0LUY8HWBXD5zyLkOf.jpg"}, {"aired": "1992-05-22", "airdate": "2020-08-15T23:07:45Z", "flag": true, "genres": "Science-Fiction,Action,Horreur", "rating": "\u2605 6.3", "release": "$date", "runtime": 144, "title": "Alien\u00b3", "studio": "Brandywine Productions", "fanart": "http://image.tmdb.org/t/p/original/9WO0CELoWq6tSdjqCs34Y0qek7l.jpg", "poster": "http://image.tmdb.org/t/p/original/6vWHGE0IZCkp1o4cqJ7PqqlYC1s.jpg"}, {"aired": "1986-07-18", "airdate": "2020-08-15T23:06:24Z", "flag": true, "genres": "Action,Thriller,Science-Fiction", "rating": "\u2605 7.9", "release": "$date", "runtime": 154, "title": "Aliens, le retour", "studio": "Brandywine Productions", "fanart": "http://image.tmdb.org/t/p/original/jMBpJFRtrtIXymer93XLavPwI3P.jpg", "poster": "http://image.tmdb.org/t/p/original/3eHFrdmBENZMbutlNMguqTAl3bf.jpg"}, {"aired": "1979-05-25", "airdate": "2020-08-15T23:04:23Z", "flag": true, "genres": "Horreur,Science-Fiction", "rating": "\u2605 8.1", "release": "$date", "runtime": 115, "title": "Alien, le huiti\u00e8me passager", "studio": "Brandywine Productions", "fanart": "http://image.tmdb.org/t/p/original/AmR3JG1VQVxU8TfAvljUhfSFUOx.jpg", "poster": "http://image.tmdb.org/t/p/original/l8CES84JndFlNfBNMxdLRYaLvI6.jpg"}, {"aired": "2020-08-14", "airdate": "2020-08-15T23:04:23Z", "flag": true, "genres": "Action,Crime,Science-Fiction", "rating": "\u2605 6.7", "release": "$date", "runtime": 113, "title": "Project Power", "studio": "Screen Arcade", "fanart": "http://image.tmdb.org/t/p/original/qVygtf2vU15L2yKS4Ke44U4oMdD.jpg", "poster": "http://image.tmdb.org/t/p/original/fjCezXiQWfGuNf4t7LruKky7kwV.jpg"}, {"aired": "2020-07-22", "airdate": "2020-08-15T23:01:59Z", "flag": true, "genres": "Com\u00e9die,Drame", "rating": "\u2605 6.8", "release": "$date", "runtime": 137, "title": "The King of Staten Island", "studio": "Universal Pictures", "fanart": "http://image.tmdb.org/t/p/original/5rwcd24GGltKiqdPT4G2dmchLr9.jpg", "poster": "http://image.tmdb.org/t/p/original/wIYkb0mS9WY53a2dOqCrg0xaSpt.jpg"}, {"aired": "1997-11-12", "airdate": "2020-08-15T22:55:45Z", "flag": true, "genres": "Science-Fiction,Horreur,Action", "rating": "\u2605 6.1", "release": "$date", "runtime": 116, "title": "Alien, la r\u00e9surrection", "studio": "Brandywine Productions", "fanart": "http://image.tmdb.org/t/p/original/zQI8yxl61JTpjCB3MrTbcQBOT82.jpg", "poster": "http://image.tmdb.org/t/p/original/ePPdAnGJk9mR1qNxHhGrIhLAo4Q.jpg"}, {"aired": "2020-06-19", "airdate": "2020-08-15T22:49:16Z", "flag": true, "genres": "Guerre,Action,Drame", "rating": "\u2605 7.5", "release": "$date", "runtime": 91, "title": "USS Greyhound - La bataille de l'Atlantique", "studio": "Playtone", "fanart": "http://image.tmdb.org/t/p/original/xXBnM6uSTk6qqCf0SRZKXcga9Ba.jpg", "poster": "http://image.tmdb.org/t/p/original/stfW5cfX0A5Fvo2SBcXAazlWihg.jpg"}, {"aired": "2020-07-08", "airdate": "2020-08-15T08:33:44Z", "flag": true, "genres": "Familial,Animation,Com\u00e9die,Aventure", "rating": "\u2605 7.5", "release": "$date", "runtime": 93, "title": "Scooby !", "studio": "Warner Animation Group", "fanart": "http://image.tmdb.org/t/p/original/fKtYXUhX5fxMxzQfyUcQW9Shik6.jpg", "poster": "http://image.tmdb.org/t/p/original/4xiq5NpooMCBFjQhGQjx8LqmhTy.jpg"}, {"aired": "2020-02-19", "airdate": "2020-07-07T16:49:30Z", "flag": true, "genres": "Com\u00e9die", "rating": "\u2605 5.8", "release": "$date", "runtime": 97, "title": "10 jours sans maman", "studio": "Soyouz Films", "fanart": "http://image.tmdb.org/t/p/original/5xYyXBhcRfXmZMQ9gCr0a4W2lpu.jpg", "poster": "http://image.tmdb.org/t/p/original/xEbSztKAAwIljX8A537HeZDKXUS.jpg"}, {"aired": "2020-03-04", "airdate": "2020-07-07T16:44:16Z", "flag": true, "genres": "Histoire,Drame", "rating": "\u2605 6.2", "release": "$date", "runtime": 108, "title": "De Gaulle", "studio": "Vertigo Productions", "fanart": "http://image.tmdb.org/t/p/original/gQV3joTmJmqN7I5G6Cpjvy84WWd.jpg", "poster": "http://image.tmdb.org/t/p/original/lfxs2YnuuLR037Ad4wesW5O9oUW.jpg"}, {"aired": "2019-11-27", "airdate": "2020-07-07T16:43:23Z", "flag": true, "genres": "Com\u00e9die,Drame", "rating": "\u2605 4.5", "release": "$date", "runtime": 83, "title": "Toute ressemblance\u2026", "studio": "Les Films du 24", "fanart": "http://image.tmdb.org/t/p/original/ofZaU8KxCjWMZ6dz8uL5lbxuxre.jpg", "poster": "http://image.tmdb.org/t/p/original/pqSaIXltXdFKsu8dt4ppNmuBPWs.jpg"}, {"aired": "2019-12-19", "airdate": "2020-06-29T17:11:02Z", "flag": true, "genres": "Fantastique,Familial,Aventure,Drame", "rating": "\u2605 6.9", "release": "$date", "runtime": 125, "title": "Pinocchio", "studio": "Fonds Eurimages du Conseil de l'Europe", "fanart": "http://image.tmdb.org/t/p/original/AdqOBPw4PdtzOcfEuQuZ8MNeTKb.jpg", "poster": "http://image.tmdb.org/t/p/original/xoYcb037L7JQw6MZo1fhM16mfJ7.jpg"}, {"aired": "2018-01-27", "airdate": "2020-06-29T17:08:49Z", "flag": true, "genres": "", "rating": 0.0, "release": "$date", "runtime": 11, "title": "Bluebird", "studio": "", "fanart": "", "poster": "http://image.tmdb.org/t/p/original/c97uq80B1A3JxNS3SiVsK9xWoBM.jpg"}, {"aired": "2020-03-06", "airdate": "2020-06-13T16:58:23Z", "flag": true, "genres": "Drame", "rating": "\u2605 7.6", "release": "$date", "runtime": 120, "title": "The Banker", "studio": "Romulus Entertainment", "fanart": "http://image.tmdb.org/t/p/original/jqz8FwISQfyum47PUqgPTGtmiMk.jpg", "poster": "http://image.tmdb.org/t/p/original/biXzsw22U6vSd0XktmZwAOc4uik.jpg"}, {"aired": "1998-10-30", "airdate": "2020-06-13T16:55:41Z", "flag": true, "genres": "Drame", "rating": "\u2605 8.4", "release": "$date", "runtime": 118, "title": "American History X", "studio": "New Line Cinema", "fanart": "http://image.tmdb.org/t/p/original/9LSsSPbP715XT9B7acIZzantPyX.jpg", "poster": "http://image.tmdb.org/t/p/original/yygSRdHdcIVPRNC0rDv658ZdJiD.jpg"}, {"aired": "2019-07-19", "airdate": "2020-06-13T16:54:41Z", "flag": true, "genres": "Animation,Romance,Fantastique,Drame,Aventure", "rating": "\u2605 8.0", "release": "$date", "runtime": 113, "title": "Les Enfants du Temps", "studio": "Toho Company, Ltd.", "fanart": "http://image.tmdb.org/t/p/original/ize3ZieqSy0TCWljmVoEiy8fSFS.jpg", "poster": "http://image.tmdb.org/t/p/original/k0tHYSbzOEkxOYoVLLstLg4Gdkd.jpg"}, {"aired": "2019-07-10", "airdate": "2020-06-03T17:14:01Z", "flag": true, "genres": "Horreur", "rating": "\u2605 6.4", "release": "$date", "runtime": 95, "title": "The Wretched", "studio": "", "fanart": "http://image.tmdb.org/t/p/original/su0huGwZfAmzPvUjnlG42LO9GFl.jpg", "poster": "http://image.tmdb.org/t/p/original/7Jk4pDMM3G9h29lWshEZjX711wg.jpg"}, {"aired": "2018-01-25", "airdate": "2020-06-03T17:13:32Z", "flag": true, "genres": "Drame", "rating": 0.0, "release": "$date", "runtime": 71, "title": "Tranquillo", "studio": "Letterbox Collective Filmproduktion", "fanart": "", "poster": "http://image.tmdb.org/t/p/original/y6frInBbBht833Y40JSWiOfPMxu.jpg"}, {"aired": "2007-01-24", "airdate": "2020-06-03T17:13:06Z", "flag": true, "genres": "Com\u00e9die,Drame", "rating": "\u2605 6.5", "release": "$date", "runtime": 93, "title": "King of California", "studio": "Nu Image", "fanart": "http://image.tmdb.org/t/p/original/dp3SyjDLboXzyYHOciPGdAWemX7.jpg", "poster": "http://image.tmdb.org/t/p/original/zLoa3oJ83zo9g3mV9LNCHbqO7jH.jpg"}, {"aired": "2020-04-16", "airdate": "2020-05-29T14:41:41Z", "flag": true, "genres": "Science-Fiction,Drame,Thriller", "rating": "\u2605 6.3", "release": "$date", "runtime": 113, "title": "Spoutnik", "studio": "Vodorod", "fanart": "http://image.tmdb.org/t/p/original/lGydLXSaDLxN8WoAdubHCnhAgfd.jpg", "poster": "http://image.tmdb.org/t/p/original/tBi5xW9Rd0YoGB0aAggV0EN5LDP.jpg"}, {"aired": "2020-02-06", "airdate": "2020-05-29T14:39:36Z", "flag": true, "genres": "Horreur", "rating": "\u2605 5.2", "release": "$date", "runtime": 104, "title": "A Night of Horror: Nightmare Radio", "studio": "Black Mandala", "fanart": "http://image.tmdb.org/t/p/original/bs7mYckE4BeVRtxK9MRYhNZTTqg.jpg", "poster": "http://image.tmdb.org/t/p/original/g7EYDfGgNEF1IQymS7EvDLKnpxT.jpg"}, {"aired": "1986-05-16", "airdate": "2020-05-26T11:17:43Z", "flag": true, "genres": "Action,Drame", "rating": "\u2605 6.9", "release": "$date", "runtime": 109, "title": "Top Gun", "studio": "Paramount", "fanart": "http://image.tmdb.org/t/p/original/vSZtQrlJqgjz4GIbnF3kBDkzJFE.jpg", "poster": "http://image.tmdb.org/t/p/original/oBe6dugbK95jabwiIo5uwMU7DYJ.jpg"}, {"aired": "2020-01-01", "airdate": "2020-05-22T09:13:18Z", "flag": true, "genres": "Drame", "rating": "\u2605 8.0", "release": "$date", "runtime": 144, "title": "S\u00e9jour dans les monts Fuchun", "studio": "Dadi Film Group", "fanart": "http://image.tmdb.org/t/p/original/AsDanXphy2uvK227rIZP1BiUWEr.jpg", "poster": "http://image.tmdb.org/t/p/original/7vSuF1621x63Zc5OOyCAx5sxtu.jpg"}], friendly_name=kodi_recently_added_movies @ 2020-09-02T19:17:32.692334+02:00>

maybe its the &plex_poster and *plex_poster?
sorry i’m really lost in css and half only in yaml :stuck_out_tongue:

thx again !

I think I’m done! Thanks very much for this awesome layout and design!! Unfortunately my nexus 7 (2012) is not powerful enough to show this dashboard, so guess I need a new tablet :frowning:

7 Likes

What do you get in template dev tools?

{% set data = states.sensor.kodi_recently_added_movies.attributes.data %}
{{ data }}

{{ data[1].title }}
{{ data[1].poster }}

You don’t seem to have “number” in your attributes but the js is pretty much the same syntax. Here it checks if there is an episode number, if not then it’s a movie so it returns the release year instead. You can try removing that.

state_display: >
  [[[ const data = states[entity.entity_id].attributes.data;
  const number = data[1].number == undefined ? '(' + data[1].aired.split('-')[0] + ')' : data[1].number;
  return `${data[1].title} ${number}`; ]]]

I also have max 1 entry because it only shows the last added anyway and have it set to save the poster locally.

  - platform: plex_recently_added
    token: !secret plex_token
    host: !secret plex_host
    port: !secret plex_port
    max: 1
    img_dir: '/'
    image_resolution: 500

Since I’m a beginner, I would ask one of you to show me only part of the view:

grafik

Can someone make the part available to me?

Thank You!!

Did you install hacs? I bet /hacsfiles/… are only served if you install it. And then install all the resources yourself instead of cloning my repo so hacs can keep them up to date.