Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

State dependant icons (motion, door / window sensors) replaced with mdi:bookmark #330

Closed
tomtom13 opened this issue Feb 8, 2024 · 22 comments · Fixed by #331
Closed

State dependant icons (motion, door / window sensors) replaced with mdi:bookmark #330

tomtom13 opened this issue Feb 8, 2024 · 22 comments · Fixed by #331
Labels
bug Something isn't working

Comments

@tomtom13
Copy link

tomtom13 commented Feb 8, 2024

Hi, after most recent update to HASS, the icons for stuff that has icon dependant of it's state (motion sensors / window & door sensors) stoped showing appropriate icons and shows mdi:bookmark. Saying that the state colour works.

Current system info:
Core 2024.2.0
Supervisor 2024.01.1
Operating System 11.5
Frontend 20240207.0

@noharminthat
Copy link

noharminthat commented Feb 8, 2024

I have the same issue with cover entities. The issue started occurring for me immediately upon upgrading to Core 2024.2.0.

Core 2024.2.0
Supervisor 2024.01.1
Operating System 11.4
Frontend 20240207.0

@QRPp
Copy link

QRPp commented Feb 8, 2024

Same (or similar) here. Started once updated to HA 2024.2.0 from 2024.1.6. Same with HA 2024.2.1 also.

In more detail as per what I observe:

  • The problem doesn't apply to entities with icons overridden either in their per-entity HA configuration or their per-entity multiple-entity-row configuration (then correctly shown).
  • The problem doesn't apply to primary entities of any multiple-entity-row, affecting only their listed entities, i.e., entities: [{ entity: sensor.foo; icon: true; }]. Wrong icons are shown for the latter even when the same entity is also the primary entity of same row, i.e., the icon is correct at the start of the row but wrong later on the same row.
  • The problem seems to apply regardless of whether the icon of an entity is or is not state-dependent: e.g., all my temperature and humidity sensors listed via multiple-entity-row (bar the above exceptions) currently show up as mdi:eye at the moment, same as all my switches and binary sensors there (ditto) show up as mdi:bookmark.
  • The icon wrongly shown is the one of the domain of the entity (e.g., mdi:eye for sensors) or mdi:bookmark for domains with no icon. What appears somehow ignored is the icon that depends on the device class of the entity.

Core: 2024.2.0 (later 2024.2.1)
Supervisor: 2024.01.1
Frontend: 20240207.0 (later 20240207.1)

@tankdeer
Copy link

tankdeer commented Feb 9, 2024

Adding a little more context plus a visual to what others have observed.

image

Here you can see a mix and match of icons that show properly, and ones that don't. I hadn't fully figured out the pattern until the previous post. To add to what was mentioned before, with the exception of the window, all of the correctly showing icons in my case are template sensors. The icon changes based on state. The window is a normal Z-wave contact sensor set to show as window

@sulimoff
Copy link

sulimoff commented Feb 9, 2024

Confirm, leakage sensors also began to appear as bookmarks
Screenshot_20240209-181010

@aredon
Copy link

aredon commented Feb 9, 2024

Very similar issue with battery status icons. They have been replaced with mdi:eye.

image

@bratanon
Copy link
Contributor

bratanon commented Feb 9, 2024

A PR is submitted #331

@tomtom13
Copy link
Author

tomtom13 commented Feb 9, 2024

Very similar issue with battery status icons. They have been replaced with mdi:eye.

image

TBH, this proves that somebody is always watching :D

@zhenyatk
Copy link

