diff --git a/diagrams/arch.svg b/diagrams/arch.svg index f39c32d..cca2409 100644 --- a/diagrams/arch.svg +++ b/diagrams/arch.svg @@ -29,48 +29,54 @@ Node1 - - + + Node2 - - -Node3 - - - - + + +Node3 + + + + + - + + - -i2c - -uart - -Custom TCP - -mqtt - - - - - + +i2c + +uart + +Custom TCP + +mqtt + +Custom TCP + +Custom TCP + + + + + - + -Event Proxy -Home Assistant Servier -bme280 -mc1 -pms5003 +Event Proxy +Home Assistant Servier +bme280 +pico w +pms5003 Anemometer pico w Wind Vane -MIPS Microphone +MIPS Microphone ltr-559 pico w diff --git a/diagrams/index.ts b/diagrams/index.ts index 48a3b3a..1d7bbf2 100644 --- a/diagrams/index.ts +++ b/diagrams/index.ts @@ -1,25 +1,33 @@ -import { renderMermaid } from "beautiful-mermaid"; +import { renderMermaid, renderMermaidAscii } from "beautiful-mermaid"; -const diagram = await renderMermaid(` +// Parse command line arguments +const args = process.argv.slice(2); +const renderMode = args.includes("--ascii") ? "ascii" : "normal"; + +const diagram = ` flowchart TD subgraph Node1 - bme280 -->|i2c| mc1 + bme280 -->|i2c| mc1[pico w] pms5003 -->|uart| mc1 end - mc1[pico w] -->|Custom TCP| proxy[Event Proxy] + mc1 -->|Custom TCP| proxy[Event Proxy] proxy -->|mqtt| ha[Home Assistant Servier] - mc2[pico w] --> |Custom TCP| proxy + mc2[pico w] -->|Custom TCP| proxy subgraph Node2 wind_speed[Anemometer] --> mc2 wind_dir[Wind Vane] --> mc2 mic[MIPS Microphone] --> mc2 end - mc3[pico w] --> |Custom TCP| proxy + mc3[pico w] -->|Custom TCP| proxy subgraph Node3 ltr-559 --> mc3 - end -`); -console.log(diagram); + end`; + +if (renderMode === "ascii") { + console.log(renderMermaidAscii(diagram)); +} else { + console.log(await renderMermaid(diagram)); +}