A different take on designing a Lovelace UI

Use this template for state_display. I already deleted the unneccessary lines from the additional “value”.

  climate:
    template: ['base']
    aspect_ratio: 1/1
    show_state: false
    show_icon: false
    show_name: true
    show_current_temperature: true
    show_control: true
    state_display: >
        [[[ if (entity.attributes.hvac_action === 'heating' ) { return 'verwarmen'; }
        if (entity.attributes.hvac_action === 'idle') { return 'inactief'; 
        } ]]]
    state:
      - operator: template
        value: >
          [[[ return (states[entity.entity_id].attributes.hvac_action == 'heating') ]]]
        styles:
          card: [background-color: 'rgba(255, 255, 255, 0.8)']
          name: [color: 'rgba(0, 0, 0, 0.6)']
          value: [color: 'rgba(0, 0, 0, 0.6)']
    custom_fields:
      circle_current: >
        [[[ {
        const temperature = entity.attributes.current_temperature;
        const stroke_color = entity.attributes.hvac_action === 'heating' ? 'rgba(255, 255, 255, 0.8)' : 'rgba(255, 255, 255, 0.8)'; 
        const fill_color = entity.attributes.hvac_action === 'heating' ? 'rgba(255, 255, 255, 0.8)' : 'rgba(255, 255, 255, 0.8)';
        const radius = 0;
        return `<svg viewBox="0 0 60 60"><circle cx="30" cy="30" r="${radius}" stroke="${stroke_color}" stroke-width="0" fill="${fill_color}" style="
        transform: rotate(-90deg); transform-origin: 50% 50%; " />
        <text x="50%" y="54%" fill="#8d8e90" font-size="25" text-anchor="middle" alignment-baseline="middle">${temperature}<tspan font-size="10">°</tspan></text></svg>`; } ]]]
      circle_target: >
        [[[ if (entity.attributes.hvac_action === 'heating' && entity.attributes.temperature) {
        const temperature = entity.attributes.temperature;
        const stroke_color = entity.attributes.hvac_action === 'heating' ? '#b2b2b2' : '#313638'; 
        const fill_color = entity.attributes.hvac_action === 'heating' ? 'idle' : '#FFFFFF08';
        const radius = 0;
        return `<svg viewBox="0 0 50 50"><circle cx="30" cy="30" r="${radius}" stroke="${stroke_color}" stroke-width="0" fill="${fill_color}" style="
        transform: rotate(-90deg); transform-origin: 50% 50%; " />
        <text x="50%" y="54%" fill="#3182b7" font-size="14" text-anchor="middle" alignment-baseline="middle">${temperature}<tspan font-size="10">°</tspan></text></svg>`; } ]]]
    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]
      custom_fields:
        circle_target: 
          [top: 8.5%, left: 54.5%, width: 3.5vw, position: absolute, letter-spacing: 0.03vw]
        circle_current: 
          [top: 8.5%, left: 6%, width: 3.5vw, position: absolute, letter-spacing: 0.03vw]

Does your climate.entity does not have a state like heat or idle? If so, you can also replace

    state:
      - operator: template
        value: >
          [[[ return (states[entity.entity_id].attributes.hvac_action == 'heating') ]]]
        styles:
          card: [background-color: 'rgba(255, 255, 255, 0.8)']
          name: [color: 'rgba(0, 0, 0, 0.6)']
          value: [color: 'rgba(0, 0, 0, 0.6)']

with

    state:
      - value: 'heating'

Just change ‘heating’ to whatever your entity has.
I used the template only to change color to red in depence of boost is activated or not.

Thanks for the reply, but it isn’t working. Now it won’t show anything. The climate.entity only has two states, one is heat the thermostat is working and one is off and this is really off. I have to do it with the hvac_action this is the one that does change from heating to idle when i set a temprature.
On Off

So please only change the template. Ignore the last two pieces of code in my post.

Can you confirm that you only changed the template and it is still not working?

I only used your template and it won’t work.

EDIT
Its working now.
the show_state was set to false and in styles for state there where value: instead of state:
Thanks for helping

1 Like

Got problems with border-radius.

Why is the border-radius not taken?

          - type: 'custom:mini-graph-card'
            entities:
              - sensor.wohnzimmer_temperatursensor_luftfeuchtigkeit
            color_thresholds:
              - color: '#007BFE'
                value: 55
              - color: '#26fe00'
                value: 47.5
              - color: '#FF5733'
                value: 40
              - color: '#fe0000'
                value: 35
            style:
              top: 43.4%
              left: 30.31%
              width: 10%
              border-radius: 0.8vw
            line_color: blue
            line_width: 8
            font_size: 75
            show:
              name: false
              icon: false
              state: false

Tried 0.8vw and 25px. nothing works.

Also card-mod workaround wont work

How are you implementing it?

screenshot
this works fine

          - type: custom:button-card
            entity: light.skrivbord
            name: Skrivbord
            style:
              top: 20.35%
              left: 41.31%
              width: 10%
            custom_fields:
              graph:
                card:
                  type: 'custom:mini-graph-card'
                  entities:
                    - sensor.hall_temperature
                  color_thresholds:
                    - color: '#007BFE'
                      value: 55
                    - color: '#26fe00'
                      value: 47.5
                    - color: '#FF5733'
                      value: 40
                    - color: '#fe0000'
                      value: 35
                  line_color: blue
                  line_width: 8
                  font_size: 75
                  show:
                    name: false
                    icon: false
                    state: false
            styles:
              custom_fields:
                graph:
                  [top: 75%, left: 0%, width: 100%, position: absolute]
            template: light
