Mariusthvdb/custom-ui

Icon color not working in 2023.1

Closed this issue · 24 comments

Used my prev config from Ver 2022.x and works fine. Upgraded to 2023.1 and no icons are no longer colored.
Attribut logic still works but not working.

Please add some context...

Config, yaml, templates and screenshot of a failing entity in dev tools

Latest version:
image

Customization:

homeassistant:
  customize_glob:

    input_number.test_level_3:
      templates:
        icon_color: >-
          return 'magenta';

    input_number.test_level_4:
      templates:
        friendly_name: >-
          return 'custom_name';

Card:

  - type: entities
    entities:
      - entity: input_number.test_level_3
      - entity: input_number.test_level_4

image

Dev tools:
image
image

just for some perspective, nothing has changed on this side in any of my customizations:

Scherm­afbeelding 2023-01-10 om 14 36 50

Scherm­afbeelding 2023-01-10 om 14 37 00

all colorizations and more-info manipulation is as expected, running
Home Assistant 2023.1.2
Supervisor 2022.12.1
Operating System 9.4
Frontend-versie: 20230104.0 - latest

and my latest experimental GPT version,

Scherm­afbeelding 2023-01-10 om 14 47 03

but certainly also with the latest release:

Scherm­afbeelding 2023-01-10 om 14 40 41

can ya'll confirm the resource is correctly loaded (check inspector)?

btw, the glob customizations are hardly templates, but certainly no globs, so they should at least be listed under
customize: and Not under customize_glob:

just set the color to:

homeassistant:
  customize:

    input_number.test_level_3:
      icon_color: magenta

the friendly name is totally out of perspective, as it does not contain any template, and can be set directly in HA without custom-ui....

but certainly no globs, so they should at least be listed under
customize: and Not under customize_glob:

This code was simplified to:

homeassistant:
  customize_glob:

    input_number.test_level_3:
      templates:
        icon_color: >-
          return 'magenta';

from smth more complex:

homeassistant:
  customize_glob:
    input_number.test_level_2:      ###TODO_CUSTOM_UI
      templates:
        icon_color: >-
          if (state <= 10) return 'yellow';
          else
          if (state <= 20) return 'brown';
          else
          if (state <= 30) return 'magenta';
          else
          if (state <= 40) return 'lightblue';
          else
          if (state <= 50) return 'green';
          else
          if (state <= 60) return 'orange';
          else
          if (state <= 70) return 'purple';
          else
          if (state <= 80) return 'red';
          else
          if (state <= 90) return 'gold';
          else
          return 'cyan';

which does not work too.

the friendly name is totally out of perspective, as it does not contain any template, and can be set directly in HA without custom-ui....

Same is about friendly_name, it was this:

homeassistant:
  customize_glob:
    sensor.testing_device_class_*:
      templates:
        friendly_name: >-
          if (entity)
          {
            var HEADER = 'testing_device_class_';
            var NAME = entity.entity_id.split('.')[1].split(HEADER)[1].replaceAll("_"," ");
            return NAME;
          }
          else return null;

Both complex examples worked fine some time ago.

can ya'll confirm the resource is correctly loaded (check inspector)?

Strange, cannot find Custom UI in Code Inspector.
Gonna reinstall Custom UI, did it by HACS.

well, the first still is no glob, so move that to customize: and please report what happens.

as for the second, why make testing so difficult. currently its hard to see if its a javascript issue, or a custom-ui issue.

Strange, cannot find Custom UI in Code Inspector.

that would be the root cause I suspect. always check that first. without it, it just indicates the resource isnt loaded at all

as for the second, why make testing so difficult

What do you mean?
Do you mean this this code is wrong?

homeassistant:
  customize_glob:
    sensor.testing_device_class_xxxxxx:
      templates:
        friendly_name: >-
          return ...;

and it MUST BE

homeassistant:
  customize:

?

no, please read carefully. I wrote the first (input_number.test_level_2:) needs to be under customize: because it is not a glob.

the second is just a test template, but so complex you are not sure whether it is your javascript code, or the custom-ui.

but for you I just tested this

homeassistant:

  customize_glob:
    '*.test*':
      templates:
        templated_attribute: >
          return entity.entity_id.split('.')[1] + ' templated';


        friendly_name: >
          var splitfname = entity.entity_id.split('test')[1];
          var fname = 'Friendly name changed to: ' + splitfname;
          return fname;

and it works perfectly on all entities:

Scherm­afbeelding 2023-01-10 om 15 12 31

as do templates like this:

homeassistant:

  customize:

    person.marijn: &picture
      hide_attributes:
        - templates
      templates:
        entity_picture: >
          var id = entity.entity_id.split('.')[1];
          var sensor = 'sensor.' + id + '_picture';
          if (entities[sensor]) return entities[sensor].state;
          return '/local/family/' + id + '_not_home.png';
        country: >
          var id = entity.entity_id.split('.')[1];
          var sensor= 'sensor.' + id + '_geocoded_location';
          if (entities[sensor]) return entities[sensor].attributes.Country;
          return 'Searching...'

