šŸŒ» Lovelace UI ā€¢ Minimalist

I have a problem with buttons no alway on same place during on / off.

ezgif.com-gif-maker (1)

Here is code:

  widget_temperature:
    tap_action:
      action: toggle
    color: var(--google-grey-500)
    show_icon: false
    show_name: false
    show_label: true
    size: 20px
    label: |-
      [[[
          var current_temperature = entity.attributes.current_temperature;
          var temperature = entity.attributes.temperature;
          if (entity.state == 'off') {
            var temperature = current_temperature;
          }
          return temperature + 'Ā°C'
      ]]]
    styles:
      card:
        - box-shadow: none
        - padding: 0px
        - background-color: 'rgba(var(--couleur-theme),0)'
        - border-radius: 14px
        - place-self: center
        - height: 42px
      grid:
        - grid-template-areas: '"l"'
      label:
        - color: 'rgba(var(--couleur-theme),0.9)'  

########################################################################################################
#                                                                                                      #
#                                               HEATING                                                #
#                                                                                                      #
########################################################################################################

  heating:
    tap_action:
      action: more-info
    icon: |
      [[[
          if (entity.state =='auto') {
            return 'mdi:robot-industrial';
          } else if (entity.state =='heat') {
            return 'mdi:radiator';
          }
          return 'mdi:radiator-off';
      ]]]
    label: >-
      [[[
          if (entity.state =='off') {
            return "Izključeno";
          } else if (entity.state =='heat') {
            return "Gretje";
          } else if (entity.state =='auto') {
            return "Auto";
          }
          return entity.state;
      ]]]
    state:
      - operator: template
        value: >
          [[[
            return entity.state != 'off';
          ]]]
        styles:
          icon:
            - color: 'rgba(var(--couleur-rouge),1)'
          img_cell:
            - background-color: 'rgba(var(--couleur-rouge),0.2)'
    template: 
      - red

####################################################
#                                                  #
#              HEATING WITH BOUTONS                #
#                                                  #
####################################################

  heating_buttons:
    styles:
      card:
        - border-radius: 20px
        - box-shadow: var(--box-shadow)
        - padding: 12px
      grid:
        - grid-template-areas: '"item1" "item2"'
        - grid-template-columns: 1fr
        - grid-template-rows: min-content  min-content
        - row-gap: 12px
    custom_fields:
      item1:
        card:
          template: list_items_favorite
          type: custom:button-card
          custom_fields:
            item1:
              card:
                entity: '[[[ return variables.entity ]]]'
                name: >
                  [[[
                      if (variables.name == null) {
                        return variables.entity;
                      }
                      return variables.name;
                  ]]]
                tap_action:
                  action: more-info
                template:
                  - icon_info
                  - heating
                type: 'custom:button-card'
            item2:
              card:
                type: horizontal-stack
                cards:
                  - type: conditional
                    conditions:
                      - entity: '[[[ return variables.entity ]]]'
                        state: 'off'
                    card:
                      icon: mdi:power
                      tap_action:
                        action: call-service
                        service: climate.set_hvac_mode
                        service_data:
                          entity_id: '[[[ return variables.entity ]]]'
                          hvac_mode: 'heat'
                      type: custom:button-card
                      template: widget_icon
                  - type: conditional
                    conditions:
                      - entity: '[[[ return variables.entity ]]]'
                        state_not: 'off'
                    card:
                      icon: mdi:power-off
                      tap_action:
                        action: call-service
                        service: climate.set_hvac_mode
                        service_data:
                          entity_id: '[[[ return variables.entity ]]]'
                          hvac_mode: 'off'
                      type: custom:button-card
                      template: widget_icon
      item2:
        card:
          template: list_items
          type: 'custom:button-card'
          custom_fields:
            item1:
              card:
              
                type: horizontal-stack
                cards:
                  - type: conditional
                    conditions:
                      - entity: '[[[ return variables.entity ]]]'
                        state_not: 'off'
                    card:
                      icon: 'mdi:minus'
                      tap_action:
                        action: call-service
                        service: script.decrease_heating_temperature
                        service_data:
                          entity_id: '[[[ return variables.entity ]]]'
                      type: 'custom:button-card'
                      template: widget_icon
                  - type: conditional
                    conditions:
                      - entity: '[[[ return variables.entity ]]]'
                        state: 'off'
                    card:
                      icon: 'mdi:home-thermometer-outline'
                      tap_action:
                        action: none
                      type: 'custom:button-card'
                      template: widget_icon
            item2:
              card:
                icon: 'mdi:temperature-celsius'
                tap_action:
                  action: none
                type: 'custom:button-card'
                template: widget_temperature
                entity: '[[[ return variables.entity ]]]'
            item3:
              card:
              
                type: horizontal-stack
                cards:
                  - type: conditional
                    conditions:
                      - entity: '[[[ return variables.entity ]]]'
                        state_not: 'off'
                    card:
                      icon: 'mdi:minus'
                      tap_action:
                        action: call-service
                        service: script.increment_heating_temperature
                        service_data:
                          entity_id: '[[[ return variables.entity ]]]'
                      type: 'custom:button-card'
                      template: widget_icon
                  - type: conditional
                    conditions:
                      - entity: '[[[ return variables.entity ]]]'
                        state: 'off'
                    card:
                      icon: 'mdi:home-thermometer-outline'
                      tap_action:
                        action: none
                      type: 'custom:button-card'
                      template: widget_icon

