Lovelace: Button card

Maybe FFMPEG is the reason there is no preview, I stream my cameras to MotionEye and using MJPEG stream to HA.

Try adding simple image:

entity_picture: 1920x1080 TP - Imgur

If it works you need to replace it with still image URL from camera.

Or adding still image setting to camera config in HA might solve this

Hi RomRider,

Thanks for your help. Got an error. I’m trying to reproduce my original card to work out what the differences are. trial and error :slight_smile:

thanks,
tried and same thing not working now when i click on it nothing happens. i’m using duckdns, maybe it’s related?

copied from anoterh of my button_templates:

button_body_lock:
  lock: true
  color: auto
  size: 30%
  aspect_ratio: 1/1
  show_state: true
  show_label: true
  tap_action:
    action: toggle
    haptic: light
  hold_action:
    action: more-info
    haptic: success

and added the lock: true.

showing:

20

which is perfect for my needs. However, click/holding it doesnt show the more-info. It does show the blue circle, bt when releasing the mouse the lock disappears, as if I simply clicked it.

Isnt the lock compatible with the hold_action?

thanks for having a look

I am trying to template a service call

              - type: custom:button-card  
                template: custom_button_lights
                entity: binary_sensor.youtube_via_http
                name: '[[[ if (entity.state == "on") return "Block"; else return "Unblock" ]]]'
                icon: mdi:youtube
                show_last_changed: false
                tap_action:
                  action: call-service
                  service: '[[[ if (entity.state == "on") return "adguard.disable_url"; else return "adguard.enable_url" ]]]'
                  #service: adguard.disable_url
                  service_data:
                     url: "https://thisisaplaceholder.com"

I am getting the name field correct but the service call is not working, Is template supported for service?, what am I doing wrong.

Could you share the code for the notifications? I was planning to do something like this, but then I came across this. This looks cool.

1 Like

filed a feature request for adding a lock (permanent-not switchable) and to differentiate that from the current (allow-)lock.

would appreciate feedback to maybe find other solutions to the goal Id like to accomplish: having a button for a switch entity, and not allow it to switch at all (so not the current lock: true which still offers 5 seconds of opportunity)

2 options:

  • why not just disable the action? action: none
  • you can achieve exactly what you want by putting an unknown name in unlock_users array. If the user is unknown from HA, no-one will ever be able to unlock it.

Thanks, I missed the option for unlock_users before… sorry bout that.

have it tested like this now:

button_body_lock:
  lock: true
  unlock_users: nobody
  color: auto
  size: 30%
  aspect_ratio: 1/1
  show_state: true
  show_label: true
  tap_action:
    action: none
    haptic: light
  hold_action:
    action: more-info
    haptic: success
  styles:
    lock:
      - color: red
      - icon: mdi:lock-alert

and there are a 2 ‘issues’:

the icon is not changed in to lock-alert 07
did I configure that incorrectly?

no more-info pops up on hold. Of course I’d need the more-info not to have a moveable switch…

I have an Aqara motion sensor that also has a temperature sensor. I want to use that sensor on a another card.
I can’t see what I’m doing wrong with this card and I’m soon getting bonkers.

Whatever I do I only get the lux-measurement.

          - type: "custom:button-card"
            template: temp_button
            entity: sensor.rs_entre
            label_template: >
              return `'states.entity.attributes.temperature' + ' °C';`

So what is wrong with this template?

This can already be done though:

I’d go for an input_boolean as the switch, and a state template to show the state. The button wil now correctly show the state (you might consider templating color as well) but the button will do nothing (just like a permanent lock would do).

You could also do a tap_action: none for example or a service-call to do something else. This way you wouldn’t need the input boolean.

Not the most beautiful solution but it works for me. For example I have servers in HA as switches which should never ever be turned of. Pressing the button does nothing but show a more-info window.

Edit: lol I should have read up :joy::rofl: this was already answered :+1:

tbh, I think a switch needs to be able to be a switch… lots of hacks possible, but thats what makes it all too complex all over.

I probably will endup not using lock: true, set a dedicated icon lock-alert, and have tap action show more info…
o wait, that can’t be, I need the lock-alert to be the lock icon, not the entity icon…
feature request holds…:wink:
tap_action and hold_action don’t work as configured

Lock is the same for hold and tap and double tap. There’s no way to differentiate it.
You have to see it as an overlay that captures all your clicks until it’s unlocked.

If you want to display a lock icon just use a custom field and put the tap_action to none while keeping the hold action to more info.

I don’t quite understand your use case honestly :blush:

BTW, putting icon: mdi:something in the styles of the lock will not do anything, it’s not valid css.

You’re not using the latest version of button card. label_template doesn’t exist anymore, it’s just label now. Plus the template would be "[[[ return entity.attributes.temperature + ' °C' ]]]"

I don’t need to differentiate it for these actions, I need it to be different than the default lock icon. Can’t that be done styling the lock, just as we can set the color?

so I understand correctly with unlock_users: unknown, the lock will never be unlocked, and no action at all is possible?

That will be my first custom field, will have to check the docs how to create this overlay, with the lock-alert icon.

well, I want it to be visually different from the regular locks (since the behavior is different), so need another lock icon.
I do want to be able to use a more-info, probably of the locked switch, maybe even use another entity. for now, simply the locked switch as more info, on both tap and hold to be sure.

I noticed that :wink: since I now need to use it in a custom-field, I must check the docs for setting a custom icon here. don’t suppose you could assist me, please?

thanks for letting me know, appreciated!

@RomRider, maybe you can help me.
i used state custom ui card in the past and i was getting “last-triggered” info for automations as below:

>-
    if(!attributes.last_triggered)return null;
    var t,s=(new Date()-new Date(attributes.last_triggered))/1e3;
    return(
    (t=Math.floor(s/86400))?t+(t>1?" days":" day"):
    (t=Math.floor(s/3600))?t+(t>1?" hours":" hour"):
    (t=Math.floor(s/60))?t+(t>1?" minutes":" minute"):
    (t=Math.floor(s))!==1?t+" seconds":" second"
    )+" ago";

i would love to get same info with buttoncard but i have no idea how to do it. any help? :slight_smile:

1 Like

A simple

show_last_changed: true

Should do the trick :slight_smile:

its still not so simple. last_changed and last_triggered showing different info.

Ah true, the problem with that is that it will not update automatically because your entity will not change over time and the display will not update, that’s why we have a specific show_last_changed option.

Your code should just work in button-card by replacing attributes.last_triggered with entity.attributes.last_triggered but again, it will not update properly :man_shrugging: