diff --git a/package-lock.json b/package-lock.json index 31c0954..c43f93b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "calendar-card-pro-dev", - "version": "3.0.6", + "version": "3.1.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "calendar-card-pro-dev", - "version": "3.0.6", + "version": "3.1.0", "license": "MIT", "dependencies": { "@material/web": "^2.2.0", diff --git a/src/config/config.ts b/src/config/config.ts index 7541221..9db390e 100644 --- a/src/config/config.ts +++ b/src/config/config.ts @@ -110,6 +110,8 @@ export const DEFAULT_CONFIG: Types.Config = { show_conditions: true, show_high_temp: true, show_low_temp: false, + show_uvindex: true, + show_uvindex_threshold: 0, icon_size: '14px', font_size: '12px', color: 'var(--primary-text-color)', @@ -117,6 +119,8 @@ export const DEFAULT_CONFIG: Types.Config = { event: { show_conditions: true, show_temp: true, + show_uvindex: true, + show_uvindex_threshold: 0, icon_size: '14px', font_size: '12px', color: 'var(--primary-text-color)', diff --git a/src/rendering/editor.ts b/src/rendering/editor.ts index c94e44e..39ca7bd 100755 --- a/src/rendering/editor.ts +++ b/src/rendering/editor.ts @@ -1232,6 +1232,14 @@ export class CalendarCardProEditor extends LitElement { 'weather.date.show_low_temp', this._getTranslation('show_low_temp'), )} + ${this.addBooleanField( + 'weather.date.show_uvindex', + this._getTranslation('show_uvindex'), + )} + ${this.addTextField( + 'weather.date.show_uvindex_threshold', + this._getTranslation('show_uvindex_threshold'), + )} ${this.addTextField( 'weather.date.icon_size', this._getTranslation('icon_size'), @@ -1255,6 +1263,14 @@ export class CalendarCardProEditor extends LitElement { 'weather.event.show_temp', this._getTranslation('show_temp'), )} + ${this.addBooleanField( + 'weather.event.show_uvindex', + this._getTranslation('show_uvindex'), + )} + ${this.addTextField( + 'weather.event.show_uvindex_threshold', + this._getTranslation('show_uvindex_threshold'), + )} ${this.addTextField( 'weather.event.icon_size', this._getTranslation('icon_size'), diff --git a/src/rendering/render.ts b/src/rendering/render.ts index def8b7e..78d5daa 100644 --- a/src/rendering/render.ts +++ b/src/rendering/render.ts @@ -517,6 +517,7 @@ function renderDateColumn( const showConditions = dateConfig.show_conditions !== false; const showHighTemp = dateConfig.show_high_temp !== false; const showLowTemp = dateConfig.show_low_temp === true && dailyForecast.templow !== undefined; + const showUvIndex = (dateConfig.show_uvindex !== false) && (dailyForecast.uvindex >= dateConfig.show_uvindex_threshold); // Get styling from config const iconSize = dateConfig.icon_size || '14px'; @@ -539,6 +540,13 @@ function renderDateColumn( ${showLowTemp ? html` /${dailyForecast.templow}° ` : nothing} + ${showUvIndex + ? html` + + ${dailyForecast.uvindex} + + ` + : nothing} `; } @@ -1038,6 +1046,7 @@ function renderEventWeather( const eventConfig = config.weather?.event || {}; const showConditions = eventConfig.show_conditions !== false; const showTemp = eventConfig.show_temp !== false; + const showUvIndex = eventConfig.show_uvindex !== false && forecast.uvindex >= eventConfig.show_uvindex_threshold; // Get styling from config const iconSize = eventConfig.icon_size || '14px'; @@ -1055,6 +1064,12 @@ function renderEventWeather( ${forecast.temperature}° ` : nothing} + ${showUvIndex + ? html` + + ${forecast.uvindex} + ` + : nothing} `; } diff --git a/src/translations/languages/de.json b/src/translations/languages/de.json index f8b3cdf..aa5ad74 100644 --- a/src/translations/languages/de.json +++ b/src/translations/languages/de.json @@ -218,6 +218,8 @@ "color": "Farbe", "event_row_weather": "Ereignisreihe Wetter", "show_temp": "Temperatur anzeigen", + "show_uvindex": "Zeige UV Index", + "show_uvindex_threshold": "Grenzwert ab dem der UV Index angezeigt werden soll", "interactions": "Interaktionen", "tap_action": "Aktion antippen", diff --git a/src/translations/languages/en.json b/src/translations/languages/en.json index fbe6123..0c2965d 100644 --- a/src/translations/languages/en.json +++ b/src/translations/languages/en.json @@ -210,7 +210,9 @@ "color": "Color", "event_row_weather": "Event Row Weather", "show_temp": "Show temperature", - + "show_uvindex": "Show UV index", + "show_uvindex_threshold": "Threshold when to show UV index", + "interactions": "Interactions", "tap_action": "Tap Action", "hold_action": "Hold Action", diff --git a/src/utils/weather.ts b/src/utils/weather.ts index 0479f77..42850f0 100644 --- a/src/utils/weather.ts +++ b/src/utils/weather.ts @@ -97,6 +97,7 @@ function processForecastData( hour, precipitation: item.precipitation, precipitation_probability: item.precipitation_probability, + uvindex: item.uv_index !== undefined ? Math.round(item.uv_index) : undefined, }; });