Homekit Infused 5 (HKI) v2023.1.3

Thank you, it’s working, one thing is that header is barely visible, how can i change the text color to Aliceblue in the code, tried without success.

code:

  popuptest1:
    card: 
      type: 'custom:button-card'  
      color: auto
      size: 30%
      icon: '[[icon]]'
      entity: '[[entity]]'
      show_last_changed: true
      aspect_ratio: 1/1
      show_state: true
      name: '[[name]]'
      show_label: true
      tap_action:
        action: call-service
        service: browser_mod.popup
        service_data:
          title: Popup example
          style:
            background: var(--background-image)
          card:
            type: 'custom:button-card'
            entity: light.corner_living_room_lights
          deviceID:
            - this
            - dashboard
      hold_action:
        action: more-info
        haptic: success
      styles:
        card:
          - padding-left: 10px
          # - background-color: 'rgba(255,255,240,0.9)'
          # - background-color: '#fff5bc'
          - background-color: 'rgb(100,100,100)'
          - border-radius: 15px
        name:
          - justify-self: start
          - font-weight: bold
          - font-size: 13px
        label:
          - font-size: 11px
          - font-family: Helvetica
          - padding: 0px 10px
          - justify-self: start
        state:
          - font-size: 11px
          - font-family: Helvetica
          - padding: 1px 10px
          - justify-self: start
          - text-transform: capitalize
          - font-weight: bold
        grid:
          - grid-template-areas: '"i" "n" "s" "l"'
          - grid-template-columns: 1fr
          - grid-template-rows: 1fr min-content min-content
        img_cell:
          - justify-content: start
          - align-items: start
      state:
        - value: 'on'
          styles:
            card:
              - box-shadow: 0px 0px 3px 2px var
            name:
              - color: AliceBlue
            state:
              - color: AliceBlue
            label:
              - color: AliceBlue
          id: on-icon
        - value: 'off'
          styles:
            card:
              - box-shadow: 0px 0px 3px 2px var
              # - opacity: 0.3
            label:
              - color: AliceBlue
            icon:
              - color: 'AliceBlue'
            name:
              - color: AliceBlue
            state:
              - color: 'AliceBlue'
          id: off-icon
        - value: unavailable
          styles:
            card:
              - opacity: 0.2
              - color: grey
              - '--paper-item-icon-color': grey
            label:
              - color: 'rgba(0, 0, 0, 0.0)'

Thank you again

      tap_action:
        action: call-service
        service: browser_mod.popup
        service_data:
          title: Popup example
          style:
            background: var(--background-image)
            color: AliceBlue
          card:
            type: 'custom:button-card'
            entity: light.corner_living_room_lights
          deviceID:
            - this
1 Like

Thank you!!!
all working great, one last thing, the color of the name can it be changed to Alice blue?

code:

  popuptest1:
    card: 
      type: 'custom:button-card'  
      color: auto
      size: 30%
      icon: '[[icon]]'
      entity: '[[entity]]'
      show_last_changed: true
      aspect_ratio: 1/1
      show_state: true
      name: '[[name]]'
      show_label: true
      tap_action:
        action: call-service
        service: browser_mod.popup
        service_data:
          title: Popup example
          style:
            background: var(--background-image)
            color: AliceBlue
            border-radius: 15px
            --ha-card-border-radius: 15px
            --ha-card-background: '#646464'            
          card:
            type: 'custom:button-card'
            entity: light.corner_living_room_lights       
          deviceID:
            - this
            - dashboard
      hold_action:
        action: more-info
        haptic: success
      styles:
        card:
          - padding-left: 10px
          # - background-color: 'rgba(255,255,240,0.9)'
          # - background-color: '#fff5bc'
          - background-color: 'rgb(100,100,100)'
          - border-radius: 15px
        name:
          - justify-self: start
          - font-weight: bold
          - font-size: 13px
        label:
          - font-size: 11px
          - font-family: Helvetica
          - padding: 0px 10px
          - justify-self: start
        state:
          - font-size: 11px
          - font-family: Helvetica
          - padding: 1px 10px
          - justify-self: start
          - text-transform: capitalize
          - font-weight: bold
        grid:
          - grid-template-areas: '"i" "n" "s" "l"'
          - grid-template-columns: 1fr
          - grid-template-rows: 1fr min-content min-content
        img_cell:
          - justify-content: start
          - align-items: start
      state:
        - value: 'on'
          styles:
            card:
              - box-shadow: 0px 0px 3px 2px var
            name:
              - color: AliceBlue
            state:
              - color: AliceBlue
            label:
              - color: AliceBlue
          id: on-icon
        - value: 'off'
          styles:
            card:
              - box-shadow: 0px 0px 3px 2px var
              # - opacity: 0.3
            label:
              - color: AliceBlue
            icon:
              - color: 'AliceBlue'
            name:
              - color: AliceBlue
            state:
              - color: 'AliceBlue'
          id: off-icon
        - value: unavailable
          styles:
            card:
              - opacity: 0.2
              - color: grey
              - '--paper-item-icon-color': grey
            label:
              - color: 'rgba(0, 0, 0, 0.0)'

