From 107e7fdc89ac2a2e86be508ef4e6bf4552e3378d Mon Sep 17 00:00:00 2001 From: Avii Date: Sat, 8 Aug 2026 13:56:02 +0200 Subject: [PATCH] $(date +%s) --- dashboard/src/ha_ext.rs | 30 +++++-- dashboard/ui/climate.slint | 158 ++++++++++++++++++++----------------- 2 files changed, 110 insertions(+), 78 deletions(-) diff --git a/dashboard/src/ha_ext.rs b/dashboard/src/ha_ext.rs index e102b33..65f15cc 100644 --- a/dashboard/src/ha_ext.rs +++ b/dashboard/src/ha_ext.rs @@ -77,16 +77,36 @@ impl From<&HassEntity> for DateTimeData { } } +/* +temperature: float, +dew_point: float, +temperature_unit: string, +humidity: int, +cloud_coverage: int, +uv_index: float, +pressure: float, +pressure_unit: string, +wind_bearing: float, +wind_speed: float, +wind_speed_unit: string, +visibility_unit: string, +precipitation_unit: string, +attribution: string, +friendly_name: string, +supported_features: int +*/ impl From<&HassEntity> for WeatherData { fn from(value: &HassEntity) -> Self { - let outside_temperature = value + let temperature = value .attributes - .get("outside_temperature") - .unwrap_or_default() - .to_shared_string(); + .get("temperature") + .and_then(|x| x.as_f64()) + .unwrap_or_default() as f32; + + todo!(); Self { - outside_temperature, + temperature, outside_high: todo!(), outside_condition: todo!(), weather_kind: todo!(), diff --git a/dashboard/ui/climate.slint b/dashboard/ui/climate.slint index 655e741..c0f2628 100644 --- a/dashboard/ui/climate.slint +++ b/dashboard/ui/climate.slint @@ -6,10 +6,22 @@ in property : "cloud"; */ export struct WeatherData { - outside-temperature: string, - outside-high: string, - outside-condition: string, - weather-kind: string, + temperature: float, + dew_point: float, + temperature_unit: string, + humidity: int, + cloud_coverage: int, + uv_index: float, + pressure: float, + pressure_unit: string, + wind_bearing: float, + wind_speed: float, + wind_speed_unit: string, + visibility_unit: string, + precipitation_unit: string, + attribution: string, + friendly_name: string, + supported_features: int, } export component Climate inherits Rectangle { @@ -17,79 +29,79 @@ export component Climate inherits Rectangle { Text { width: 300px; height: 116px; - text: weather.outside-temperature; + text: "\{weather.temperature}\{weather.temperature-unit}"; 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; - } + // 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; - } + // 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; + // } }