From 9478b883495fa5ebcaf4d9351e7af056aaf95dc3 Mon Sep 17 00:00:00 2001 From: Avii Date: Sat, 8 Aug 2026 14:49:19 +0200 Subject: [PATCH] 1786193359 --- dashboard/src/ha_ext.rs | 26 ++++++++++++-------------- dashboard/ui/climate.slint | 24 ++++++++++++------------ 2 files changed, 24 insertions(+), 26 deletions(-) diff --git a/dashboard/src/ha_ext.rs b/dashboard/src/ha_ext.rs index e64e71c..4267e7c 100644 --- a/dashboard/src/ha_ext.rs +++ b/dashboard/src/ha_ext.rs @@ -97,19 +97,17 @@ supported_features: int */ impl From<&HassEntity> for WeatherData { fn from(value: &HassEntity) -> Self { - let kind = match value.state.as_str() { - "sunny" => "sun", - "clear-night" => "moon", - // "partlycloudy" if is_night => "cloud-moon", - "partlycloudy" => "cloud-sun", - "rainy" => "cloud-rain", - "pouring" | "windy" | "windy-variant" => "cloud-rain-wind", - "lightning" | "lightning-rainy" => "cloud-lightning", - "snowy" | "snowy-rainy" | "hail" => "snowflake", - "fog" => "cloud-fog", - _ => "cloud", - } - .to_shared_string(); + let icon_index = match value.state.as_str() { + "sunny" => 0, + "partlycloudy" => 1, + "clear-night" => 9, + "rainy" => 4, + "pouring" | "windy" | "windy-variant" => 5, + "lightning" | "lightning-rainy" => 6, + "snowy" | "snowy-rainy" | "hail" => 7, + "fog" => 8, + _ => 3, + }; let label = pretty_label(&value.state).to_shared_string(); @@ -217,7 +215,7 @@ impl From<&HassEntity> for WeatherData { .to_shared_string(); Self { - kind, + icon_index, label, attribution, cloud_coverage, diff --git a/dashboard/ui/climate.slint b/dashboard/ui/climate.slint index ab969cc..403f242 100644 --- a/dashboard/ui/climate.slint +++ b/dashboard/ui/climate.slint @@ -7,7 +7,7 @@ in property : "cloud"; import { Palette, HorizontalBox, VerticalBox } from "std-widgets.slint"; export struct WeatherData { - kind: string, + icon-index: int, label: string, temperature: float, dew_point: float, @@ -31,10 +31,19 @@ export component Climate inherits Rectangle { in property weather; in property is-night; + property icon-index: weather.icon-index == 1 && is-night ? 2 : weather.icon-index; + property <[image]> icons: [ @image-url("icons/sun.svg"), @image-url("icons/cloud-sun.svg"), - @image-url("icons/cloud-moon.svg") + @image-url("icons/cloud-moon.svg"), + @image-url("icons/cloud.svg"), + @image-url("icons/cloud-rain.svg"), + @image-url("icons/cloud-rain-wind.svg"), + @image-url("icons/cloud-lightning.svg"), + @image-url("icons/snowflake.svg"), + @image-url("icons/cloud-fog.svg"), + @image-url("icons/moon.svg"), ]; VerticalLayout { @@ -63,20 +72,11 @@ export component Climate inherits Rectangle { colorize: Palette.foreground; width: 120px; height: 105px; - source: icons[0]; + source: icons[icon-index]; image-fit: contain; } } Rectangle { } } - - // Text { - // width: 150px; - // height: 32px; - // text: weather.outside-high; - // font-size: 20px; - // font-weight: 700; - // vertical-alignment: center; - // } }