Some problem :(

@jeremysherriff
Copy link

Is there a way to test this while waiting for the PR to be merged? I can't find the patched file (index.js) in my local filesystem

@ildar170975
Copy link

ildar170975 commented Feb 10, 2024

Tested it locally (made changes in an obfuscated js file by myself) with no success.
Do not think the added ".hass=${this._hass}" line helps, the changed ha-state-icon object seems to be needed here.
But ofc we should wait for a feedback from the author of the PR.

@jeremysherriff
Copy link

@ildar170975 I saw your comment on the PR. Where/how did you access the obfuscated file?

@ildar170975
Copy link

@jeremysherriff
The obfuscated file is located in /config/www/community/lovelace-multiple-.... folder.
What I did was:

  1. Remove gz-file.
  2. Open js file in a text editor.
  3. Find the place where this ".hass=${this._hass}" line should be added. Add the line (similarly like already present lines).
  4. Save, clear cache, refresh a page.

Have to do this "brute" update since did not have the generated updated js-file.
But later after reading Dev blog started to doubt about a correctness of added change.

@QRPp
Copy link

QRPp commented Feb 10, 2024

Tested it locally (made changes in an obfuscated js file by myself) with no success. Do not think the added ".hass=${this._hass}" line helps, the changed ha-state-icon object seems to be needed here. But ofc we should wait for a feedback from the author of the PR.

I've also tested the proposed fix locally by overriding the code directly using Chrome dev tools, and it surely fixes the problem as it should. The ha-state-icon component is already in use, just not directly but wrapped via state-badge, so to speak. Responded to the PR comment too.

How to:

  • Load a HA panel that uses multiple-entity-row in Google Chrome, open dev tools.
  • On the Sources tab, search for renderIcon to find the snippet:
key: "renderIcon",
value: function(t, e) {
    return H(ye || (ye = we(['<state-badge\n [...]
  • Start a local override, to which, in front of .overrideIcon="', '"\n, insert .hass="', '"\n and, further along the same line, change t, to t, this._hass,. Be careful with all those commas and quote marks etc, the code editor wants to “help”, which here may be counter-productive.
  • Save, reload and enjoy.

I hope this helps!

@ildar170975
Copy link

ildar170975 commented Feb 10, 2024

  • in front of .overrideIcon="', '"\n, insert .hass="', '"\n and, further along the same line, change t, to t, this._hass,.

Very tricky.
What I did was just adding this line:
image
which seems to be wrong.
In fact, all these is a waste since we cannot get an updated js ))))

Oh, bingo:
image
Seems to be fixed )))))

@jeremysherriff
Copy link

Order is important, as this is messing with concatenation of text strings within a function.
Adding a text version for easier copy/paste, and pointers to the location of the edits.
I actually edited the file in the HA filesystem, but forcing the browser to flush the original file from cache was harder than it should have been, so I recommend using the local override file as described above.

Relevant part of original line:

<state-badge\n            class="icon-small"\n            .stateObj="','"\n            .overrideIcon="','"\n            .stateColor="','"\n        ></state-badge>'])),t,!0===e.icon

Alter to:

<state-badge\n            class="icon-small"\n            .stateObj="','"\n            .hass="','"\n            .overrideIcon="','"\n            .stateColor="','"\n        ></state-badge>'])),t,this._hass,!0===e.icon
---------------------------------------------------------------------------------------^^^^^^^^^^^^^---------------------------------------------------------------------------------------------^^^^^^^^^^^

If you do use a local override file, you'll need to remember to remove that override once the update has been released.

@tomtom13
Copy link
Author

I think I might be not the only person wondering,
BUT
assuming that this PR would be berged this very instant - how quickly we would be blessed with a release that includes it ?

@kineticscreen
Copy link

Not seeing any activity from @benct since December...

@tomtom13
Copy link
Author

So ... is that repo dead ? Should we fork it ?

@benct
Copy link
Owner

benct commented Feb 21, 2024

I'll merge the PR and try to get a new version released as soon as possible.

@benct benct added the bug Something isn't working label Feb 21, 2024
@tomtom13
Copy link
Author

heeeeeeyyyy ! lost person found ! thanks a lot bud !

@benct
Copy link
Owner

benct commented Feb 22, 2024

Should be fixed with version 4.5.1.

@tomtom13
Copy link
Author

FYI - works like a charm ! Thanks again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.