Honestly, you should shun away from coding your buttons like this. Because every button will take up this much of code. Making the code very very very long and harder to find what you want (if you’d ever need to change it). Performance might be lower as well but not sure about that. For now I will share the code you need, but I will highly advise you to look at either yaml anchors (if you use a single file) or decluttering-card if you have a split configuration like I have.

Learn to use these cards and you will only need to set all these colors, styles etc once. For example. I use a single template for ALL my buttons. Buttons with a tap_action, buttons without it, buttons with a number badge in the corner etc etc. All coming from a single template and at most my light buttons take up only 10 lines of code.

But for learning how to code your method is a good one as it will teach you how yaml structure works. (I started out the same way so no shame in there).

Anyways here is the code you need for making that text AliceBlue

  popuptest1:
    card: 
      type: 'custom:button-card'  
      color: auto
      size: 30%
      icon: '[[icon]]'
      entity: '[[entity]]'
      show_last_changed: true
      aspect_ratio: 1/1
      show_state: true
      name: '[[name]]'
      show_label: true
      tap_action:
        action: call-service
        service: browser_mod.popup
        service_data:
          title: Popup example
          style:
            background: var(--background-image)
            color: AliceBlue
            border-radius: 15px
            --ha-card-border-radius: 15px
            --ha-card-background: '#646464'            
          card:
            type: 'custom:button-card'
            entity: light.corner_living_room_lights 
            styles:
              name:
                - color: AliceBlue   
          deviceID:
            - this
            - dashboard
      hold_action:
        action: more-info
        haptic: success
      styles:
        card:
          - padding-left: 10px
          # - background-color: 'rgba(255,255,240,0.9)'
          # - background-color: '#fff5bc'
          - background-color: 'rgb(100,100,100)'
          - border-radius: 15px
        name:
          - justify-self: start
          - font-weight: bold
          - font-size: 13px
        label:
          - font-size: 11px
          - font-family: Helvetica
          - padding: 0px 10px
          - justify-self: start
        state:
          - font-size: 11px
          - font-family: Helvetica
          - padding: 1px 10px
          - justify-self: start
          - text-transform: capitalize
          - font-weight: bold
        grid:
          - grid-template-areas: '"i" "n" "s" "l"'
          - grid-template-columns: 1fr
          - grid-template-rows: 1fr min-content min-content
        img_cell:
          - justify-content: start
          - align-items: start
      state:
        - value: 'on'
          styles:
            card:
              - box-shadow: '0px 0px 3px 2px var'
            name:
              - color: 'AliceBlue'
            state:
              - color: 'AliceBlue'
            label:
              - color: 'AliceBlue'
          id: on-icon
        - value: 'off'
          styles:
            card:
              - box-shadow: '0px 0px 3px 2px var'
              # - opacity: 0.3
            label:
              - color: 'AliceBlue'
            icon:
              - color: 'AliceBlue'
            name:
              - color: 'AliceBlue'
            state:
              - color: 'AliceBlue'
          id: off-icon
        - value: unavailable
          styles:
            card:
              - opacity: 0.2
              - color: 'grey'
              - --paper-item-icon-color: 'grey'
            label:
              - color: 'rgba(0, 0, 0, 0.0)'

