home-assistant-custom-ui icon indicating copy to clipboard operation
home-assistant-custom-ui copied to clipboard

Top of the page badges don't apply by-group templating

Open tringler opened this issue 7 years ago • 7 comments

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

tringler avatar Mar 12 '18 23:03 tringler

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.

andrey-git avatar Mar 16 '18 19:03 andrey-git

It is on the roadmap or just technically not possible to implement on the current HA frontend architecture?

tringler avatar Mar 18 '18 21:03 tringler

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?

andrey-git avatar Mar 19 '18 05:03 andrey-git

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:

schermafbeelding 2018-03-19 om 08 40 24 schermafbeelding 2018-03-19 om 08 40 34 schermafbeelding 2018-03-19 om 08 40 45

Would be way convenient to be able to do that through customizing the same sensor context dependent.

Mariusthvdb avatar Mar 19 '18 07:03 Mariusthvdb

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.

andrey-git avatar Mar 19 '18 11:03 andrey-git

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 avatar Mar 20 '18 11:03 tringler

@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".

mateuszdrab avatar Apr 14 '18 19:04 mateuszdrab