# Development Guide ## Architecture Overview ### Core Components 1. **Victron Config Node** - Manages D-Bus connection - Initializes core services - Maintains system configuration 2. **VictronClient** - Handles D-Bus communication - Manages message subscriptions - Maintains service cache 3. **SystemConfiguration** - Tracks available services - Provides service metadata - Manages device discovery ```mermaid graph TD A[Victron Config Node] --> B[VictronClient] A --> C[SystemConfiguration] B --> D[D-Bus] C --> E[Service Cache] ``` ## Development Environment Setup ### Prerequisites 1. Node.js (LTS version recommended) 2. Access to a GX device or simulator 3. Git 4. Basic understanding of: - Node-RED node development - D-Bus - Victron Energy systems ### Initial Setup 1. **Clone Repository** ```bash git clone https://github.com/victronenergy/node-red-contrib-victron.git cd node-red-contrib-victron ``` 2. **Install Dependencies** ```bash npm install ``` 3. **Link for Development** ```bash npm link cd ~/.node-red npm link @victronenergy/node-red-contrib-victron ``` ## Adding New Nodes ### 1. Define Service Whitelist ```javascript // scripts/service-whitelist.js module.exports = { "input-new-node": { "service_type": [ "/Path/To/Service", ] } } ``` ### 2. Generate Service Definitions ```bash node parse-services.js ./missingpaths.json ``` ### 3. Create Node Files ```javascript // src/nodes/victron-nodes.js RED.nodes.registerType('victron-input-new-node', BaseInputNode); // src/nodes/victron-nodes.html registerInputNode('victron-input-new-node', 'New Node', 'input-new-node'); ``` ### 4. Update System Configuration ```javascript // src/services/victron-system.js listAvailableServices() { return { "input-new-node": this.getNodeServices("input-new-node"), // ... } } ``` ## Testing ### Manual Testing 1. Deploy to test environment 2. Verify node behavior 3. Test error conditions 4. Validate documentation ## Release Process ### 1. Update Dependencies ```bash rm ./package-lock.json ./npm-shrinkwrap.json ./yarn.lock rm -rf ./node_modules npm install --omit=dev ``` ### 2. Version Bump ```bash npm version [major|minor|patch] ``` ### 3. Build and Test ```bash npm run build npm test ``` ### 4. Release ```bash npm run release npm publish ``` ## Documentation ### Generating Documentation Make sure you've got `moreutils` installed (for `sponge`) first. ```bash # Update node documentation ( sed '/^