From 73b0659ffd1aa03cf993965b020d72d271a90576 Mon Sep 17 00:00:00 2001 From: Avii Date: Sat, 8 Aug 2026 13:41:02 +0200 Subject: [PATCH] 1786189262 --- dashboard/src/ha_ext.rs | 17 +++++ dashboard/src/main.rs | 5 ++ dashboard/ui/climate.slint | 96 +++++++++++++++++++++++++- dashboard/ui/icons/cloud-fog.svg | 3 + dashboard/ui/icons/cloud-lightning.svg | 3 + dashboard/ui/icons/cloud-moon.svg | 3 + dashboard/ui/icons/cloud-rain-wind.svg | 3 + dashboard/ui/icons/cloud-rain.svg | 3 + dashboard/ui/icons/cloud-sun.svg | 3 + dashboard/ui/icons/cloud.svg | 3 + dashboard/ui/icons/moon.svg | 3 + dashboard/ui/icons/snowflake.svg | 3 + dashboard/ui/icons/sun.svg | 3 + dashboard/ui/main.slint | 7 +- 14 files changed, 151 insertions(+), 4 deletions(-) create mode 100644 dashboard/ui/icons/cloud-fog.svg create mode 100644 dashboard/ui/icons/cloud-lightning.svg create mode 100644 dashboard/ui/icons/cloud-moon.svg create mode 100644 dashboard/ui/icons/cloud-rain-wind.svg create mode 100644 dashboard/ui/icons/cloud-rain.svg create mode 100644 dashboard/ui/icons/cloud-sun.svg create mode 100644 dashboard/ui/icons/cloud.svg create mode 100644 dashboard/ui/icons/moon.svg create mode 100644 dashboard/ui/icons/snowflake.svg create mode 100644 dashboard/ui/icons/sun.svg diff --git a/dashboard/src/ha_ext.rs b/dashboard/src/ha_ext.rs index 82370bd..e102b33 100644 --- a/dashboard/src/ha_ext.rs +++ b/dashboard/src/ha_ext.rs @@ -76,3 +76,20 @@ impl From<&HassEntity> for DateTimeData { } } } + +impl From<&HassEntity> for WeatherData { + fn from(value: &HassEntity) -> Self { + let outside_temperature = value + .attributes + .get("outside_temperature") + .unwrap_or_default() + .to_shared_string(); + + Self { + outside_temperature, + outside_high: todo!(), + outside_condition: todo!(), + weather_kind: todo!(), + } + } +} diff --git a/dashboard/src/main.rs b/dashboard/src/main.rs index 20a4889..49a72b8 100644 --- a/dashboard/src/main.rs +++ b/dashboard/src/main.rs @@ -37,6 +37,11 @@ fn apply_state(app: &Weak, state: State) { if let Some(date_time_iso) = state.get("sensor.date_time_iso").as_ref() { app.set_date_time(date_time_iso.into()); } + + // Weather + if let Some(weather) = state.get("weather.forecast_home").as_ref() { + app.set_weather(weather.into()); + } }) .ok(); } diff --git a/dashboard/ui/climate.slint b/dashboard/ui/climate.slint index 40a48b4..655e741 100644 --- a/dashboard/ui/climate.slint +++ b/dashboard/ui/climate.slint @@ -1,3 +1,95 @@ -export component Climate inherits Rectangle { - // .. +/* +in property : "--"; +in property : "HIGH --"; +in property : "CONNECTING"; +in property : "cloud"; +*/ + +export struct WeatherData { + outside-temperature: string, + outside-high: string, + outside-condition: string, + weather-kind: string, +} + +export component Climate inherits Rectangle { + in property weather; + Text { + width: 300px; + height: 116px; + text: weather.outside-temperature; + font-size: 104px; + font-weight: 700; + vertical-alignment: center; + } + + Text { + width: 150px; + height: 32px; + text: weather.outside-high; + font-size: 20px; + font-weight: 700; + vertical-alignment: center; + } + + if weather.weather-kind == "sun": Image { + width: 120px; + height: 105px; + source: @image-url("icons/sun.svg"); + image-fit: contain; + } + if weather.weather-kind == "cloud-sun": Image { + width: 120px; + height: 105px; + source: @image-url("icons/cloud-sun.svg"); + image-fit: contain; + } + if weather.weather-kind == "cloud-moon": Image { + width: 120px; + height: 105px; + source: @image-url("icons/cloud-moon.svg"); + image-fit: contain; + } + if weather.weather-kind == "cloud": Image { + width: 120px; + height: 105px; + source: @image-url("icons/cloud.svg"); + image-fit: contain; + } + if weather.weather-kind == "cloud-rain": Image { + width: 120px; + height: 105px; + source: @image-url("icons/cloud-rain.svg"); + image-fit: contain; + } + if weather.weather-kind == "cloud-rain-wind": Image { + width: 120px; + height: 105px; + source: @image-url("icons/cloud-rain-wind.svg"); + image-fit: contain; + } + if weather.weather-kind == "cloud-lightning": Image { + width: 120px; + height: 105px; + source: @image-url("icons/cloud-lightning.svg"); + image-fit: contain; + } + if weather.weather-kind == "snowflake": Image { + width: 120px; + height: 105px; + source: @image-url("icons/snowflake.svg"); + image-fit: contain; + } + if weather.weather-kind == "cloud-fog": Image { + width: 120px; + height: 105px; + source: @image-url("icons/cloud-fog.svg"); + image-fit: contain; + } + if weather.weather-kind == "moon": Image { + width: 120px; + height: 105px; + source: @image-url("icons/moon.svg"); + image-fit: contain; + } } diff --git a/dashboard/ui/icons/cloud-fog.svg b/dashboard/ui/icons/cloud-fog.svg new file mode 100644 index 0000000..34ac0c7 --- /dev/null +++ b/dashboard/ui/icons/cloud-fog.svg @@ -0,0 +1,3 @@ + + + diff --git a/dashboard/ui/icons/cloud-lightning.svg b/dashboard/ui/icons/cloud-lightning.svg new file mode 100644 index 0000000..5c1d330 --- /dev/null +++ b/dashboard/ui/icons/cloud-lightning.svg @@ -0,0 +1,3 @@ + + + diff --git a/dashboard/ui/icons/cloud-moon.svg b/dashboard/ui/icons/cloud-moon.svg new file mode 100644 index 0000000..4474c3a --- /dev/null +++ b/dashboard/ui/icons/cloud-moon.svg @@ -0,0 +1,3 @@ + + + diff --git a/dashboard/ui/icons/cloud-rain-wind.svg b/dashboard/ui/icons/cloud-rain-wind.svg new file mode 100644 index 0000000..f34f405 --- /dev/null +++ b/dashboard/ui/icons/cloud-rain-wind.svg @@ -0,0 +1,3 @@ + + + diff --git a/dashboard/ui/icons/cloud-rain.svg b/dashboard/ui/icons/cloud-rain.svg new file mode 100644 index 0000000..75e32f3 --- /dev/null +++ b/dashboard/ui/icons/cloud-rain.svg @@ -0,0 +1,3 @@ + + + diff --git a/dashboard/ui/icons/cloud-sun.svg b/dashboard/ui/icons/cloud-sun.svg new file mode 100644 index 0000000..131c462 --- /dev/null +++ b/dashboard/ui/icons/cloud-sun.svg @@ -0,0 +1,3 @@ + + + diff --git a/dashboard/ui/icons/cloud.svg b/dashboard/ui/icons/cloud.svg new file mode 100644 index 0000000..6cf5f81 --- /dev/null +++ b/dashboard/ui/icons/cloud.svg @@ -0,0 +1,3 @@ + + + diff --git a/dashboard/ui/icons/moon.svg b/dashboard/ui/icons/moon.svg new file mode 100644 index 0000000..edb7977 --- /dev/null +++ b/dashboard/ui/icons/moon.svg @@ -0,0 +1,3 @@ + + + diff --git a/dashboard/ui/icons/snowflake.svg b/dashboard/ui/icons/snowflake.svg new file mode 100644 index 0000000..f044805 --- /dev/null +++ b/dashboard/ui/icons/snowflake.svg @@ -0,0 +1,3 @@ + + + diff --git a/dashboard/ui/icons/sun.svg b/dashboard/ui/icons/sun.svg new file mode 100644 index 0000000..9563744 --- /dev/null +++ b/dashboard/ui/icons/sun.svg @@ -0,0 +1,3 @@ + + + diff --git a/dashboard/ui/main.slint b/dashboard/ui/main.slint index 25b814b..17aec7d 100644 --- a/dashboard/ui/main.slint +++ b/dashboard/ui/main.slint @@ -8,7 +8,7 @@ import { StandardTableView, } from "std-widgets.slint"; -import { Climate } from "./climate.slint"; +import { Climate, WeatherData } from "./climate.slint"; import { Calendar } from "calendar.slint"; import { Energy } from "energy.slint"; @@ -92,6 +92,7 @@ export component AppWindow inherits Window { property page: 0; in property date-time; + in property weather; in property <[ThermometerData]> thermometers; in property <[LightData]> lights; @@ -130,7 +131,9 @@ export component AppWindow inherits Window { Rectangle { preferred-width: root.width; VerticalLayout { - if root.page == 0: Climate { } + if root.page == 0: Climate { + weather: weather; + } if root.page == 1: Calendar { } if root.page == 2: Energy { }