This repository has been archived by the owner on Nov 4, 2023. It is now read-only.
fix: update history tile's start date on state change #581
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Proposed change 1
When a history tile is shown 24/7 on a dashboard, new entries get added, but the initial start date never moves forward.
As a result, data piles up, and the initial requested offset increases constantly. After days/weeks, huge amount of data stored in the dataset can cause issues on the client side.
This small change will constantly update the start date and delete any data that is older than (NOW - OFFSET).
Shown time frame will constantly be moving forward.
Proposed change 2
In some particular cases, especially when entity states get updated rarely (only a few times a day, or even week), the history tile will no longer show any value after a while. (=> moving time window).
Hassio itself has this issue and a workaround is described here: https://community.home-assistant.io/t/add-force-update-support-to-template-sensor/106901
The workaround consists in updating any entity attribute value. This will cause the entity's last_updated value to be updated.
On the history tile, this is easily fixed by adding entity's last_updated value to the watcher.
Watcher will add new data, when state or last_updated changes...