# Node-RED flows analysis

Flows pulled from **root@10.20.30.12** (`/root/.node-red/flows.json`).  
Snapshot: Feb 8, 2026.

---

## Tabs (flow sheets)

| Tab            | Purpose (from nodes)        |
|----------------|-----------------------------|
| **Flow 1**     | CODESYS NVL (UDP), HA buttons, Room Lights subflow, dashboard links |
| Flow 2–7       | (Unnamed / per-room or feature) |
| **Living Room**| Living room–specific logic → **[Living Room flow doc](nodered-livingroom-flow.md)** |
| **Notifications** | Notifications (Telegram, etc.) |
| **Zigbee**     | Zigbee2MQTT in/out, MQTT     |
| **Scheduler** | cronplus, bigtimer, triggers |

---

## Node counts (summary)

| Category        | Node types / count |
|-----------------|--------------------|
| **UI**          | 128 ui_button, 17 ui_tab, 17 ui_group, 1 ui_base |
| **Logic**       | 59 function, 12 change, 10 switch, 17 inject, 2 trigger, 2 delay, 2 bigtimer, 3 cronplus |
| **Home Assistant** | 47 ha-entity-config, 29 ha-button, 18 ha-binary-sensor, 15 ha-device-config, 5 api-current-state, 2 api-call-service, 1 server-state-changed, 1 poll-state, 1 trigger-state, 1 ha-sensor |
| **Zigbee**      | 28 zigbee2mqtt-in, 9 zigbee2mqtt-out, 1 zigbee2mqtt-server, 1 zigbee2mqtt-get |
| **CODESYS / NVL** | 1 nvl-send, 1 nvl-receive, 1 nvl-datatypes, 1 udp in, 1 udp out |
| **Other**       | 1 server (HA WebSocket), 1 mqtt-broker, 2 mqtt in, 9 http request, 2 telegram bot, 1 telegram sender, 1 telegram receiver, 43 debug, 29 link in, 29 link out |
| **Subflows**    | Room Lights (57bd1b149526fcee), Room filter (4dc13919bcc9d676), Subflow 1 |

---

## CODESYS connectivity (Flow 1)

All NVL and UDP nodes are on tab **Flow 1** (`z": "46892ced77481340"`).

| Node      | Role | Config |
|-----------|------|--------|
| **udp out** | Send to PLC | `addr`: **10.20.30.5**, `port`: **1202** |
| **udp in**  | Receive from PLC | `port`: **1202** |
| **nvl-send** | Build NVL_In payload | Feeds **udp out**. Uses `node-red-contrib-nvl` with inline definition (struct_switches × 15 rooms + cmd_livingroom struct_room_cmds). |
| **nvl-receive** | Parse NVL_Out | Triggered by **udp in**. Definition: 15 × struct_lights + **light_livingRoom** as struct_room_outs. |

**Notes**

- PLC IP is **10.20.30.5**; Node-RED uses the same port **1202** for both sending to and receiving from the PLC (CODESYS NVL Sender and Receiver may use the same port or different; confirm in CODESYS).
- nvl-receive uses **struct_lights** (6 BOOLs) for 15 rooms and **struct_room_outs** (6 outputs + 6 status) only for `light_livingRoom`. Your `codesys/src/NVL` docs use struct_room_outs for all rooms; the flow is a subset.
- Room Lights subflow (**Room Lights**) is used from Flow 1 (and possibly Living Room) to map HA/buttons to room/light commands.

---

## Integrations

- **Home Assistant**: WebSocket **server** config; many **ha-entity-config** / **ha-device-config**; **ha-button**, **ha-binary-sensor**; **api-current-state**, **api-call-service**.
- **Zigbee2MQTT**: One **zigbee2mqtt-server**; **zigbee2mqtt-in** (28) and **zigbee2mqtt-out** (9) for device events and commands.
- **MQTT**: One **mqtt-broker**; **mqtt in** (2) for other topics.
- **Telegram**: **telegram bot** (2), **telegram sender**, **telegram receiver** for notifications.
- **Dashboard**: **node-red-dashboard** (ui_base, ui_tab, ui_group, ui_button) for a simple UI.

---

## File location

- **Flows (full export):** [nodered-flows.json](nodered-flows.json)
- **This analysis:** [nodered-flows-analysis.md](nodered-flows-analysis.md)

To refresh: from the project PC run  
`ssh root@10.20.30.12 "cat /root/.node-red/flows.json" > docs/integration/nodered-flows.json`
