Top of the page badges don't apply by-group templating
Hello,
if I use the by-group templating it will not apply for top of the page badges.
- It works if I remove the by-group templating part and just use templates
- The error only applies to top of the page badges
Checklist
- [x] I'm running the latest version of CustomUI (Update guide) or using a specific release that is not marked as "Broken".
- [x] I tried to force-refresh (Ctrl+Shift+R / Ctrl+F5) the browser
- [x] (Optional, but recommended) I'm using Chrome or tried to reproduce the feature on Chrome.
Browser + Version: Chrome 64
CustomUI version: 20180216
Home Assistant release (hass --version): 0.65.3
Problem-relevant configuration.yaml entries:
livingroom:
view: yes
name: Wohnzimmer
icon: mdi:television
entities:
- binary_sensor.livingroom_climate_windowshutter
binary_sensor.livingroom_climate_windowshutter:
icon: mdi:glassdoor
friendly_name: Wohnzimmerfenster
group:
group.livingroom:
templates:
theme: if (entities['binary_sensor.livingroom_climate_windowshutter'].state === 'on') return 'active';
friendly_name: if (entities['binary_sensor.livingroom_climate_windowshutter'].state === 'on') return 'Seit ' + (entities['sensor.livingroom_climate_windowshutter_openingtime'].state) + ' Minuten geöffnet'; else return 'Fenster';
state_card_mode: badges
I assume livingroom is under group and binary_sensor.livingroom_climate_windowshutter is under homeassistant and customize.
In any case tom-of-the-page badges don't support full customization. They support theming and templates, but not context-aware.
It is on the roadmap or just technically not possible to implement on the current HA frontend architecture?
It is possible to implement, but what is the usecase? Do you have the same sensor badge in several views and you want to show them differently?
since you ask, as a matter of fact i do have these yes. several top of the page badges i need there, but would love to show them in a group too, where they an show different attributes.
I had to make different sensors now (several in python) for them to behave like this:

Would be way convenient to be able to do that through customizing the same sensor context dependent.
Unless you want the top badges to look different depending on view - you can do that.
Template whatever you like for the top badges, and use context-aware for non-top.
In my use case I have in the livingroom group this sensor:
binary_sensor.livingroom_climate_windowshutter:
icon: mdi:glassdoor
friendly_name: Wohnzimmerfenster
group:
group.livingroom:
templates:
theme: if (entities['binary_sensor.livingroom_climate_windowshutter'].state === 'on') return 'active';
friendly_name: if (entities['binary_sensor.livingroom_climate_windowshutter'].state === 'on') return 'Seit ' + (entities['sensor.livingroom_climate_windowshutter_openingtime'].state) + ' Minuten geöffnet'; else return 'Fenster';
state_card_mode: badges
Which shows up just as "window" and changing the friendly_name if it's open and how long it is opened oon the livingroom group while on other groups like in the history view I want to have the global friendly_name "Livingroom window".
@tringler Does the friendly_name override work for you in the group.livingroom view?
I tried everything and I can't get my sensor to show as "temperature" on the badge in the "bathroom" group (view) but show as "temperature - bathroom" everywhere else.
It does work fine if the override references a group that is not the view (or perhaps the badge doesn't apply the override).
@andrey-git
I think I've tried everything, I just can't get it to work. Is there really no way to do context-aware friendly_name override for top-of-page badges? I even tried forcing a badge into a group, overriding its name which worked in that group. Setting that group to 'state_card_mode: badges' wouldn't make the entities from that group appear on top of page. Quite depressing, I think I need to open a new issue for that. It's preventing me from being able to implement history_graps because I just have 6 temperature entities and I don't want the sensor to show "Temperature - Bathroom" in the Bathroom view nor I want it shown as "Temperature" in a chart with 6 other sensors called "Temperature".