lozzd / octopus-energy-rates-card

This lovelace card for Home Assistant displays the Octopus Energy rate prices per each 30 minute slot
MIT License
60 stars 22 forks source link

Feature Request: Make more lightweight as causing wall panel tablet to lag #59

Closed prestonsmartuk closed 3 months ago

prestonsmartuk commented 5 months ago

Love this card. However on my Lenovo Tab K10 wall panel tablet using Fully Kiosk, this card (only this card) causes the tablet to really lag when in use. As soon as I remove this card from the UI, the tablet goes back to normal operation.

This might be a silly request, but as I've narrowed it down to this card being he culprit - would be great to see to see if this card could use less resources?

alinbalutoiu commented 5 months ago

This got me a bit more curious about how it works, and it seems that Home Assistant will call the update method quite often:

Home Assistant will set the hass property when the state of Home Assistant changes (frequent). Whenever the state changes, the component will have to update itself to represent the latest state.

In my case, that seems to be a few times per second. Obviously this card is pretty static and doesn't change much. It could use some optimisations to skip doing any work if nothing relevant has changed in the state.

lozzd commented 5 months ago

Huh, nice digging. I had no clue where to start here but did some profiling (aka clicking around) in the Chrome dev tools and 90% of the CPU time was spent in the calls to convert the time to the user's locale. But that's only going to be a big deal if it's being called a few times a second.. that's definitely unnecessary!

alinbalutoiu commented 4 months ago

@prestonsmartuk I would be curious if you can test with https://github.com/lozzd/octopus-energy-rates-card/pull/71 Wondering if that helps with making your tablet less laggy.

lozzd commented 3 months ago

This is now live in HACS as version 0.7.0