1 Like

as a final post on this (sub) topic (otherwise we should take it to a new thread, not to waste @jimz011’s topic here) I share this script, which is run before bedtime here:

  light_notification:
    alias: 'Light notification'
    sequence:
      service_template: >
        {{ notify_entity_id }}
      data_template:
        message: >
          {% set lights_on = states.light |
             selectattr('entity_id','in',state_attr('group.all_inside_lights','entity_id'))| 
             selectattr('state','eq','on') | map(attribute='name') | list %}
          {% if lights_on | length == 0 %}
            No lights on. Sleep well..
          {% elif lights_on | length == 1 %}
            The {{ lights_on[0] }} light is on.
          {% elif lights_on | length == 2 %}
            The {{ lights_on[0] }} and {{ lights_on[1] }} lights are on.
          {% else %}
            The {{ lights_on[:-1] | join(', ') }}, and {{ lights_on[-1] }} lights are on.
          {% endif %}

it has the exact template, and works perfectly, so calling this always renders the correct lights. Add |count and it should be fine. Must think wy this workds and why the sensors wouldn’t update. Only thing I can think of now is running this script, updates the template instantaneously, like if one would use the service update entity…

Hi guys, im fairly new.
Awesome job first of all!

Now I am wondering. Any way to have a conditional setting in person.yaml because the text is barely visible when home and having a very bright image. Can’t seem to figure out how to do this the best way.

Hi i’m using decluttering-card all my templates is stored in the file below

This is the configuration in lovelace:
decluttering_templates: !include lovelace/decluttering_templates.yaml

This is the template:

  popuptest1:
    card: 
      type: 'custom:button-card'  
      color: auto
      size: 30%
      icon: '[[icon]]'
      entity: '[[entity]]'
      show_last_changed: true
      aspect_ratio: 1/1
      show_state: true
      name: '[[name]]'
      show_label: true
      tap_action:
        action: call-service
        service: browser_mod.popup
        service_data:
          title: Popup example
          style:
            background: var(--background-image)
            color: AliceBlue
            border-radius: 15px
            --ha-card-border-radius: 15px
            --ha-card-background: '#646464'            
          card:
            type: 'custom:button-card'
            entity: '[[entity]]'
            styles:
              name:
                - color: AliceBlue 
            state:
              - value: 'on'
                styles:
                  card:
                    - box-shadow: '0px 0px 3px 2px var'
                  name:
                    - color: 'AliceBlue'
                  state:
                    - color: 'AliceBlue'
                  label:
                    - color: 'AliceBlue'
                  icon:
                    - color: '#ffd633'
                id: on-icon
              - value: 'off'
                styles:
                  card:
                    - box-shadow: '0px 0px 3px 2px var'
                    # - opacity: 0.3
                  label:
                    - color: 'AliceBlue'
                  icon:
                    - color: 'AliceBlue'
                  name:
                    - color: 'AliceBlue'
                  state:
                    - color: 'AliceBlue'
                  icon:
                    - color: 'AliceBlue'
                id: off-icon                
          deviceID:
            - this
            - dashboard
      hold_action:
        action: more-info
        haptic: success
      styles:
        card:
          - padding-left: 10px
          # - background-color: 'rgba(255,255,240,0.9)'
          # - background-color: '#fff5bc'
          - background-color: 'rgb(100,100,100)'
          - border-radius: 15px
        name:
          - justify-self: start
          - font-weight: bold
          - font-size: 13px
        label:
          - font-size: 11px
          - font-family: Helvetica
          - padding: 0px 10px
          - justify-self: start
        state:
          - font-size: 11px
          - font-family: Helvetica
          - padding: 1px 10px
          - justify-self: start
          - text-transform: capitalize
          - font-weight: bold
        grid:
          - grid-template-areas: '"i" "n" "s" "l"'
          - grid-template-columns: 1fr
          - grid-template-rows: 1fr min-content min-content
        img_cell:
          - justify-content: start
          - align-items: start
      state:
        - value: 'on'
          styles:
            card:
              - box-shadow: '0px 0px 3px 2px var'
            name:
              - color: 'AliceBlue'
            state:
              - color: 'AliceBlue'
            label:
              - color: 'AliceBlue'
            icon:
              - color: '#ffd633'
          id: on-icon
        - value: 'off'
          styles:
            card:
              - box-shadow: '0px 0px 3px 2px var'
              # - opacity: 0.3
            label:
              - color: 'AliceBlue'
            icon:
              - color: 'AliceBlue'
            name:
              - color: 'AliceBlue'
            state:
              - color: 'AliceBlue'
            icon:
              - color: 'AliceBlue'
          id: off-icon
        - value: unavailable
          styles:
            card:
              - opacity: 0.2
              - color: 'grey'
              - --paper-item-icon-color: 'grey'
            label:
              - color: 'rgba(0, 0, 0, 0.0)'

