New CustomUI release

Thank you!

in the end what was your solution?

trying to change the badge color here based on home/away, or online/offline. Please share your code?

Thanks Marius

Exactly as @andrey originally suggested but changing the theme part to…

frontend:
  themes:
    home:
      label-badge-red: green

Ok thanks .
And which customization ?

ive customized three badges as follows:

homeassistant:
  customize:
    sensor.status_badge:
      templates:
        theme: if (state === '0') return 'home'; else return null;
    sensor.inuse_badge:
      templates:
        theme: if (state === '7') return 'home'; else return null;
    sensor.home_badge:
      templates:
        theme: if (state != '0') return 'home'; else return null;

with this in frontend_themes:

home:
  ha-label-badge-red: green

they wont turn green, so maybe the customizations is incorrect? I want them to meet the math =0 =7, or not=0…

26

Apart from anything else you’ve added an ‘ha-’ to the theme.

HI Andrey,

will this work for a sensor badge also? Im trying to implement it but it wont stick.

have this theme:

green_badge:
  ha-label-badge-red: green
  label-badge-red: green
  label-badge-background-color: white
  label-badge-text-color: green

and these sensors customizations:

homeassistant:
  customize:
    sensor.status_badge:
      templates:
        theme: "if (state === '0') return 'green_badge'; else return null;"
    sensor.inuse_badge:
      templates:
        theme: "if (state === '7') return 'green_badge'; else return null;"
    sensor.home_badge:
      templates:
        theme: "if (state !== '0') return 'green_badge'; else return null;"

badges will only show as:

29

maybe the math-expression is incorrect? im uncertain when to use === and == and != or maybe !== respectively. the numbers represent the real count of certain entities.

the sensor_badges are created in python:

    hass.states.set(entity_id, groups_count[idx], {
      'friendly_name': fname,
      'unit_of_measurement': badge, 
      'entity_picture': picture,
      'hidden': hidden,
      'order': order
    })

Thanks,
Marius

1 Like

I have been using CustomUI for awhile and love the features, thanks for your work.

I was rereading the docs and discovered a feature that I have been needing for the past year. I have set it up but it shows all entities that are on including automations.

Is there a way to limit the entities in the group.on_devices in the example?

Make a group that contains all on entities.
Note that the group itself must be preexisting, CustomUI can’t create a new group.

Note this doesn’t change group membership that the backend sees, so calling services on this group would only affect the original members.

homeassistant:
  customize:
    group.on_devices:
      templates:
        entity_id: return Object.keys(entities).filter(key => entities[key].state === 'on')

I don’t quite understand the question? You can make any template rule you like. For example to make a group of “on” entitites which end with “a”:

homeassistant:
  customize:
    group.on_devices:
      templates:
        entity_id: "return Object.keys(entities).filter(key => entities[key].state === 'on' && key.endsWith('a'))"
2 Likes

Got it, thanks. I have never seen or used Java script before but you pointed me in the right direction.

group.active:
  templates:
    entity_id: "return Object.keys(entities).filter(key => entities[key].state === 'on' != key.startsWith('auto'))"
1 Like

If you mean “and not” it would be ... && !(condition_here)

Also key is the entity_id, i.e. light.my_bedroom so it will never start with auto.

1 Like

For some reason my automation entities showed up but that filter worked.

automation.lock_door

it might be because of this

group.all_automations:
  hidden: false

that’s what Andrey suggested wasn’t it? still struggling here…

=== compare values of the same type.

If you use hass.states.set then maybe you are setting a numeric (and not string) value?
In that case compare "if (state === 0) ..."

yes numeric indeed. and the ‘is-not version’, is that (state !== 0) ? I need that too for one of the badges

Like I said,

ha-label-badge-color

couldn’t be overridden so changed it to…

label-badge-red

which works perfectly but you put…

ha-label-badge-red

a, i missed that.
still, im using this now:

green_badge:
  ha-label-badge-red: green
  label-badge-red: green
  label-badge-background-color: white
  label-badge-text-color: green

and when i select this theme as full frontend theme, it works perfectly.
09

Will take out the ha-label for sure, but i feel it has something to do with the template, or even more obscure, with HAssio not showing the correct result in the Frontend. There are several battery icon templates that calculate just fine (in the templating tool) but wont show in the frontend. Seems something is preventing that.

1 Like

@andrey since theming top-of-the-page badges is mentioned on your change log for version 0126, is there anything special we need to set for that? Cant seem to find any other reference to these
top-of-the-page badges .

I ask because the badges in my example are, so maybe they need special care?
moreover, this does work,

sensor.br_temperature:
  templates:
    theme: >
      if (entity.state < 0) return 'blue_badge'; else return 'green_badge';

54

which seems to imply it’s not the definition of the theme, nor the logic, but either the fact that the problem sensors are top of the page badges, or they are created in python?

Thanks,
Marius

@Bobby_Nobble
got it sorted, had to do with the fact that the badges i aimed at are created differently. We now customize them in the python script they are created in, if you’re interested, check:Summary card and badges for people, devices and status (with python script and custom card)

still would like to know the specific parts of the badges, to be able to customize them.
would love to be able to change the bottom (label) independently from the top (badge).

it must be possible to change the color of the text in the label and the label itself.
Names are a bit confusing here cause label-badge refers to both…

just cant find any documentation on the names of these elements on https://github.com/PolymerElements/
Cheers,
Marius

1 Like

If you do a right-click > Inspect on the element in Chrome, or however you do it in the browser of your choice, you can follow the code in the panel that opens and that should hopefully give some answers. That’s how I found what was actually controlling the colour of the badge I wanted to change rather than what seemed right at face value.

aha, good idea ! will try that.

its a bit silly one has to change the color of label-badge-red to green…

and these:

#source https://github.com/home-assistant/home-assistant-polymer/blob/master/src/resources/ha-style.html

 /* for label-badge */
    --label-badge-background-color: white;
    --label-badge-text-color: rgb(76, 76, 76);
    --label-badge-red: #DF4C1E;

    --label-badge-blue: #039be5;
    --label-badge-green: #0DA035;
    --label-badge-yellow: #f4b400;
    --label-badge-grey: var(--paper-grey-500);

not sure what they do, or which parts they refer to. Your tip might help, will report back if successful …

1 Like