From 5422daed749dc18cceb2bc20690d52f0b5ab6193 Mon Sep 17 00:00:00 2001 From: Michael Geers Date: Fri, 9 Aug 2024 20:55:06 +0200 Subject: [PATCH] support different protocols per product --- src/generateFromTemplate.js | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/src/generateFromTemplate.js b/src/generateFromTemplate.js index c2b017775..7d3f3a54a 100644 --- a/src/generateFromTemplate.js +++ b/src/generateFromTemplate.js @@ -32,6 +32,15 @@ const TRANSLATIONS = { "tab.aux": "AUX", }; +const PROTOCOLS = { + localapi: "Local API", + cloudapi: "Cloud API", + mqtt: "MQTT", + modbus: "Modbus", + eebus: "EEBus", + ocpp: "OCPP", +}; + function escapeRegExp(text) { return text.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&"); } @@ -151,6 +160,23 @@ function generateMarkdown(data, type, target) { }, ]); + // add ` (protocol)` to non-unique products + dataSorted + .filter( + (x) => + dataSorted.filter( + (y) => + y.product.group === x.product.group && + y.product.brand === x.product.brand && + y.product.description === x.product.description, + ).length > 1, + ) + .forEach((x) => { + if (x.protocol) { + x.product.description += ` (${PROTOCOLS[x.protocol]})`; + } + }); + let generated = ""; let lastGroup = ""; let lastBrand = "";