Skip to content

Commit c8bb4b5

Browse files
committed
Fix precision
1 parent b6a8a0a commit c8bb4b5

2 files changed

Lines changed: 14 additions & 8 deletions

File tree

src/global.d.ts

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,18 @@
11
declare type StateValue = number | string | boolean;
22

33
interface Entity {
4-
entity_id: string;
5-
device_id: string;
6-
}
4+
entity_id: string;
5+
name?: string;
6+
icon?: string;
7+
device_id?: string;
8+
area_id?: string;
9+
labels: string[];
10+
hidden?: boolean;
11+
entity_category?: EntityCategory;
12+
translation_key?: string;
13+
platform?: string;
14+
display_precision?: number;
15+
has_entity_name?: boolean;}
716

817
type Context = {
918
id: string;

src/ts/StarlineCard.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -295,11 +295,8 @@ export class StarlineCard extends HTMLElement {
295295
stateObj.attributes.unit_of_measurement = '';
296296
}
297297

298-
const numState = Number(stateObj.state);
299-
this._info[key].element!.querySelector('.info-i-cnt')!.textContent = this._hass.formatEntityState(
300-
stateObj,
301-
isFinite(numState) ? String(Math.round(numState)) : stateObj.state
302-
);
298+
this._hass.entities[stateObj.entity_id].display_precision = 0;
299+
this._info[key].element!.querySelector('.info-i-cnt')!.textContent = this._hass.formatEntityState(stateObj);
303300
}
304301
}
305302

0 commit comments

Comments
 (0)