Hello @Mariusthvdb
trying to split up chips to separated files like you with an swipe card but i get error when loading my include file that it cannot find card type. Can you help?

- type: 'custom:button-card'
  template: edge
- type: 'custom:button-card'
  template: chips_temperature

This is my swipe-card setup

              - type: custom:swipe-card
                parameters:
                  spaceBetween: 8
                  freeMode: true
                cards:
                  - !include /config/lovelace/includes/chip_temperature.yaml

Never mind, i nail it :smiley:
Beginners mistake.

@lpt2007

I have no idea, maybe the different icons have different sizes which makes everything shift?
Iā€™m just guessing here.

@tben is a frontend developer. Maybe he can look into this?

I find solution couple minutes ago. It was horizontal-stack.

I changed card type horizontal-stack to grid, and I added width: 62px in widget_icon and card style.

ezgif.com-gif-maker (2)

Still have some card left / right offset problems.

Here is complete code. (I added room temperature when heating is off)

  widget_temperature:
    tap_action:
      action: toggle
    color: var(--google-grey-500)
    show_icon: false
    show_name: false
    show_label: true
    size: 20px
    label: |-
      [[[
          var current_temperature = entity.attributes.current_temperature;
          var temperature = entity.attributes.temperature;
          if (entity.state == 'off') {
            var temperature = current_temperature;
          }
          return temperature + 'Ā°C'
      ]]]
    styles:
      card:
        - box-shadow: none
        - padding: 0px
        - background-color: 'rgba(var(--couleur-theme),0)'
        - border-radius: 14px
        - place-self: center
        - height: 42px
      grid:
        - grid-template-areas: '"l"'
      label:
        - color: 'rgba(var(--couleur-theme),0.9)' 

########################################################################################################
#                                                                                                      #
#                                                WIDGET ICON                                           #
#                                                                                                      #
########################################################################################################

  widget_icon:
    tap_action:
      action: toggle
    color: var(--google-grey)
    show_icon: true
    show_name: false
    size: 20px
    styles:
      card:
        - box-shadow: none
        - padding: 0px
        - background-color: 'rgba(var(--color-theme),0.05)'
        - border-radius: 14px
        - place-self: center
        - height: 42px
        - width: 62px
      grid:
        - grid-template-areas: '"i"'
      icon:
        - color: 'rgba(var(--color-theme),0.9)'

########################################################################################################
#                                                                                                      #
#                                               HEATING                                                #
#                                                                                                      #
########################################################################################################

  heating:
    tap_action:
      action: more-info
    icon: |
      [[[
          if (entity.state =='auto') {
            return 'mdi:robot-industrial';
          } else if (entity.state =='heat') {
            return 'mdi:radiator';
          }
          return 'mdi:radiator-off';
      ]]]
    label: >-
      [[[
          if (entity.state =='off') {
            return "Izključeno";
          } else if (entity.state =='heat') {
            return "Gretje";
          } else if (entity.state =='auto') {
            return "Auto";
          }
          return entity.state;
      ]]]
    state:
      - operator: template
        value: >
          [[[
            return entity.state != 'off';
          ]]]
        styles:
          icon:
            - color: 'rgba(var(--couleur-rouge),1)'
          img_cell:
            - background-color: 'rgba(var(--couleur-rouge),0.2)'
    template: 
      - red

####################################################
#                                                  #
#              HEATING WITH BOUTONS                #
#                                                  #
####################################################

  heating_buttons:
    styles:
      card:
        - border-radius: 20px
        - box-shadow: var(--box-shadow)
        - padding: 12px
      grid:
        - grid-template-areas: '"item1" "item2"'
        - grid-template-columns: 1fr
        - grid-template-rows: min-content  min-content
        - row-gap: 12px
    custom_fields:
      item1:
        card:
          template: list_items_favorite
          type: custom:button-card
          custom_fields:
            item1:
              card:
                entity: '[[[ return variables.entity ]]]'
                name: >
                  [[[
                      if (variables.name == null) {
                        return variables.entity;
                      }
                      return variables.name;
                  ]]]
                tap_action:
                  action: more-info
                template:
                  - icon_info
                  - heating
                type: 'custom:button-card'
            item2:
              card:
                type: grid
                columns: 2
                square: false
