1786890987

This commit is contained in:
2026-08-16 16:36:27 +02:00
parent a9b4e75539
commit f51d4b33cb
5 changed files with 96 additions and 8 deletions

85
Cargo.lock generated
View File

@@ -352,6 +352,23 @@ version = "0.23.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ac07cdecf99051d9a5238b80f35af32cdeba5b336e55d957b318b50137e18da5" checksum = "ac07cdecf99051d9a5238b80f35af32cdeba5b336e55d957b318b50137e18da5"
[[package]]
name = "battery"
version = "0.7.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b4b624268937c0e0a3edb7c27843f9e547c320d730c610d3b8e6e8e95b2026e4"
dependencies = [
"cfg-if",
"core-foundation 0.7.0",
"lazycell",
"libc",
"mach",
"nix 0.19.1",
"num-traits",
"uom",
"winapi",
]
[[package]] [[package]]
name = "bincode" name = "bincode"
version = "2.0.1" version = "2.0.1"
@@ -738,16 +755,32 @@ dependencies = [
"x11-clipboard", "x11-clipboard",
] ]
[[package]]
name = "core-foundation"
version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "57d24c7a13c43e870e37c1556b74555437870a04514f7685f5b354e090567171"
dependencies = [
"core-foundation-sys 0.7.0",
"libc",
]
[[package]] [[package]]
name = "core-foundation" name = "core-foundation"
version = "0.9.4" version = "0.9.4"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "91e195e091a93c46f7102ec7818a2aa394e1e1771c3ab4825963fa03e45afb8f" checksum = "91e195e091a93c46f7102ec7818a2aa394e1e1771c3ab4825963fa03e45afb8f"
dependencies = [ dependencies = [
"core-foundation-sys", "core-foundation-sys 0.8.7",
"libc", "libc",
] ]
[[package]]
name = "core-foundation-sys"
version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b3a71ab494c0b5b860bdc8407ae08978052417070c2ced38573a9157ad75b8ac"
[[package]] [[package]]
name = "core-foundation-sys" name = "core-foundation-sys"
version = "0.8.7" version = "0.8.7"
@@ -761,7 +794,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c07782be35f9e1140080c6b96f0d44b739e2278479f64e02fdab4e32dfd8b081" checksum = "c07782be35f9e1140080c6b96f0d44b739e2278479f64e02fdab4e32dfd8b081"
dependencies = [ dependencies = [
"bitflags 1.3.2", "bitflags 1.3.2",
"core-foundation", "core-foundation 0.9.4",
"core-graphics-types", "core-graphics-types",
"foreign-types", "foreign-types",
"libc", "libc",
@@ -774,7 +807,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "45390e6114f68f718cc7a830514a96f903cccd70d02a8f6d9f643ac4ba45afaf" checksum = "45390e6114f68f718cc7a830514a96f903cccd70d02a8f6d9f643ac4ba45afaf"
dependencies = [ dependencies = [
"bitflags 1.3.2", "bitflags 1.3.2",
"core-foundation", "core-foundation 0.9.4",
"libc", "libc",
] ]
@@ -784,7 +817,7 @@ version = "20.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c9d2790b5c08465d49f8dc05c8bcae9fea467855947db39b0f8145c091aaced5" checksum = "c9d2790b5c08465d49f8dc05c8bcae9fea467855947db39b0f8145c091aaced5"
dependencies = [ dependencies = [
"core-foundation", "core-foundation 0.9.4",
"core-graphics", "core-graphics",
"foreign-types", "foreign-types",
"libc", "libc",
@@ -898,6 +931,7 @@ checksum = "f27ae1dd37df86211c42e150270f82743308803d90a6f6e6651cd730d5e1732f"
name = "dashboard" name = "dashboard"
version = "0.1.0" version = "0.1.0"
dependencies = [ dependencies = [
"battery",
"chrono", "chrono",
"dotenvy", "dotenvy",
"hass-rs", "hass-rs",
@@ -1339,7 +1373,7 @@ checksum = "2c7e611d49285d4c4b2e1727b72cf05353558885cc5252f93707b845dfcaf3d3"
dependencies = [ dependencies = [
"bitflags 2.13.1", "bitflags 2.13.1",
"byteorder", "byteorder",
"core-foundation", "core-foundation 0.9.4",
"core-graphics", "core-graphics",
"core-text", "core-text",
"dirs", "dirs",
@@ -2124,7 +2158,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e31bc9ad994ba00e440a8aa5c9ef0ec67d5cb5e5cb0cc7f8b744a35b389cc470" checksum = "e31bc9ad994ba00e440a8aa5c9ef0ec67d5cb5e5cb0cc7f8b744a35b389cc470"
dependencies = [ dependencies = [
"android_system_properties", "android_system_properties",
"core-foundation-sys", "core-foundation-sys 0.8.7",
"iana-time-zone-haiku", "iana-time-zone-haiku",
"js-sys", "js-sys",
"log", "log",
@@ -2595,6 +2629,12 @@ version = "1.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe"
[[package]]
name = "lazycell"
version = "1.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55"
[[package]] [[package]]
name = "lebe" name = "lebe"
version = "0.5.3" version = "0.5.3"
@@ -2771,6 +2811,15 @@ dependencies = [
"num-traits", "num-traits",
] ]
[[package]]
name = "mach"
version = "0.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b823e83b2affd8f40a9ee8c29dbc56404c1e34cd2710921f2801e2cf29527afa"
dependencies = [
"libc",
]
[[package]] [[package]]
name = "maybe-rayon" name = "maybe-rayon"
version = "0.1.1" version = "0.1.1"
@@ -2903,6 +2952,18 @@ version = "1.0.6"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "650eef8c711430f1a879fdd01d4745a7deea475becfb90269c06775983bbf086" checksum = "650eef8c711430f1a879fdd01d4745a7deea475becfb90269c06775983bbf086"
[[package]]
name = "nix"
version = "0.19.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b2ccba0cfe4fdf15982d1674c69b1fd80bad427d293849982668dfe454bd61f2"
dependencies = [
"bitflags 1.3.2",
"cc",
"cfg-if",
"libc",
]
[[package]] [[package]]
name = "nix" name = "nix"
version = "0.29.0" version = "0.29.0"
@@ -5258,6 +5319,16 @@ version = "0.0.4"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6d49784317cd0d1ee7ec5c716dd598ec5b4483ea832a2dced265471cc0f690ae" checksum = "6d49784317cd0d1ee7ec5c716dd598ec5b4483ea832a2dced265471cc0f690ae"
[[package]]
name = "uom"
version = "0.30.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e76503e636584f1e10b9b3b9498538279561adcef5412927ba00c2b32c4ce5ed"
dependencies = [
"num-traits",
"typenum",
]
[[package]] [[package]]
name = "ureq" name = "ureq"
version = "3.4.0" version = "3.4.0"
@@ -5835,7 +5906,7 @@ dependencies = [
"calloop 0.13.0", "calloop 0.13.0",
"cfg_aliases", "cfg_aliases",
"concurrent-queue", "concurrent-queue",
"core-foundation", "core-foundation 0.9.4",
"core-graphics", "core-graphics",
"cursor-icon", "cursor-icon",
"dpi", "dpi",

3
build
View File

@@ -7,7 +7,8 @@ fi
ssh -t trekstor -- "systemctl --user stop dashboard" ssh -t trekstor -- "systemctl --user stop dashboard"
scp target/release/dashboard trekstor:~/dashboard scp target/release/dashboard trekstor:~/dashboard
ssh -t trekstor -- "systemctl --user start dashboard" # ssh -t trekstor -- "systemctl --user start dashboard"
ssh -t trekstor -- "~/dashboard"
git add . git add .
git commit -am "$(date +%s)" git commit -am "$(date +%s)"

View File

@@ -17,6 +17,7 @@ paste = "1.0.15"
ureq = { version = "3.4.0", default-features = false, features = ["json", "rustls"] } ureq = { version = "3.4.0", default-features = false, features = ["json", "rustls"] }
serde = { version = "1.0.229", features = ["derive"] } serde = { version = "1.0.229", features = ["derive"] }
plotters = "0.3.7" plotters = "0.3.7"
battery = "0.7.8"
[features] [features]
dev = ["slint/backend-winit-x11"] dev = ["slint/backend-winit-x11"]

View File

@@ -17,4 +17,7 @@ pub enum AppError {
#[error(transparent)] #[error(transparent)]
HomeAssistant(#[from] Box<hass_rs::HassError>), HomeAssistant(#[from] Box<hass_rs::HassError>),
#[error(transparent)]
Battery(#[from] battery::Error),
} }

View File

@@ -19,6 +19,18 @@ use crate::{
async fn main() -> Result<(), AppError> { async fn main() -> Result<(), AppError> {
dotenvy::dotenv().ok(); dotenvy::dotenv().ok();
let manager = battery::Manager::new()?;
for (idx, maybe_battery) in manager.batteries()?.enumerate() {
let battery = maybe_battery?;
println!("Battery #{}:", idx);
println!("Vendor: {:?}", battery.vendor());
println!("Model: {:?}", battery.model());
println!("State: {:?}", battery.state());
println!("Time to full charge: {:?}", battery.time_to_full());
println!();
}
#[cfg(not(feature = "dev"))] #[cfg(not(feature = "dev"))]
slint::platform::set_platform(Box::new(trekstor::Trekstor::new())).expect("set platform"); slint::platform::set_platform(Box::new(trekstor::Trekstor::new())).expect("set platform");