so, on this side, there is not a single issue on the templates or customizations. icon_color also working as ever.
Since you can not see the resource in the inspector panel, that would be the main cause, and you need to fix that first.

please confirm the correct loading of the resource (check inspector) so we can close this.

needs to be under customize: because it is not a glob.

This is exactly what I asked you here.
I believed that both ways - "customize_glob: apply to sensor.test_*" or "customize_glob: apply to sensor.test_xxxx" - should return SAME result. In other systems it usually works this way.

the second is just a test template, but so complex you are not sure whether it is your javascript code, or the custom-ui.

The JS code is absolutely correct.
But anyway I first replaced it with simple "return 'xxxx'" to be sure.

please confirm the correct loading of the resource (check inspector)

Cannot confirm, not loaded according to Code Inspector after redownloading Custom UI by HACS and rebooting HA.

you may believe what you want of course, but as a user of custom-ui since its inception, (and a maintainer of this resource since the archival of the original custom-ui) it has been common practice to add glob customizations to the customize_glob: section, and entity customizations to customize:.

it causes trouble not doing so. I won't comment on that any further.

The JS code is absolutely correct.

sure, I take your word for it, but it doesnt matter, because:

not loaded according to Code Inspector

there's not much I can say or do there other than show what I have (using yaml mode):

# https://github.com/Mariusthvdb/custom-ui
- url: /local/resources/custom-ui/custom-ui-gpt.js?v=20230102-entity_id
# - url: /hacsfiles/custom-ui/custom-ui.js
  type: module

as you can see I simply flip between those 2 when testing and reloading. no restarts required at all, let alone reboot. A mere reload resources suffices, never fails

A mere reload resources suffices, never fails

Nice, but updating Custom UI by HACS currently does not make Custom UI to load properly.
Are there any other steps to make your plugin to load properly?
Like renaming files? Editing resources? Anything else not mentioned in docs?

it has been common practice to add glob customizations to the customize_glob: section, and entity customizations to customize:.

Well, when your plugin WAS LOADED properly I successfully used "customize_glob" for one entity too.

not sure.
did HACS update/change anything lately?
maybe delete it from HACS and redownload?

as you can see I use the HACS resource too, and have no issue there. Any other issues with HACS?

I'll close this, as it is not an icon_color issue at all, if anything custom-ui, it is a HACS resource matter.

Ill have a check at HACS, please do so too, and maybe meet at HACS discord to see what gives.
thanks for your investigations, appreciated.
cheers

Note that this issue was created not by me - it was created by another person.
And you closed this issue.

correct.

This behaviour is inappropriate.

Ok, so Ill give you the chance to delete that post, since it must be a mistake.
I'll check back later, so I can moderate this repo if necessary.

Meanwhile, let me suggest once more to fix your issue, before anything else.

do what you wish )

once more to fix your issue

and where is your suggestion?) Fix what exactly?

Seems you do not understand.
People are using your work.
When they face a problem - you should HELP them instead of accusing them w/o explaing what they are doing wrong.
This is the 2nd time you deleted my issue in this Repo.
It will never happen again.

never deleted anything, I closed. No accusing going on.
Since you wont help yourself, I can not either.

Please calm down.

Nonsense, there is nothing you suggested here to "help yourself" ))
The only thing you said "could be a HACS issue" - and closed this issue.
Surely it COULD BE a HACS issue - but this is not a reason to simply close this issue before knowing it for sure.
Closed, deleted - same output.

Lets focus,

I reloaded the HACS plugin but its still not working.
Screenshot 2023-01-10 at 16 20 25

All icons with the same customising file worked in 2022.x version.

The other icons are coloured using the card-mod for test. It works.

I reloaded the HACS plugin but its still not working.

Same question as above: Can you confirm it is loaded in inspector?

The other icons are coloured using the card-mod for test. It works.

That is of no consequence for this issue, since it has a completely different technique of colorizing and does not set the attribute.

Can you please detail out what you want me to check? The plugin states as loaded in HACS. Where do I find inspector? Im running a docker install

right click in most browsers to open the inspector, and select Console. all currently loaded custom resources are listed, see the screenshots of the 2 versions I posted in #86 (comment)

as per documentation in https://github.com/Mariusthvdb/custom-ui/blob/master/INSTALLING.md

Failed to load resource: the server responded with a status of 404 (Not Found)

Deleted the plugin and reinstall, did not help.

http://x.x.x.x:8123/hacsfiles/custom-ui/custom-ui.js?hacstag=26755814820230106 net::ERR_ABORTED 404 (Not Found)