Lovelace: Button card

Hi. how can i setup correctly two actions under tap_action? Below is what i would like to do.

        type: 'custom:button-card'
        entity: input_boolean.media_shuffle_kokken   
        tap_action:
          action: call-service
          service: media_player.shuffle_set
          service_data:
            entity_id: media_player.kokken
        tap_action:            
          action: toggle 

Create a script which does the 2 actions and call the script. You can’t call 2 actions.

1 Like

I doubt that reinstalling everything will change the result :blush:

trying tio compress some logic and integrate switches with different properties, I want a hold_action depending on whether the entity.entity_is is includes in a group.z_wave_switches, but I cant get the correct syntax for that:

button_switch:
  variables:
    id: >
      [[[ entity.entity_id.split('.')[1]; ]]]
    z_wave: >
      [[[ return group.z_wave_switches.includes(entity.entity_id); ]]]   #<------

  tap_action:
    action: toggle
    haptic: light
#  hold_action:
#    action:  call-service
#    service: script.turn_on
#    service_data:
#      entity_id: >
#        [[[ var id = entity.entity_id.split('.')[1];
#            return 'script.' + id + '_meterget_power'; ]]]

  hold_action:
    action: >
      [[[ return variables.z_wave ? 'more-info' : 'call-service'; ]]]
    service: >
      [[[ return variables.z_wave ? null : 'script.turn_on'; ]]]
    service_data:
      entity_id: >
        [[[ return variables.z_wave ? null : 'script.' + id + '_meterget_power'; ]]]

please help me find that
 it must be simple?

tried

 [[[ return states['group.z_wave_switches'].attributes.entity_id.includes(entity.entity_id); ]]]

too but the hold action wasn’t performed (and it horrendously turn off the power off my Mac while editing


thanks for having a look

That is the correct syntax. If it doesn’t work, make sure the entity is actually in the list by checking your dev-tools panel.

thanks, and yes, it does work after all
 maybe a cache thing going on. Love the versatility of the button-card.

I am having an issue with this button card template on iOS (Safari and Companion App). The issue is not present in Chrome or Fully Kiosk on Windows or Android. If the switch is “on” it works as expected. If the switch is “off”, the border is not shown. I tested by commenting out:

card:
   - filter: opacity(50%)

After doing this the border was visible in iOS when the state is “off”.

Any idea why this would impact iOS only?

      
# Homekit type buttons
  switch_homekit:
    color: var(--google-yellow)
    hold_action:
      action: more-info
    show_state: true
    styles:
      card:
        - border-style: solid
        - border-width: 2px
        - border-color: var(--primary-color)
        - height: 90px
        - width: 90px        
      grid:
        - grid-template-areas: '"i" "n" "s"'
        - grid-template-columns: 1fr
        - grid-template-rows: 1fr min-content min-content
      icon:
        - margin-top: '-5%'
        - padding-left: 10px
      img_cell:
        - justify-content: start
        - text-align: start
      name:
        - font-size: 14px
        - font-weight: bold
        - justify-self: start
        - margin-bottom: 3%
        - padding-left: 10px
      state:
        - font-size: 14px
        - justify-self: start
        - padding-left: 10px
        - text-transform: lowercase
    state:
      - value: 'off'
        styles:
          card:
            - filter: opacity(50%)
          icon:
            - filter: grayscale(100%)

I have the answer for you: Apple’s safari sucks :wink:

1 Like

I agree. I only tested it on there because it is not working on the iOS Companion app either. Is this an issue that I should post there since the card works as expected on Chrome?

That is pure CSS compatibility issue with safari vs chrome/firefox. Not something button-card can fix.

Got it. Well that sucks. Must be a recent change in iOS. I hadn’t accessed HA on the app in awhile. It had been working previously.

Is there the possibility of using button cards while keeping the toggle switch?
Thanks

Hi, short question on the new structure, with fire-dom-event: Should every card already support this out-of-the-box?
I got it working for all standard buttons, also for the custom:button-card, but I can’t get it to work with the custom:mini-graph-card

is that related to the card?
Thanks, JKW

Yepp! It is!

Hi
Can anyone tell me why the “text-align: left” property doesn’t work?
I wish the text was on the left in the buttons. Thanks

type: horizontal-stack
cards:
  - type: 'custom:button-card'
    name: Stato allarme Bentel
    styles:
      card:
        - background-color: white
      name:
        - font-size: 15px
        - text-align: left
  - type: 'custom:button-card'
    custom_fields:
      stato_allarme_bentel: |-
        [[[
         if (states['binary_sensor.stato_allarme_bentel'].state == "on")
         return "Enable";
         return "Disable";
        ]]]  
    styles:
      card:
        - background-color: white
      custom_fields:
        stato_allarme_bentel:
          - font-size: 15px
          - text-align: left

center

You should use justify-self: start instead of text-align

Thanks for your help.
It works with the first card but not with the custom field

center2

That’s because you didn’t put the custom_field in the grid.
You should use the name field with your code instead of putting that in a custom_field, it’s going to be easier.

1 Like

Thanks again, it works. I have achieved my goal. But I would like to understand: with the custom field was the grid the only solution?

Hi,

using

type: custom:button-card
template: button_alarm
entity: script.alarm_disarm
icon: >
  [[[ if (states['alarm_control_panel.ha_rpi4_alarm'].state == 'triggered') return 'mdi:shield-alert';
      return 'mdi:shield-check'; ]]]
hold-action:
  action: navigate
  navigation_path: >
    [[[ return (window.location.pathname.split('/')[2] == 'alarm')
        ? null : '/ui-settings/alarm'; ]]]

wont navigate
 It simply shows. Tap does trigger the script. No errors


please help me find what’s up? Ive checked the window.location.pathname.split('/')[2] == 'alarm' in inspector to be correct.

thanks for having a look