-
Notifications
You must be signed in to change notification settings - Fork 1
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
added continously automatic icon color updates for tile card #9
base: main
Are you sure you want to change the base?
Conversation
thanks for your contribution! let me chime in @elchininet, he's the technical brains behind our plugin. some thoughts: because: card_mod is only used when the actual entity is displayed in the frontend, and, custom-ui is evaluated upon each state change. Minimizing its processes to me seems of eminent priority. I tested this locally and indeed it updates the icon and icon background accordingly very nicely, and see no errors. let's wait and see what dev says. |
Hey, I‘ll check it when I get some time but @chillymattster, if you can make the changes in a gist, @Mariusthvdb will be able to test them. He has a set up with a lot of custom icon colors so he can spot an issue or an unwanted behaviour quickly. |
Hi, Let me briefly explain the rational I had in mind when proposing this change. I might be completely wrong with my understanding and if so, please apologize and I'm happy to adopt and learn more about the goals and principles of From a technical perspective I tried to understand how cards in home assistant work to copy the behaviour for icon colors. Therefore I followed the developer docs for custom cards. My current understanding is, that |
It's ok like this , testing as we speak . I see the tile cards being updated live. So that is progress What is still buggy is when you pull down to refresh (iOS app) Then they lose some colorization and we need to navigate to another dashboard and back again to see them updating again |
custom-icon-color.js
Outdated
const shadowRoot = this.shadowRoot; | ||
if (shadowRoot?.childNodes) { | ||
for (const node of shadowRoot.childNodes) { | ||
if (node.nodeName?.localeCompare('ha-card', 'en', { sensitivity: 'base' }) == 0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a specific reason to use localeCompare
to compare the strings? Is it faster?
If the reason is performance it would be good to instantiate a Int.Collator
somewhere and make the comparison using that instance.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @chillymattster,
I have compared the three. Using an Int.Collator
instance is almost 30 times faster than the localeCompare
method. But a strict equality keeps wining by far. As this code will be potentially executed recurrently it is good to keep performance as high as possible.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @elchininet
would this also be a result of the Mariusthvdb/custom-ui#122 that was done on the original custom-ui, exactly to prevent excessive updating ?
If yes, should that be reverted like you say with that strict equality
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Mariusthvdb,
No, not related. This is just about the regular strict equality
(or even the regular equality
) to compare two strings performs better than Int.Collator
or localeCompare
that is being introduced here. It is not about the number of updates but to the speed of those updates.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @elchininet,
I updated the PR following your suggestion 😄, see also my comment from Oct 20th.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is still buggy is when you pull down to refresh (iOS app)
Then they lose some colorization and we need to navigate to another dashboard and back again to see them updating again
Hi,
I used localCompare as I liked the idea of being case-insensitive in order to be a bit more independent of possible changes or inconsistencies in HA and therefore to increase stability. But it seems that it comes with high costs so I doubt that my decision was a good trade-of.
Unfortunately I won't be able to work on this or fix it as I don't own any iOS device. What I observe on Android is, that your describes behaviour occurs from time to time on Android as well. In such a case there is not just the color not working correct any more but also data updates in general are affected. My observation is that this happens when the connection to HA is flaky / unstable in general which leads to a general mess in the whole underlying routines to update the |
update for tile card. Signed-off-by: chillymattster <[email protected]>
Signed-off-by: chillymattster <[email protected]>
Signed-off-by: chillymattster <[email protected]>
Hi @Mariusthvdb, do you have any idea on how to proceed with the iOS problem you encountered? |
No I dont tbh, I didnt check this anymore awaiting your works on the PR. As for the generic implication of the PR: I am very worried this 'continuously automatic' aspect will cause a burden on the system. Given the way HA is moving, I did decide to no longer update custom-ui and its siblings (like this plugin), and follow HA dev advice to not burden the system with extra attributes that need constant evaluations. the way to go is with core Frontend options, and where they fall short, use card-mod (for as long that still works, because the author seems to have no interest in updating his resources anymore either). Aware this is not the same as what we do here (we set a true attribute icon_color and show it in all cards, including more-info etc etc). Unfortunately I feel it is the only way forward. Maybe @elchininet can share his thoughts on that. Anyways, first test your own PR in your own local instance so you are 100% sure it works and does not break the system (check inspector logs) |
Hi, Thanks @Mariusthvdb for sharing your thoughts about further development. I have to admit that I'm not really deep into HA development so this is new knowledge for me. I fully understand if you don't want to further develop custom-ui. |
ok, but is it any better than the current release. Not much use making these changes id there is no progress..
please see https://github.com/Mariusthvdb/custom-ui/blob/master/README.md#please-read-this-before-using-custom-ui |
What I understood he meant was, that the new changes work as well as his previous changes. Which is strictly better than the current release. Is there something else holding this back? |
yes, |
Hi @Mariusthvdb, |
Hi,
after creating issue #8 "Icon color of tile card only updated on page refresh" and catching up with the discussion #3 "add icon-color to Tile card" I spend some more time on how automatic update could be done for tile card without the need for page refresh or card_mod.
I found a way which I would like to present with this pull request.
Setting and modifiying icon_color attribute for entities with templates and showing those entities with tile cards for me results in exactly the same behaviour as the default behaviour if tile card with entities that change icon color on their own, e.g. lights.
I'm happy to take any comments and hope you like my contribution 😄