This in code in lovelace:

              - type: custom:decluttering-card 
                template: popuptest1
                variables:
                  - name: bulb test
                  - entity: light.bedroom_lights
                  - icon: mdi:lightbulb

my lovelace file is 222kb.

i’m not quite sure how to split the template into multiple files , what i need to configure in love in order to map the files.

Any how you helped me a lot , Than you!

Hey keen to use your button template however I cant seem to get it working
Here are hte steps I’ve taken

  1. install decluttering card and button card (and loaded via resources)
  2. included the templates dir with buttons.yaml in it

Here is my ui-lovelace.yaml - can you help me find what the issue with my config is?
I dont get any errors however no button displays either

# views
views:
  - title: Main
    cards:
      - type: custom:decluttering-card
        template: button
        variables:
          - entity: light.hallway
          - name: Hallway

I will try to answer all your questions tonight.

It would probably easier to hardcode a dark text color into that person template. (Just add this line to the styles color: black;)

Unless you use multiple photos to use for home/away. But if you use that you could use a js template for that.

Well this looks like a correct way to do it. This way you call the template within your decluttering card and then define the variables. This saves you a lot of code!!!

Do you have my latest template? If yes you will need a few things (at least one thing) to make it work.

You will need input_selects (for selecting a border-radius on the fly). Automations and in this version you’d also need groups. (I will upload a shorter and easier version tonight).

The only thing you would really need to make it work are the border-radius input_selects and box-shadow. You can find them in configuration/input_select.yaml on my repo. Just copy those to your own input_select configuration (that is either in configuration.yaml or if you have split files like me it could be any file, in my case input_select.yaml)

If you do not plan to use the provided theme selector. Then change 2 lines in your button template (button.yaml).

Change border-radius: [[[ a long string ]]] to border-radius: var(--border-radius)
and box-shadow: none

This way your buttons will show correctly as it no longer requires the input_selects state, however the provided theme selector will not work!

There are a bunch of automations that come with it, but I would suggest waiting on the new ones which I will release tonight. They are in separate files from that point on and you will be able to find and copy the required automations/input_selects very quickly.

Let me know if you still face errors.

Edit: for the template to work properly you will need my themes as well. Or change all theme names to your own desired theme.

(Names look like var(–card-color-off))

thanks! got it working although the background image does not load in the theme - tried to debug this for ages, not sure what to change!

ok, please open the yaml file of the theme you currently have set and share the first configuration line with me. It should look like this:

background-image: 'center / cover no-repeat url("/local/images/wallpapers/gray-wood.png") fixed'

So if you have this line, then please check if you have the following directory in you /www/images/ folder.

/www/images/wallpapers

If you do not have this, please download them from my repo.

yes i checked this and it looks OK also the file is at the correct path

background-image: 'center / cover no-repeat url("/local/images/wallpapers/gray-wood.png") fixed'

