Custom Header

Suddenly i got the log full of these errors:

2020-06-04 17:41:05 ERROR (MainThread) [frontend.js.latest.202005195] https://192.168.1.24:8123/hacsfiles/custom-header/custom-header.js:596:35592 Uncaught TypeError: Cannot read property 'partialPanel' of undefined

Almost 400kb of these errors…
Hints?

Please give the latest version a try ( 1.5.1 ) or the latest pre-release ( 1.5.2 ).

If this is still an issue, please submit it to github with the required info.

Release 1.5.3

:warning: This release is designed for HA versions 0.110+

There have been a few releases that I haven’t mentioned on this thread (check the change logs here). The most notable changes between the last time I posted here and this release:

  • No longer need to refresh after using “Raw Config Editor”. Thank @Villhellm for his persistence and patience for this one.
  • {{ hassVersion }} template variable. Displays current HA version number. Suggested by @dede34fr

1.5.3 Added Features

  • restrict_users: This will prevent non-admin users from disabling CH and accessing CH settings. Suggested by Github user @KRA77.
  • tab_icons_and_text: Will display both icons and text on tabs. Suggest by @jankete.
  • tab_text: Change a tab’s text, works just like button_text and accepts templates.
5 Likes

Hi Mayker, thanks for the continued development.

The latest release generates this warning in the logs:

'install' is deprecated, use 'async_install' instead

You sure that’s coming from Custom Header? What’s the full error in the logs?

I’ve since restarted and no longer have access to the error, but it could well be HACS as it occurred when updating Custom Header through HACS.

That is from HACS itself, it’s using a old method somewhere.

1 Like

Translations for Custom Header are now powered by Lokalise :tada:

Instructions on how to join are described here https://maykar.github.io/custom-header/#development/translation

1 Like

do we need to add anything to the config, because I now receive this new error (without having used any of the newly added features) once per minute (I think):

In Safari:

In Chrome:

Try the latest, 1.5.4

Solved! Cool, and thanks for the quick fix!
for now I have Zero CH errors… been a long time and worth the wait!

1 Like

I really love CH and the things it does! I’m struggling with two issues though:

  1. Is it possible to use media_query for the same user_agent in order to have two different configs depending on whether I’m holding my tablet in portrait or landscape mode (my tablet has a 1920x1200 resolution)?

  2. I can’t seem to find a way to use two user_agents for one config. Is user_agent: Windows, X705L not enough?

Here is my current setup

