A different take on designing a Lovelace UI

Hy Mathias
I started to develop my lovelace with a menu in the sidebar.
I have a yam file for each lovelace panel and one sidebar.yaml file for the menu which is called by each file.
Now, I would like to change the item menu style according to the current dashboard. Do you have any idea for a condition on the current lovelace ? Or maybe my way is not the best and I need to change the grid and have a conditional card like you mentioned it ?
Thanks for your help

Could anybody tell me, where i can specify “state_color: true” if im using mdi:icons?

hi @Mattias_Persson So that the weather card takes up more space in height. Do I have to put together a grid and customize it?
Thanks

The weather card is not designed with a square layout in mind. Can you conceptualize how you would fill that space without stretching the card?

You could make your own with button card [example]
or add the weather card to the sidebar

Use the icon: config variable instead (not custom field). if you must use <ha-icon> you can add a css variable

custom_fields:
  icon: |
    <ha-icon icon="hue:play-bar" style="color:var(--button-card-light-color);"></ha-icon>
1 Like

You can use this template by @Mariusthvdb for current view as a condition in sidebar yaml

[[[ return window.location.pathname.split('lovelace/')[1]; ]]]
1 Like

I don’t know about the first one but changing icons in type: button is potentially bugged

1 Like

I’m using this layout

swipe-card
→ horizontal-stack → conditional
→ grid

some people tried (which I didn’t test)

swipe-card
→ grid
→ grid

which cut off the bottom part and the reason I added height: 100%

working example

      - type: grid
        title: Media
        view_layout:
          grid-area: media
        columns: 1
        cards:

          - type: custom:swipe-card
            start_card: 1
            parameters:
              roundLengths: true
              effect: coverflow
              speed: 650
              spaceBetween: 20
              threshold: 7
              coverflowEffect:
                rotate: 80
                depth: 300
            cards:

              - type: grid
                columns: 2
                cards:

                  - type: custom:button-card
                    entity: media_player.vardagsrum
                    name: Vardagsrum
                    template:
                      - media
                      - icon_apple_tv

                  - type: custom:button-card
                    name: Sovrum
                    entity: media_player.sovrum
                    template:
                      - media
                      - icon_apple_tv

                  - type: custom:button-card
                    entity: media_player.spotify
                    name: Spotify
                    template:
                      - media
                      - icon_spotify

                  - type: custom:button-card
                    entity: media_player.kok
                    name: Nest Mini
                    template:
                      - media
                      - icon_nest_mini

              - type: grid
                columns: 2
                cards:

                  - type: custom:button-card
                    entity: media_player.vardagsrum
                    name: Vardagsrum
                    template:
                      - media
                      - icon_apple_tv

                  - type: custom:button-card
                    name: Sovrum
                    entity: media_player.sovrum
                    template:
                      - media
                      - icon_apple_tv

                  - type: custom:button-card
                    entity: media_player.spotify
                    name: Spotify
                    template:
                      - media
                      - icon_spotify

                  - type: custom:button-card
                    entity: media_player.kok
                    name: Nest Mini
                    template:
                      - media
                      - icon_nest_mini
1 Like

Do you have this line? extra_styles fix

There’s this basic guide at least. You’re welcome to make a video :wink:

Have you tried putting custom:thermostat-dark-card by itself and not inside custom:button-card?

I bet my templates are messing with your bottom right icons. Can you post how you’ve set those up?

Yeah, and to add to that I don’t think that markdown is inherently bad but styling it is a nightmare.

The nice thing about button card is that if one doesn’t want to convert all jinja templates to javascript, incorporating existing template sensors works fine too.

1 Like

The easiest way would be to swap out the svg
on = a.svg
off = b.svg

custom_fields:
  icon: >
    [[[
      if (entity.state == 'on') {
        return `
          <svg viewBox="0 0 50 50">
            <rect width="40" height="40" fill="blue" />
          </svg>
        `;
      }
      if (entity.state == 'off') {
        return `
          <svg viewBox="0 0 50 50">
            <circle cx="20" cy="20" r="20" fill="red" />
          </svg>
        `;
      }
    ]]]

I would probably just conditionally display the “light” path though

4 Likes

Here’s how, timeout is in milliseconds

Do you have these sensors working?

  • sensor.hass_version_latest_beta
  • sensor.hass_version_latest
  • sensor.hass_release_notes_rc
  • sensor.hass_release_notes

It’s because you’re not following the guide

1 Like

Thanks, @anon36468094 assisted and everything went ok. for now my lovelace is like below, improving every day… your design is awesome.


2 Likes

Yes. equal

thanks for getting back to me.
in fact I haven’t, other than on the entity itself, the button-cards are very plain, and only use your templates as posted.
I’ve also carefully checked if I dont use any templates with the same name myself, which happened in another spot :wink:

Just checked, and Firefox looks identical to Safari. Only Chrome shows the animated icons…

wait: I had edited the base: template and commented some code that I didnt use (screensaver, galaxy etc) but apparently commented too much. now looking like:


which is much better. Interesting to learn once again that not all browsers are equal…
not sure why it shows the ‘unknown’ s yet, but that should be easy to fix :wink: fixed… wrong entity_id’s duh…

1 Like