can you try the following?

  1. go to your developer-tools
  2. from the dropdown menu select frontend.reload_themes
  3. in the service area paste the following code
{"name":"Space Gray"}
  1. then call the service and see what happens.

edit: wait - got it working! thanks

Great to hear !

Remember, every file described below has #comments, use these comments as guidelines for your update!

Homekit Infused Release v. 0.13.2

Hi all, a few small fixes and changes to the 0.13.x version. I have gotten a few questions and I will answer them here.

  • Where did my icons go? mdi: is no longer hardcoded in the template, you WILL have to add mdi: to every single view/include/template/popup-card etc. to EVERY icon you already had. So if you had - icon: washing-machine you will now have to change it to mdi:washing-machine. This is so it makes it possible to have the default icon of an entity if you did not set one and it will give us the ability to use a button-template (string) directly in your decluttering-card. E.g. - icon: "[[[ if (entity.state === 'on') return 'mdi:door-open'; else return 'mdi:door'; ]]]".

  • Help, all my buttons are gone? Alright this is because you are missing pieces for this template to work. You are missing the following v.0.13.0/1: you are missing automations, groups and input_selects. You need to copy all of these for the template to work. Because this question was the most common this week I have added a commented out config in the button.yaml template so you can use that in case you either don’t want to use my provided theme selector, or you simply do not want to change right now or maybe it is too complicated to understand at the moment. No worries, I’ve got you covered in this update! So before you start copying the automations/groups/input_selects from version 0.13.0/0.13.1 please use the new automations and input_selects from 0.13.2 (this release). Not only are they massively shorter, they are also a lot easier to find and groups are no longer needed. (I will tell you later on in this guide). So remember for the button.yaml template to function properly you will either have to copy the automations and input_selects or change the config in button.yaml to the provided (commented out) config. Either way will work, though using the ‘old’ config will disable the extra options in theme selector (changing themes will still work, just the changing of border-radius and box-shadow won’t).

  • I want your style of defining views in ui-lovelace.yaml but if I do this it gives me errors, what can I do? Well to use an included directory you will first have to know how including files work. Not only will this make including files a lot easier for you in the future you can also compare the different kinds of includes in my configuration giving you all sorts of examples. Please check out this page for that https://www.home-assistant.io/docs/configuration/splitting_configuration/ For the lazy readers, just skip ahead to the advanced usage section. It will contain all you need with clear examples on which include command you can use on which kind of files or types. Having that said, I use an !include_dir_merge_list. This means items need to be displayed as a list (they start with a hyphen like all views and lovelace cards need by default). Because I used an included file in the past, the hyphen was already coded into ui-lovelace.yaml. This means that you no longer need the hyphen in the included file. (because the hyphen sits in front of the included file)

views:
  - !include lovelace/views/lights.yaml

As you can see in this example, there is already a hyphen in front of the include. Meaning the file has started with a hyphen.
Using my current method means all the hyphens are no longer hardcoded in ui-lovelace.yaml This means we need to put a hyphen on every view. What you need to do here is, add two spaces to the beginning of every line and put a hyphen on the first line and first column of every view. ui-lovelace.yaml will now read the entire directory at once without the need of defining each view ourselves in ui-lovelace.yaml. Now why would I want to do this? Well 2 reasons, I no longer have to create an entry in ui-lovelace.yaml whenever I add a new view. I simply create a new file. The other reason is that I can now have multiple views in a single file. So if I would have really small views I could just add more views without needing to create more files. Remember that this is absolutely unnecessary, you will have NO performance improvements or ANY improvements at all using this method but the previously mentioned two reasons. The only other reason I can think of why you should do this is because you will be up to date with my config and you will not have to remove the 2 spaces at the beginning of the line if you copy my views in the future. So feel free to do with this as you please but if you want to keep the old way, remove the hyphen and the two spaces at the beginning of each line so that the title sits on line 1 column 1 instead of the hyphen.

# New method
- title: view1
  path: view1
  cards:
    - etc