custom_header:
  active_tab_color: var(--state-icon-active-color)
  background: var(--app-header-background-color)
  editor_warnings: false
  elements_color: var(--app-header-text-color)
  exceptions:
    - conditions:
        user_agent: Windows
      config:
        button_text:
          options: >-
            {{ hours24 }}:{{ minutesLZ }} <div style='display:inline-block;
            height:24px; width:24px; vertical-align:bottom;'><ha-icon
            icon='mdi:weather-{% if is_state("weather.gismeteo", "partlycloudy")
            -%}partly-cloudy{%- else -%}{{ states('weather.gismeteo')}}{%- endif
            %}'></ha-icon></div> {{ states('sensor.temperature_38') }}°        
        default_tab: FLOORPLAN
        header_text: >-
          <style>ha-icon {display:inline-block; float:left} #flipper
          {color:#999;} #flip {height:24px;overflow:hidden;} #flip > div > div
          {color:#99h;height:24px;margin-bottom:24px;display:inline-block;}
          #flip div:first-child {animation: show 10s linear infinite;}
          @keyframes show { 0% {margin-top:-144px;} 5% {margin-top:-96px;} 33%
          {margin-top:-96px;} 38% {margin-top:-48px;} 66% {margin-top:-48px;}
          76% {margin-top:0px;} 100% {margin-top:0px;}} #flipper p
          {position:fixed;color:#999; } </style> <div><ha-icon icon='{% if
          is_state("switch.sonoff_1000b19f94_2", "on") %}mdi:water{% else
          %}mdi:water-off{% endif %}' style='color:{% if
          is_state("switch.sonoff_1000b19f94_2", "on") %}green{% else %}#800{%
          endif %}'</ha-icon></div><div><ha-icon icon='{% if
          is_state("switch.sonoff_1000b19f94_3", "on") %}mdi:water{% else
          %}mdi:water-off{% endif %}' style='color:{% if
          is_state("switch.sonoff_1000b19f94_3", "on") %}green{% else %}#800{%
          endif %}'</ha-icon></div><div><ha-icon icon='{% if
          is_state("switch.sonoff_1000b19f94_4", "on") %}mdi:water{% else
          %}mdi:water-off{% endif %}' style='color:{% if
          is_state("switch.sonoff_1000b19f94_4", "on") %}green{% else %}#800{%
          endif %}'</ha-icon></div><div id=flipper><div id=flip><div> <div>
          {{states('counter.count_espresso')}} coffees
          today</div></div><div><div> Last 48h rain:
          {{float(states('sensor.total_48h_precipitation'))}}
          mm</div></div><div><div> Sonoff 2 was ON for {{
          float(states('sensor.sonoff_2_on')) * 60 }} minutes
          </div></div><div><div> {{states('counter.count_espresso')}} coffees
          today</div></div><div><div>
        hide_tabs: '1,2'
    - conditions:
        user_agent: VOG-L29
      config:
        button_text:
          options: >-
            <div style='display:inline-block; height:24px; width:24px;
            vertical-align:bottom;'><ha-icon icon='mdi:weather-{% if
            is_state("weather.gismeteo", "partlycloudy") -%}partly-cloudy{%-
            else -%}{{ states('weather.gismeteo')}}{%- endif
            %}'></ha-icon></div> {{ states('sensor.temperature_38') }}°       
        default_tab: FLOOR1
        header_text: >-
          <div> <div style='display:inline-block'> <ha-icon icon='{% if
          is_state("switch.sonoff_1000b19f94_2", "on") %}mdi:water{% else
          %}mdi:water-off{% endif %}' style='color:{% if
          is_state("switch.sonoff_1000b19f94_2", "on") %}green{% else %}#800{%
          endif %}'</ha-icon> </div> <div style='display:inline-block'> <ha-icon
          icon='{% if is_state("switch.sonoff_1000b19f94_3", "on") %}mdi:water{%
          else %}mdi:water-off{% endif %}' style='color:{% if
          is_state("switch.sonoff_1000b19f94_3", "on") %}green{% else %}#800{%
          endif %}'</ha-icon> </div> <div style='display:inline-block'> <ha-icon
          icon='{% if is_state("switch.sonoff_1000b19f94_4", "on") %}mdi:water{%
          else %}mdi:water-off{% endif %}' style='color:{% if
          is_state("switch.sonoff_1000b19f94_4", "on") %}green{% else %}#800{%
          endif %}'</ha-icon> </div>
        hide_tabs: '0,6'
    - conditions:
        user_agent: X705L
      config:
        button_text:
          options: >-
            {{ hours24 }}:{{ minutesLZ }} <div style='display:inline-block;
            height:24px; width:24px; vertical-align:bottom;'><ha-icon
            icon='mdi:weather-{% if is_state("weather.gismeteo", "partlycloudy")
            -%}partly-cloudy{%- else -%}{{ states('weather.gismeteo')}}{%- endif
            %}'></ha-icon></div> {{ states('sensor.temperature_38')
            }}°                
        default_tab: FLOORPLAN
        header_text: >-
          <style>ha-icon {display:inline-block; float:left} #flipper
          {color:#999;} #flip {height:24px;overflow:hidden;} #flip > div > div
          {color:#99h;height:24px;margin-bottom:24px;display:inline-block;}
          #flip div:first-child {animation: show 10s linear infinite;}
          @keyframes show { 0% {margin-top:-144px;} 5% {margin-top:-96px;} 33%
          {margin-top:-96px;} 38% {margin-top:-48px;} 66% {margin-top:-48px;}
          76% {margin-top:0px;} 100% {margin-top:0px;}} #flipper p
          {position:fixed;color:#999; } </style> <div><ha-icon icon='{% if
          is_state("switch.sonoff_1000b19f94_2", "on") %}mdi:water{% else
          %}mdi:water-off{% endif %}' style='color:{% if
          is_state("switch.sonoff_1000b19f94_2", "on") %}green{% else %}#800{%
          endif %}'</ha-icon></div><div><ha-icon icon='{% if
          is_state("switch.sonoff_1000b19f94_3", "on") %}mdi:water{% else
          %}mdi:water-off{% endif %}' style='color:{% if
          is_state("switch.sonoff_1000b19f94_3", "on") %}green{% else %}#800{%
          endif %}'</ha-icon></div><div><ha-icon icon='{% if
          is_state("switch.sonoff_1000b19f94_4", "on") %}mdi:water{% else
          %}mdi:water-off{% endif %}' style='color:{% if
          is_state("switch.sonoff_1000b19f94_4", "on") %}green{% else %}#800{%
          endif %}'</ha-icon></div><div id=flipper><div id=flip><div> <div>
          {{states('counter.count_espresso')}} coffees
          today</div></div><div><div> Last 48h rain:
          {{float(states('sensor.total_48h_precipitation'))}}
          mm</div></div><div><div> Sonoff 2 was ON for {{
          float(states('sensor.sonoff_2_on')) * 60 }} minutes
          </div></div><div><div> {{states('counter.count_espresso')}} coffees
          today</div></div><div><div>        
        hide_tabs: '1,2'
  footer_mode: true
  menu_dropdown: true
  shadow: false
  split_mode: true
  tab_indicator_color: var(--state-icon-active-color)

