feat(commands): route data.flow through the registry unit normaliser; wiki sync

- data.flow: declare unit:'m3/h' (payloadSchema any) and drop the handler's own
  convert() call — the registry now converts any number/string/{value,unit} to
  m3/h before the handler. Handler reads the normalised scalar.
- Regenerate wiki topic-contract.

data.flow integration test green.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
znetsixe
2026-05-29 18:41:33 +02:00
parent 6c88b6464d
commit 9427b64bbe
3 changed files with 12 additions and 16 deletions

View File

@@ -5,8 +5,6 @@
// handler (the legacy nodeClass did it inline) — anything else inbound
// is passed straight through to source.handleInput.
const { convert } = require('generalFunctions');
exports.cmdStart = (source, msg) => {
source.handleInput('i_start', Boolean(msg.payload));
};
@@ -20,17 +18,15 @@ exports.setRain = (source, msg) => {
};
exports.dataFlow = (source, msg, ctx) => {
// The registry has already normalised any accepted shape (number, numeric
// string, or { value, unit }) to a number in m3/h and tagged msg.unit.
const log = ctx?.logger || source.logger;
const value = Number(msg.payload?.value);
const unit = msg.payload?.unit;
if (!Number.isFinite(value) || !unit) {
log?.warn?.('data.flow payload must include numeric value and unit.');
const value = Number(msg.payload);
if (!Number.isFinite(value)) {
log?.warn?.(`data.flow payload must be numeric, got '${JSON.stringify(msg.payload)}'.`);
return;
}
let converted = value;
try { converted = convert(value).from(unit).to('m3/h'); }
catch (err) { log?.warn?.(`data.flow unit conversion failed: ${err.message}`); return; }
source.handleInput('input_q', { value: converted, unit: 'm3/h' });
source.handleInput('input_q', { value, unit: msg.unit || 'm3/h' });
};
exports.setMode = (source, msg) => {