#                type: horizontal-stack
                cards:
                  - type: conditional
                    conditions:
                      - entity: '[[[ return variables.entity ]]]'
                        state: 'off'
                    card:
                      icon: mdi:power
                      tap_action:
                        action: call-service
                        service: climate.set_hvac_mode
                        service_data:
                          entity_id: '[[[ return variables.entity ]]]'
                          hvac_mode: 'heat'
                      type: custom:button-card
                      template: widget_icon
                  - type: conditional
                    conditions:
                      - entity: '[[[ return variables.entity ]]]'
                        state_not: 'off'
                    card:
                      icon: mdi:power-off
                      tap_action:
                        action: call-service
                        service: climate.set_hvac_mode
                        service_data:
                          entity_id: '[[[ return variables.entity ]]]'
                          hvac_mode: 'off'
                      type: custom:button-card
                      template: widget_icon
      item2:
        card:
          template: list_items
          type: 'custom:button-card'
          custom_fields:
            item1:
              card:

                type: grid
                columns: 2
                square: false              
#                type: horizontal-stack
                cards:
                  - type: conditional
                    conditions:
                      - entity: '[[[ return variables.entity ]]]'
                        state_not: 'off'
                    card:
                      icon: 'mdi:minus'
                      tap_action:
                        action: call-service
                        service: script.decrease_heating_temperature
                        service_data:
                          entity_id: '[[[ return variables.entity ]]]'
                      type: 'custom:button-card'
                      template: widget_icon
                  - type: conditional
                    conditions:
                      - entity: '[[[ return variables.entity ]]]'
                        state: 'off'
                    card:
                      icon: 'mdi:home-thermometer-outline'
                      tap_action:
                        action: none
                      type: 'custom:button-card'
                      template: widget_icon
            item2:
              card:
                icon: 'mdi:temperature-celsius'
                tap_action:
                  action: none
                type: 'custom:button-card'
                template: widget_temperature
                entity: '[[[ return variables.entity ]]]'
            item3:
              card:

                type: grid
                columns: 2
                square: false              
#                type: horizontal-stack
                cards:
                  - type: conditional
                    conditions:
                      - entity: '[[[ return variables.entity ]]]'
                        state_not: 'off'
                    card:
                      icon: 'mdi:plus'
                      tap_action:
                        action: call-service
                        service: script.increment_heating_temperature
                        service_data:
                          entity_id: '[[[ return variables.entity ]]]'
                      type: 'custom:button-card'
                      template: widget_icon
                  - type: conditional
                    conditions:
                      - entity: '[[[ return variables.entity ]]]'
                        state: 'off'
                    card:
                      icon: 'mdi:home-thermometer-outline'
                      tap_action:
                        action: none
                      type: 'custom:button-card'
                      template: widget_icon

scripts

increment_heating_temperature:
  alias: increment_heating_temperature
  sequence:
  - service: climate.set_temperature
    data_template:
      entity_id: '{{ entity_id }}'
      temperature: '{{ (state_attr(entity_id, ''temperature'') | float) + ( 0.5 |
        float) | float }}

        '
  mode: single
decrease_heating_temperature:
  alias: decrease_heating_temperature
  sequence:
  - service: climate.set_temperature
    data_template:
      entity_id: '{{ entity_id }}'
      temperature: '{{ (state_attr(entity_id, ''temperature'') | float) - (0.5 | float)
        | float }}'
  mode: single

card:

                  - type: 'custom:button-card'
                    variables:
                      entity: climate.haos_vir_haos_srv_thermostat_group
                      name: Ogrevanje
                    template: heating_buttons
3 Likes

It is possible to add scroll text in label?

Like This?

Found a workaround to fix the floating of chips inside condditionals:

I packed them inside a grid-card (5 columns are perfect for my iPhone display). Within the grid card all chips are aligned left without the flex are between the chips.

Maybe it is a solution for others using conditional cards.

Perhaps someone has a better solution to the problem?

1 Like

Donā€™t know if you can use this, but instead of the condition i just use a if function under the part I want to change.

              - type: 'custom:button-card'
                entity: input_select.status_hus_ha
                template: chips
                label: >
                  [[[
                      if (entity.state == 'hjemme') return 'šŸ ';
                      if (entity.state == 'borte') return 'šŸƒ';
                      if (entity.state == 'ferie') return 'ā›±ļø';
                      else return 'šŸ”„';
                  ]]]
1 Like

Nice idea. Will remember for the future.

