Compact Custom Header

hi,

trying a second tab to have a dynamic icon gives me issues… I am trying to configure my alarm-panel tab as follows:

conditional_styles:
  - template:
      tab:
        7:
          - icon: >
              if (entities['alarm_control_panel.ha_main_alarm'].state == 'disarmed') return 'mdi:shield-check';
              if (entities['alarm_control_panel.ha_main_alarm'].state == 'armed_away') return 'mdi:shield-lock';
              if (entities['alarm_control_panel.ha_main_alarm'].state == 'armed_custom_bypass') return 'mdi:security';
              if (entities['alarm_control_panel.ha_main_alarm'].state == 'armed_home') return 'mdi:shield-home';
              if (entities['alarm_control_panel.ha_main_alarm'].state == 'armed_night') return 'mdi:shield-home';
              if (entities['alarm_control_panel.ha_main_alarm'].state == 'pending') return 'mdi:shield-outline';
              if (entities['alarm_control_panel.ha_main_alarm'].state == 'triggered') return 'mdi:bell-alert';
              return 'mdi:shield-check';
        14:
          - icon: >
              if (entity['sensor.family_home'].state == '0') 'mdi:account-off';
              else if (entity['sensor.family_home'].state == '1') 'mdi:account';
              else if (entity['sensor.family_home'].state == '2') 'mdi:account-multiple';
              else if (entity['sensor.family_home'].state == '3') 'mdi:account-multiple-check';
              else 'mdi:account-group';

when I click refresh, the correct icon is displayed for a fraction of a second after which it resorts to the icon of tab 14…

04

what could be going on here? I have both views set with an icon, without an icon in the view, the custom header icon won’t change

icon 7 (the alarm) uses

title: Alarm
icon: mdi:shield-check
path: alarm
cards:
  - type: custom:compact-custom-header

icon 14 uses:

title: Phones & Tablets
path: phones_tablets
icon: mdi:account-group
cards:
  - type: custom:compact-custom-header

changing the template to:

          - icon: >
              if (entities['alarm_control_panel.ha_main_alarm'].state == 'disarmed') 'mdi:shield-check';
              if (entities['alarm_control_panel.ha_main_alarm'].state == 'armed_away') 'mdi:shield-lock';
              if (entities['alarm_control_panel.ha_main_alarm'].state == 'armed_custom_bypass') 'mdi:security';
              if (entities['alarm_control_panel.ha_main_alarm'].state == 'armed_home') 'mdi:shield-home';
              if (entities['alarm_control_panel.ha_main_alarm'].state == 'armed_night') 'mdi:shield-home';
              if (entities['alarm_control_panel.ha_main_alarm'].state == 'pending') 'mdi:shield-outline';
              if (entities['alarm_control_panel.ha_main_alarm'].state == 'triggered') 'mdi:bell-alert';
              return 'mdi:shield-check';

doesnt make a difference, nor does:

  - template:
      tab:
        7:
          - icon: >
              if (entity['alarm_control_panel.ha_main_alarm'].state == 'disarmed') 'mdi:shield-check';
              else if (entity['alarm_control_panel.ha_main_alarm'].state == 'armed_away') 'mdi:shield-lock';
              else if (entity['alarm_control_panel.ha_main_alarm'].state == 'armed_custom_bypass') 'mdi:security';
              else if (entity['alarm_control_panel.ha_main_alarm'].state == 'armed_home') 'mdi:shield-home';
              else if (entity['alarm_control_panel.ha_main_alarm'].state == 'armed_night') 'mdi:shield-home';
              else if (entity['alarm_control_panel.ha_main_alarm'].state == 'pending') 'mdi:shield-outline';
              else if (entity['alarm_control_panel.ha_main_alarm'].state == 'triggered') 'mdi:bell-alert';
              return 'mdi:shield-check';

out of ideas how to change the template, which in traditional js customize version does its job in regular HA…

homeassistant:
  customize:
    group.home_alarm: #menu tab
      templates:
        icon: >
          if (entities['alarm_control_panel.ha_main_alarm'].state === 'disarmed') return 'mdi:shield-check';
          if (entities['alarm_control_panel.ha_main_alarm'].state === 'armed_away') return 'mdi:shield-lock';
          if (entities['alarm_control_panel.ha_main_alarm'].state === 'armed_custom_bypass') return 'mdi:security';
          if (entities['alarm_control_panel.ha_main_alarm'].state === 'armed_home') return 'mdi:shield-home';
          if (entities['alarm_control_panel.ha_main_alarm'].state === 'armed_night') return 'mdi:shield-home';
          if (entities['alarm_control_panel.ha_main_alarm'].state === 'pending') return 'mdi:shield-outline';
          if (entities['alarm_control_panel.ha_main_alarm'].state === 'triggered') return 'mdi:bell-alert';
          return 'mdi:shield-check';

separate post.please allow…

since my efforts above wont work, I decided to updated to the latest CCH version. But now it isnt loaded at all, and I see this in the inspector:

SyntaxError: Importing binding name 'hass' is not found.

my HA system isnt yet on 96, so I probably need to downgrade CCH. But where can I find version 1.10 on the Github please?

You can load older versions if you are using HACS… click on the release list and you will see a dropdown (in HACS) and you can revert.

o really? that would be a reason to reinstate HACS…cool. didnt know that yet. thanks!

but, as things stand now, I dont use HACS, and would need a link to the version on the Github directly…

So on the github page there is a releases link/tab and you can scroll down and see all the releases

must be going silly here, but I cant see it…

update

duh, found it! completely missed out on that one before.

thanks David, learn something new each day…

1 Like

releases