These sound like 2 good feature requests.

Currently, CH doesn’t rebuild when screen orientation changes. So, while this would work, you would need to refresh when you change orientation or already have it in the desired orientation before opening.

user_agent isn’t setup to allow for multiple user agents per condition…yet

Again, these are two very helpful feature requests. I highly suggest adding them to Github so that I don’t forget to work on them on my next go around.

Give it time, I’m sure you’ll be able to find some more :rofl:

2 Likes

Added as requests in github @mayker! Thanks for your time!

1 Like

haha,
honored by your trust :vulcan_salute:

its been 3 hours now, still no issue in sight…

I’ve mentioned this in the feature request on Github, but in case anyone else is in a similar situation:

I was working on adding a feature for this when I remembered that it already exists. This is exactly the kind of thing the template condition was made for. To cut down on feature bloat, this should be used rather than adding another feature to accomidate.

  exceptions:
    - conditions:
        template: "{{ 'Windows' in userAgent or 'X705L' in userAgent }}"
      config:
2 Likes

It’s working as advertised! Thanks once again!

1 Like

v1.5.8

Added Features:

  • Config and header now update on device orientation change. Suggested by @nassost
  • tab_text_only: Display only text on tabs, no icons. Suggested by @LordShadowen
3 Likes

Can someone help me please?

I’ve split up my theme in a light version and a dark version.
I’ve made an automation so it auto changes…
The only problem i have is with my custom header.

When using dark theme, the text of the header (white) is fine
However, when using light theme, i dont see anything in my header lol

How do i fix this?
Heres my code.

custom_header:
  background: var(--primary-background-color);
  elements_color: var(--primary-text-color);
  active_tab_color: var(--state-icon-active-color);
  tab_indicator_color: var(--primary-text-color);
  compact_mode: true
  split_mode: true
  reverse_tab_direction: false
  reverse_button_direction: false
  options_hide: true
  shadow: false
  header_text: >-
    <style>
    #flipper {color:#999;}
    #flip {height:24px;overflow:hidden;}
    #flip > div > div {color:#fff;height:24px;margin-bottom:24px;display:inline-block;}
    #flip div:first-child {animation: show 10s linear infinite;}
    @keyframes show {
    0% {margin-top:-144px;}
    5% {margin-top:-96px;}
    33% {margin-top:-96px;}
    38% {margin-top:-48px;}
    66% {margin-top:-48px;}
    76% {margin-top:0px;}
    100% {margin-top:0px;}}
    #flipper p {position:fixed;color:#999; }
    </style>
    <div id=flipper><div id=flip><div><div>
    Huidige buitentemperatuur: {{states('sensor.temperature')}}°C</div></div><div><div>
    {{states('sensor.greeting')}}</div></div><div><div>
    {{states('sensor.afval')}}</div></div><div><div>