fix: use a proper config in renderState() (#1217)

This commit is contained in:
ildar170975
2025-04-29 23:14:03 +03:00
committed by GitHub
parent f930fa60df
commit c980460098

View File

@@ -259,12 +259,11 @@ class MiniGraphCard extends LitElement {
}
renderStates() {
const [firstEntityConfig] = this.config.entities;
if (this.config.show.state)
return html`
<div class="states flex" loc=${this.config.align_state}>
${this.renderState(firstEntityConfig, 0)}
<div class="states--secondary">${this.config.entities.map((entityConfig, i) => i > 0 && this.renderState(entityConfig, i) || '')}</div>
${this.renderState(0)}
<div class="states--secondary">${this.config.entities.map((entityConfig, i) => i > 0 && this.renderState(i) || '')}</div>
${this.config.align_icon === 'state' ? this.renderIcon() : ''}
</div>
`;
@@ -285,14 +284,16 @@ class MiniGraphCard extends LitElement {
}
}
renderState(entityConfig, id) {
renderState(id) {
const isPrimary = id === 0; // rendering main state element?
if (isPrimary || entityConfig.show_state) {
if (isPrimary || this.config.entities[id].show_state) {
const state = this.getEntityState(id);
// use tooltip data for main state element, if tooltip is active
const { entity: tooltipEntity, value: tooltipValue } = this.tooltip;
const value = isPrimary && tooltipEntity !== undefined ? tooltipValue : state;
const entity = isPrimary && tooltipEntity !== undefined ? tooltipEntity : id;
const isTooltip = isPrimary && tooltipEntity !== undefined;
const value = isTooltip ? tooltipValue : state;
const entity = isTooltip ? tooltipEntity : id;
const entityConfig = this.config.entities[entity];
return html`
<div
class="state ${!isPrimary && 'state--small'}"