try this:

conditional_styles:
  - template:
    - tab:
        7:
          icon: >
            if (entities['alarm_control_panel.ha_main_alarm'].state == 'disarmed') 'mdi:shield-check';
            else if (entities['alarm_control_panel.ha_main_alarm'].state == 'armed_away') 'mdi:shield-lock';
            else if (entities['alarm_control_panel.ha_main_alarm'].state == 'armed_custom_bypass') 'mdi:security';
            else if (entities['alarm_control_panel.ha_main_alarm'].state == 'armed_home') 'mdi:shield-home';
            else if (entities['alarm_control_panel.ha_main_alarm'].state == 'armed_night') 'mdi:shield-home';
            else if (entities['alarm_control_panel.ha_main_alarm'].state == 'pending') 'mdi:shield-outline';
            else if (entities['alarm_control_panel.ha_main_alarm'].state == 'triggered') 'mdi:bell-alert';
            else 'mdi:shield-check';
    - tab:
        14:
          icon: >
            if (entity['sensor.family_home'].state == '0') 'mdi:account-off';
            else if (entity['sensor.family_home'].state == '1') 'mdi:account';
            else if (entity['sensor.family_home'].state == '2') 'mdi:account-multiple';
            else if (entity['sensor.family_home'].state == '3') 'mdi:account-multiple-check';
            else 'mdi:account-group';

thanks!
your suggestion made progress, in that it at least showed my default icon, set in the view (do we still need that?)

then I noticed you had also used entities, while we need entity (those annoying different version if JS floating around…), so I changed it to

conditional_styles:
  - template:
      - tab:
          7:
            icon: >
              if (entity['alarm_control_panel.ha_main_alarm'].state == 'disarmed') 'mdi:shield-check';
              else if (entity['alarm_control_panel.ha_main_alarm'].state == 'armed_away') 'mdi:shield-lock';
              else if (entity['alarm_control_panel.ha_main_alarm'].state == 'armed_custom_bypass') 'mdi:security';
              else if (entity['alarm_control_panel.ha_main_alarm'].state == 'armed_home') 'mdi:shield-home';
              else if (entity['alarm_control_panel.ha_main_alarm'].state == 'armed_night') 'mdi:shield-home';
              else if (entity['alarm_control_panel.ha_main_alarm'].state == 'pending') 'mdi:shield-outline';
              else if (entity['alarm_control_panel.ha_main_alarm'].state == 'triggered') 'mdi:bell-alert';
              else 'mdi:shield-check';
      - tab:
          14:
            icon: >
              if (entity['sensor.family_home'].state == '0') 'mdi:account-off';
              else if (entity['sensor.family_home'].state == '1') 'mdi:account';
              else if (entity['sensor.family_home'].state == '2') 'mdi:account-multiple';
              else if (entity['sensor.family_home'].state == '3') 'mdi:account-multiple-check';
              else 'mdi:account-group';

et voila, that works fine!
took the liberty to experiment with the extra 2 spaces before the - tab:, to have my space-ocd behave :wink:

thanks!

btw, why would the latest version of your CCH render the

SyntaxError: Importing binding name 'hass' is not found.

error? It does so even on 96.5, which I have updated to in the meanwhile.

Ah cool, glad it worked. I just modified your first example and didn’t even notice the entities/entity.

Not sure what’s going on with the error, will look into it. Is that the full error? Where’s it happening, in dev tools or in HA logs?

yes I believe so, it was shown in inspector, right clicking in the browser window…

happened on 95.4, and now on 96.5.
I dld the version from: GitHub - maykar/compact-custom-header: This project has been replaced by Custom Header

for my new install on 96.5, I reverted to an older version used on another instance, but dont know the version because it doesn’t say in the file ( dont use HACS)

1 Like

now notice your post, thanks, will give it another try soon. Very nice feature indeed.

I’ll admit that I haven’t read this entire thread so apologies if this has been asked/answered but is it possible to use tab (view) names instead of tab numbers?

I added a view and I just realized that it changed the numbering sequence so it messed up the config.

Not yet, but this feature is coming

4 Likes

Is it possible that a login user will already set themes from the themes.yaml file

I’m not sure exactly what you’re asking, but I don’t think I’ll be adding anything in CCH to set themes. Anything to do with setting themes can already be done without CCH, either in the backend or in user’s preferences.

2 Likes

cool, would be really nice if we could simply use the path: field for that ! thanks for considering this long wished feature :+1:

You will be able to use a view’s title:, path:, number, or range for hide_tabs/show_tabs and title:, path:, or number in conditional styling.

2 Likes

Question: with 0.96 the notications indicator moved to the sidebar, which in the mobile view with CCH is hidden, i.e. if there are notifications, they won’t be seen until the sidebar is manually expanded. I would much prefer to keep the “notification bell” icon on the top bar like it was before. Is this something that CCH can be configured to do?

after scanning the current configuration options I can’t seem to find this. (it’s been many months since I last tweaked my CCH config).
If possible, I’d prefer to also restore the “alarm bell in the top right of the top bar” view even for the desktop (non-mobile) view

This is with: latest CCH (installed/updated via HACS)
HA 0.96.5 (docker container / RPi3)

This isn’t something that CCH currently does and I’m not sure I’d add it either.

This is only true if you are hiding the menu button.

In the current version of HA there is a notification dot that appears on the menu icon, then clicking the menu icon will expand the sidebar to access notifications. I feel like adding another notification indicator and button would be redundant.

You could change the menu icon to be a notification bell using CCH, but it would be on the left side instead of the right. You could even use CCH’s conditional styling to change an icons color or header background when there are notifications.