Compact Custom Header

https://maykar.github.io/compact-custom-header/Exception-Config/

“This is the Home Assistant user’s name, not username (if they’re different). You can look to the bottom of the CCH editor or in the HA user list to see which to use. This option is case sensitive.”

The user list can be found by clicking the “configuration” tab in the sidebar, then “users”

Thank you, I saw that instruction, but I can’t find the CCH editor (I use yaml) and in the HA user list, the name is not the same as the login name.

For an example, I just created a new user on my system. This user has the username “username” and the user’s name is “User Name”. It displays like this in the list:

So in CCH I would use “User Name” not “username”:

  exceptions:
    - conditions:
        user: User Name

Edit: I fear that I may made it more confusing by using “User Name” as the example, if so I apologize.

If you’ve forgotten which name was used or are still having issues you can go into your browser’s dev-tools (F12) while on HA and paste this into the console:

document.querySelector("home-assistant").hass.user.name

That will output the correct name you should use for the logged in user.

Perfect, thanks, that works!

1 Like

Release 1.3.7

Until I find the time to update the docs you can refer to this post and the previous pre-release’s post for new features/fixes. Will have the docs updated soon, but I wanted to get this release out since it has fixes for 0.99. Will be updating the version for legacy devices soon as well.

Added Features:

  • time_css: & date_css: add custom css for time and date seperately. Used like the custom css options explained in the previous release’s post.
  • default_tab_template: Use javascript templates for default tab. Template should return a tab number, path, or title. Used like conditional styling templates, example below.
  • edit_mode_show_tabs: set to true to always show all tabs when in edit mode.

Fixes

  • Occasionally the current tab was hidden from view when navigating with a button or using default_tab. The tab is now scrolled into view in those cases.
  • Non-template conditional styles were very buggy and sometimes wouldn’t survive a page reload. I’ve rewritten that portion to deal with those issues.
  • Added fixes for background images and a few other elements for HA 0.99

Default Tab Template Example:

cch:
  default_tab_template: >
    if (states["input_boolean.home"].state == "off") "home";
    else if (states["input_boolean.away"].state == "on") 2;
    else 0;
2 Likes

Ahh the default tab template would enable me to show a different view based on states correct? So for example if I make a shoppinglist view and my device tracker’s state is in the supermarket I could have it show the shoppinglist when I open HA?

Are conditions possible as wel? Or say default tab per user?

Yep and you can use default_tab_template with any of the conditions as well.

So far the latest update doesn’t have the previously mentioned problem with the login screen. I will test out tab groups later today.

Thanks for your hard work.

1 Like

FIXED thank you


Also the new tab template will be awesome for Spotify :grin: if music playing switch to media tab :ok_hand: thanks again

1 Like

Exactly this templating stuff is great as it will save me from using state-switches and/or browser_mod to achieve this.

Really great work. Just a wild question which has nothing to do with your custom card @mayker, would it be possible to do the same for backgrounds? As in lovelace wallpaper with a template like the header?

hoped this would have solved my issue with the navigation to the out of view tab, but it hasn’t unfortunately: Compact Custom Header - #1150 by Mariusthvdb still as it was

btw, I see this (unrelated?) error:

local/lovelace/resources/compact-custom-header/compact-custom-header.js?v=1.3.7:1033:13 Uncaught ReferenceError: above is not defined

1 Like

That was my mistake, just pushed 1.3.8 to fix and also make default tab respect redirect settings. It’s likely that error was preventing the view from being shown as well.

not just yet…now see this:

/local/lovelace/resources/compact-custom-header/compact-custom-header.js?v=1.3.8:1110:42 Uncaught TypeError: Cannot read property 'querySelector' of undefined

and see the tab in view for a second, and then see it sliding out of view 1 tab again…

What does your config look like?

# https://github.com/maykar/compact-custom-header/wiki/Main-Config-Options
#type: custom:compact-custom-header
#main_config: true
header: true
menu: show
options: show
swipe: true
swipe_animate: none
chevrons: true
exceptions:
  - conditions:
      user_agent: iPhone
    config:
      menu: hide
      notifications: hide
      header: true
      options: hide
conditional_styles:
  - template:
      - tab:
          'alarm':
            icon: >
              var alarm = entity['alarm_control_panel.ha_main_alarm'].state;
              if (alarm == 'disarmed') 'mdi:shield-check';
              else if (alarm == 'armed_away') 'mdi:shield-lock';
              else if (alarm == 'armed_custom_bypass') 'mdi:security';
              else if (alarm == 'armed_home') 'mdi:shield-home';
              else if (alarm == 'armed_night') 'mdi:shield-home';
              else if (alarm == 'pending') 'mdi:shield-outline';
              else if (alarm == 'triggered') 'mdi:bell-alert';
              else 'mdi:shield-check';
      - tab:
          'phones_tablets':
            icon: >
              var family = entity['sensor.family_home'].state;
              if (family == '0') 'mdi:account-off';
              else if (family == '1') 'mdi:account';
              else if (family == '2') 'mdi:account-multiple';
              else if (family == '3') 'mdi:account-multiple-check';
              else 'mdi:account-group';
      - tab:
          'weer_klimaat':
            icon: >
              var weer = entity['sensor.weather_icon'].state;
              weer;
  - entity: notifications
    condition:
      state: false      # When there are no notifications...
    button:             # hide notifications button.
      notifications:
        hide: true

it’s the tab weer_klimaat I am navigating to.

If you’re using HA version 0.96 or above remove this:

  - entity: notifications
    condition:
      state: false      # When there are no notifications...
    button:             # hide notifications button.
      notifications:
        hide: true

I’ll make an exception for it in the next release, but there is no longer a notifications button in the header so that code does nothing, except cause an error.

I’ve made the template to switch to the music tab if Spotify is playing which is great, One question though is it possible for it to switch to that tab when HA is already open? I’ve noticed it will only go to that tab on opening HA. Great update mate :grinning:

1 Like

Hi I just upgraded to HA 99.1 and my menu button has stopped working. I have tried to update to 99.2 on docker but it keeps downloading 99.1
:

  main_config: true
  swipe: true
  background: 'rgba(46, 45, 45, 1)' 
  menu: overflow
  options: overflow
  clock_format: 12
  clock_date: true
  date_locale: true
  clock_am_pm: true
  hide_help: true
  hide_config: true
  hide_unused: true
  compact_header: true
  voice: hide

Any help please thanks.

I created a new user, i’m running the latest version of hassio.
my question is how can i configure that the user will see only one tab, i want to hide everything else.

can someone help can i do it?