From c3678152f7cb0f339d7afd730264012d9bfc6e42 Mon Sep 17 00:00:00 2001 From: oleg-d Date: Wed, 10 Apr 2024 10:44:31 +0300 Subject: [PATCH] Add ability to be able to show more precision in main temperature displayed (#360) --- README.md | 2 ++ src/clock-weather-card.ts | 5 +++-- src/types.ts | 2 ++ 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index d860ba23..8b91aab7 100644 --- a/README.md +++ b/README.md @@ -115,6 +115,7 @@ hide_date: false hourly_forecast: false use_browser_time: false time_zone: null +show_decimal: false ``` ### Options @@ -142,6 +143,7 @@ time_zone: null | hourly_forecast | boolean | **Optional** | Displays an hourly forecast instead of daily | `false` | | use_browser_time | boolean | **Optional** | Uses the time from your browser to indicate the current time. If not provided, uses the [time_zone](https://www.home-assistant.io/blog/2015/05/09/utc-time-zone-awareness/#setting-up-your-time-zone) configured in HA | `false` | | time_zone | string | **Optional** | Uses the given [time zone](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones) to indicate the current date and time. If not provided, uses the time zone configured in HA | `null` | +| show_decimal | boolean | **Optional** | Displays main temperature without rounding | `false` | ## Footnotes diff --git a/src/clock-weather-card.ts b/src/clock-weather-card.ts index 12dbf95d..5c946a89 100644 --- a/src/clock-weather-card.ts +++ b/src/clock-weather-card.ts @@ -209,7 +209,7 @@ export class ClockWeatherCard extends LitElement { private renderToday (): TemplateResult { const weather = this.getWeather() const state = weather.state - const temp = roundIfNotNull(this.getCurrentTemperature()) + const temp = this.config.show_decimal ? this.getCurrentTemperature() : roundIfNotNull(this.getCurrentTemperature()) const tempUnit = weather.attributes.temperature_unit const humidity = roundIfNotNull(this.getCurrentHumidity()) const iconType = this.config.weather_icon_type @@ -425,7 +425,8 @@ export class ClockWeatherCard extends LitElement { hide_date: config.hide_date ?? false, date_pattern: config.date_pattern ?? 'D', use_browser_time: config.use_browser_time ?? false, - time_zone: config.time_zone ?? undefined + time_zone: config.time_zone ?? undefined, + show_decimal: config.show_decimal ?? false } } diff --git a/src/types.ts b/src/types.ts index 73c68b73..c0f907f5 100644 --- a/src/types.ts +++ b/src/types.ts @@ -30,6 +30,7 @@ export interface ClockWeatherCardConfig extends LovelaceCardConfig { hide_date?: boolean use_browser_time?: boolean time_zone?: string + show_decimal?: boolean } export interface MergedClockWeatherCardConfig extends LovelaceCardConfig { @@ -53,6 +54,7 @@ export interface MergedClockWeatherCardConfig extends LovelaceCardConfig { hide_date: boolean use_browser_time: boolean time_zone?: string + show_decimal: boolean } export const enum WeatherEntityFeature {