Skip to content
Merged
Changes from all 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
15 changes: 9 additions & 6 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -286,21 +286,24 @@ class MiniGraphCard extends LitElement {
}

renderState(entityConfig, id) {
const isPrimary = id === 0;
const isPrimary = id === 0; // rendering main state element?
if (isPrimary || entityConfig.show_state) {
const { entity, value: tooltipValue } = this.tooltip;
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;
return html`
<div
class="state ${!isPrimary && 'state--small'}"
@click=${e => this.handlePopup(e, this.entity[id])}
style=${entityConfig.state_adaptive_color ? `color: ${this.computeColor(state, id)};` : ''}>
${entityConfig.show_indicator ? this.renderIndicator(state, id) : ''}
style=${entityConfig.state_adaptive_color ? `color: ${this.computeColor(value, entity)}` : ''}>
${entityConfig.show_indicator ? this.renderIndicator(value, entity) : ''}
<span class="state__value ellipsis">
${this.computeState((isPrimary && tooltipValue !== undefined) ? tooltipValue : state)}
${this.computeState(value)}
</span>
<span class="state__uom ellipsis">
${this.computeUom(isPrimary && entity || id)}
${this.computeUom(entity)}
</span>
${isPrimary && this.renderStateTime() || ''}
</div>
Expand Down