13 Commits

Author SHA1 Message Date
8398bb17ed Fix dependencies conflict
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/tag Build is passing
2025-12-09 14:00:02 +01:00
cfcb7a0ebb Merge branch 'master' of ssh://gitea.communiquons.org:52001/pierre/SolarEnergy
Some checks failed
continuous-integration/drone/push Build is failing
2025-12-09 13:55:10 +01:00
ff47f86792 Can check if relay is online or not 2025-12-09 14:54:01 +01:00
465477e862 Merge pull request 'Update dependency @typescript-eslint/eslint-plugin to ^8.49.0' (#384) from renovate/typescript-eslint-eslint-plugin-8.x into master
Some checks failed
continuous-integration/drone/push Build is failing
2025-12-09 00:36:12 +00:00
6075085b0b Update dependency @typescript-eslint/eslint-plugin to ^8.49.0
Some checks failed
renovate/artifacts Artifact file update failure
continuous-integration/drone/push Build is failing
continuous-integration/drone/pr Build is failing
2025-12-09 00:36:02 +00:00
c469d49ff7 Update custom consumption dependencies
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/tag Build is passing
2025-12-08 20:45:04 +01:00
45ece6d052 Add anonymous route to get access to all relays at once
Some checks failed
continuous-integration/drone/push Build is failing
2025-12-08 20:16:57 +01:00
fee7841253 Update frontend dependencies 2025-12-08 18:52:29 +01:00
af69a3f1d9 Updated backend dependencies 2025-12-08 15:36:31 +01:00
c30e2327e0 Merge pull request 'Update dependency typescript-eslint to ^8.48.1' (#383) from renovate/typescript-eslint-8.x into master
Some checks failed
continuous-integration/drone/push Build is failing
2025-12-07 00:35:45 +00:00
15dc46ae54 Update dependency typescript-eslint to ^8.48.1
Some checks failed
continuous-integration/drone/push Build is failing
continuous-integration/drone/pr Build is failing
2025-12-07 00:35:41 +00:00
0afe2e877a Merge pull request 'Update dependency @typescript-eslint/parser to ^8.48.1' (#382) from renovate/typescript-eslint-parser-8.x into master
Some checks failed
continuous-integration/drone/push Build is failing
2025-12-06 00:35:23 +00:00
29338a4a5e Update dependency @typescript-eslint/parser to ^8.48.1
Some checks failed
continuous-integration/drone/push Build is failing
continuous-integration/drone/pr Build is failing
2025-12-05 00:22:33 +00:00
9 changed files with 2088 additions and 1744 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -4,7 +4,7 @@ version = "1.0.3"
edition = "2024"
[dependencies]
log = "0.4.28"
log = "0.4.29"
env_logger = "0.11.8"
lazy_static = "1.5.0"
dotenvy = "0.15.7"
@@ -13,7 +13,7 @@ anyhow = "1.0.100"
thiserror = "2.0.17"
openssl = { version = "0.10.75" }
openssl-sys = "0.9.111"
libc = "0.2.177"
libc = "0.2.178"
foreign-types-shared = "0.1.1"
asn1 = "0.23.0"
actix-web = { version = "4.12.1", features = ["openssl"] }
@@ -29,14 +29,14 @@ actix-cors = "0.7.1"
actix-multipart = { version = "0.7.2", features = ["derive"] }
actix-remote-ip = "0.1.0"
futures-util = "0.3.31"
uuid = { version = "1.18.1", features = ["v4", "serde"] }
uuid = { version = "1.19.0", features = ["v4", "serde"] }
semver = { version = "1.0.27", features = ["serde"] }
lazy-regex = "3.4.2"
tokio = { version = "1.48.0", features = ["full"] }
tokio_schedule = "0.3.2"
mime_guess = "2.0.5"
rust-embed = "8.8.0"
jsonwebtoken = { version = "10.1.0", features = ["use_pem", "rust_crypto"] }
rust-embed = "8.9.0"
jsonwebtoken = { version = "10.2.0", features = ["use_pem", "rust_crypto"] }
prettytable-rs = "0.10.0"
chrono = "0.4.42"
serde_yml = "0.0.12"

View File

@@ -389,7 +389,7 @@ impl Handler<SynchronizeDevice> for EnergyActor {
pub struct ResDevState {
pub id: DeviceId,
last_ping: u64,
online: bool,
pub online: bool,
}
/// Get the state of devices

View File

@@ -48,6 +48,10 @@ pub async fn unsecure_server(energy_actor: EnergyActorAddr) -> anyhow::Result<()
"/relay/{id}/legacy_state",
web::get().to(unsecure_relay_controller::legacy_state),
)
.route(
"/relay/relays_full_state",
web::get().to(unsecure_relay_controller::relays_full_state),
)
})
.bind(&AppConfig::get().unsecure_listen_address)?
.run()

View File

@@ -1,5 +1,6 @@
use crate::devices::device::DeviceRelayID;
use crate::energy::{energy_actor, relay_state_history};
use crate::energy::engine::RelayForcedState;
use crate::energy::{consumption, energy_actor, relay_state_history};
use crate::server::WebEnergyActor;
use crate::server::custom_error::HttpResult;
use actix_web::{HttpResponse, web};
@@ -58,3 +59,78 @@ pub async fn legacy_state(
required_uptime: relay.daily_runtime.map(|r| r.min_runtime).unwrap_or(0),
}))
}
#[derive(serde::Serialize)]
pub struct FullRelayState {
/// Indicates if the relay (or its parent device) is enabled or not
enabled: bool,
/// Indicate if the device is online or not
online: bool,
/// Indicates if relay is on or off
is_on: bool,
/// Relay name
name: String,
/// Relay priority (0 = lowest)
priority: usize,
/// Duration since last change of state
r#for: usize,
/// Total uptime since last reset
total_uptime: usize,
/// Required uptime during a day (in seconds)
daily_requirement: Option<usize>,
/// Forced relay state
relay_forced_state: RelayForcedState,
}
#[derive(serde::Serialize)]
pub struct RelaysFullState {
/// Current global consumption, if successful
curr_consumption: Option<i32>,
/// Cached consumption
cached_consumption: i32,
/// Total relays consumptions
relays_consumption: usize,
/// Individual relays state
relays: Vec<FullRelayState>,
}
pub async fn relays_full_state(energy_actor: WebEnergyActor) -> HttpResult {
let cached_consumption = energy_actor.send(energy_actor::GetCurrConsumption).await?;
let relays_consumption = energy_actor.send(energy_actor::RelaysConsumption).await?;
let curr_consumption = consumption::get_curr_consumption().await.ok();
let devices = energy_actor.send(energy_actor::GetDeviceLists).await?;
let devices_state = energy_actor.send(energy_actor::GetDevicesState).await?;
let mut relays = energy_actor.send(energy_actor::GetRelaysList).await?;
relays.sort_by_key(|r| -(r.priority as i64));
let relays_state = energy_actor.send(energy_actor::GetAllRelaysState).await?;
Ok(HttpResponse::Ok().json(RelaysFullState {
curr_consumption,
cached_consumption,
relays_consumption,
relays: relays
.into_iter()
.map(|r| {
let device = devices
.iter()
.find(|d| d.relays.iter().any(|sr| sr.id == r.id))
.expect("All relay shall have an associated device!");
let device_state = devices_state.iter().find(|s| s.id == device.id);
let relay_state = relays_state.iter().find(|s| s.id == r.id);
FullRelayState {
enabled: r.enabled && device.enabled,
online: device_state.map(|d| d.online).unwrap_or(false),
is_on: relay_state.map(|s| s.on).unwrap_or(false),
name: r.name,
priority: r.priority,
r#for: relay_state.map(|s| s.r#for).unwrap_or(0),
total_uptime: 0,
daily_requirement: r.daily_runtime.map(|r| r.min_runtime),
relay_forced_state: relay_state
.map(|s| s.forced_state.clone())
.unwrap_or_default(),
}
})
.collect(),
}))
}

