Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ clock_format: 24h # 12h or 24h
| `height` | number | `200` | Card height in pixels |
| `language` | string | `auto` | `auto`, `en`, `ru`, `de`, `fr`, `nl`, `es`, `it`, `hu`, `sk`, `pt`, `da`, `sr`, `pl` |
| `overlay_opacity` | number | `0.1` | Dark overlay opacity (0-1) for text readability |
| `show_animations` | boolean | `true` | Render canvas weather animations (set `false` for a static gradient) |
| **Temperature** |
| `show_feels_like` | boolean | `true` | Display "feels like" temperature |
| `show_min_temp` | boolean | `true` | Display minimum temperature |
Expand Down
1 change: 1 addition & 0 deletions README.ru.md
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ clock_format: 24h # 12h или 24h
| `height` | number | `200` | Высота карточки в пикселях |
| `language` | string | `auto` | `auto`, `en`, `ru`, `de`, `fr`, `nl`, `es`, `it`, `hu`, `sk`, `pt`, `da`, `sr`, `pl` |
| `overlay_opacity` | number | `0.1` | Прозрачность тёмного наложения (0-1) для читаемости текста |
| `show_animations` | boolean | `true` | Рисовать анимации погоды на канвасе (`false` — статичный градиент) |
| **Температура** |
| `show_feels_like` | boolean | `true` | Отображать ощущаемую температуру |
| `show_min_temp` | boolean | `true` | Отображать минимальную температуру |
Expand Down
24 changes: 12 additions & 12 deletions dynamic-weather-card.js

Large diffs are not rendered by default.

