Skip to content

Commit

Permalink
Fix number duration format
Browse files Browse the repository at this point in the history
  • Loading branch information
piitaya committed Nov 22, 2024
1 parent b6f2615 commit d1fd163
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 12 deletions.
14 changes: 3 additions & 11 deletions src/cards/number-card/number-card.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@ import {
actionHandler,
ActionHandlerEvent,
computeRTL,
formatNumber,
getDefaultFormatOptions,
getNumberFormatOptions,
handleAction,
hasAction,
HomeAssistant,
Expand Down Expand Up @@ -125,15 +122,10 @@ export class NumberCard

let stateDisplay = this.hass.formatEntityState(stateObj);
if (this.value !== undefined) {
const numberValue = formatNumber(
this.value,
this.hass.locale,
getNumberFormatOptions(
stateObj,
this.hass.entities[stateObj.entity_id]
) ?? getDefaultFormatOptions(stateObj.state)
stateDisplay = this.hass.formatEntityState(
stateObj,
this.value.toString()
);
stateDisplay = `${numberValue} ${stateObj.attributes.unit_of_measurement ?? ""}`;
}

const rtl = computeRTL(this.hass);
Expand Down
2 changes: 1 addition & 1 deletion src/shared/input-number.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export class InputNumber extends LitElement {
@property({ type: Number })
public max?: number;

@property({ attribute: "false" })
@property({ attribute: false })
public formatOptions: Intl.NumberFormatOptions = {};

@state() pending = false;
Expand Down

0 comments on commit d1fd163

Please sign in to comment.