Lovelace: Button card

Hi Russell, I just copied this piece from someone else. So I can’t help you. The documentation on this point is very light. @RomRider can maybe help us ?

Hi Pedolsky,

I tried it, but it seems that the warning card values don’t overide the values in the standard template
The button with the jja_alarm template does exactly the same as the jja_standaard template

  jja_alarm:
    template: jja_standaard
    alarm_shadow: '0px 0px 10px 3px #FF0B37'
    alarm_card_color: '#ff0000'
    alarm_card_bg: |
        [[[
          if (entity.state == 'on') return '#FF0B37'; return '#696868'; 
        ]]]
    alarm_card_icon: '#ff0000'
    show_last_changed: true
    styles:
      card:
        - color: '[[[ return variables.alarm_card_color ]]]'
        - background-color: '[[[ return variables.alarm_card_bg ]]]'
      icon:
        - color: '[[[ return variables.alarm_card_icon ]]]'

Would you please post your jja_standaard?

Here it is:

  jja_standaard:
    variables:
      basis_color_on: '#F9C536'
      basis_color_off: '#696868'
      basis_bg1: '#1E1E1E'
      basis_bg2: '#141446'
      basis_icon_on: '#F9C536'
      basis_icon_off: '#696868'
      basis_shadow: '0px 0px 10px 3px #F9C536'
    hold_action:
      action: more-info
    aspect_ratio: 1/1
    size: 80%
    label: >
      [[[ var bri = Math.round(entity.attributes.brightness / 2.55);  if
      (entity.state === 'on') return (bri ? (bri+"%") : '') ]]]
    show_label: true
    show_name: true
    styles:
      card:
        - border-radius: 15px
        - margin: 5px 5px 5x 5x
        - padding: 0px 0px
        - '--mdc-ripple-color': green
        - '--mdc-ripple-press-opacity': 0.8
      name:
        - text-transform: uppercase
        - font-size: 11px
        - color: dimgray
        - white-space: normal
      state:
        - font-size: 10px
        - white-space: normal
      label:
        - font-size: 10px
        - white-space: normal
    state:
      - id: value_on
        value: 'on'
        styles:
          card:
            - background-color: '[[[ return variables.basis_bg1 ]]]'
            - box-shadow: '[[[ return variables.basis_shadow ]]]'
          icon:
            - color: '[[[ return variables.basis_color_on ]]]'
          name:
            - color: '[[[ return variables.basis_color_on ]]]'
            - font-size: 10px
      - id: value_off
        value: 'off'
        styles:
          card:
            - color: '[[[ return variables.basis_color_off ]]]'
            - background-color: '[[[ return variables.basis_bg1 ]]]'
          icon:
            - color: '[[[ return variables.basis_color_off ]]]'
          name:
            - color: '[[[ return variables.basis_color_off ]]]'

Thank you. There‘s a variables: missing in template jja_alarm.
I assume that the state: section of the standard-template overrides the alarm-template because the latter has no corresponding parameters defined.

Thank you.
It was much simpler than I thought

  jja_alarm:
    template: jja_standaard
    state:
      - id: value_off
        value: 'off'
        styles:
          name:
            - color: green
          icon:
            - color: green
      - id: value_on
        value: 'on'
        styles:
          name:
            - color: red
          icon:
            - color: red
          card:
            - box-shadow: 0px 0px 10px 3px red
1 Like

Hello!

Did you ever tried that code? Did it work?

I am trying something similar, but in a single color bulb. I want to choose a diferent color from the themes settings for the state on, and i am trying this but it only change de color and Don,t change the brightness equal to value of brightness of the bulb:

color: red
filter: >
    [[[
      var bri = states['light.test_light'].attributes.brightness;
      return 'Brightness: ' + (bri ? bri : '0') + '%';
    ]]]

I am trying this without the variables. Do i need to use them?

how can i play this for ninja loop on button-card, i don’t know javascript

          HACS: {% for repo in states.sensor.hacs.attributes.repositories %}
          {{ repo.display_name }} {{ repo.available_version }}
          {% endfor %}

what is your end goal? if you want the list to be shown, you maybe better of with a markdown card?

I would like to write it in the button-card label, yes with the markdown that code works, but I need to use button-card if possible. :laughing:

Hey guys!

Quick question over here.

I have a full custom dashboard based on Custom Button Card. I’ve implemented some simple hold actions to show the more info popup. Nothing fancy to be honest.

I realized that, the hold action is not working 100% of the times. I basically need to be really cautious when I’m pressing the card. If I move a bit my finger while I’m pressing it, the hold action does not work. This makes handling the device with just one hand really difficult.

I’m the only one experiencing this issue?

Thanks guys!

Trying to toggle an automation by clicking the button. If I create a normal standard button this works but not with the button card, any ideas why?

tap_action:
  action: call-service
  service: automation.toggle
  service_data: {}
  target:
    entity_id: automation.cover_markiser_i_arbetsrummet

target is not needed:


tap_action:
  action: call-service
  service: …
  service_data:
    entity_id: …

1 Like

Worked perfectly - thanks a lot!

I’m trying to implement s simple “back” button to many of my views using custom button card. It should navigate the view back to my previous / home view (like using the browser’s back button)
How can I do that?

I tried this:

tap_action:
      action: |
        [[[
          window.history.back()
        ]]]

It works, but it seems like it will also be called immediately when you open a view for the first time, causing the view to close automatically without the button being tapped.

Hey @RomRider ,

been a while since I had a button-card question, but having an update ‘issue’ please let me ask, before I create an issue in the repo:

I need a card to update on a group and its members, while that group is not the button entity. So, I tried this:

  group_expand: true
  triggers_update: >
    [[[ return 'group.' + variables.id; ]]]

and this yields no errors. However, triggers_update isnt listed in the supported configuration fields. Could you please confirm this is allowed?
thanks!

Is it possible to turn on several lights with one button? I’m not talking about light groups but instead specifying several entities for one button? :thinking:

you could have a button run a script, and in that script write all entities you’d like to be turned on.
Or, use a template for the entity in the button card itself

Alright, but there is no way specifying several entities?

Edit:
I solved it, might not be the most beautiful code ever seen but it works :slight_smile:

tap_action:
  action: call-service
  service: light.toggle
  service_data:
    entity_id:
      - light.arbetsrummet
      - light.plejd_arbetsrum_takspot
      - light.plejd_altanspottar

well, this is (1 of the) the way(s) to do it, so nothing wrong with the code :wink:

1 Like