18 changes: 17 additions & 1 deletion src/components/card.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,21 @@ export class AnimatedWeatherCard extends LitElement {

updated(changedProperties: Map<string, unknown>): void {
super.updated(changedProperties);

if (changedProperties.has('config')) {
const prev = changedProperties.get('config') as WeatherCardConfigInternal | undefined;
const wasAnimating = prev ? prev.showAnimations !== false : true;
const isAnimating = this.config.showAnimations !== false;
if (wasAnimating && !isAnimating) {
this.animationManager.destroy();
} else if (!wasAnimating && isAnimating) {
this.updateComplete.then(() => {
const container = this.shadowRoot?.querySelector('.canvas-container');
if (container) this.animationManager.setup(container);
});
}
}

if (changedProperties.has('hass') || changedProperties.has('config')) {
const entity = this.config.entity;
const showDaily = this.config.showDailyForecast ?? false;
Expand Down Expand Up @@ -177,6 +192,7 @@ export class AnimatedWeatherCard extends LitElement {
overlayOpacity: config.overlay_opacity !== undefined ? config.overlay_opacity : DEFAULT_CONFIG.overlayOpacity,
language: config.language || DEFAULT_CONFIG.language,
windSpeedUnit: config.wind_speed_unit || DEFAULT_CONFIG.windSpeedUnit,
showAnimations: config.show_animations !== false,
sunriseEntity: config.sunrise_entity || null,
sunsetEntity: config.sunset_entity || null,
templowAttribute: config.templow_attribute || null,
Expand Down Expand Up @@ -259,7 +275,7 @@ export class AnimatedWeatherCard extends LitElement {
@pointercancel=${(e: PointerEvent) => this.actionHandler.handlePointerUp(e)}
>
<div class="${cardClasses}" style="min-height: ${minHeight}; ${bgStyle}; ${overlayStyle} cursor: pointer;">
<div class="canvas-container"></div>
${this.config.showAnimations !== false ? html`<div class="canvas-container"></div>` : ''}
<div class="content">
${this.config.name && this.config.name.trim() !== '' ? html`
<div class="header">
Expand Down
2 changes: 2 additions & 0 deletions src/components/editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ export class DynamicWeatherCardEditor extends LitElement {
show_daily_forecast: DEFAULT_CONFIG.showDailyForecast,
daily_forecast_days: DEFAULT_CONFIG.dailyForecastDays,
show_sunrise_sunset: DEFAULT_CONFIG.showSunriseSunset,
show_animations: DEFAULT_CONFIG.showAnimations,
show_clock: DEFAULT_CONFIG.showClock,
clock_position: DEFAULT_CONFIG.clockPosition,
clock_format: DEFAULT_CONFIG.clockFormat,
Expand Down Expand Up @@ -108,6 +109,7 @@ export class DynamicWeatherCardEditor extends LitElement {
}
}
},
{ name: 'show_animations', selector: { boolean: {} } },
{ name: 'overlay_opacity', selector: { number: { min: 0, max: 1, step: 0.05, mode: 'box' } } },
{
name: 'language',
Expand Down
3 changes: 2 additions & 1 deletion src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,6 @@ export const DEFAULT_CONFIG: Required<Omit<WeatherCardConfig, 'entity' | 'type'>
overlayOpacity: 0.1,
language: 'auto',
height: null,
windSpeedUnit: 'ms'
windSpeedUnit: 'ms',
showAnimations: true
};
3 changes: 2 additions & 1 deletion src/internationalization/locales/de/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@
"language_pt": "Portugiesisch",
"wind_speed_unit": "Einheit der Windgeschwindigkeit",
"wind_speed_unit_ms": "m/s",
"wind_speed_unit_kmh": "km/h"
"wind_speed_unit_kmh": "km/h",
"show_animations": "Animationen anzeigen"
},
"demo": {
"pageTitle": "Dynamische Wetterkarte",
Expand Down
3 changes: 2 additions & 1 deletion src/internationalization/locales/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@
"language_pl": "Polish",
"wind_speed_unit": "Wind Speed Unit",
"wind_speed_unit_ms": "m/s",
"wind_speed_unit_kmh": "km/h"
"wind_speed_unit_kmh": "km/h",
"show_animations": "Show Animations"
},
"demo": {
"pageTitle": "Dynamic Weather Card",
Expand Down
3 changes: 2 additions & 1 deletion src/internationalization/locales/es/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@
"language_pt": "Portugués",
"wind_speed_unit": "Unidad de velocidad del viento",
"wind_speed_unit_ms": "m/s",
"wind_speed_unit_kmh": "km/h"
"wind_speed_unit_kmh": "km/h",
"show_animations": "Mostrar animaciones"
},
"demo": {
"pageTitle": "Tarjeta Meteorológica Dinámica",
Expand Down
3 changes: 2 additions & 1 deletion src/internationalization/locales/fr/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@
"language_pt": "Portugais",
"wind_speed_unit": "Unité de vitesse du vent",
"wind_speed_unit_ms": "m/s",
"wind_speed_unit_kmh": "km/h"
"wind_speed_unit_kmh": "km/h",
"show_animations": "Afficher les animations"
},
"demo": {
"pageTitle": "Carte Météo Dynamique",
Expand Down
3 changes: 2 additions & 1 deletion src/internationalization/locales/hu/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@
"language_pt": "Portugál",
"wind_speed_unit": "Szélsebesség egység",
"wind_speed_unit_ms": "m/s",
"wind_speed_unit_kmh": "km/h"
"wind_speed_unit_kmh": "km/h",
"show_animations": "Animációk megjelenítése"
},
"demo": {
"pageTitle": "Dynamic Weather Card",
Expand Down
3 changes: 2 additions & 1 deletion src/internationalization/locales/it/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@
"language_pt": "Portoghese",
"wind_speed_unit": "Unità velocità del vento",
"wind_speed_unit_ms": "m/s",
"wind_speed_unit_kmh": "km/h"
"wind_speed_unit_kmh": "km/h",
"show_animations": "Mostra animazioni"
},
"demo": {
"pageTitle": "Dynamic Weather Card",
Expand Down
3 changes: 2 additions & 1 deletion src/internationalization/locales/nl/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@
"language_pt": "Portugees",
"wind_speed_unit": "Windsnelheidseenheid",
"wind_speed_unit_ms": "m/s",
"wind_speed_unit_kmh": "km/u"
"wind_speed_unit_kmh": "km/u",
"show_animations": "Animaties weergeven"
},
"demo": {
"pageTitle": "Dynamische Weerkaart",
Expand Down
3 changes: 2 additions & 1 deletion src/internationalization/locales/ru/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@
"language_pt": "Португальский",
"wind_speed_unit": "Единицы скорости ветра",
"wind_speed_unit_ms": "м/с",
"wind_speed_unit_kmh": "км/ч"
"wind_speed_unit_kmh": "км/ч",
"show_animations": "Показывать анимации"
},
"demo": {
"pageTitle": "Динамическая карточка погоды",
Expand Down
3 changes: 2 additions & 1 deletion src/internationalization/locales/sk/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@
"language_pt": "Portugalčina",
"wind_speed_unit": "Jednotka rýchlosti vetra",
"wind_speed_unit_ms": "m/s",
"wind_speed_unit_kmh": "km/h"
"wind_speed_unit_kmh": "km/h",
"show_animations": "Zobraziť animácie"
},
"demo": {
"pageTitle": "Dynamická karta počasia",
Expand Down
1 change: 1 addition & 0 deletions src/internationalization/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ export interface EditorTranslations {
wind_speed_unit: string;
wind_speed_unit_ms: string;
wind_speed_unit_kmh: string;
show_animations?: string;
}

export interface Translation {
Expand Down
2 changes: 2 additions & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ export interface WeatherCardConfig {
language?: 'auto' | 'en' | 'ru' | 'de' | 'nl' | 'fr' | 'es' | 'it' | 'sk' | 'hu';
height?: number | null;
windSpeedUnit?: 'ms' | 'kmh';
showAnimations?: boolean;
}

// Time of Day
Expand Down Expand Up @@ -219,6 +220,7 @@ export interface ConfigInput {
overlay_opacity?: number;
language?: 'auto' | 'en' | 'ru' | 'de' | 'nl' | 'fr' | 'es' | 'it' | 'sk' | 'hu';
wind_speed_unit?: 'ms' | 'kmh';
show_animations?: boolean;
sunrise_entity?: string;
sunset_entity?: string;
templow_attribute?: string;
Expand Down