Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ Optional. Controls the poll loop and the HTTP status endpoint.
| `timezone` | string | `"UTC"` | IANA timezone name (e.g. `Europe/Brussels`). Used for day boundaries, archive timestamps and view localization. Must be a name recognized by the timezone database. |
| `listen` | string (socket addr) | *(unset → disabled)* | Address for the `/healthz` and `/status` HTTP endpoints, e.g. `0.0.0.0:8080`. Omit to disable the HTTP server. Required if you use the [`healthcheck`](operations.md#healthcheck) subcommand. |
| `poll_at_night` | bool | `false` | When `false`, polling only happens between sunrise and sunset (plus [`sun_rs_offset`](#plant) slack). Set `true` to poll around the clock. |
| `calc_missing_spot` | bool | `false` | SBFspot `CalcMissingSpot`: derive missing Pdc/Pac values from voltage × current when the inverter reports zero. |
| `calc_missing_spot` | bool | `false` | SBFspot `CalculateMissingSpotValues`: derive missing Pdc/Pac values from voltage × current when the inverter reports zero. **Set this if a tracker shows 0 W beside a real DC voltage and current** — older inverters such as the SB 2500 never send `DcMsWatt`, and their string power (and with it the efficiency) stays empty without it. The service logs a hint when it sees that combination. |
| `poll_consumption` | bool | `false` | Poll the inverter's consumer-power LRIs (`MeteringCsmpTotWIn` / `TotWhIn`) and fill canonical `site_consumption_measurements`. Not in SBFspot, which never queries these; only useful with an SMA consumption meter attached (inverters without one report "LRI not available"). |
| `transmission_log_retention_hours` | integer (hours) | `48` | How long recorded inverter exchanges are kept for the dashboard's System area. `0` switches recording off; rows already stored are **not** deleted. Must be `0`–`8760`. |
| `application_log_retention_hours` | integer (hours) | `48` | How long captured application log records are kept **in the service's memory**. They are never written to the database and are lost on restart. `0` switches capture off entirely. Must be `0`–`8760`. |
Expand Down
21 changes: 21 additions & 0 deletions docs/operations.md
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,27 @@ what stdout already receives) but it is new reach. Keep the dashboard behind a
reverse proxy if it is exposed, and set
`service.application_log_retention_hours = 0` to switch capture off entirely.

### A tracker shows 0 W with voltage and current present

Some inverters never report DC power (`DcMsWatt`) — the SB 2500 is one. Their
string power is stored as zero, so the device statistics show `0,00 W` beside a
perfectly real `372,00 V` and `1,24 A`, and the average efficiency stays empty
because it has no DC side to divide by.

That is what `service.calc_missing_spot` is for: with it set, Pdc is derived as
`Udc × Idc`, exactly as SBFspot's `CalculateMissingSpotValues` does. It also
fills per-phase Pac and, from those, the total.

```toml
[service]
calc_missing_spot = true
```

The service logs the hint once per inverter when it sees voltage and current
without power. Whether the inverter answered the query at all is visible under
**System → Transmissions**, filtered to `spot.dc_power`: `nicht verfügbar`
means it refused, `ok` means it answered — with zeros.

## The poll loop

### Wall-clock-aligned ticks
Expand Down
13 changes: 13 additions & 0 deletions src/crates/smalog-connection/src/collector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ pub struct Collector {
/// This session's refusals, loaded from `support` once the devices are
/// known: serial → query identifiers.
refused: HashMap<u32, BTreeSet<String>>,
/// Serials already told about their missing DC power, so the hint is
/// logged once per process instead of once per poll cycle.
dc_power_hinted: BTreeSet<u32>,
}

impl Collector {
Expand All @@ -72,6 +75,7 @@ impl Collector {
sink: None,
support: None,
refused: HashMap::new(),
dc_power_hinted: BTreeSet::new(),
}
}

Expand Down Expand Up @@ -605,6 +609,15 @@ impl Collector {
for inv in &mut self.inverters {
if calc {
calc_missing_spot(inv);
} else if inv.dc_power_missing() && self.dc_power_hinted.insert(inv.serial) {
// Silently storing zero would look like a dead string, and
// the number to fix it is one the operator has to set.
warn!(
serial = inv.serial,
"inverter reports DC voltage and current but no DC power; \
set service.calc_missing_spot = true to derive it (SBFspot \
CalculateMissingSpotValues)"
);
}
inv.calc_derived();
}
Expand Down
50 changes: 50 additions & 0 deletions src/crates/smalog-connection/src/smadata2/inverter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,20 @@ impl InverterData {
self.configured_name.as_deref().unwrap_or(&self.device_name)
}

/// True when a tracker reports DC voltage and current but no DC power.
///
/// Some inverters — the SB 2500 among them — never send `DcMsWatt`. Their
/// DC power is then stored as zero, which reads as "the string produced
/// nothing" even though voltage times current says otherwise. SBFspot
/// calls that a missing value and derives it (`CalculateMissingSpotValues`
/// / `service.calc_missing_spot`), so this is what the collector points at
/// when the option is off.
pub fn dc_power_missing(&self) -> bool {
self.mpp
.values()
.any(|tracker| tracker.pdc == 0 && tracker.udc > 0 && tracker.idc > 0)
}

/// CalcMissingSpot + calPacTot/calEfficiency (SBFspot Inverter.cpp).
pub fn calc_derived(&mut self) {
self.cal_pac_tot = self.pac1 + self.pac2 + self.pac3;
Expand Down Expand Up @@ -394,3 +408,39 @@ impl InverterData {
)
}
}

/// The DC-power gap some inverters leave, and what the collector makes of it.
#[cfg(test)]
mod dc_power_tests {
use super::*;

fn with_tracker(pdc: i32, udc: i32, idc: i32) -> InverterData {
let mut inv = InverterData::new(String::new());
inv.mpp.insert(1, Mppt { pdc, udc, idc });
inv
}

#[test]
fn voltage_and_current_without_power_is_a_missing_value() {
// The SB 2500 in the field: 372.00 V, 1.24 A, no DcMsWatt.
assert!(with_tracker(0, 37_200, 1_240).dc_power_missing());
}

#[test]
fn a_string_that_is_genuinely_dark_is_not_a_missing_value() {
assert!(!with_tracker(0, 0, 0).dc_power_missing());
}

#[test]
fn a_reported_power_is_not_missing() {
assert!(!with_tracker(461, 37_200, 1_240).dc_power_missing());
}

#[test]
fn deriving_it_matches_sbfspots_arithmetic() {
let mut inv = with_tracker(0, 37_200, 1_240);
crate::collector::calc_missing_spot(&mut inv);
assert_eq!(inv.mpp[&1].pdc, 461);
assert!(!inv.dc_power_missing());
}
}