Lovelace: Button card

I assume you restarted? (Just checking…)

Yes, restarted… and after several minutes i finally get the ID !!! :-:sweat_smile:

must be missing the obvious, but I can’t find a way to do what I want: have a button with an input_number slider…

As it stands I have it in an entity card, and it is utterly disturbing my Hassio system tab:

so question for my fellow buttoneers: can we Button down an input_number?

thanks for pointing me in the right direction…

1 Like

What do you mean with button down? Are you looking for a folding entity card? Which folds downwards when pressed? Or is it that the card is larger than your stacks?

it was a pun… sorry if that wasn’t clear.
No, I am simply looking for a button with a slider. Nothing fancy, no motion or sliding needed.

Ah ok and the entity card you use is too high? (At least that is what I can make out of this).

Hm I don’t use entities cards myself, but wouldn’t removing the title (if that is even possible) do what you want?

Nothing missed. button-card does not show sliders for input.

ok thanks, so I can stop looking :wink:
might be a cool enhancement though…

might I conclude from your words it does take input_numbers box?

Why not make a button that shows the value and a popup on tap with the slider?

well, yes, why not :wink:
(other than it requires yet another user action, would like it to be as effortless as possible)
Didn’t think about that yet, and don’t have any popups configured other than the regular more-info cards.
do I need something special for that?

a ok. saw that before… and because of all the complexity had it parked up to now.
tbc, had something simpler in my mind than that…will check it out though, so thanks!

hey @Mariusthvdb this buttons look great can you share the code for one of these buttons ?
thank you

Standard popup cards are a bit simpler than browser-mod (though deprecated). I use it in my setup to show sliders after a hold_action for e.g. lights.

But indeed having a slider would be a cool idea. Though I am still waiting on the one person that will create a vertical slider as that is one of the things I miss from HomeKit (all other stuff I definitely don’t miss from Homekit :rofl::joy:)

Is it possible to add a third color depending on the entity value?

        custom_fields:                
          notification:
            - background-color: >
                [[[
                  if (states['[[entity_2]]'].attributes.battery >= 20)
                   return "green";
                  return "red";
                ]]]

thanks

1 Like

if you read several posts above the partner has already shared the code
:wink:

Will you share the code of your card with entity_picture with battery status? I really like this…
Thanks…

sure:
buttons:

  - type: horizontal-stack
    cards:

      - type: custom:button-card
        template: horizontal-filler

      - type: custom:button-card
        template: button_body
        entity: automation.count_warnings
        name: Count warnings
        state:
          - value: 'on'
            spin: true
        styles:
          state:
            - color: >
                [[[ if (entity.state == 'on') return 'rgb(251, 210, 41)'; return 'grey';]]]
          icon:
            - color: >
                [[[ if (entity.state == 'on') return 'rgb(251, 210, 41)'; return 'grey';]]]

      - type: custom:button-card
        template: button_body
        entity: script.reset_warning_counter
        name: Reset warnings

      - type: custom:button-card
        color_type: blank-card

      - type: custom:button-card
        color_type: blank-card

      - type: custom:button-card
        template: horizontal-filler

template:

button_body:
  color: auto
  size: 30%
  aspect_ratio: 1/1
  show_state: true
  show_label: true
  tap_action:
    action: more-info
    haptic: light
  hold_action:
    action: more-info
    haptic: success
  styles:
    icon:
      - color: grey
    lock:
      - color: red
    card:
      - color: grey
#      - border-radius: 6px
      - background-color: 'var(--paper-card-background-color)'
      - padding-left: 5px
#      - box-shadow: '0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19)'      #- box-shadow: 0px 0px 2px 1px
    name:

      - text-overflow: unset
      - white-space: unset
      - word-break: break-word

      - text-align: start
      - justify-self: start
      - font-weight: bold
      - font-family: Helvetica 
      - font-size: 13px
    label:
      - text-align: start
      - font-size: 11px
      - font-family: Helvetica
      - justify-self: start
    state:
      - text-align: start
      - font-size: 11px
      - font-family: Helvetica
      - justify-self: start
      - text-transform: capitalize
      - font-weight: bold
    grid:
      - grid-template-areas: '"i" "n" "s" "l"'
      - grid-template-columns: 1fr
      - grid-template-rows: 1fr min-content min-content
    img_cell:
      - justify-content: start
      - align-items: start

box-shadow and border-radius are set in my theme, so commented out here. If you dont use that in your theme, and want it, uncomment here.

the buttons sometimes override the settings in the template (check color eg) but the template is used in other button configs too, and then set all as default.

in this case I use a button_body with action more-info, an all, automation and script. You could set a tap-action to action, and have the button act immediately,(without the need to set the action on the more-info)

can we have a service for triggering an automation on a button click, just like when we would do so in the service page?

I find myself experimenting but not succeeding using the available actions and service_data but don’t think I am on the right track.

looking to shorten something like:

              type: custom:button-card
              template: button-template
              entity_id: automation.trigger_this_automation
              tap_action:
                action: trigger

closest I would gather would be:

              tap_action:
                action: call-service
                service: automation.trigger
                service_data:
                  entity_id: automation.trigger_this_automation

or

              type: custom:button-card
              template: button-body
              entity: automation.trigger_this_automation
              tap_action:
                action: call-service
                service: automation.trigger
                service_data:
                  entity_id: entity

which seems to work alright.

a simple tap-action: trigger would be magic.

i´m trying to make a simple thermostat button. i´d like to show it the current temperature not the current sate tho.
is there a way to do it?

like instead of show_state: true something like show_state: sensor.current_temperature