A different take on designing a Lovelace UI

I’m working on different dashboards with different styles and for both im using different themes and even dark or light mode.

Therefore is it somehow possible to specify a specific theme AND if dark or light mode on a specific dashboard and others for another dashboard?

Right now i actually can only use one properly which will destroy the visuals on the other one. I manually need to change the theme for the using device depending on the dashboard i want to use :frowning:

image
this alone is not working because the other one is in light mode.
Any ideas?

I just can’t get the weather max/min label working. I’m running into this error:
image
If I remove the label section it is working, just without obviously the labels of min and max temp :confused:
Any ideas? I tried to work with the sensor directly in the template and not with variables but this doesn’t change it…

if you have a temperature sensor you can try to change this way.

    label: >   
      [[[
        return `<ha-icon
          icon="mdi:arrow-up-thin"
          style="width: 20px; height: 20px; margin-right: -5px;">
          </ha-icon><span>: ${states[variables.sensor].state}°</span>
                <ha-icon
          icon="mdi:arrow-down-thin"
          style="width: 20px; height: 20px; margin-right: -5px;">
          </ha-icon><span>: ${states[variables.sensor].state}°</span>          
        `
      ]]]

sadly that didnt work, I already tried alot but nothing :confused:
image
But the sensor is working

share the code of the card

  - type: custom:button-card
    entity: weather.pirateweather
    name: Berlin
    template:
      - base
      - widget_weather
    variables:
      temp_min: sensor.pirateweather_daytime_low_temperature_0d
      temp_max: sensor.pirateweather_daytime_high_temperature_0d

Try this.

    label: >   
      [[[
        return `<ha-icon
          icon="mdi:arrow-up-thin"
          style="width: 20px; height: 20px; margin-right: -5px;">
          </ha-icon><span>: ${states[variables.temp_max].state}°</span>
                <ha-icon
          icon="mdi:arrow-down-thin"
          style="width: 20px; height: 20px; margin-right: -5px;">
          </ha-icon><span>: ${states[variables.temp_min].state}°</span>          
        `
      ]]]

nope, not working :confused:

I’m sorry, but I don’t know :pensive:

1 Like

Thanks for your effort!
Bay the way i changed the template to:

    entity_picture: |
      [[[
        return entity && entity.state
          ? `/local/animated-weather-icons/${entity.state}.svg`
          : '?';
      ]]]

and im using slightly different .svg’s

image

3 Likes

Hello Mattias,

Thanks for your work

I have a problem with this sensor template. It’s return : 1970-01-01T00:00:00+00:00

This is my code :

And the basic sensor

Hi @Mattias_Persson . Why do I not see fullykiosk services.
The error is when you want to call this service. Says that does not exist. The fullykios-mode integration is added and I don’t see any errors there.
Thanks

      - service: fullykiosk.load_start_url
        data:
          entity_id: media_player.tab_10_pro

I tweaked your code (well Mattias’s) just a little bit more. Took out all the un needed light template stuff.
I also use the Tesla integration on github that you offered but found that it often gives back unknown values. So I’m using Teslamate which ALWAYS gives back values. So much more accurate.
I also used the push action as a climate control instead of the given popup info card as I’m already using that in the sidebar bottom icons.

This is what it looks like.

And this is the changed code:

ui-lovelace:

                  - type: custom:button-card
                    entity: sensor.tesla_est_battery_range_mi_1
                    tap_action:
                      !include popup/tesla1_climate.yaml
                    name: Blanche
                    variables:
                      retain: binary_sensor.blanche_charger_sensor
                    template:
                      - tesla1
                      - icon_tesla

tesla1 template:

tesla1:
  template:
    - base
    - charge1
  aspect_ratio: 1/1
  show_state: true
  show_icon: false
  show_name: true
  show_current_temperature: true
  show_control: true
  state:
    - operator: template
      value: >
        [[[ return (states['sensor.tesla_battery_level_1'].state > 20) ]]]
      styles:
        card: [background-color: "rgba(255, 255, 255, 0.8)"]
        name: [color: "rgba(0, 0, 0, 0.6)"]
        state: [color: "rgba(0, 0, 0, 0.6)"]
  styles:
    name: [top: 57.7%, left: 11%, line-height: 2vw, position: absolute]
    state: [top: 74%, left: 11%, line-height: 2vw, position: absolute]
    card:
      [
        font-family: Sf Display,
        letter-spacing: 0.05vw,
        font-weight: 400,
        color: "rgba(255, 255, 255, 0.3)",
        font-size: 1.34vw,
        background-color: "rgba(115, 115, 115, 0.2)",
        border-radius: 0.8vw,
        box-shadow: none,
        transition: none,
      ]

charge1 template:

charge1:
  custom_fields:
    circle: >
      [[[
        if (Math.round(states['sensor.blanche_battery_sensor'].state) > 0) {
          const input = states['sensor.blanche_battery_sensor'].state;
          const radius = 20.5;
          const circumference = radius * 2 * Math.PI;
          return `
            <svg viewBox="0 0 50 50">
              <style>
                circle {
                  transform: rotate(-90deg);
                  transform-origin: 50% 50%;
                  stroke-dasharray: ${circumference};
                  stroke-dashoffset: ${circumference - input / 100 * circumference};
                }
                tspan {
                  font-size: 10px;
                }
              </style>
              <circle cx="25" cy="25" r="${radius}" stroke="#b2b2b2" stroke-width="1.5" fill="none" />
              <text x="50%" y="54%" fill="#8d8e90" font-size="14" text-anchor="middle" alignment-baseline="middle" dominant-baseline="middle">${input}<tspan font-size="10">%</tspan></text>
            </svg>
          `;
        }
      ]]]
  styles:
    custom_fields:
      circle: &person1
        - display: initial
        - width: 90%
        - letter-spacing: 0.03vw
        - margin: -6% -6% 0 0
        - justify-self: end
        - opacity: 1

I kept your icon-telsa template the same. Thanks a ton. It looks nice.

@Mattias_Persson One thing I didn’t understand was this:

circle: &person1

What does this portion do? I have 2 cars so I had to use &person1 and &person2 in order to make it work but I have not clue what circle: &person1 does?

2 Likes

Do you know why my fonts don’t have the right size? I used the code from pex81 and only edited the last displayed line on the button card.
image

you can change the size in the Template:

try this:

      extra_styles: |
        [[[
          return `
            #name {
              font-size: 0.60vw;
            }
            #temp {
              font-size: 1.9vw;
            }
            #state {
              font-size: 0.60vw;
            }  
            #label {
              font-size: 0.60vw;
            }

Worked! Thank you

image

Shame on me!
…In Germany we have a saying which is translated word by word to:
“not being able to see the forest for the trees”…
(missing the obvious)

The sensor for low-temp had a slightly different name than the high-temp one additional to just high and low…

-.-

Hello. @Mattias_Persson Why did you choose to load the resources with yaml mode and not installing them by hacs. In the case of loading them from configuration.yaml, how do you know if there are new versions or how do you update them? Thank you

Is there a way to say button card XY can only be toggled by a specific user? Like every person can only control the buttons of his own room?

EDIT: Solved it on my own using the locked feature.

You know I have to admit if I would just read the docs on “templating”, custom:button-card, and browser-mod, and refresh myself on CSS, I wouldn’t have so many questions.