Skip to content

Templates

Compare
Choose a tag to compare
@RomRider RomRider released this 16 May 00:44
· 259 commits to master since this release
4a2f16e

NEW FEATURES

  • Configuration templating support:

    • Define your config template in the main lovelace configuration and then use it in your button-card. This will avoid a lot of repetitions! It's basically YAML anchors, but without using YAML anchors and is very useful if you split your config in multiple files 😄
    • You can overload any parameter with a new one, appart from the states. The state arrays in templates will be concatenated together with your config, meaning you can add new states but not change/delete states. Your main config states will be appended to the ones in the template.
    • You can also inherit another template from within a template.

    In ui-lovelace.yaml (or in another file using !import)

    button_card_templates:
      header:
        styles:
          card:
            - padding: 5px 15px
            - background-color: var(--paper-item-icon-active-color)
          name:
            - text-transform: uppercase
            - color: var(--primary-background-color)
            - justify-self: start
            - font-weight: bold
          label:
            - text-transform: uppercase
            - color: var(--primary-background-color)
            - justify-self: start
            - font-weight: bold
    
      header_red:
        template: header
        styles:
          card:
            - background-color: '#FF0000'
    
      my_little_template:
        [...]

    And then where you use button-card, you can apply this template, and/or overload it:

    - type: custom:button-card
      template: header
      name: My Test Header
  • To ease template usage, you can now refer to the entity assigned to the button on a call-service action using the entity keyword in the entity_id parameter:

    - type: custom:button-card
      entity: cover.mycover
      tap_action:
        action: call-service
        service: cover.open_cover
        service_data:
          entity_id: entity  ## This will actually call the service on cover.mycover

FIXES

  • Fixes #157, map file not found
  • minified the file, it's now 50% smaller