${this.computeUom(entity)}
@@ -356,7 +356,7 @@ class MiniGraphCard extends LitElement {
const { show_legend_state = false } = this.config.entities[index];
if (show_legend_state) {
- legend += ` (${this.computeState(state)}`;
+ legend += ` (${this.computeState(state, index)}`;
if (!(['unavailable'].includes(state))) {
const uom = this.computeUom(index);
if (!(['%', ''].includes(uom)))
@@ -615,8 +615,8 @@ class MiniGraphCard extends LitElement {
if (!this.config.show.labels_secondary || this.secondaryYaxisSeries.length === 0) return;
return html`
- ${this.computeState(this.boundSecondary[1])}
- ${this.computeState(this.boundSecondary[0])}
+ ${this.computeState(this.boundSecondary[1], -1)}
+ ${this.computeState(this.boundSecondary[0], -1)}
`;
}
@@ -628,7 +628,7 @@ class MiniGraphCard extends LitElement {
${entry.type}
- ${this.computeState(entry.state)} ${this.computeUom(0)}
+ ${this.computeState(entry.state, 0)} ${this.computeUom(0)}
${entry.type !== 'avg' ? getTime(new Date(entry.last_changed), this.config.format, this._hass.language) : ''}
@@ -725,7 +725,7 @@ class MiniGraphCard extends LitElement {
);
}
- computeState(inState) {
+ computeState(inState, index) {
if (this.config.state_map.length > 0) {
const stateMap = Number.isInteger(inState)
? this.config.state_map[inState]
@@ -744,7 +744,20 @@ class MiniGraphCard extends LitElement {
} else {
state = Number(inState);
}
- const dec = this.config.decimals;
+
+ let dec;
+ if (index === undefined) {
+ dec = this.config.decimals;
+ } else if (index === -1) {
+ dec = this.config.decimals_secondary !== undefined
+ ? this.config.decimals_secondary
+ : this.config.decimals;
+ } else {
+ dec = this.config.entities[index].decimals !== undefined
+ ? this.config.entities[index].decimals
+ : this.config.decimals;
+ }
+
const value_factor = 10 ** this.config.value_factor;
if (dec === undefined || Number.isNaN(dec) || Number.isNaN(state)) {