artem-sedykh / mini-humidifier

Minimalistic humidifier card for Home Assistant Lovelace UI
MIT License
155 stars 26 forks source link

Icons not shown on entities card #89

Closed Anonym-tsk closed 2 years ago

Anonym-tsk commented 2 years ago

My configuration:

type: entities
entities:
  - type: custom:mini-humidifier
    entity: fan.mi_humidifier
    model: xiaomi_miio_airpurifier:deerma.humidifier.mjjsq
    name: Увлажнитель в спальне
    group: true
  - type: custom:mini-humidifier
    entity: fan.mi_humidifier_kids
    model: xiaomi_miio_airpurifier:deerma.humidifier.mjjsq
    name: Увлажнитель в детской
    group: true
  - type: custom:mini-humidifier
    entity: fan.mi_humidifier_old
    model: xiaomi_miio_airpurifier:deerma.humidifier.mjjsq
    name: Увлажнитель старый
    icon: mdi:air-purifier
    group: true

There are no icons:

image

But (!!!) if i add card with one humidifier:

type: custom:mini-humidifier
entity: fan.mi_humidifier
model: xiaomi_miio_airpurifier:deerma.humidifier.mjjsq

It fixes all humidifiers on all cards:

image

regevbr commented 2 years ago

I can't reproduce it locally.... are you using the latest version of this component and home assistant?

Anonym-tsk commented 2 years ago

I use component from master and latest HA.

regevbr commented 2 years ago

I see, sadly it doesn't happen to me so I can't fix what i can't see

Anonym-tsk commented 2 years ago

I ran HA locally and reprodiced problem

image

Just create new lovelace card with content

type: entities
entities:
  - type: custom:mini-humidifier
    entity: fan.mi_humidifier_kids
    model: xiaomi_miio_airpurifier:deerma.humidifier.mjjsq
    name: Увлажнитель в детской
    icon: mdi:air-purifier
    group: true
regevbr commented 2 years ago

sorry, as I said, for me it doesn't happen... If you know how to debug and fix, a PR will be more than welcome image image

Anonym-tsk commented 2 years ago

Save lovelace and refresh the page

regevbr commented 2 years ago

already did, still no issue appears...

Anonym-tsk commented 2 years ago

I don't know why do you need @lit-labs/scoped-registry-mixin and extends ScopedRegistryHost, but without it all works well. I think that problem in globalElementLoader, because it register modules asynchronously and after card render.

class MiniHumidifier extends LitElement

regevbr commented 2 years ago

This behavior is relatively new and it is required by the guidelines of HA as they urge developers to not pollute/rely on the global scope of registered elements. please refer to #80. There isn't supposed to be an issue with the module being registered asynchronously. If there was, all of your cards would not have worked, but according to you, they do. If you remove what you removed, it might work now, but can be broken at any moment without any prior notice from HA. Can you pinpoint to something more specific that causes the issue?

Anonym-tsk commented 2 years ago

So... If i skip first 1-2 render calls, then all works.

image

I think it's because first render called before globalElementLoader('ha-icon') resolved.