diff --git a/src/editor.ts b/src/editor.ts index 5279dcc..4a2fdf6 100644 --- a/src/editor.ts +++ b/src/editor.ts @@ -50,6 +50,10 @@ export class RainGaugeCardEditor extends ScopedRegistryHost(LitElement) implemen return this._config?.entity || ''; } + get _hide_units(): boolean { + return this._config?.hide_units || false; + } + get _is_imperial(): boolean { return this._config?.is_imperial || false; } @@ -117,6 +121,13 @@ export class RainGaugeCardEditor extends ScopedRegistryHost(LitElement) implemen .configValue=${'fill_drop_colour'} @input=${this._valueChanged} > + + + -
-
-

- ${localize('common.total', '', '', this.config.language)}
- ${stateValue} ${unitOfMeasurement} -

-
-
- ${this._showHourlyRate(hourlyRateEntityState, hourlyRateStateValue, unitOfMeasurement)} -
-
+ ${this._showUnits(hideUnits, stateValue, hourlyRateEntityState, hourlyRateStateValue, unitOfMeasurement)} `; @@ -188,6 +180,21 @@ export class RainGaugeCard extends LitElement {

` } + private _showUnits(hide: boolean, stateValue: number, hourlyRateEntityState: any | undefined, hourlyRateStateValue: number, unitOfMeasurement: string): TemplateResult | void { + if (hide) return + return html`
+
+

+ ${localize('common.total', '', '', this.config.language)}
+ ${stateValue} ${unitOfMeasurement} +

+
+
+ ${this._showHourlyRate(hourlyRateEntityState, hourlyRateStateValue, unitOfMeasurement)} +
+
` + } + private _handleAction(ev: ActionHandlerEvent): void { if (this.hass && this.config && ev.detail.action) { handleAction(this, this.hass, this.config, ev.detail.action); diff --git a/src/types.ts b/src/types.ts index 6e19a4c..9c739a0 100644 --- a/src/types.ts +++ b/src/types.ts @@ -16,6 +16,7 @@ export interface RainGaugeCardConfig extends LovelaceCardConfig { test_gui?: boolean; entity?: string; language?: string; + hide_units?: boolean; is_imperial?: boolean; max_level?: number; hourly_rate_entity?: string;