1786272593
This commit is contained in:
@@ -5,13 +5,29 @@ use std::sync::{Arc, RwLock};
|
||||
use dotenvy::var;
|
||||
use hass_rs::{HassClient, HassEntity};
|
||||
use serde_json::{Value, json};
|
||||
use slint::language::ColorScheme;
|
||||
use slint::{ModelRc, VecModel, Weak};
|
||||
use tokio::sync::mpsc::{self, UnboundedReceiver, UnboundedSender};
|
||||
|
||||
slint::include_modules!();
|
||||
|
||||
fn apply_state(app: &Weak<AppWindow>, state: State) {
|
||||
app.upgrade_in_event_loop(move |app| {
|
||||
// Light/Dark mode
|
||||
//
|
||||
if let Some(illuminance) = state
|
||||
.get("sensor.living_room_motion_sensor_illuminance")
|
||||
.as_ref()
|
||||
&& let Ok(illuminance) = illuminance.state.parse::<i32>()
|
||||
{
|
||||
let scheme = if illuminance < 100 {
|
||||
ColorScheme::Dark
|
||||
} else {
|
||||
ColorScheme::Light
|
||||
};
|
||||
|
||||
app.set_color_scheme(scheme);
|
||||
}
|
||||
|
||||
// Lights
|
||||
let lights = state
|
||||
.domain("light")
|
||||
|
||||
@@ -44,12 +44,6 @@ export struct DateTimeData {
|
||||
component Clock {
|
||||
in property <DateTimeData> date-time;
|
||||
|
||||
TouchArea {
|
||||
clicked => {
|
||||
Palette.color-scheme = Palette.color-scheme == ColorScheme.dark ? ColorScheme.light : ColorScheme.dark;
|
||||
}
|
||||
}
|
||||
|
||||
VerticalLayout {
|
||||
alignment: center;
|
||||
padding-left: 5px;
|
||||
@@ -129,8 +123,9 @@ export component AppWindow inherits Window {
|
||||
height: 600px;
|
||||
default-font-size: 16px;
|
||||
|
||||
in property <DateTimeData> date-time;
|
||||
in-out property <ColorScheme> color-scheme <=> Palette.color-scheme;
|
||||
|
||||
in property <DateTimeData> date-time;
|
||||
in property <[ThermostatData]> thermostats;
|
||||
in property <WeatherData> weather;
|
||||
in property <bool> is-night;
|
||||
|
||||
Reference in New Issue
Block a user