5 Commits
1.0.4 ... 1.0.5

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
4 changed files with 426 additions and 379 deletions

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

@@ -64,6 +64,8 @@ pub async fn legacy_state(
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
@@ -96,6 +98,8 @@ 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?;
@@ -107,16 +111,24 @@ pub async fn relays_full_state(energy_actor: WebEnergyActor) -> HttpResult {
relays: relays
.into_iter()
.map(|r| {
let state = relays_state.iter().find(|s| s.id == r.id);
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,
is_on: state.map(|s| s.on).unwrap_or(false),
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: state.map(|s| s.r#for).unwrap_or(0),
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: state.map(|s| s.forced_state.clone()).unwrap_or_default(),
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

@@ -31,15 +31,15 @@
"@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.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.1",
"typescript-eslint": "^8.49.0",
"vite": "^7.2.7"
}
}