Lovelace: Button card

Wow, I never thought of passing 0 in as the brightness for light.turn_on in order to turn it off! I learned something today. :slight_smile:

I donā€™t know if this is of any use to anyone, but I wanted to share my lovelace setup with you guys. Why in this thread you might ask? Well because the majority of my lovelace setup consists of this mighty button-card (lets say almost 80% of my setup are these buttons?).

Anyways I hope you guys can make use of it.
Thread:

Repo:

5 Likes

Add a delay to the end of the script.

anyone else seeing this:

no idea which file it canā€™t find, they are all thereā€¦in fact, im not using any files at all, only some mdi: icons and they are all showingā€¦

Youā€™re not using the latest version (or you didnā€™t clear your cache). This is fixed in 1.9.0.

Thanks , thought I did both but will check again. no easy way of finding the version in the .js file?

Made me thinking : this couldnā€™t be caused by entities not being available? I ask because I have my Hue lights on the buttons, and they are logged ā€˜unavailableā€™ regularlyā€¦ (long story)

Also some simply are powered off, so they should show unavailable on the button (which they do btw)

Nope. However if you use custom updater, you should use the /customcards endpoint instead of /local for your card files to skip cache. See https://custom-components.github.io/custom_updater/How-it-works

And itā€™s unrelated it entities that are unavailable.

cool, thanks, no worries: I simply always dl the file from https://raw.githubusercontent.com/custom-cards/button-card/master/dist/button-card.js and trust is is the latest :wink:

have custom updater installed, but didnā€™t yet change to the new endpoints, since I donā€™t like custom cards requiring extra system file settings in my setup. Since the card changed white a bit lately, Ill hit and hold till things have materialized. manual updating till that time for me.

good to know! thanks.

Good thing is I used your code and I just used the option you think is even better and that one works :smiley: Thanks!
To make it perfect I am wondering if thereā€™s a way to get this back as a status to this button card. Would be cool if I could get the status to switch between off / dim / on, where it now does off / on / on. If I could have different states there, then I can also use different styling for each, where I could make it greyscale when off, icon light up when dimmed and the full card light up when fully on.

color: auto is what youā€™re looking for :slight_smile:, the color of the icon color will change automatically based on the light brightness.
However for the state itā€™s not possible (as a light is either on or off), youā€™ll have to use label_template and display what you want based on the state of your light.
Something like:

show_label: true
show_state: false
label_template: >
  if (entity.state == 'on' && entity.attributes.brightness && entity.attributes.brightness < 255) return "Dim";
  if (entity.state == 'on') return "On";
  return "Off";

Ok, so I understand I need to add conditional labels and use those instead of states, but that also means I cannot do something like below? (Mock-up in Excelā€¦, will recreate later in HASS)

Lights_layout

Sure you can, using state on top of it:

state:
- operator: template
  value: >
    return entity.state == 'on' && entity.attributes.brightness && entity.attributes.brightness < 255;
  styles:
    # Your Dim Styles
- operator: template
  value: >
    return entity.state == 'on'
  styles:
   # Your On Styles
- operator: default
  styles:
    # Your Off Styles
1 Like

Cool! Gonna try that immediately when I get home. Will show the results :smiley:

Thatā€™s what Iā€™m currently doing but I noticed that there is a graphic for pressed events. I want to modify that graphic instead of adding or creating scripts with a delay at the end. Also, the delay in response on a cellphone is long enough that the on/off doesnā€™t register.

There is already feedback when the button is pressed (ripple effect), but because your background is really dark, you canā€™t see it. I would have to modify the color of the ripple effect based on the background color, or maybe use the color as the feedback color for the ripple effect.

Is there a way for me to do it with CSS in the style section? If not, that could be a good enhancement. Nothing too pressing so donā€™t break your back on it. I can make a PR if thatā€™s the route you want to go.

have a button with lock, not to accidentally switch the switch. Works just fine. When holding this, and the blue circle shows, no more-info window pops up though. It does on all the other buttons.

Is this a bug? or per design. it is a bit confusing tbh, to have the same user action have different response from the system. especially sinde the blue more-info circle shows as expected.?

thanks for having a look

Itā€™s expected. lock, locks everything (even hold_action). The blue circle is just feedback about the fact that youā€™re holding down your mouse or your finger on the screen. When lock is true, youā€™ll first have to tap on the button to unlock it, and then hold the button to have the hold_action fire up.

Thereā€™s no way to do that right now. Iā€™ll have a look.

2 Likes

Did something change again?

      - type: horizontal-stack
        cards:
          - type: conditional
            conditions:
              - entity: switch.watch_tv
                state: 'on'
            card:
              type: custom:button-card
              color_type: card
              action: service
              service: 
                domain: remote
                action: send_command
                data:
                  entity_id: remote.harmony
                  device: 55198007
                  command: 'VolumeDown'
              icon: mdi:volume-minus
              color: rgb(75, 75, 77)

worked like a charm before, but now I am unable to click the button.

This stopped working a long time agoā€¦ Please read the documentation on github.
It should be:

tap_action:
  action: call-service
  service: remote.send_command
  service_data:
    entity_id: remote.harmony
    device: 55198007
    command: 'VolumeDown'