Skip to content
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import {
getFirstDefinedItem,
compareArray,
log,
isPre2025_5,
} from './utils';

class MiniGraphCard extends LitElement {
Expand Down Expand Up @@ -332,6 +333,9 @@ class MiniGraphCard extends LitElement {
&& this.config.entities[index].show_graph !== false,
))
|| this.config.show.loading_indicator === false;
const loadingElement = isPre2025_5(this._hass)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I'm wondering if we really need to make this distinction. Couldn't we just put both tags in the card. Only one will be shown, because the other is not defined?

Or we wait another month and only insert the new spinner?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Couldn't we just put both tags in the card. Only one will be shown, because the other is not defined?

Seems that currently only one spinner (the latest one) is available in HA. So, see no need to wait a month.

? html`<ha-circular-progress indeterminate></ha-circular-progress>`
: html`<ha-spinner aria-label="Loading" size="small"></ha-spinner>`;
return this.config.show.graph ? html`
<div class="graph">
${ready ? html`
Expand All @@ -343,9 +347,7 @@ class MiniGraphCard extends LitElement {
</div>
</div>
${this.renderLegend()}
` : html`
<ha-circular-progress indeterminate></ha-circular-progress>
`}
` : loadingElement}
</div>` : '';
}

Expand Down
5 changes: 4 additions & 1 deletion src/style.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,10 @@ const style = css`
cursor: pointer;
}
ha-circular-progress {
margin: auto;
margin: auto; /*pre 2025.5*/
}
ha-spinner {
margin: 4px auto;
}
.flex {
display: flex;
Expand Down
5 changes: 5 additions & 0 deletions src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,13 @@ const log = (message) => {
console.warn('mini-graph-card: ', message);
};

const isPre2025_5 = hass => hass

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This will be false for things like 2024.6. If we really want to handle versions differently, we should maybe make this more generic to compare arbitrary versions, like isVersionBefore('2025.4.1', '2025.5')?

But it will be complicated and we'll be starting to support old versions. Considering this, I think, we should take the decision to just support the most recent version. At least actively.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

You are right, the whole function must be revised.
(if we decide to support older versions)

&& Number(hass.config.version.split('.')[0]) <= 2025
&& Number(hass.config.version.split('.')[1]) < 5;

export {
getMin, getAvg, getMax, getTime, getMilli, compress, decompress, log,
getFirstDefinedItem,
compareArray,
isPre2025_5,
};