From a3c8e2cf0cce7d4a145c1d9fe4c1c66150c5d3d3 Mon Sep 17 00:00:00 2001 From: Frank Gehann Date: Thu, 20 Aug 2026 12:51:11 +0200 Subject: [PATCH] feat(collector): point at the setting when DC power is missing MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit An inverter that never sends DcMsWatt — the SB 2500 among them — has its string power stored as zero. The device statistics then show 0 W beside a real 372 V and 1.24 A, and the average efficiency stays empty, with nothing saying why. SBFspot covers this with CalculateMissingSpotValues, and smalog has the same option in service.calc_missing_spot, off by default; there was just no way to find out that it is what is missing. The collector now logs a hint, once per inverter, when a tracker reports voltage and current but no power and the option is off. The arithmetic it points at is unchanged and matches SBFspot: 37200 · 1240 / 100000 = 461 W for the inverter above. Documented in the configuration reference and under "diagnosing a silent inverter", including how to tell a refused query from one that answered with zeros. --- docs/configuration.md | 2 +- docs/operations.md | 21 ++++++++ src/crates/smalog-connection/src/collector.rs | 13 +++++ .../src/smadata2/inverter.rs | 50 +++++++++++++++++++ 4 files changed, 85 insertions(+), 1 deletion(-) diff --git a/docs/configuration.md b/docs/configuration.md index bd16ca8..816683f 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -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`. | diff --git a/docs/operations.md b/docs/operations.md index afbf8c3..25c57d0 100644 --- a/docs/operations.md +++ b/docs/operations.md @@ -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 diff --git a/src/crates/smalog-connection/src/collector.rs b/src/crates/smalog-connection/src/collector.rs index 4d25210..416b0f8 100644 --- a/src/crates/smalog-connection/src/collector.rs +++ b/src/crates/smalog-connection/src/collector.rs @@ -57,6 +57,9 @@ pub struct Collector { /// This session's refusals, loaded from `support` once the devices are /// known: serial → query identifiers. refused: HashMap>, + /// 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, } impl Collector { @@ -72,6 +75,7 @@ impl Collector { sink: None, support: None, refused: HashMap::new(), + dc_power_hinted: BTreeSet::new(), } } @@ -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(); } diff --git a/src/crates/smalog-connection/src/smadata2/inverter.rs b/src/crates/smalog-connection/src/smadata2/inverter.rs index 6c32087..5ce30e9 100644 --- a/src/crates/smalog-connection/src/smadata2/inverter.rs +++ b/src/crates/smalog-connection/src/smadata2/inverter.rs @@ -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; @@ -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()); + } +}