Custom Header

Hey Ryan,

didn’t really notice the test_template functionality before, but this is a marvelous tool! So much, I would like to ask if you couldn’t create a small dedicated card for that, so we can test our templates outside of the inspector.

I ask, because I’ve been struggling with these newlines mostly in my messaging and notification templates, which can be a real pain to format, when using templates and passing variables. The template editor isn’t really of much use in that case, because it doesn’t show the newlines like your test_template does.

Having a dedicated card for the frontend would be a real treat indeed, so hope you would consider…

edit

now that I asked for a special card above, I’d love to add the same request for the marquee. There has been only 1 marquee card, and that is now deprecated. Seeing how the Custom header allows for both a vertical and horizontal marquee, my hopes are up this could be achieved in a dedicated card also… Would you consider creating that, based on what now is done in CH #fingerscrossed

thanks!

update this snapped in today: Finally made my first marquee (on a custom: button-card) which suffices for now in the marquee.

Please, read the first post in this thread. It links to the issues section of the docs that explains what info I would need to help you.

I’m mostly interested in errors either in HA logs or the browsers dev console, but anything more than the fact that it isn’t working is helpful.

have a related issue:

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

won’t show me tab 28. 0 to 21 and 26 show fine. Doesn’t mater if I use

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

also, the else clause kicks in as the template prescribes, showing all tabs

leaving that out:

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

makes no difference in behavior (though I still don’t like if’s without else’s…)
maybe you could introduce ‘all’ and ‘none’ so we can use that in the templates?

edit

after some further experimenting even reverting to my original 0 to 21, 26 didn’t work any longer… tested it in the test_template (great tool!) and found it returned Custom Header test returned: "0 to 21, 26 "

darned whitespace…

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

does the trick again!

Have you tried that in the test_template:?

sorry, crossposted… yes! see above.

1 Like

Yup you beat me to it. Also, your else statement has a space before it resulting in " 0 to 28". This wouldn’t be a problem with something like hide tabs as I strip spaces in that case, but in other options it might.

I don’t think I’d introduce something like this as it’s already handled by not using an else statement, but I did see your mention of this behavior not working with header text and am looking into it.

Edit: Actually thinking of it a bit more, something like ‘all’ and ‘none’ might be helpful even outside of templates. That way the behavior would stay the same even when you add or remove views. I’ll add it to the growing list :slight_smile:

it is still a mystery sometimes why things work or don’t work.

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

has this as output:

and works just fine…in both cases of the template

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

or is the >- taking care of the white spaces even the test_template shows?

The white space in this case with " 0 to 28 " as mentioned above is actually handled by Custom Header. With hide tabs and show tabs it is necessary for me to strip the white space, so CH just sees “0to28” the problem was when you didn’t use >- and just used >. In that case it was rendering as "0 to 21, 26, 28 n" the “n” being the new line that wasn’t stripped.

Other options won’t handle that white space as well.

1 Like

Pre-Release 1.1.9

This one is marked as a pre-release since I’ve now got babel converting everything (need to “show beta” in HACS to install). I have tested to the best of my ability, but this has the potential to cause some issues. If you’re having issues then report the issue and downgrade if necessary.

  • Use Babel to hopefully support some of the less common browsers
  • Fix button text justification
  • Fix for view names containing the letters “to” being detected as a range
  • Fix for boolean reporting in test_template:
  • Fix for notification dot color
  • Fix for cards overlapping in split mode and footer mode

I’ve got a (hopefully easy) question about using multiple templates in the “show_tabs” & “hide_tabs” options.

right now I’ve got a hide_tabs set up that hides only one tab dependent on the state of a switch:

hide_tabs: '{% if states.switch.debug_view.state == "off" %}Debug{% endif %}'

I just added some tabs that I only want to show to a specific user (I think I can get that part working) but I want to also hide it from my own frontend views unless I turn on another switch.

how would I format the hide_tabs: above to add the second template to only show the views if the switch is on.

can I do this:

hide_tabs: 
  - '{% if states.switch.debug_view.state == "off" %}Debug{% endif %}'
  - '{% if states.switch.other_switch.state == "off" %}other tabs{% endif %}'

it definitely doesn’t look right.

Or do I have to template the whole thing out in one big template using if/else, and/or?

Might something like this work?

hide_tabs: >-
  {{ 'Debug' if states.switch.debug_view.state == "off" else '' }}
  {{ 'other tabs' if states.switch.other_switch.state == "off" else '' }}

Edit: realised you’d probably also need another test in between those two to add a comma if both switches are off

1 Like

Yeah, I was just testing it before your last edit and realized the same thing. But it ended up being even easier than that.

It looks like having the commas+spaces at the end of the list is still OK.

Here’s what I came up with that worked:

hide_tabs: >-
    {{ 'Debug, ' if states.switch.debug_view.state == "off" else '' }}{{ 'view_1, view_2, view_3' if states.input_boolean.show_kids_views.state == "off" else '' }}

If in future you want more granular control (e.g more switches for individual views) something like this would also work and would probably be easier to maintain (it basically builds up a list of the tabs to hide and then joins the list using commas):

hide_tabs: >-
  {%- set tabs = [] -%}
  {%- if states.switch.debug_view.state == "off" -%}{%- set tabs = tabs + ['Debug'] -%}{%- endif -%}
  {%- if states.switch.other_switch.state == "off" -%}{%- set tabs = tabs + ['other tabs'] -%}{%- endif -%}
  {{ tabs | join(',') }}
2 Likes

Thanks, I’ll keep that handy for later.

Quick question. Regarding the User Agent entry. Is there a way that you could just declare any/all windows devices? Instead of having to declare something like “Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:72.0) Gecko/20100101 Firefox/72.0” just for Firefox alone? Because since I just updated Firefox, it went from 71.0 to 72.0, and I had to update all exceptions I had made. If possible, I’d rather future proof it and have just “if windows”. Because I have a different Home Screen for my family members and I, based on whether you’re on the computer, or on a phone.

Thank you in advanced, for whoever helps answer this question.

user_agent: A matching word or phrase from the devices user agent.”

So, user_agent: Windows will probably be what you’re looking for.

Now I just feel like an idiot. I had no idea it could just be any matching word/phrase from the giant string. Thanks!

Good day! Help the newcomer! Installed a compact header from the repository via HACKS But apparently touched some switch in the settings and I lost the top menu completely. And I can not change the settings, and reinstalling or resetting the cache does not help! How else can I return the plugin to the custom state?!

hh|690x359

It’s all in the docs.
https://maykar.github.io/custom-header/#intro/notes

1 Like

You most likely turned on kiosk mode. Follow the link from @VDRainer above to see how to temporarily restore the default header. Then you’ll be able to turn it off via Custom Header’s settings or by removing the option from “raw config editor”.

The editor warns you of any option that will remove your ability to edit the UI. While in the editor, be sure to read the warnings at the very top, look out for options with the warning icon, and read the important notes on the docs page.