$(date +%s)

This commit is contained in:
2026-08-08 13:56:02 +02:00
parent 73b0659ffd
commit 107e7fdc89
2 changed files with 110 additions and 78 deletions

View File

@@ -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!(),

View File

@@ -6,10 +6,22 @@ in property <string> : "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;
// }
}