# robert-ai-development/plant-watering-shelly-smt50 architecture

> Architecture diagram of the GitHub repository robert-ai-development/plant-watering-shelly-smt50, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-25). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/robert-ai-development/plant-watering-shelly-smt50
- Repository: https://github.com/robert-ai-development/plant-watering-shelly-smt50

## Overview

This repository implements local, scheduled plant irrigation on a Shelly Plus Uni: periodic sensing creates a watering job, and scheduled pump runs measure again, water in portions, and update learned pump effectiveness. Installation configures schedules and starting values; hardware checks and calibration support setup and tuning. The README documents these runtime capabilities, while sampled source mainly covers supporting tools and the mock, so links for core script behavior follow the documented workflow rather than inspected script internals.

Main entry points: [`tools/hwtest.js`](https://github.com/robert-ai-development/plant-watering-shelly-smt50/blob/main/tools/hwtest.js) (Hardware Test Driver), [`scripts/bw_install.js`](https://github.com/robert-ai-development/plant-watering-shelly-smt50/blob/main/scripts/bw_install.js) (Installer), [`scripts/bw_pump.js`](https://github.com/robert-ai-development/plant-watering-shelly-smt50/blob/main/scripts/bw_pump.js) (Portioning Pump), [`scripts/bw_main.js`](https://github.com/robert-ai-development/plant-watering-shelly-smt50/blob/main/scripts/bw_main.js) (Periodic Monitor)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_device["Shelly Runtime"]
  node_installer["Installer<br/>[bw_install.js]"]
  node_main["Periodic Monitor<br/>[bw_main.js]"]
  node_pump["Portioning Pump<br/>[bw_pump.js]"]
  node_kvs[("Device KVS")]
  node_schedule["Schedules"]
  node_switch["Pump Switch"]
end

subgraph group_setup["Setup and Calibration"]
end

subgraph group_operations["Device Operations"]
  node_hwt["Hardware Check<br/>[bw_hwtest.js]"]
  node_hwp["Pump Check<br/>[bw_hwpump.js]"]
  node_timelapse["Time-lapse<br/>[bw_zeitraffer.js]"]
  node_hwcontrol["Hardware Test Driver<br/>[hwtest.js]"]
  node_calibration["Calibration Analysis<br/>[kal.js]"]
end

subgraph group_support["Debug Support"]
  node_mock["Shelly Mock<br/>[shelly-mock.js]"]
  node_demo["Hardware Demo<br/>[hwdemo.js]"]
  node_runner["Script Runner<br/>[run-script.js]"]
end

node_grower(("Grower"))
node_sensors(("Sensors"))
node_plant(("Plant and Water"))
node_shelly["Shelly Plus Uni"]
node_operator(("Operator"))

node_grower -->|"configures"| node_installer
node_installer -->|"creates schedules"| node_schedule
node_installer -->|"sets start values"| node_kvs
node_installer -->|"sets auto-off"| node_switch
node_schedule -->|"starts periodically"| node_main
node_main -->|"reads every 15 min"| node_sensors
node_main -->|"writes watering job"| node_kvs
node_schedule -->|"starts twice daily"| node_pump
node_pump -->|"fresh measurements"| node_sensors
node_pump -->|"reads job; stores learning"| node_kvs
node_pump -->|"waters in portions"| node_switch
node_switch -->|"delivers water"| node_plant
node_sensors -->|"measure moisture"| node_plant
node_operator -->|"runs checks"| node_hwcontrol
node_hwcontrol -->|"controls remotely"| node_hwt
node_hwcontrol -->|"controls remotely"| node_hwp
node_hwcontrol -->|"starts remotely"| node_timelapse
node_hwcontrol -->|"requests write plan"| node_calibration
node_calibration -->|"proposes updated values"| node_kvs
node_runner -->|"runs scripts in"| node_mock
node_runner -->|"enables hardware demo"| node_demo
node_demo -->|"drives simulated device"| node_mock
node_mock -.->|"simulates device RPC"| node_shelly

click node_installer "https://github.com/robert-ai-development/plant-watering-shelly-smt50/blob/main/scripts/bw_install.js"
click node_main "https://github.com/robert-ai-development/plant-watering-shelly-smt50/blob/main/scripts/bw_main.js"
click node_pump "https://github.com/robert-ai-development/plant-watering-shelly-smt50/blob/main/scripts/bw_pump.js"
click node_hwt "https://github.com/robert-ai-development/plant-watering-shelly-smt50/blob/main/scripts/bw_hwtest.js"
click node_hwp "https://github.com/robert-ai-development/plant-watering-shelly-smt50/blob/main/scripts/bw_hwpump.js"
click node_timelapse "https://github.com/robert-ai-development/plant-watering-shelly-smt50/blob/main/scripts/bw_zeitraffer.js"
click node_hwcontrol "https://github.com/robert-ai-development/plant-watering-shelly-smt50/blob/main/tools/hwtest.js"
click node_calibration "https://github.com/robert-ai-development/plant-watering-shelly-smt50/blob/main/tools/lib/kal.js"
click node_mock "https://github.com/robert-ai-development/plant-watering-shelly-smt50/blob/main/tools/mock/shelly-mock.js"
click node_demo "https://github.com/robert-ai-development/plant-watering-shelly-smt50/blob/main/tools/mock/hwdemo.js"
click node_runner "https://github.com/robert-ai-development/plant-watering-shelly-smt50/blob/main/tools/run-script.js"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_installer,node_main,node_pump,node_kvs,node_schedule,node_switch toneBlue
class node_hwt,node_hwp,node_timelapse,node_hwcontrol,node_calibration toneMint
class node_mock,node_demo,node_runner toneRose
class node_grower,node_sensors,node_plant,node_shelly,node_operator toneIndigo
```

## Components

### Shelly Runtime

- [Installer](https://github.com/robert-ai-development/plant-watering-shelly-smt50/blob/main/scripts/bw_install.js): `scripts/bw_install.js`
- [Periodic Monitor](https://github.com/robert-ai-development/plant-watering-shelly-smt50/blob/main/scripts/bw_main.js): `scripts/bw_main.js`
- [Portioning Pump](https://github.com/robert-ai-development/plant-watering-shelly-smt50/blob/main/scripts/bw_pump.js): `scripts/bw_pump.js`
- **Device KVS**
- **Schedules**
- **Pump Switch**

### Device Operations

- [Hardware Check](https://github.com/robert-ai-development/plant-watering-shelly-smt50/blob/main/scripts/bw_hwtest.js): `scripts/bw_hwtest.js`
- [Pump Check](https://github.com/robert-ai-development/plant-watering-shelly-smt50/blob/main/scripts/bw_hwpump.js): `scripts/bw_hwpump.js`
- [Time-lapse](https://github.com/robert-ai-development/plant-watering-shelly-smt50/blob/main/scripts/bw_zeitraffer.js): `scripts/bw_zeitraffer.js`
- [Hardware Test Driver](https://github.com/robert-ai-development/plant-watering-shelly-smt50/blob/main/tools/hwtest.js): `tools/hwtest.js`
- [Calibration Analysis](https://github.com/robert-ai-development/plant-watering-shelly-smt50/blob/main/tools/lib/kal.js): `tools/lib/kal.js`

### Debug Support

- [Shelly Mock](https://github.com/robert-ai-development/plant-watering-shelly-smt50/blob/main/tools/mock/shelly-mock.js): `tools/mock/shelly-mock.js`
- [Hardware Demo](https://github.com/robert-ai-development/plant-watering-shelly-smt50/blob/main/tools/mock/hwdemo.js): `tools/mock/hwdemo.js`
- [Script Runner](https://github.com/robert-ai-development/plant-watering-shelly-smt50/blob/main/tools/run-script.js): `tools/run-script.js`

### Other components

- **Grower**
- **Sensors**
- **Plant and Water**
- **Shelly Plus Uni**
- **Operator**

## Connections

- Grower → Installer: configures
- Installer → Schedules: creates schedules
- Installer → Device KVS: sets start values
- Installer → Pump Switch: sets auto-off
- Schedules → Periodic Monitor: starts periodically
- Periodic Monitor → Sensors: reads every 15 min
- Periodic Monitor → Device KVS: writes watering job
- Schedules → Portioning Pump: starts twice daily
- Portioning Pump → Sensors: fresh measurements
- Portioning Pump → Device KVS: reads job; stores learning
- Portioning Pump → Pump Switch: waters in portions
- Pump Switch → Plant and Water: delivers water
- Sensors → Plant and Water: measure moisture
- Operator → Hardware Test Driver: runs checks
- Hardware Test Driver → Hardware Check: controls remotely
- Hardware Test Driver → Pump Check: controls remotely
- Hardware Test Driver → Time-lapse: starts remotely
- Hardware Test Driver → Calibration Analysis: requests write plan
- Calibration Analysis → Device KVS: proposes updated values
- Script Runner → Shelly Mock: runs scripts in
- Script Runner → Hardware Demo: enables hardware demo
- Hardware Demo → Shelly Mock: drives simulated device
- Shelly Mock → Shelly Plus Uni: simulates device RPC