4 Likes

Then you can pretty much delete everything under content: >

{{ states('sensor.energy1') }} | {{ states('sensor.energy2') }}

It’s working.

Made a second card and placed it over the button-card. Read it anywhere in this thread. Didn’t know that I can implement it that way.

That way is very nice. Just finished the first version of my camera-card:


Use the picture-glance card here. Only the black bar on the bottom is annoying. Dont know how to get rid of that, or maybe another card, which can show me a regulary updated picture of a camera.

1 Like

Thanks! Almost there, seem to have some issues with the alignment of the sensor/data.

          - type: custom:hui-markdown-card
            class: coronavirus
            style: {top: 93.65%, left: 70.2%}
            content: >
                <font color='#6a7377'>
                <ha-icon icon="mdi:power-plug"></ha-icon> <b>Temperature</b>{{ break -}}
                <ha-icon icon="mdi:chart-bar"></ha-icon> <b>{{ states('sensor.aqara_temp_bedroom_temperature') }}</b> fall{{ break -}}
                <ha-icon icon="mdi:chart-bar"></ha-icon> <b>{{ states('sensor.aqara_temp_bedroom_humidity') }}</b> fall{{ break -}}
                <ha-icon icon="mdi:chart-bar"></ha-icon> <b>{{ states('sensor.aqara_temp_bedroom_humidity') }}</b> fall{{ break -}}
                </font>

Using Temperature sensors now to have some data to present, should work with other sensors I guess.
Help will be much appreciated!

It’s natively supported. Search camera.

1 Like

How did you get the camera in there? :slight_smile:
Do you have the code for me please? I would then namely finish a popup when clicking so that it is then enlarged

I just changed to picture-elements-card like @Mattias_Persson mentioned above.

Also struggling with the state-badge. As far as I see, at least one element is neccessary, so o moved the badge out of sight. The best would be, to have a nice animated svg-icon to show motion.

          - type: custom:button-card
            entity: camera.garten_kamera_hof
            name: Hof
            show_entity_picture: false
            show_state: false
            style:
              top: 64.5%
              left: 55.18%
              width: 10%
            tap_action: 
              action: more-info
            # hold_action: 
            custom_fields:
              picture:
                card:
                  type: picture-elements
                  camera_image: camera.garten_kamera_hof
                  elements:
                    - type: state-badge
                      entity: binary_sensor.garten_kamera_hof_bewegung
                      style:
                        top: 20%
                        left: 15%
            styles:
              custom_fields:
                picture:
                  [top: -7%, left: -75%, width: 190%, position: absolute]
            template: base

The position of the custom_field “picture” is optimated to see the best area of the camera, because its widescreen and not square.

The option camera_view for the picture-elements-card should give you a live-view if you want that. But note that it will require the stream component.
Just add it unter camera_image

camera_view: live

I dont use that, because i disabled the stream component to prevent camera lags.

2 Likes

I meant just adding the camera

picture elements -> camera

You’re doing

picture elements -> button-card -> picture elements -> camera

I mean it works but it’s unnecessary

Hi, can somebody tell what am I missing? There’s clock somehow shifted up, the sidebar fonts are strange, and something missing in a middle of sidebar…

pls help mi.

how to solve this problem with updating time?

Did you choose the right theme?

I dont get it. Any hints?
If I only add the camera as a entity and use the entity_picture then I get empty bars at top and bottom.
So i started to nest a picture-entity into the button-card. Then changed to picture-elements to get rid of the bar from picture-entity.

Now you telling me that there is an easier way. I want that way, because I prefer cleaner code. But dont understand what you are trying so say. :confused:

As far as i understand, this is the bare minimum. Like you did in the media-controls. But now I am getting an error “Unknown type encounterd: picture-elements” :confounded::confounded::confounded:

          - type: picture-elements
            camera_image: camera.garten_kamera_hof
            elements:
              - type: state-badge
                entity: binary_sensor.garten_kamera_hof_bewegung
                style:
                  top: 20%
                  left: 15%
            style:
              top: 64.5%
              left: 55.18%
              width: 10%
            tap-action:
              action: more-info
            template: base

€: got it!
The whole thing is a picture-elements card, and you to say, that i can easily make an element called “image” in this. :sob: obviously never understood the whole thing.

          - type: image
            camera_image: camera.garten_kamera_hof
            elements:
              - type: state-badge
                entity: binary_sensor.garten_kamera_hof_bewegung
                style:
                  top: 20%
                  left: 15%
            style:
              top: 64.5%
              left: 55.18%
              width: 10%
            tap-action:
              action: more-info
            template: base

But the problem now is, that the camera picture is widescreen and wont fit. Keep working on it…

I really like your climate card, but i´m unable to recreate it. i copied your code to button_card_templates.yaml and also your example for ui-lovelace. I don´t get error messages. thermostat-popup-card is installed. Any idea why nothing is shown?
thanks!

Double check that everything is on the right place. Also check that the style attribute is correct.
This is reliable for the position.

And what exactly is the problem? Just nothing shown? Can you post a screenshot of your dashboard?