# Old method
title: view1
path: view1
cards:
  - etc

Remember that the new method renders EVERY file in the folder, if you have faulty config in any of those your lovelace will not render. Best practice to the new method is to put the views you don’t use in a seperate folder so you can add them later on. Also I need to mention the reason behind numbering the first 4 views is because I want those 4 views to be in that order and the first 4 views are swipable. If you use the header remember to number all files in the order you’d want. As I do NOT use the header and I only have the first 4 views swipable the other views do not require a number as I don’t care in what order they are as the way to access them will not be with the header.

Changes Overview 05/10/2019:

v. 0.13.2

  • Split entire configuration
  • Renewed a lot of automations with a simpler template (because they are split now they can be found faster)
  • Minor changes to the button template
  • Removed tablet config (in preparation for a separate tablet view!)
  • Merged main_view.yaml and frontpage.yaml (there was too much confusion around this!)
  • New theme Valentine (experimental)
  • NOTE: if you use iOS 2.0 APP, do NOT update to HA 0.100.0b0 as your app WILL crash!!!

Update Guide from 0.13.1 to 0.13.2:

Please read this first. In all changed files there is a # Changed/Added in 0.13.2 tag. Change/Add these lines in your own files. Most changes are relatively small. Find these tags in any of the files that have changed so you can easily change/add your own lines/files.
This is true for every file below. Note: If it says a file has changed but there are no comments, than it is most likely you only need to remove lines. Below you can read which lines/stacks you will need to remove.
I am only human, I do this for hobby, am an amateur and bound to make mistakes. If you find anything missing to the information below feel free to make suggestions.

Added

*custom_components:

  • Added plex_recently_added custom_component (please download this via HACS, don’t use this if you don’t use Plex)

*views:

  • Added about.yaml (this shows the version of the current setup and contains links to some of my channels, obviously not necessary but it will help me supporting you faster as long as you update this file with every update that comes after this)

*themes:

  • Added new theme (Valentine)

Changed:

*Templates: if you do not change templates I provide you can always just copy these files without the need of checking the code, Unless when there are added variables!

  • Changed button.yaml (minor changes related to default config with icons/names and added a default config for use without theme selector. Removed old code which contained var(–upcoming-color), I have tagged the line to remove with # Removed in 0.13.2)

*Views: views contain information about your own entities, do not just copy this!

  • Changed main_menu.yaml (it has the quick-access-menu changed so it can call the previously added about view that can show version information)
  • Changed all views that contained a tablet part (all tablet parts have been removed because I will create a proper one)
  • Changed main_view.yaml and frontpage.yaml (these files created so much confusion whilst that was never its purpose. Since tablet code is gone I have merged the two views so it’d be a single view again as any other view would be, only notifications remain split. End result is that only frontpage.yaml will remain. I’m sure this will help a lot with the confusion)

*Configuration: please do not copy these files, copy the lines you need.

  • Changed ALL configuration (the configuration folder is now split into multiple files which makes finding them easier)
  • Changed configuration.yaml (references to all configuration have changed to point at the new folders/files)
  • Changed most of the automations to be shorter in code (it saves hundreds of lines of code)

*Note:

  • I have removed most of the names/icons in lights.yaml and devices.yaml. Because of this update default icons are possible. I have changed their configuration in customize.yaml instead. This means that icons now come from the backend instead of the frontend which should (in theory) improve frontend loading. As I said before nothing will break if you don’t do this.

REMINDER: To make the button template work you will need to copy the following files (or copy their config) to your own files:

/configuration/input_select/themes.yaml
/configuration/automations/automations.yaml
/configuration/themes/ *entire directory

Thanks for taking the time to read this and enjoy this release.

Last but not least, the video’s on this update had been postponed, but I will release the videos this weekend. This gave me the time to answer some questions in the video (which I have answered here above as well). Thank you for your patience.

1 Like

I posted code for that last year and I am still using it combined with automations and it works great, auto-backgrounds just before I posted the editable instant styling … you may want to take a look for some ancient, but working ideas :rofl:

1 Like