1786189262
@@ -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!(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,6 +37,11 @@ fn apply_state(app: &Weak<AppWindow>, 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();
|
||||
}
|
||||
|
||||
@@ -1,3 +1,95 @@
|
||||
export component Climate inherits Rectangle {
|
||||
// ..
|
||||
/*
|
||||
in property <string> : "--";
|
||||
in property <string> : "HIGH --";
|
||||
in property <string> : "CONNECTING";
|
||||
in property <string> : "cloud";
|
||||
*/
|
||||
|
||||
export struct WeatherData {
|
||||
outside-temperature: string,
|
||||
outside-high: string,
|
||||
outside-condition: string,
|
||||
weather-kind: string,
|
||||
}
|
||||
|
||||
export component Climate inherits Rectangle {
|
||||
in property <WeatherData> 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;
|
||||
}
|
||||
}
|
||||
|
||||
3
dashboard/ui/icons/cloud-fog.svg
Normal file
@@ -0,0 +1,3 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="#000" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
||||
<path d="M4 14.899A7 7 0 1 1 15.71 8h1.79a4.5 4.5 0 0 1 2.5 8.242"/><path d="M16 17H7"/><path d="M17 21H9"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 269 B |
3
dashboard/ui/icons/cloud-lightning.svg
Normal file
@@ -0,0 +1,3 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="#000" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
||||
<path d="M6 16.326A7 7 0 1 1 15.71 8h1.79a4.5 4.5 0 0 1 .5 8.973"/><path d="m13 12-3 5h4l-3 5"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 257 B |
3
dashboard/ui/icons/cloud-moon.svg
Normal file
@@ -0,0 +1,3 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="#000" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
||||
<path d="M13 16a3 3 0 0 1 0 6H7a5 5 0 1 1 4.9-6z"/><path d="M18.376 14.512a6 6 0 0 0 3.461-4.127c.148-.625-.659-.97-1.248-.714a4 4 0 0 1-5.259-5.26c.255-.589-.09-1.395-.716-1.248a6 6 0 0 0-4.594 5.36"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 363 B |
3
dashboard/ui/icons/cloud-rain-wind.svg
Normal file
@@ -0,0 +1,3 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="#000" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
||||
<path d="M4 14.899A7 7 0 1 1 15.71 8h1.79a4.5 4.5 0 0 1 2.5 8.242"/><path d="m9.2 22 3-7"/><path d="m9 13-3 7"/><path d="m17 13-3 7"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 295 B |
3
dashboard/ui/icons/cloud-rain.svg
Normal file
@@ -0,0 +1,3 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="#000" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
||||
<path d="M4 14.899A7 7 0 1 1 15.71 8h1.79a4.5 4.5 0 0 1 2.5 8.242"/><path d="M16 14v6"/><path d="M8 14v6"/><path d="M12 16v6"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 288 B |
3
dashboard/ui/icons/cloud-sun.svg
Normal file
@@ -0,0 +1,3 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="#000" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
||||
<path d="M12 2v2"/><path d="m4.93 4.93 1.41 1.41"/><path d="M20 12h2"/><path d="m19.07 4.93-1.41 1.41"/><path d="M15.947 12.65a4 4 0 0 0-5.925-4.128"/><path d="M13 22H7a5 5 0 1 1 4.9-6H13a3 3 0 0 1 0 6Z"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 366 B |
3
dashboard/ui/icons/cloud.svg
Normal file
@@ -0,0 +1,3 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="#000" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
||||
<path d="M17.5 19H9a7 7 0 1 1 6.71-9h1.79a4.5 4.5 0 1 1 0 9Z"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 224 B |
3
dashboard/ui/icons/moon.svg
Normal file
@@ -0,0 +1,3 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="#000" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
||||
<path d="M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 283 B |
3
dashboard/ui/icons/snowflake.svg
Normal file
@@ -0,0 +1,3 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="#000" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
||||
<path d="m10 20-1.25-2.5L6 18"/><path d="M10 4 8.75 6.5 6 6"/><path d="m14 20 1.25-2.5L18 18"/><path d="m14 4 1.25 2.5L18 6"/><path d="m17 21-3-6h-4"/><path d="m17 3-3 6 1.5 3"/><path d="M2 12h6.5L10 9"/><path d="m20 10-1.5 2 1.5 2"/><path d="M22 12h-6.5L14 15"/><path d="m4 10 1.5 2L4 14"/><path d="m7 21 3-6-1.5-3"/><path d="m7 3 3 6h4"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 501 B |
3
dashboard/ui/icons/sun.svg
Normal file
@@ -0,0 +1,3 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="#000" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
||||
<circle cx="12" cy="12" r="4"/><path d="M12 2v2"/><path d="M12 20v2"/><path d="m4.93 4.93 1.41 1.41"/><path d="m17.66 17.66 1.41 1.41"/><path d="M2 12h2"/><path d="M20 12h2"/><path d="m6.34 17.66-1.41 1.41"/><path d="m19.07 4.93-1.41 1.41"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 402 B |
@@ -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 <int> page: 0;
|
||||
|
||||
in property <DateTimeData> date-time;
|
||||
in property <WeatherData> 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 { }
|
||||
|
||||
|
||||