From 29b78a3f9b432985425b9713f3a3988749a89c16 Mon Sep 17 00:00:00 2001 From: znetsixe Date: Mon, 13 Apr 2026 15:53:21 +0200 Subject: [PATCH] fix(childRegistrationUtils): alias rotatingmachine/machinegroupcontrol so production parents see them The MGC and pumpingStation registerChild handlers dispatch on softwareType === 'machine' / 'machinegroup' / 'pumpingstation' / 'measurement'. But buildConfig sets functionality.softwareType to the lowercased node name, so in production rotatingMachine reports 'rotatingmachine' and machineGroupControl reports 'machinegroupcontrol'. Result: the MGC <-> rotatingMachine and pumpingStation <-> MGC wiring silently never hit the right branch in production, even though every unit test passes (tests pass an already-aliased softwareType manually). Fix: tiny SOFTWARE_TYPE_ALIASES map at the central registerChild dispatcher in childRegistrationUtils. Real production names get translated to the dispatch keys parents already check for, while tests that pass already-aliased keys are unaffected (their values aren't in the alias map and pass through unchanged). rotatingmachine -> machine machinegroupcontrol -> machinegroup Verified end-to-end on Dockerized Node-RED: MGC now reports '3 machine(s) connected' when wired to 3 rotatingMachine ports; pumpingStation registers MGC as a machinegroup child and listens to its predicted-flow stream. Co-Authored-By: Claude Opus 4.6 (1M context) --- src/helper/childRegistrationUtils.js | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/helper/childRegistrationUtils.js b/src/helper/childRegistrationUtils.js index 191f5f6..f6a3827 100644 --- a/src/helper/childRegistrationUtils.js +++ b/src/helper/childRegistrationUtils.js @@ -1,3 +1,17 @@ +// Map a child's raw softwareType (the lowercased node name from +// buildConfig) to the "role" key that parent registerChild() handlers +// dispatch on. Without this, MGC/pumpingStation register-handlers (which +// branch on 'machine' / 'machinegroup' / 'pumpingstation' / 'measurement') +// silently miss every real production child because rotatingMachine +// reports softwareType='rotatingmachine' and machineGroupControl reports +// 'machinegroupcontrol'. Existing tests that pass already-aliased keys +// ('machine', 'machinegroup') stay green because those aren't in the +// alias map and pass through unchanged. +const SOFTWARE_TYPE_ALIASES = { + rotatingmachine: 'machine', + machinegroupcontrol: 'machinegroup', +}; + class ChildRegistrationUtils { constructor(mainClass) { this.mainClass = mainClass; @@ -15,7 +29,8 @@ class ChildRegistrationUtils { return false; } - const softwareType = (child.config.functionality.softwareType || '').toLowerCase(); + const rawSoftwareType = (child.config.functionality.softwareType || '').toLowerCase(); + const softwareType = SOFTWARE_TYPE_ALIASES[rawSoftwareType] || rawSoftwareType; const name = child.config.general.name || child.config.general.id || 'unknown'; const id = child.config.general.id || name;