But I would display the different chips cards only if certain conditions are met. In my example snapshot the chip with the light bulb should only be displayed, when there are lights in state on.
If all lights are switched off, the card shouldnā€™t be displayed.

Iā€™m surprised this is working. :slight_smile: :+1: Nonetheless you should work with correct syntax. :slight_smile: Iā€™m sure, what you want is this:

              - type: 'custom:button-card'
                entity: input_select.status_hus_ha
                template: chips
                label: >
                  [[[
                      if (entity.state == 'hjemme'){
                        return 'šŸ ';
                      } else if (entity.state == 'borte') {
                        return 'šŸƒ';
                      } else if (entity.state == 'ferie') {
                        return 'ā›±ļø';
                      } else {
                        return 'šŸ”„';
                      }
                  ]]]

In your template you should very often see ā€˜:fire:ā€™ as this should always come up, if your entity.state is not ferie.

EDIT: the code above is not technically wrong, but the way it was before is evenly right as well! See here. Sorry for the confusion!

3 Likes

Ahh thanks:) I have changed it now.

I have an question regards the chips. I have multiple page and all have the same chips on top and when I do a change I have to do it to all pages. Is it possible to split this to a separat yaml-file, and have someone an example to do this?

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:

hello @clemalex
i have trouble to get the same cool alarm panel like your picture. Check mine below.
Did copy your code and changed some few lines, can you see what i have missed?

  - title: Alarm
    icon: 'mdi:security'
    path: alarm
    cards:
      - cards:
          - cards:
              - template: edge
                type: 'custom:button-card'
              - template: chips_return
                type: 'custom:button-card'
              - template: chips_power_consumption_price
                type: 'custom:button-card'
              - template: edge
                type: 'custom:button-card'
            type: horizontal-stack

          - type: vertical-stack
            cards:
              - card:
                  entity: alarm_control_panel.alarm
                  states:
                    - arm_home
                  style:
                    .: |
                      ha-card > ha-label-badge{
                        --alarm-state-color: var(--google-green-500) !important;
                      }
                      ha-card{
                        padding-top: 16px;
                        padding-bottom: 12px !important;
                        border-radius: 21px;
                      }
                      ha-card > h1{
                        padding-top: 0;
                        color: transparent;
                      }
                      ha-card > h1::before{
                        content: "Larma av";
                        color: var(--google-green-500);
                        position: absolute;
                        font-variant: small-caps;
                      }
                      #alarmCode{
                        display: none;
                      }
                      #keypad{
                        display: none !important;
                      }
                    '#armActions':
                      mwc-button:
                        $: |
                          #button > span.slot-container{
                            color: transparent;
                            position: absolute;

                          }
                          #button{
                            width: 150px;
                            border-radius: 21px;
                          }
                          #button > span.slot-container::before{
                            color: var(--mdc-theme-primary, #6200ee);
                            content: "Aktivera";
                            margin: 0 0 0 50%;
                          }
                  title: Alarme
                  type: alarm-panel
                conditions:
                  - entity: alarm_control_panel.alarm
                    state: disarmed
                type: conditional
              - card:
                  entity: alarm_control_panel.alarm
                  states:
                    - armed_home
                  title: Alarm
                  type: alarm-panel
                  style:
                    .: |
                      ha-card > ha-label-badge{
                        --alarm-state-color: var(--google-red-500) !important;
                      }
                      ha-card{
                        padding-top: 16px;
                        padding-bottom: 12px !important;
                        border-radius: 21px;
                      }
                      ha-card > h1{
                        padding-top: 0;
                        color: transparent;
                      }
                      ha-card > h1::before{
                        content: "ActivƩe";
                        color: var(--google-red-500);
                        position: absolute;
                        font-variant: small-caps;
                      }
                    '#armActions':
                      mwc-button:
                        $: |
                          #button > span.slot-container{
                            color: transparent;
                            position: absolute;    
                          }
                          #button{
                            width: 150px;
                            border-radius: 21px;
                          }
                          #button > span.slot-container::before{
                            color: var(--mdc-theme-primary, #6200ee);
                            content: "Larma av";
                            margin: 0 0 0 50%;
                          }
                    '#keypad':
                      mwc-button:
                        $: |
                          #button{
                            border-radius: 12px
                          }
                conditions:
                  - entity: alarm_control_panel.alarm
                    state_not: disarmed
                type: conditional

        type: vertical-stack

image
Found out the error but not sure how i could fix it no other way than remove -500 from color part.

var(--google-green-500)

Oh! :roll_eyes:
ofcourse, add it to theme template

Can someone explain how-to setup Scene part. Not sure how-to create this sensors

sensor.presence
sensor.absent
sensor.travail

The colors have changed. Yes it is necessary to correct then

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