Custom Header

I’m aware of the error, it’s been reported many times in this thread and on GitHub. I’m unable to work on Custom Header at the moment but will again soon.

Use this. If the input boolean is on then its true, else it’s false:

  disabled_mode: '{{ states.input_boolean.ha_ui.state  == "on" }}'

Notice when using your example in test_template

  test_template: >
    {%- if states.input_boolean.ha_ui.state == 'on' -%}
      true
    {%- else -%}
      false
    {%- endif -%}

it returns:

image

or “nfalsenn” because it’s rendering all new lines as \n, even without those issues it would render the booleans as strings instead of true booleans.

1 Like

Bingo! It worked.

Btw, that’s a cool trick to test that template. I was under the impression
that > replaces each line break by a space and ‘{%-’ would take care of removing those spaces.

When I was testing this template without any spaces and ‘>-’, got this error message in the logs. I am not sure if this is relevant issue or mistake on my part.

  test_template: >-
    {%- if states.input_boolean.ha_ui.state == 'on' -%}true
    {%- else -%}false
    {%- endif -%}
custom-header.js:576 Uncaught TypeError: e.test_template.toLowerCase is not a function
    at processAndContinue (custom-header.js:576)
    at custom-header.js:576
    at Object.i.subscribeMessage.type [as callback] (custom-header.js:576)
    at c._handleMessage (haws.es.js:1)
    at WebSocket.<anonymous> (haws.es.js:1)

2020-01-04 14:19:01 ERROR (MainThread) [frontend.js.latest.201911196] http://192.168.86.226:8123/community_plugin/custom-header/custom-header.js:576:23992 Uncaught TypeError: e.test_template.toLowerCase is not a function

That’s just a bug with test_template I think. Your above test_template should work fine as a config template, but I believe test_template is expecting a string and is getting a boolean. So I just need to handle that better in test templates.

Hi Ryan, not wanting to be lazy, but since you have the templates in your documentation, would you please share the templates you use here:

I like the little dashboard and it would have a nice place in the frontend settings page …:wink:

1 Like

Hi all, does anyone know if it’s allowed to combine exceptions and templates like so:

custom_header:
  compact_mode: true
  exceptions:
    - conditions:
        user: kiosk
      config:
        header_text: '{{ hours12 }}:{{ minutesLZ }} {{ ampm }}'

or

custom_header:
  compact_mode: true
  exceptions:
    - conditions:
        user: kiosk
      config:
        button_text:
          menu: '{{ dayNameShort }}. {{ monthNameShort }}. {{ dayNum }} {{ year4d }}'

I just want a clock in the menubar that only appears for this user.

Also, for some reason I can’t get to the refresh menu in the … menu in the upper right hand corner, has anyone else solved that problem?
It’s not working for me, am I doing something wrong?

That is actually from my devcontainer that I use for testing. The entire lovelace file is here and the config file is here.

2 Likes

great! missed that, but thanks a bunch, truly appreciated!

It is

The refresh menu only exists in YAML mode. Do you use lovelace in YAML mode?

It is

Any idea why the syntax above doesn’t show anything?

Do you use lovelace in YAML mode?

Yes I do.

The menu is there but nothing pops up when I press it so I can’t get to refresh. This is on kindle fire with fully kiosk browser. Worked in CCH…

Is that your full config? If not please share the whole CH config. The above should work fine, do you get any errors? Does the “refresh” option work if you temporarily remove CH from your resources? Are you sure that’s the correct user’s name?

Please read the issues section of the docs.

Here’s the whole thing, though I’ve tried both variants above for different users with no luck. I am sure it’s working for this user because it’s following all the other rules set for the user.

And, yes, if I take out CH from resources, the button works again and I get the dropdown menu.

  compact_mode: true
  exceptions:
    - conditions:
        user: kiosk
      config:
        hide_tabs: '0'
        disable_sidebar: true
        default_tab: '1'
        hide_help: true
        hide_config: true
        hide_unused: true
        voice_hide: true
        button_text:
          menu: '{{ dayNameShort }}. {{ monthNameShort }}. {{ dayNum }} {{ year4d }}'
    - conditions:
        user: Alena
      config:
        hide_tabs: '1'
        disable_sidebar: true
        default_tab: 0
        hide_help: true
        hide_config: true
        hide_unused: true
        voice_hide: true
        menu_hide: true
    - conditions:
        user: Sophie
      config:
        hide_tabs: '1'
        disable_sidebar: true
        default_tab: 0
        hide_help: true
        hide_config: true
        hide_unused: true
        voice_hide: true
        menu_hide: true
    - conditions:
        user: Sean Straus
      config:
        hide_tabs: '1'
        default_tab: 0
        hide_help: true
        hide_config: true
        voice_hide: true

Does this only happen on that device and/or only in fully kiosk?

Yes, the problem with the menu button only happens on that device, though I think I may have experienced it for some time on my other device too as I was fixing problems from my CCH migration.

The problem with not being able to use button_text or header_text under exceptions I am having on every device.

3rd time now: Do you get any errors?

Sorry if that sounds rude, but it’s needed information for me to help you.

My bad, I don’t know how I missed you asking that twice.

I didn’t notice any from the frontend or I would have mentioned them up front, but when I go into the log I can find a couple:

http://myhost:8123/community_plugin/custom-header/custom-header.js:576:4919 TypeError: e is undefined

http://myhost:8123/community_plugin/custom-header/custom-header.js:576:4921 Uncaught TypeError: Cannot read property 'split_mode' of undefined

Hey all,

Maybe someone stumbled already in this situation… I have a RPI3 with touchscreen installed. From that panel i login with chromium browser to go to the HA main webpage. What i configured is that when i login with user X then it should only display panel Y with no fancy features etc. Now this works on my normal laptop but the moment that i login via my rpi it always shows the default HA ui. Any ideas?

Thnx

have a small dashboard which enables testing the various settings extremely easily. So cool. Only possible because of your relentless effort to create something beautiful for the community. So thanks again!

(added split mode and a few others…once you get the taste for it the endless options won’t let you go)

ch_split_mode:
  name: Split mode
  icon: mdi:arrow-split-horizontal #or mdi:page-layout-header-footer ;-)

only thing is one needs to set exclusions settings either hard coded, or with dedicated booleans… the work never ends :wink:

1 Like

Hey Ryan,
do need some help…

right now I use this for button_text on options:

button_text:
  options: >-
    {{ time }} - <ha-icon icon='{{states('sensor.weather_icon')}}' style='vertical-align: middle';></ha-icon> - {{states('sensor.temp_current') }}°

How can I create a boolean input_boolean.ch_options_text that shows the above when on, and the default value when off? I think I can do this:

button_text:
  options: >-
    {% if is_state('input_boolean.ch_use_options_text_template','on')%}{{ time }} - <ha-icon icon='{{states('sensor.weather_icon')}}' style='vertical-align: middle';></ha-icon> - {{states('sensor.temp_current') }}°
    {% endif %}

but am not sure if I can leave out the {%else%} clause? For now this seems to work on the options text not sure if it is ‘safe’ though.

This technique doesn’t work on the header text, which is the vertical marquee as created in theo the thread. If I disable the input_boolean, the marquee disappears alright, but the default header text doesn’t appear, leaving an empty header…

is that a bug or simply unsupported…

Any way you can share your code for that dashboard (including the CH code)? please? :wink:

sure here you go:

ch header:

#https://maykar.github.io/custom-header/#configuration/main
#test_template: >-
#  System alerts: {{states('sensor.marquee_alerts')}}

header_text: >-
  {% if is_state('input_boolean.ch_use_header_text_template','on')%}
  <style>
  #flipper{color:#999;}
  #flip {height:24px;overflow:hidden;}
  #flip > div > div {color:var(--primary-text-color);height:24px;margin-bottom:24px;display:inline-block;text-overflow: clip;white-space: nowrap;}
  #flip div:first-child {animation: show 10s linear infinite;}
  @keyframes show {
  0% {margin-top:-144px;}
  17% {margin-top:-96px;}
  33% {margin-top:-96px;}
  50% {margin-top:-48px;}
  67% {margin-top:-48px;}
  83% {margin-top:0px;}
  100% {margin-top:0px;}}
  #flipper p {position:fixed;color:#999; }
  </style>
  <div style='float: left'>Ha Rpi4:&nbsp;</div>
  <div id=flip><div><div>
  Summary - {{states('sensor.dark_sky_summary')}}</div></div><div><div>
  Daily -  {{states('sensor.dark_sky_daily_summary')}}</div></div><div><div>
  Hourly - {{states('sensor.dark_sky_hourly_summary')}}</div></div><div><div>
  Summary - {{states('sensor.dark_sky_summary')}}</div></div><div><div>
  {% endif %}
#  {{states('sensor.dark_sky_summary')}}</div></div><div><div>
#  {{states('sensor.br_symbol')}}</div></div><div><div>

## all default
disabled_mode: >-
  {{is_state('input_boolean.ch_disabled_mode','on')}}
kiosk_mode: >-
  {{ is_state('input_select.mode','Kiosk') }}
compact_mode: >-
  {{is_state('input_boolean.ch_compact_mode','on')}}
shadow: >-
  {{is_state('input_boolean.ch_shadow','on')}}
footer_mode: >-
  {{is_state('input_boolean.ch_footermode_mode','on')}}
split_mode: >-
  {{is_state('input_boolean.ch_split_mode','on')}}
disable_sidebar: >-
  {{is_state('input_boolean.ch_disable_sidebar','on')}}
hide_header: >-
  {{is_state('input_boolean.ch_hide_header','on')}}
hide_help: >-
  {{is_state('input_boolean.ch_hide_help','on')}}
hide_unused: >-
  {{is_state('input_boolean.ch_hide_unused','on')}}
hide_refresh: >-
  {{is_state('input_boolean.ch_hide_refresh','on')}}
hide_config: >-
  {{is_state('input_boolean.ch_hide_config','on')}}
#hide_raw: false
default_tab_on_refresh: false

# https://maykar.github.io/custom-header/#configuration/buttons
menu_hide: >
  {{is_state('input_boolean.ch_menu_hide','on')}}
voice_hide: >-
  {{is_state('input_boolean.ch_voice_hide','on')}}
options_hide: >-
  {{is_state('input_boolean.ch_options_hide','on')}}
menu_dropdown: >-
  {{is_state('input_boolean.ch_menu_dropdown','on')}}
voice_dropdown: >-
  {{is_state('input_boolean.ch_voice_dropdown','on')}}
reverse_button_direction: >-
  {{is_state('input_boolean.ch_reverse_button_direction','on')}}
#button_icons:

button_text:
  options: >-
    {% if is_state('input_boolean.ch_use_options_text_template','on')%}{{ time }} - <ha-icon icon='{{states('sensor.weather_icon')}}' style='vertical-align: middle';></ha-icon> - {{states('sensor.temp_current') }}°
    {% endif %}
#options_css: 'color:var(--primary-text-color);'

show_tabs: >
  {% if not is_state('input_select.mode','Developer') %}0 to 21, 26 to 28
  {% else %} 0 to 28
  {% endif %}

# https://maykar.github.io/custom-header/#configuration/exceptions
exceptions:
  - conditions:
      user: Gezin, redacted names
    config:
      show_tabs: 0 to 3,6,15 to 18
      voice_hide: true
      options_hide: true
  - conditions:
      user_agent: iPhone
    config:
      footer_mode: true
      indicator_top: false
      header_text: >-
        {% set inside=states('sensor.temperatuur_living')%}
        {% set outside=states('sensor.temp_current')%} 
        {% set temp_color='var(--primary-text-color)'%} 
        {% set symbol='°C' %}
        <div style='display: flex;display: -webkit-flex;'>
        <div>Ha&nbspRpi4:&nbsp;</div>
        <marquee>
        <span style='color: {{ temp_color }}'>
        Inside temperature: {{ inside }}{{ symbol }},
        Outside temperature: {{ outside }}{{ symbol }},
        </span>
        <span style='color: orange;'> 
        System alerts: {{states('sensor.marquee_alerts')}},
        </span>
        <span style='color: {{ temp_color }}'>
        Summary - {{states('sensor.dark_sky_summary')}},
        Daily -  {{states('sensor.dark_sky_daily_summary').split('.')[0]}},
        Hourly - {{states('sensor.dark_sky_hourly_summary').split('.')[0]}}.
        </span>
        </marquee>

#        {% set alerts = namespace(active=[], color='var(--google-red-500)') %}
#        {% if states('sensor.weatheralerts') | float != 0 %}
#          {% for alert in state_attr('sensor.weatheralerts', 'alerts') %}
#          {% set alerts.active = alerts.active + [alert['title']] %}
#          {% endfor %}
#        {% else %} {% set alerts.active = alerts.active + ['No active alerts'] %}
#        {% endif %}
#        {% set inside=states('sensor.temperatuur_living')%}
#        {% set outside=states('sensor.temp_current')%} 
#        {% set temp_color='var(--primary-text-color)'%} 
#        {% set symbol='°C' %}
#        <div style='display: flex;display: -webkit-flex;'>
#        <div>Ha&nbspRpi4:&nbsp;</div>
#        <marquee>
#        <span style='color: {{ temp_color }}'>
#        Inside temperature: {{ inside }}{{ symbol }},
#        Outside temperature: {{ outside }}{{ symbol }},
#        </span>
#        <span style='color: {{ alerts.color }};'>
#        Alerts: {{ alerts.active | join(' - ')}},
#        </span>
#        <span style='color: orange;'> 
#        System alerts: {{states('sensor.marquee_alerts')}},
#        </span>
#        <span style='color: {{ temp_color }}'>
#        Summary - {{states('sensor.dark_sky_summary')}},
#        Daily -  {{states('sensor.dark_sky_daily_summary').split('.')[0]}},
#        Hourly - {{states('sensor.dark_sky_hourly_summary').split('.')[0]}}.
#        </span>
#        </marquee>

      menu_hide: true
#      voice_hide: false
      options_hide: true
  - conditions:
      user_agent: iPad
    config:
      menu_hide: true
#      voice_hide: false
      options_hide: true

# https://maykar.github.io/custom-header/#configuration/tabs
chevrons: >-
  {{is_state('input_boolean.ch_chevrons','on')}}
indicator_top: >-
  {{is_state('input_boolean.ch_indicator_top','on')}}

#default_tab:
reverse_tab_direction: >-
  {{is_state('input_boolean.ch_reverse_tab_direction','on')}}

#hide_tabs: An array or comma separated string of tabs to hide, more info below
#show_tabs: An array or comma separated string of tabs to hide, more info below
hidden_tab_redirect: >-
  {{is_state('input_boolean.ch_hidden_tab_redirect','on')}}

tab_icons:
  alarm: >-
    {{states('sensor.alarm_panel_icon')}}
  phones_tablets: >-
    {{states('sensor.presence_icon')}}
  weer_klimaat: >-
    {{states('sensor.weather_icon')}}
  alarmclock: >-
    {{'mdi:alarm-off' if is_state('sensor.next_alarm','Not set') else 'mdi:alarm'}}

#active_tab_color: black
active_tab_css: 'background-color: rgba(0, 0, 0, 0.3);'
tab_indicator_color: black
tabs_color:
  alarm: >-
    {{states('sensor.alarm_panel_icon_color')}}
  phones_tablets: >-
    {{state_attr('sensor.family_home','icon_color')}}
  alarmclock: >-
    {{'green' if is_state('sensor.next_alarm','Not set') else 'red'}}

package:

homeassistant:
  customize_glob:
    input_boolean.ch_*:
      templates:
        icon_color: >
          if (state === 'on') return 'green';
          return 'grey';

  customize:
    input_boolean.ch_disabled_mode:
      templates:
        icon: >
          if (state === 'on') return 'mdi:death-star-variant';
          return 'mdi:death-star';
        icon_color: >
          if (state === 'on') return 'red';
          return 'green';

##########################################################################################
# Inputs
##########################################################################################

input_boolean:
  ch_disabled_mode:
    name: Disabled mode

  ch_use_options_text_template:
    name: Use options text template
    icon: mdi:code-braces

  ch_use_header_text_template:
    name: Use header text template
    icon: mdi:code-braces

#  ch_kiosk_mode:
#    name: Ch Kiosk mode
#    icon: mdi:overscan

  ch_compact_mode:
    name: Compact mode
    icon: mdi:resize

  ch_disable_sidebar:
    name: Disable sidebar
    icon: mdi:dock-left

  ch_menu_dropdown:
    name: Menu dropdown
    icon: mdi:menu

  ch_voice_dropdown:
    name: Voice dropdown
    icon: mdi:microphone

  ch_reverse_tab_direction:
    name: Reverse tab direction
    icon: mdi:arrow-left-right-bold

  ch_hidden_tab_redirect:
    name: Hidden tab redirect
    icon: mdi:directions

  ch_reverse_button_direction:
    name: Reverse button direction
    icon: mdi:arrow-left-right-bold

  ch_footer_mode:
    name: Footer mode
    icon: mdi:arrow-down-bold-box

  ch_split_mode:
    name: Split mode
    icon: mdi:page-layout-header-footer

  ch_chevrons:
    name: Chevrons
    icon: mdi:chevron-right-box-outline

  ch_shadow:
    name: Shadow
    icon: mdi:text-shadow

  ch_indicator_top:
    name: Indicator top
    icon: mdi:format-vertical-align-top

  ch_hide_header:
    name: Hide header
    icon: mdi:format-header-1

  ch_hide_help:
    name: Hide help
    icon: mdi:help

  ch_hide_unused:
    name: Hide unused
    icon: mdi:block-helper

  ch_hide_refresh:
    name: Hide refresh
    icon: mdi:refresh

  ch_hide_config:
    name: Hide config
    icon: mdi:settings-helper

  ch_hide_raw:
    name: Hide raw
    icon: mdi:code-braces-box

  ch_menu_hide:
    name: Menu hide
    icon: mdi:menu

  ch_voice_hide:
    name: Voice hide
    icon: mdi:microphone

  ch_options_hide:
    name: Options hide
    icon: mdi:apple-keyboard-option

#  ch_icon_changes:
#    name: Ch icon change demo
#    icon: mdi:emoticon-poop
#
#  ch_text_changes:
#    name: Ch button text demo
#    initial: off
#    icon: mdi:alphabetical

lovelace card:

  - type: entities
    show_header_toggle: false
    title: Custom header settings
    entities:
      - input_boolean.ch_disabled_mode
      - input_boolean.ch_compact_mode
      - input_boolean.ch_footer_mode
      - input_boolean.ch_split_mode
      - input_boolean.ch_chevrons
      - input_boolean.ch_shadow
      - input_boolean.ch_indicator_top
      - input_boolean.ch_use_options_text_template
      - input_boolean.ch_use_header_text_template
      - input_boolean.ch_hidden_tab_redirect
      - type: divider
      - input_boolean.ch_reverse_tab_direction
      - input_boolean.ch_reverse_button_direction
      - input_boolean.ch_disable_sidebar
      - input_boolean.ch_menu_dropdown
      - input_boolean.ch_voice_dropdown
      - type: divider
      - input_boolean.ch_hide_header
      - input_boolean.ch_hide_help
      - input_boolean.ch_hide_unused
      - input_boolean.ch_hide_refresh
      - input_boolean.ch_hide_config
      - input_boolean.ch_hide_raw
      - type: divider
      - input_boolean.ch_menu_hide
      - input_boolean.ch_voice_hide
      - input_boolean.ch_options_hide

will customize some icons based on state, but this does it for now ;-

2 Likes