jimz011 / homekit-infused

Homekit Infused 5 2023
https://jimz011.github.io/homekit-infused/
Other
879 stars 138 forks source link

Add Own Button Templates #193

Closed Qpernicus closed 2 years ago

Qpernicus commented 2 years ago

I am a little lost.. I use my own remote, based on button templates:

 icon_button:
    aspect_ratio: 4/3
    color_type: icon
    hold_action:
      action: none
    layout: vertical
    show_label: false
    show_name: false
    show_state: false
    styles:
      card:
        - border-radius: 10px
        - border: solid 1px var(--primary-color)
        - box-shadow: none
        - padding: 6px 6px
        - margin: 0px 0px
        - '--paper-card-background-color': rgba(0, 0, 0, 0)
      icon:
        - width: 28px
      name:
        - justify-self: middle
        - align-self: end
        - font-size: 14px
        - padding: 0px 0px
        - color: var(--secondary-text-color)
    tap_action:
      action: call-service
  menu_button:
    aspect_ratio: 4/3
    color_type: icon
    hold_action:
      action: none
    layout: vertical
    show_label: false
    show_name: true
    show_state: false
    styles:
      card:
        - border-radius: 10px
        - border: solid 1px var(--primary-color)
        - box-shadow: none
        - padding: 6px 6px
        - margin: 0px 0px
        - '--paper-card-background-color': rgba(0, 0, 0, 0)
      icon:
        - width: 28px
      name:
        - justify-self: middle
        - align-self: end
        - font-size: 14px
        - padding: 0px 0px
        - color: var(--secondary-text-color)
    tap_action:
      action: call-service

How can i add this to your HKI installation?

I placed this in a remote.yaml in /config/hki-base/templates/button/templates but that doesnt work?

jimz011 commented 2 years ago

You should not touch the base files, however you can add button-card templates to the /hki-base/templates/button/templates folder.

You can also use decluttering card or lovelace_gen (lovelace_gen is only supported when using custom_legacy:. You can find examples of how jinja templates can be used by visiting my personal repo. You can find a folder there named templates, and the views that reference to them are cleaning and network.

Qpernicus commented 2 years ago

I thought I added the template to the right folder?? Or does it need some special 'tag' in the yaml? The text I quoted is all I have in the yaml atm. I'll take a look at your personal repo. Thx!

Qpernicus commented 2 years ago

I'm getting stuck in putting what where.. Just to verify, could you point me to which file needs to be where?

The above Yaml is my Button-card-template. So i put that in /hki-base/templates/button/templates in a single yaml with no other text?

I normally use a card like this together with this template:

- type: vertical-stack
  cards:
    - type: custom:mushroom-chips-card
      chips:
        - type: template
          icon: mdi:home
          tap_action:
            action: navigate
            navigation_path: entree
      alignment: end    
    - type: "vertical-stack"
      cards:                                                      
        - entities:
            - type: custom:slider-entity-row
              entity: number.set_volume_tv
              name: Volume   
            - card_type: horizontal-stack
              cards:
                - entity: input_button.kpn_power
                  name: KPN
                  styles:
                    icon:
                      - color: green
                  tap_action:
                    service: input_button.press
                    service_data:
                      entity_id: input_button.kpn_power
                  template: menu_button
                  type: custom:button-card

And this goes on for a fair while.. But i'm having a hard time translating this to you theme. I love it, and 99% i succesfully implemented, but this doesnt work..

dnestico commented 1 year ago

Did you ever figure this out? Trying to use button templates myself too...