Lovelace: Button card

Thanks. Fixed that now.

Not sure what Iā€™m doing wrong here. Iā€™d like my fan icon to spin when the fan is in an on state, yet that doesnā€™t seem to happen as configured. Has anyone managed to get spin: working with a fan?

Template

button_card_templates:
  ceiling-fan-icon-settings:
    show_icon: true
    show_label: false
    show_name: false
    styles:
      card:
        - height: 36px
        - width: 50px
      grid:
        - grid-template-areas: '"i"'
        - grid-template-columnns: auto
      icon:
        - height: 26px
        - width: 26px
    state:
      - value: 'on'
        styles:
          icon:
            - spin: true

Button

- type: custom:button-card
  template: ceiling-fan-icon-settings
  entity: fan.living_room_fan
  tap_action:
    action: call-service
    service: fan.toggle
    service_data:
      entity_id: fan.living_room_fan
1 Like

try:

  state:
    - value: 'on'
        spin: true #(uncomment this line for spinning icon)

That did the trick. Thank you sir!

The icon size is by default 40% of its area width. You can use size: 100% or any other value to resize the icon. This is a main config parameter,itā€™s not is styles.

Coincidentally, I was able to manipulate the icon size via styles using:

styles:
  icon:
    - height: XXpx
    - width: XXpx

This gave me exactly what I needed to tweak icon sizes down to the pixel.

Thatā€™s also a solution, size does exactly this with the value you provide :blush: but it existed before you where able to do the same thing with styles, so I keep it.

Hi peeps,

Any way to display more then one label, or multiple state attributes via label_template (but each in itā€™s own row)?

Use <br /> between rows you want to display. label_template supports HTML thatā€™s why this works.

Did you get the templates to work.
I am stuck at trying to import the file with the styles
No errors but the buttons looks like the plain old ones.

Hmmā€¦canā€™t make this workā€¦if I add HTML break it doesnā€™t render the card :frowning:
This is the example codeā€¦

        label_template: >
          return 'Moisture: ' + states['plant.dracaena'].attributes.moisture + '%' <br /> + states['plant.dracaena'].attributes.conductivity + 'ĀµS/cm'

Youā€™re missing a ā€œ+ā€ before your break (quotes too). Try:

        label_template: >
          return 'Moisture: ' + states['plant.dracaena'].attributes.moisture + '%' + '<br />' + states['plant.dracaena'].attributes.conductivity + 'ĀµS/cm'
1 Like

Awesome! That works!
Much appreciated :slight_smile:

Itā€™s exactly the behaviour expected (for now) but Iā€™ll work on something to make this possible. Thereā€™s no easy way to achieve that (it will involve adding an id to your state so that I can match what you want to merge).

Thereā€™s already a feature request for this here : #165

yes, i did. show us your code and we can help

cool, the exact issue yes. Thanks for working on that, will make the configs much easier.

great time to think about the entity_picture_template again ā€¦:wink:

Itā€™s already done, in the next release also :slight_smile:

wow, youā€™re fast! canā€™t wait to give it a try!

1 Like

hello
in the following code how and where do i add an image instead of an icon?
i want to use different icons for different states
thank you

cards:
  - name: INFORMAƇƃO
    template: header_marcelo
    type: 'custom:button-card'
  - cards:
      - entity: sensor.riscoincendio
        name: RISCO DE INCƊNDIO
        show_label: true
        show_state: true
        size: 70%
        state:
          - color: red
            value: REDUZIDO
        type: 'custom:button-card'
      - dbltap_action:
          action: more-info
        entity: binary_sensor.meteoalarm
        name: ALERTA METEO
        show_label: true
        show_state: true
        size: 70%
        state:
          - color: green
            value: 'off'

          - COLOR: RED
            VALUE: 'on'
        tap_action:
          action: toggle
        type: 'custom:button-card'
    type: horizontal-stack
type: vertical-stack

I take it you mean you want to use different images for different statesā€¦?

you do so under the state: you already have, and then set an entity_picture, as is explained in the docs: button-card/README.md at master Ā· custom-cards/button-card Ā· GitHub