diff --git a/dashboard/src/ha_ext.rs b/dashboard/src/ha_ext.rs index ab5e44a..2182519 100644 --- a/dashboard/src/ha_ext.rs +++ b/dashboard/src/ha_ext.rs @@ -111,6 +111,8 @@ impl From<&HassEntity> for WeatherData { } .to_shared_string(); + let label = pretty_label(&kind).to_shared_string(); + let attribution = value .attributes .get("attribution") @@ -216,6 +218,7 @@ impl From<&HassEntity> for WeatherData { Self { kind, + label, attribution, cloud_coverage, dew_point, @@ -235,3 +238,22 @@ impl From<&HassEntity> for WeatherData { } } } + +pub fn pretty_label(value: &str) -> String { + let value = match value { + "partlycloudy" => "partly cloudy", + other => other, + }; + value + .split(['_', '-', ' ']) + .filter(|word| !word.is_empty()) + .map(|word| { + let mut chars = word.chars(); + match chars.next() { + Some(first) => first.to_uppercase().collect::() + chars.as_str(), + None => String::new(), + } + }) + .collect::>() + .join(" ") +} diff --git a/dashboard/ui/climate.slint b/dashboard/ui/climate.slint index 968e302..220273b 100644 --- a/dashboard/ui/climate.slint +++ b/dashboard/ui/climate.slint @@ -8,6 +8,7 @@ in property : "cloud"; import { Palette } from "std-widgets.slint"; export struct WeatherData { kind: string, + label: string, temperature: float, dew_point: float, temperature_unit: string, @@ -37,6 +38,13 @@ export component Climate inherits Rectangle { vertical-alignment: center; } + Text { + text: weather.label; + font-size: 24px; + font-weight: 500; + vertical-alignment: center; + } + // Text { // width: 150px; // height: 32px;