File diff suppressed because it is too large Load Diff

View File

@@ -15,31 +15,31 @@
"@fontsource/roboto": "^5.2.9",
"@mdi/js": "^7.4.47",
"@mdi/react": "^1.6.1",
"@mui/icons-material": "^7.3.5",
"@mui/material": "^7.3.5",
"@mui/x-charts": "^8.20.0",
"@mui/x-date-pickers": "^8.19.0",
"@mui/icons-material": "^7.3.6",
"@mui/material": "^7.3.6",
"@mui/x-charts": "^8.21.0",
"@mui/x-date-pickers": "^8.21.0",
"date-and-time": "^4.1.1",
"dayjs": "^1.11.19",
"filesize": "^11.0.13",
"react": "^19.2.0",
"react-dom": "^19.2.0",
"react-router-dom": "^7.9.6",
"react": "^19.2.1",
"react-dom": "^19.2.1",
"react-router-dom": "^7.10.1",
"semver": "^7.7.3"
},
"devDependencies": {
"@types/react": "^19.2.7",
"@types/react-dom": "^19.2.3",
"@types/semver": "^7.7.1",
"@typescript-eslint/eslint-plugin": "^8.48.1",
"@typescript-eslint/parser": "^8.48.0",
"@vitejs/plugin-react": "^5.1.1",
"@typescript-eslint/eslint-plugin": "^8.49.0",
"@typescript-eslint/parser": "^8.49.0",
"@vitejs/plugin-react": "^5.1.2",
"eslint": "^9.39.1",
"eslint-plugin-react-hooks": "^7.0.1",
"eslint-plugin-react-refresh": "^0.4.24",
"globals": "^16.5.0",
"typescript": "^5.9.3",
"typescript-eslint": "^8.48.0",
"vite": "^7.2.6"
"typescript-eslint": "^8.49.0",
"vite": "^7.2.7"
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -5,8 +5,8 @@ edition = "2024"
[dependencies]
env_logger = "0.11.8"
log = "0.4.28"
log = "0.4.29"
clap = { version = "4.5.53", features = ["derive", "env"] }
egui = "0.33.2"
eframe = "0.32.3"
eframe = "0.33.2"
lazy_static = "1.5.0"