šŸŒ» Lovelace UI ā€¢ Minimalist

I cannot find the rest of the code for the media-player button. Can you share?
Found all now but how to setup card correct, mine does not look like your picture
image

                    - entity: media_player.kok
                      name: Sonos
                      template: 
                        - icon_info_bg
                        - media_buttons
                      type: 'custom:button-card'

Why would you say that? That template seems fine?

Iā€™m interested in that, too. I always use the option without curly brackets and it works as desired. What is the advantage of Paddyā€™s solutions?

Itā€™s not because of the brackets, itā€™s the logic behind. :slight_smile:

With this version, there are three if-statements, and the last one overwrites the previous two.
if (entity.state == 'hjemme') return 'šŸ ';
This one checks, if the state is ā€œhjemmeā€. If it is, the icon will be set.
The next line does the same, but independent from the first.
The third line is another if-statement, that answers the question, is the state ā€œferieā€, if not, show the burnng icon. It is run totally indepent of the statements before. So every state, that is not ā€œferieā€ shows the burning icon, no matter the two statements before.

To sum it up, the first two if-statements are totally ignored, the only one that is shown in the end is the third one, and that checks only, if the state is ā€œferieā€. Nothing else. :slight_smile:

I hope this is understandably explained, if not, please ask again. :slight_smile:

EDIT: This is exactly, why I use the curly brackets. Short hand code writing is easy, but it hides the logic a little bit. With the brackets it is easy to see, that the three statements donā€™t belong together and therefor donā€™t work together.

Maybe Iā€™m blind, but isnā€™t this the same logic? (from my covers template)


      label: |
        [[[ 
          if (entity.attributes.current_position == 100) return 'vollstƤndig geƶffnet';
          if (entity.attributes.current_position == 0) return 'vollstƤndig geschlossen';
          if (entity.attributes.current_position <= 20) return 'geschlossen';
          else return entity.attributes.current_position + '% geƶffnet';
        ]]]

It always works as defined.

Youā€™re totally right, my bad, Iā€™m sorry! :flushed:

The ā€œreturnā€ leaves the actual function and therefor the next statements arenā€™t run. insert-the-head-banging-smilie-here Sorry for the confusion, seems Iā€™m not awake enoughā€¦ Iā€™ll go and repair my car now, before I post other nonsenseā€¦ Sorry, really! :slight_smile:

Iā€™ll make a note at the code above. :slight_smile:

1 Like

Not referring to the brackets.
Not sure why you think it does what you state here, but itā€™s not the fact.

Upon each state change the template
is evaluated.

The template will be fine as is. For reference you can see the many templates I show in my examples for custom-ui

Btw: the ā€˜elseā€™ is not even required :wink: a simple ā€˜returnā€™ suffices in the last line

Everythingā€™s fine! I just wondered if there was a better way :slightly_smiling_face: :heart:

Totally right. I use it only for clarity purposes and so that my dumb head still knows later what I wanted to express with it. :crazy_face:

1 Like

As I said in the post above, my bad, Iā€™m sorry for the confusion! :slight_smile:

- type: 'custom:button-card'
  variables:
    entity: media_player.living_room
    template: media_buttons

This actually works here :slight_smile:

1 Like

Need some help to making the header generic.
I have made a my_chips template and added this to my frontpage yaml:

      - cards:
          - template: my_chips
            type: 'custom:button-card'
        type: horizontal-stack

Then I have made this and added it to the button_card_template.yaml:

  my_chips:
    - template: edge
      type: 'custom:button-card'
    - template: chips_temperature
      type: 'custom:button-card'
    - template: chips
      type: 'custom:button-card' 
      tap_action:
        action: navigate
        navigation_path: '/lovelace-yaml2/lys/'
      label: |
          [[[
            var antall = states['sensor.lights_on_counter'].state;
            return 'šŸ’”' + antall ;
          ]]]
    - template: chips
      label: "šŸ›’"
      type: 'custom:button-card' 
      tap_action:
        action: navigate
        navigation_path: '/lovelace-yaml2/handleliste/'
    - template: chips
      label: "šŸ§¹"
      type: 'custom:button-card' 
      tap_action:
        action: navigate
        navigation_path: '/lovelace-yaml2/vaskeoversikt/'
    - template: edge
      type: 'custom:button-card'

the result:
image

just a white line. What im a missing?:slight_smile:

      - cards:
          - template: my_chips
            type: 'custom:button-card'
        type: horizontal-stack

You are defining a button card and passing a list of cards to it.
So I think this wont work no matter what ā€¦
Thatā€™s also why youā€™re seeing one big white card

But I dont actually know how to fix it :confused:
Try and follow the configuration options from button-card: here

Ps: Nice background :smiley:

@paddy0174

Can you post the configuration of your inheritance, if possible? :slight_smile:

yeah was afraid of that, maybe I can use the !include function.

Thanks, I have stole it from someone else in this topic:)

What do you mean whit inheritance? :slight_smile:

Depending on what you have, you can use templates for that as well. Templates from button-card (thatā€™s what this is basically about) can be inherited from other templates. So what you need in the end, is a template like my_chips that inherit from the default chips.

Like this:
first_page_chips ā†’ inherits from my_chips ā†’ inherits from chips. :slight_smile:

Iā€™m guessing you took the idea from this comment from @paddy0174?
Thatā€™s what Iā€™m referring to :slight_smile:

Thats correct, yes my inherits as I think of it is just from the standard button_card_templates.yaml file. So nothing fancy there. Maybe Paddy0174 have some tips, hint hint paddy;)

Solution:

  - title: Hjemme 
    icon: 'mdi:home-variant'
    path: home
    cards:
      - cards:
          - cards:
             - !include /config/lovelace/felles/chips.yaml
            type: horizontal-stack

Then just add the cards you like in the chips.yaml file:)

1 Like

I just found this and now I feel I have to change up my own ui to this!! :heart_eyes:

2 Likes