Skip to content
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

Merged
merged 4 commits into from
Jan 31, 2021

Conversation

airthusiast
Copy link
Contributor

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...

scripts/controllers/main.js Outdated Show resolved Hide resolved
scripts/controllers/main.js Outdated Show resolved Hide resolved
@airthusiast airthusiast force-pushed the feature/history-tile-improvements branch from bafdd7d to 47840b0 Compare January 31, 2021 14:56
Copy link
Collaborator

@rchl rchl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Thanks!

@rchl rchl changed the title Feature/history tile improvements fix: update history tile's start date on state change Jan 31, 2021
@rchl rchl merged commit af1d878 into resoai:master Jan 31, 2021
@airthusiast airthusiast deleted the feature/history-tile-improvements branch January 31, 2021 21:13
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants